From 531a7e3624481a0af78ee1d62a6d7e6e61846aeb Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Thu, 14 May 2020 11:10:54 -0500 Subject: [PATCH 01/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 768 ++++++++++++++++++++++++- 1 file changed, 767 insertions(+), 1 deletion(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 95bd3228..ec77fdd4 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -55,6 +55,120 @@ end input end, + + format_payload: lambda do |payload| + if payload.is_a?(Array) + payload.map do |array_value| + call('format_payload', array_value) + end + elsif payload.is_a?(Hash) + payload.map do |key, value| + key = call('inject_special_characters', key) + if value.is_a?(Array) || value.is_a?(Hash) + value = call('format_payload', value) + end + { key => value } + end.inject(:merge) + end + end, + + format_schema: lambda do |schema| + if schema.is_a?(Array) + schema.map do |array_value| + call('format_schema', array_value) + end + elsif schema.is_a?(Hash) + schema.map do |key, value| + if %w[name].include?(key.to_s) + value = call('replace_special_characters', value.to_s) + elsif %w[properties toggle_field].include?(key.to_s) + value = call('format_schema', value) + end + { key => value } + end.inject(:merge) + end + end, + + replace_special_characters: lambda do |input| + input.gsub(/[-<>!@#$%^&*()+={}:;'"`~,.?|]/, + '-' => '__hyp__', + '<' => '__lt__', + '>' => '__gt__', + '!' => '__excl__', + '@' => '__at__', + '#' => '__hashtag__', + '$' => '__dollar__', + '%' => '__percent__', + '^' => '__pwr__', + '&' => '__amper__', + '*' => '__star__', + '(' => '__lbracket__', + ')' => '__rbracket__', + '+' => '__plus__', + '=' => '__eq__', + '{' => '__rcrbrack__', + '}' => '__lcrbrack__', + ';' => '__semicol__', + '\'' => '__apost__', + '`' => '__bckquot__', + '~' => '__tilde__', + ',' => '__comma__', + '.' => '__period__', + '?' => '__qmark__', + '|' => '__pipe__', + ':' => '__colon__', + '\"' => '__quote__') + end, + + inject_special_characters: lambda do |input| + input.gsub( + /(__hyp__|__lt__|__gt__|__excl__|__at__|__hashtag__|__dollar__|\__percent__|__pwr__|__amper__|__star__|__lbracket__|__rbracket__|__plus__|__eq__|__rcrbrack__|__lcrbrack__|__semicol__|__apost__|__bckquot__|__tilde__|__comma__|__period__|__qmark__|__pipe__|__colon__|__quote__|__slash__|__bslash__)/, + '__hyp__' => '-', + '__lt__' => '<', + '__gt__' => '>', + '__excl__' => '!', + '__at__' => '@', + '__hashtag__' => '#', + '__dollar__' => '$', + '__percent__' => '%', + '__pwr__' => '^', + '__amper__' => '&', + '__star__' => '*', + '__lbracket__' => '(', + '__rbracket__' => ')', + '__plus__' => '+', + '__eq__' => '=', + '__rcrbrack__' => '{', + '__lcrbrack__' => '}', + '__semicol__' => ';', + '__apost__' => '\'', + '__bckquot__' => '`', + '__tilde__' => '~', + '__comma__' => ',', + '__period__' => '.', + '__qmark__' => '?', + '__pipe__' => '|', + '__colon__' => ':', + '__quote__' => '"' + ) + end, + + + format_response: lambda do |payload| + if payload.is_a?(Array) + payload.map do |array_value| + call('format_response', array_value) + end + elsif payload.is_a?(Hash) + payload.map do |key, value| + key = call('replace_special_characters', key) + if value.is_a?(Array) || value.is_a?(Hash) + value = call('format_response', value) + end + { key => value } + end.inject(:merge) + end + end, format_output: lambda do |result| if result['custom_fields'].present? @@ -90,6 +204,120 @@ object_definitions: { + + log_activity_input: { + fields: lambda do |_| + custom_fields = get('/api/activity-type')&. + map do |field| + { name: "#{field['id']}~#{field['uid']}", + label: field['name'], type: field['type'] } + end + standard_fields = [ + { name: 'client', label: 'Contact ID', optional: false }, + { name: 'activity_type_id',label: 'Activity', control_type: 'select', pick_list: 'activities', optional: false, toggle_hint: 'Select from list', + toggle_field:{ + name: 'activity_id', label: 'Activity id', type: :string, control_type: "text", optional:false, toggle_hint: "Use Activity ID"} + }, + { name: 'custom_fields', + type: 'object', properties: custom_fields } + ] + call('format_schema', standard_fields) + end + }, + + contact_fields_output: { + fields: lambda do |_| + custom_fields = get('/api/client-field')&. + map do |field| + { name: field['id'], + label: field['name'], type: field['type'] } + end + standard_fields = [ + { name: 'id', type: 'integer', control_type: 'number', + label: 'Contact id' }, + { name: 'first_name' }, + { name: 'last_name' }, + { name: 'email' }, + { name: 'mobile_phone' }, + { name: 'company', + hint: 'The company at which the candidate currently works' }, + { name: 'titles', hint: 'The candidate’s current title' }, + { name: 'created', type: 'date_time', control_type: 'date_time' }, + { name: 'custom_fields', + type: 'object', properties: custom_fields } + ] + call('format_schema', standard_fields) + end + }, + + + company_fields_trigger_output: { + fields: lambda do |_| + custom_fields = get('/api/company-field')&. + map do |field| + { name: field['handle'], + label: field['name'], type: field['type'] } + end + standard_fields = [ + { name: 'id', type: 'integer', control_type: 'number', + label: 'Company id' }, + { name: 'name',label: 'Company Name' }, + { name: 'business_phone' }, + { name: 'email' }, + { name: 'mobile_phone' }, + { name: 'custom', label: 'Custom fields', + type: 'object', properties: custom_fields } + ] + call('format_schema', standard_fields) + end + }, + + contact_fields_trigger_output: { + fields: lambda do |_| + custom_fields = get('/api/client-field')&. + map do |field| + { name: field['handle'], + label: field['name'], type: field['type'] } + end + standard_fields = [ + { name: 'id', label: 'Contact id' }, + { name: 'first_name' }, + { name: 'last_name' }, + { name: 'email' }, + { name: 'mobile_phone' }, + { name: 'company', + hint: 'The company at which the candidate currently works' }, + { name: 'titles', hint: 'The candidate’s current title' }, + { name: 'created', type: 'date_time', control_type: 'date_time' }, + { name: 'custom', label: 'Custom fields', + type: 'object', properties: custom_fields } + ] + call('format_schema', standard_fields) + end + }, + + deal_fields_trigger_output: { + fields: lambda do |_| + custom_fields = get('/api/deal-custom-field')&. + map do |field| + { name: field['handle'], + label: field['name'], type: field['type'] } + end + standard_fields = [ + { name: 'id', type: 'integer', control_type: 'number', + label: 'Deal ID' }, + { name: 'name',label: 'Deal Name' }, + { name: 'amount',type: 'float' }, + { name: 'owner' }, + { name: 'stage' }, + { name: 'pipeline' }, + { name: 'custom', label: 'Custom fields', + type: 'object', properties: custom_fields } + ] + call('format_schema', standard_fields) + end + }, + object_input: { fields: lambda do |_connection, config_fields| case config_fields['object'] @@ -632,7 +860,321 @@ get("https://api.kizen.com/#{input['object']}?page=1&page_size=1") .dig('results', 0) end - } + }, + log_interaction: { #This is new + title: 'Log an interaction', + subtitle: 'Log an interaction', + description: lambda do + "Log an interaction in Kizen" + end, + + input_fields: lambda do + [ + { name: "client_id",Label: "Contact ID", optional: false}, + { name: "business_id",Label: "Business ID", optional: false}, + { name: "name",Label: "Interaction Name", optional: false}, + { name: "property_label1",Label: "Property Label 1", optional: true}, + { name: "property_label2",Label: "Property Label 2", optional: true}, + { name: "property_input1",Label: "Property Input 1", optional: true}, + { name: "property_input2",Label: "Property Input 2", optional: true}, + ] + + end, + + execute: lambda do |_connection, input| + post("https://app.kizen.com/api/interaction"). + payload( + "business_id": input["business_id"], + "client_id": input["client_id"], + "name": input["name"], + "properties": { + "#{input["property_label1"]}"=> input["property_input1"], + "#{input["property_label2"]}"=> input["property_input2"]} + ) + end, + + + output_fields: lambda do + [ + { name: "id"} + ] + end, + + }, + + add_custom_lead_source: { #This is new + title: 'Add Custom Lead Source to a Contact', + subtitle: 'Add Custom Lead Source to a Contact', + description: lambda do + "Add Custom Lead Source to a Contact" + end, + + input_fields: lambda do + [ + { name: "client_id",Label: "Contact ID", optional: false}, + { name: "source", Label: "Custom Lead Source", control_type: 'select',pick_list: 'lead_sources', hint: "To add Custom Lead Sources, navigate inside a contact record and add a custom source",optional: false}, + { name: "campaign",Label: "Campaign Name", optional: true}, + { name: "medium",Label: "Medium", optional: true}, + { name: "term",Label: "Term", optional: true}, + { name: "content",Label: "Content", optional: true} + ] + + end, + + execute: lambda do |_connection, input| + post("https://app.kizen.com/api/lead-source-custom-source"). + payload( + "client": input["client_id"], + "source": input["source"], + "campaign": input["campaign"], + "medium": input["medium"], + "term": input["term"], + "content": input["content"], + ) + end, + + + output_fields: lambda do + [ + { name: "id"}, + { name: "client", Label: "Contact ID"} + ] + end, + + }, + + log_activity: { #This is new + title: 'Log an Activity', + subtitle: 'Log an Activity', + description: lambda do + "Log an activity in Kizen" + end, + + input_fields: lambda do |object_definitions| + object_definitions['log_activity_input'] + end, + + execute: lambda do |_connection, input| + format_payload = call('format_payload', input) + payload = format_payload.map do |key, value| + if key.include?('custom_fields') + custom_fields = value&.map do |k, v| + { k.split('~').last => + { + 'field_id' => k.split('~').first, + 'value' => v + } } + end&.inject(:merge) + { 'custom_fields' => custom_fields } + else + { key => value } + end + end.inject(:merge) + result = post('/api/logged-activity', payload) + + formatted_response = + result.map do |key, value| + if key.include?('custom_fields') + custom_fields = value.values&.map do |object| + { object['field_id'] => object['value'] } + end&.inject(:merge) + + { 'custom_fields' => custom_fields } + else + { key => value } + end + end&.inject(:merge) + call('format_response', formatted_response.compact) + end, + + output_fields: lambda do + [ + { name: "id"} + ] + end, + }, + find_contact_by_email: { #This is new + title: 'Find contact by email', + subtitle: 'Find a contact in Kizen by email', + description: lambda do + "Find a contact contact in Kizen by email" + end, + + input_fields: lambda do + [ + { + name: 'email', + label: 'Contact Email', + optional: false + } + ] + end, + + execute: lambda do |connection, input| + results = get("https://app.kizen.com/api/client?email=#{input["email"]}") + records = results["results"] + puts records + { + events: records + } + end, + + output_fields: lambda do |object_definitions| + { name: "events", type: "array", of: "object", + properties: object_definitions["contact_fields_trigger_output"] } + end + }, + + find_contact_by_id: { #This is new + title: 'Find contact by ID', + subtitle: 'Find a contact in Kizen by ID', + description: lambda do + "Find a contact contact in Kizen by ID" + end, + + input_fields: lambda do + [ + { + name: 'id', + label: 'Contact ID', + optional: false + } + ] + end, + + execute: lambda do |connection, input| + result = get("https://app.kizen.com/api/client/#{input["id"]}") + + formatted_response = + result.map do |key, value| + if key.include?('custom_fields') + custom_fields = value.values&.map do |object| + { object['field_id'] => object['value'] } + end&.inject(:merge) + + { 'custom_fields' => custom_fields } + else + { key => value } + end + end&.inject(:merge) + call('format_response', formatted_response.compact) + end, + + output_fields: lambda do |object_definitions| + object_definitions['contact_fields_output'] + end + + }, + + + find_company_by_name: { #This is new + title: 'Find company by name', + subtitle: 'Find a company in Kizen by name', + description: lambda do + "Find a company contact in Kizen by name" + end, + + input_fields: lambda do + [ + { + name: 'name', + label: 'Company Name', + optional: false + } + ] + end, + + execute: lambda do |connection, input| + results = get("https://app.kizen.com/api/company?search=#{input["name"]}") + records = results["results"] + puts records + { + events: records + } + end, + + output_fields: lambda do |object_definitions| + { name: "events", type: "array", of: "object", + properties: object_definitions["company_fields_trigger_output"] } + end + }, + + find_deal_by_name: { #This is new + title: 'Find deal by name', + subtitle: 'Find a deal in Kizen by name', + description: lambda do + "Find a deal contact in Kizen by name" + end, + + input_fields: lambda do + [ + { + name: 'name', + label: 'Deal Name', + optional: false + } + ] + end, + + execute: lambda do |connection, input| + results = get("https://app.kizen.com/api/deal?search=#{input["name"]}") + records = results["results"] + puts records + { + events: records + } + end, + + output_fields: lambda do |object_definitions| + { name: "events", type: "array", of: "object", + properties: object_definitions["deal_fields_trigger_output"] } + end + }, + create_order: { #This is new + title: 'Create order', + + + input_fields: lambda do + [ + { name: "email", optional: false }, + { name: "order_status", optional: false, control_type: "select", pick_list: "order_status" }, + { name: "order_number", optional: false, hint: "This must be an integer" }, + { name: "created", optional: false, hint: "(YYYY-MM-DD)" }, + { name: "sku", label: "SKU",optional: false }, + { name: "name", optional: false,label:"Product Name" }, + { name: "price", optional: false }, + { name: "quantity", optional: false , hint: "This must be a number without decimal places. Example - 1.00 will not work."}, + ] + end, + + + + + + execute: lambda do |_connection, input| + post("https://app.kizen.com/api/commerce/orders"). + payload( + "order_status": input["order_status"], + "order_number": input["order_number"], + "created": input["created"], + "client": { "email": input["email"], + "upload":true, + }, + "line_items": [{"price": input["price"], "sku": input["sku"], "name": input["name"],"quantity": input["quantity"]}] + + + + ) + end, + + output_fields: lambda do + [ + { name: "id"}, + { name: "cart"}, + { name: "client"} + ] + end, + } }, triggers: { @@ -744,6 +1286,215 @@ get("https://api.kizen.com/#{input['object']}?page=1&page_size=1") .dig('results', 0) end + }, + new_order: { + title: 'New Order', + subtitle: 'New Order in Kizen', + description: lambda do + "New Order in Kizen" + end, + + poll: lambda do |_connection, _input, page| + page_size = 50 + page ||= 1 + response = get("https://app.kizen.com/api/commerce/orders"). + params(order_by: 'created', + order_type: 'asc', + page: page, + per_page: page_size + ) + records = response&.[]('results') || [] + page = records.size >= page_size ? page + 1 : 1 + { + events: records, + next_page: page, + can_poll_more: records.size >= page_size + } + end, + + dedup: lambda do |contact| + contact['id'] + end, + + output_fields: lambda do + [ + { name: "id"}, + {name: "client"}, + ] + end, + + }, + + + + new_scheduled_activity: { #I'm having trouble parsing the output on this one. Will need a little help from Workato, parsing an array in the output + title: 'New Scheduled Activity', + subtitle: 'New Scheduled Activity in Kizen', + description: lambda do + "New scheduled activity in Kizen" + end, + + input_fields: lambda do + [ + { name: 'activities',label: 'Activities', control_type: 'select', pick_list: 'activities', optional: false, toggle_hint: 'Select from list', + toggle_field:{ + name: 'activities_id', label: 'Activities id', type: :string, control_type: "text", optional:false, toggle_hint: "Use Activities ID"} + }, + ] + end, + + + + poll: lambda do |_connection, input, page| + page_size = 50 + activity_id = input['activities'] + puts (activity_id) + page ||= 1 + response = get("https://app.kizen.com/api/scheduled-activity?activity_type=#{activity_id}"). + params(order_by: 'created', + order_type: 'asc', + page: page, + per_page: page_size + ) + + + puts response + records = response&.[]('results') || [] + page = records.size >= page_size ? page + 1 : page + { + events: records, + next_page: page, + can_poll_more: records.size >= page_size + } + end, + + dedup: lambda do |deal| + deal['id'] + end, + + output_fields: lambda do + [ + { name: "id"}, + { name: "assigned_to"}, + { name: "client"}, #This is an array that needs to be split up. How can I do this? #Need workato's help on this one. + { name: "company"}, + { name: "deal"}, + { name: "scheduled"} + ] + end, + + }, + +updated_contact: { #This is new + + input_fields: ->() { + }, + + poll: ->(connection, input, last_updated_since) { + updated_since = last_updated_since || input['since'] || Time.now + + contacts = get("https://app.kizen.com/api/client-field-revision"). + params(order_by: 'updated_at', + order_type: 'asc', + per_page: 2, + updated_since: updated_since.to_time.utc.iso8601) + + contacts = contacts['results'] + + next_updated_since = contacts.last['updated_at'] unless contacts.blank? + + + { + events: contacts, + next_poll: next_updated_since, + + can_poll_more: contacts.length >= 2 + } + }, + + dedup: ->(contacts) { + contacts['id'] + }, + +output_fields: lambda do + [ + { + name: "id" + }, + { + name: "client" + }, + { + name: "custom_field_name" + }, + { + name: "custom_field" + }, + + { + name: "new_value" + }, + + ] + end + }, + new_logged_activity: { #I'm having trouble parsing the output on this one. Will need a little help from Workato, parsing an array in the output. + title: 'New Logged Activity', + subtitle: 'New Logged Activity in Kizen', + description: lambda do + "New logged activity in Kizen" + end, + + input_fields: lambda do + [ + { name: 'activities',label: 'Activities', control_type: 'select', pick_list: 'activities', optional: false, toggle_hint: 'Select from list', + toggle_field:{ + name: 'activities_id', label: 'Activities id', type: :string, control_type: "text", optional:false, toggle_hint: "Use Activities ID"} + }, + ] + end, + + + + poll: lambda do |_connection, input, page| + page_size = 50 + activity_id = input['activities'] + puts (activity_id) + page ||= 1 + response = get("https://app.kizen.com/api/logged-activity?activity_type_id=#{activity_id}"). + params(order_by: 'created', # Because we can only query by updated_since in this API. + order_type: 'asc', # We expect events in ascending order. + #activity_type: input['activities'], + page: page, + per_page: page_size # Small page size to help with testing + ) + + + puts response + records = response&.[]('results') || [] + page = records.size >= page_size ? page + 1 : page + { + events: records, + next_page: page, + can_poll_more: records.size >= page_size + } + end, + + dedup: lambda do |deal| + deal['id'] + end, + + output_fields: lambda do + [ + { name: "id"}, + { name: "activity_type"}, + { name: "client"}, #This is an array that needs to be split up. How can I do this? #Need workato's help on this one + { name: "company"}, + { name: "deal"}, + { name: "employee"}, + { name: "created"} + ] + end, } }, @@ -783,6 +1534,21 @@ [res['full_name'].presence || 'unknown', res['id']] end end, + + activities: ->(connection) { + url = "https://app.kizen.com/api/activity-type?fields=id,name,created" + get(url).pluck('name', 'id') + }, + lead_sources: ->(connection) { + url = "https://app.kizen.com/api/lead-source-custom-source-type" + get(url)['results'].pluck('name', 'id') + }, + order_status: lambda do |connection| + [ + # Display name, value + ["paid","paid"] + ] + end, kizen_objects: lambda do [ From e84307edb729488c2cd9ccb252eb2135a87067cd Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Mon, 18 May 2020 12:08:36 -0500 Subject: [PATCH 02/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 32 ++++++++++++-------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index ec77fdd4..fe6d0e20 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -1146,26 +1146,24 @@ { name: "quantity", optional: false , hint: "This must be a number without decimal places. Example - 1.00 will not work."}, ] end, - - - - - + execute: lambda do |_connection, input| - post("https://app.kizen.com/api/commerce/orders"). + post("https://app.kizen.com/api/commerce/orders"). payload( - "order_status": input["order_status"], - "order_number": input["order_number"], - "created": input["created"], - "client": { "email": input["email"], - "upload":true, - }, - "line_items": [{"price": input["price"], "sku": input["sku"], "name": input["name"],"quantity": input["quantity"]}] - - - + 'order_status': input['order_status'], + 'order_number': input['order_number'], + 'created': input['created'], + 'client': {'email': input['email']}, + 'upload':true, + 'line_items': [ + {'price': input['price'], + 'sku': input['sku'], + 'name': input['name'], + 'quantity': input['quantity'] + } + ] ) - end, + end, output_fields: lambda do [ From e8aecce7c89a9e8b17d233a8b9e47b7ce3c23845 Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Mon, 18 May 2020 12:19:36 -0500 Subject: [PATCH 03/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 38 ++++++++++++++------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index fe6d0e20..feff548a 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -779,7 +779,7 @@ help: lambda do |_, objects| "Create #{objects['object']&.downcase || 'object'} in Kizen." end, - + config_fields: [ { name: 'object', @@ -1484,15 +1484,15 @@ output_fields: lambda do [ - { name: "id"}, - { name: "activity_type"}, - { name: "client"}, #This is an array that needs to be split up. How can I do this? #Need workato's help on this one - { name: "company"}, - { name: "deal"}, - { name: "employee"}, - { name: "created"} - ] - end, + { name: 'id'}, + { name: 'activity_type'}, + { name: 'client'}, #This is an array that needs to be split up. How can I do this? #Need workato's help on this one + { name: 'company'}, + { name: 'deal'}, + { name: 'employee'}, + { name: 'created'} + ] + end } }, @@ -1533,20 +1533,22 @@ end end, - activities: ->(connection) { - url = "https://app.kizen.com/api/activity-type?fields=id,name,created" - get(url).pluck('name', 'id') + activities: ->(_connection) { + url = 'https://app.kizen.com/api/activity-type?fields=id,name,created' + get(url).pluck('name', 'id') }, - lead_sources: ->(connection) { - url = "https://app.kizen.com/api/lead-source-custom-source-type" - get(url)['results'].pluck('name', 'id') + + lead_sources: ->(_connection) { + url = 'https://app.kizen.com/api/lead-source-custom-source-type' + get(url)['results'].pluck('name', 'id') }, + order_status: lambda do |connection| [ # Display name, value - ["paid","paid"] + ['paid', 'paid'] ] - end, + end, kizen_objects: lambda do [ From 6aad0db7cb8399d8a89d0a6a048de798de20ee44 Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Mon, 18 May 2020 12:24:43 -0500 Subject: [PATCH 04/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index feff548a..46031420 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -1452,7 +1452,7 @@ ] end, - + #This is an array that needs to be split up. How can I do this? #Need workato's help on this one poll: lambda do |_connection, input, page| page_size = 50 @@ -1483,15 +1483,15 @@ end, output_fields: lambda do - [ - { name: 'id'}, - { name: 'activity_type'}, - { name: 'client'}, #This is an array that needs to be split up. How can I do this? #Need workato's help on this one - { name: 'company'}, - { name: 'deal'}, - { name: 'employee'}, - { name: 'created'} - ] + [ + { name: 'id' }, + { name: 'activity_type' }, + { name: 'client' }, + { name: 'company' }, + { name: 'deal' }, + { name: 'employee' }, + { name: 'created' } + ] end } }, @@ -1538,12 +1538,12 @@ get(url).pluck('name', 'id') }, - lead_sources: ->(_connection) { - url = 'https://app.kizen.com/api/lead-source-custom-source-type' - get(url)['results'].pluck('name', 'id') + lead_sources: ->(_connection) { + url = 'https://app.kizen.com/api/lead-source-custom-source-type' + get(url)['results'].pluck('name', 'id') }, - order_status: lambda do |connection| + order_status: lambda do |connection| [ # Display name, value ['paid', 'paid'] From 3f795de88c47a8d3b3d6211b9844d48acc5e7b9e Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 16:38:24 -0500 Subject: [PATCH 05/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 38 ++++++++++++-------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 46031420..034e322c 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -1451,23 +1451,19 @@ }, ] end, - - #This is an array that needs to be split up. How can I do this? #Need workato's help on this one - +#The output is an array that needs to be split up. How can I do this? +#Need workato's help on this one poll: lambda do |_connection, input, page| page_size = 50 activity_id = input['activities'] - puts (activity_id) + puts activity_id page ||= 1 response = get("https://app.kizen.com/api/logged-activity?activity_type_id=#{activity_id}"). - params(order_by: 'created', # Because we can only query by updated_since in this API. - order_type: 'asc', # We expect events in ascending order. - #activity_type: input['activities'], + params(order_by: 'created', + order_type: 'asc', page: page, - per_page: page_size # Small page size to help with testing - ) - - + per_page: page_size + ) puts response records = response&.[]('results') || [] page = records.size >= page_size ? page + 1 : page @@ -1481,16 +1477,16 @@ dedup: lambda do |deal| deal['id'] end, - + output_fields: lambda do [ - { name: 'id' }, - { name: 'activity_type' }, - { name: 'client' }, - { name: 'company' }, - { name: 'deal' }, - { name: 'employee' }, - { name: 'created' } + { name: 'id' }, + { name: 'activity_type' }, + { name: 'client' }, + { name: 'company' }, + { name: 'deal' }, + { name: 'employee' }, + { name: 'created' } ] end } @@ -1543,12 +1539,12 @@ get(url)['results'].pluck('name', 'id') }, - order_status: lambda do |connection| + order_status: lambda do |_connection| [ # Display name, value ['paid', 'paid'] ] - end, + end, kizen_objects: lambda do [ From 883cdb73315729670ad195c0d6ac4dc707612d2b Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 16:47:37 -0500 Subject: [PATCH 06/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 52 ++++++++++++++------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 034e322c..d93294a3 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -1432,38 +1432,41 @@ { name: "new_value" }, - ] - end - }, - new_logged_activity: { #I'm having trouble parsing the output on this one. Will need a little help from Workato, parsing an array in the output. - title: 'New Logged Activity', - subtitle: 'New Logged Activity in Kizen', - description: lambda do - "New logged activity in Kizen" - end, - + end +}, + new_logged_activity: { #I'm having trouble parsing the output on this one. + title: 'New Logged Activity', #Will need a little help from Workato, parsing an array in the output. + subtitle: 'New Logged Activity in Kizen', + description: lambda do + "New logged activity in Kizen" + end, + input_fields: lambda do [ - { name: 'activities',label: 'Activities', control_type: 'select', pick_list: 'activities', optional: false, toggle_hint: 'Select from list', - toggle_field:{ - name: 'activities_id', label: 'Activities id', type: :string, control_type: "text", optional:false, toggle_hint: "Use Activities ID"} + { + name: 'activities', + label: 'Activities', + control_type: 'select', + pick_list: 'activities', + optional: false }, ] end, -#The output is an array that needs to be split up. How can I do this? -#Need workato's help on this one + #The output is an array that needs to be split up. How can I do this? + #Need workato's help on this one poll: lambda do |_connection, input, page| page_size = 50 activity_id = input['activities'] puts activity_id page ||= 1 response = get("https://app.kizen.com/api/logged-activity?activity_type_id=#{activity_id}"). - params(order_by: 'created', - order_type: 'asc', - page: page, - per_page: page_size - ) + params( + order_by: 'created', + order_type: 'asc', + page: page, + per_page: page_size + ) puts response records = response&.[]('results') || [] page = records.size >= page_size ? page + 1 : page @@ -1529,15 +1532,16 @@ end end, - activities: ->(_connection) { + activities: lambda do |_connection| url = 'https://app.kizen.com/api/activity-type?fields=id,name,created' get(url).pluck('name', 'id') - }, + end, - lead_sources: ->(_connection) { + lead_sources: lambda do |_connection| url = 'https://app.kizen.com/api/lead-source-custom-source-type' get(url)['results'].pluck('name', 'id') - }, + end, + order_status: lambda do |_connection| [ From 0758292c9f829f5bb9995b4ae9d94b32414307de Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 16:59:49 -0500 Subject: [PATCH 07/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 172 ++++++++++++------------- 1 file changed, 85 insertions(+), 87 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index d93294a3..3a746612 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -1385,66 +1385,62 @@ updated_contact: { #This is new - input_fields: ->() { - }, + input_fields: ->() { + }, - poll: ->(connection, input, last_updated_since) { - updated_since = last_updated_since || input['since'] || Time.now + poll: ->(connection, input, last_updated_since) { + updated_since = last_updated_since || input['since'] || Time.now - contacts = get("https://app.kizen.com/api/client-field-revision"). - params(order_by: 'updated_at', - order_type: 'asc', - per_page: 2, - updated_since: updated_since.to_time.utc.iso8601) - - contacts = contacts['results'] + contacts = get("https://app.kizen.com/api/client-field-revision"). + params(order_by: 'updated_at', + order_type: 'asc', + per_page: 2, + updated_since: updated_since.to_time.utc.iso8601) + contacts = contacts['results'] - next_updated_since = contacts.last['updated_at'] unless contacts.blank? + next_updated_since = contacts.last['updated_at'] unless contacts.blank? + { + events: contacts, + next_poll: next_updated_since, + can_poll_more: contacts.length >= 2 + } + }, - { - events: contacts, - next_poll: next_updated_since, + dedup: ->(contacts) { + contacts['id'] + }, - can_poll_more: contacts.length >= 2 - } + output_fields: lambda do + [ + { + name: 'id' }, - - dedup: ->(contacts) { - contacts['id'] + { + name: 'client' }, - -output_fields: lambda do - [ - { - name: "id" - }, - { - name: "client" - }, - { - name: "custom_field_name" - }, - { - name: "custom_field" - }, - - { - name: "new_value" - }, - ] + { + name: 'custom_field_name' + }, + { + name: 'custom_field' + }, + { + name: 'new_value' + } + ] end }, - new_logged_activity: { #I'm having trouble parsing the output on this one. - title: 'New Logged Activity', #Will need a little help from Workato, parsing an array in the output. + new_logged_activity: { # I'm having trouble parsing the output on this + title: 'New Logged Activity', # Will need a little help from Workato, parsing an array in the output. subtitle: 'New Logged Activity in Kizen', description: lambda do "New logged activity in Kizen" end, - - input_fields: lambda do + + input_fields: lambda do [ - { + { name: 'activities', label: 'Activities', control_type: 'select', @@ -1452,48 +1448,50 @@ optional: false }, ] - end, - #The output is an array that needs to be split up. How can I do this? - #Need workato's help on this one - poll: lambda do |_connection, input, page| - page_size = 50 - activity_id = input['activities'] - puts activity_id - page ||= 1 - response = get("https://app.kizen.com/api/logged-activity?activity_type_id=#{activity_id}"). - params( - order_by: 'created', - order_type: 'asc', - page: page, - per_page: page_size - ) - puts response - records = response&.[]('results') || [] - page = records.size >= page_size ? page + 1 : page - { - events: records, - next_page: page, - can_poll_more: records.size >= page_size - } - end, - - dedup: lambda do |deal| - deal['id'] - end, + end, + # The output is an array that needs to be split up. How can I do this? + # Need workato's help on this one + + poll: lambda do |_connection, input, page| + page_size = 50 + activity_id = input['activities'] + puts activity_id + page ||= 1 + response = get("https://app.kizen.com/api/logged-activity?activity_type_id=#{activity_id}"). + params( + order_by: 'created', + order_type: 'asc', + page: page, + per_page: page_size + ) + puts response + records = response&.[]('results') || [] + page = records.size >= page_size ? page + 1 : page + { + events: records, + next_page: page, + can_poll_more: records.size >= page_size + } + end, - output_fields: lambda do - [ - { name: 'id' }, - { name: 'activity_type' }, - { name: 'client' }, - { name: 'company' }, - { name: 'deal' }, - { name: 'employee' }, - { name: 'created' } - ] - end - } - }, + dedup: lambda do |deal| + deal['id'] + end, + + + output_fields: lambda do + [ + { name: 'id' }, + { name: 'activity_type' }, + { name: 'client' }, + { name: 'company' }, + { name: 'deal' }, + { name: 'employee' }, + { name: 'created' } + ] + end + } +}, pick_lists: { pipelines: lambda do |_connection| @@ -1536,7 +1534,7 @@ url = 'https://app.kizen.com/api/activity-type?fields=id,name,created' get(url).pluck('name', 'id') end, - + lead_sources: lambda do |_connection| url = 'https://app.kizen.com/api/lead-source-custom-source-type' get(url)['results'].pluck('name', 'id') From ac99284a70675ea4df85481bbb5e667711037dbb Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 17:10:53 -0500 Subject: [PATCH 08/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 125 ++++++++++++------------- 1 file changed, 62 insertions(+), 63 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 3a746612..062ee4de 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -1391,11 +1391,12 @@ poll: ->(connection, input, last_updated_since) { updated_since = last_updated_since || input['since'] || Time.now - contacts = get("https://app.kizen.com/api/client-field-revision"). - params(order_by: 'updated_at', - order_type: 'asc', - per_page: 2, - updated_since: updated_since.to_time.utc.iso8601) + contacts = get("https://app.kizen.com/api/client-field-revision") + .params( + order_by: 'updated_at', + order_type: 'asc', + per_page: 2, + updated_since: updated_since.to_time.utc.iso8601) contacts = contacts['results'] next_updated_since = contacts.last['updated_at'] unless contacts.blank? @@ -1431,66 +1432,64 @@ ] end }, - new_logged_activity: { # I'm having trouble parsing the output on this - title: 'New Logged Activity', # Will need a little help from Workato, parsing an array in the output. - subtitle: 'New Logged Activity in Kizen', - description: lambda do - "New logged activity in Kizen" - end, - - input_fields: lambda do - [ - { - name: 'activities', - label: 'Activities', - control_type: 'select', - pick_list: 'activities', - optional: false - }, - ] - end, - # The output is an array that needs to be split up. How can I do this? - # Need workato's help on this one - - poll: lambda do |_connection, input, page| - page_size = 50 - activity_id = input['activities'] - puts activity_id - page ||= 1 - response = get("https://app.kizen.com/api/logged-activity?activity_type_id=#{activity_id}"). - params( - order_by: 'created', - order_type: 'asc', - page: page, - per_page: page_size - ) - puts response - records = response&.[]('results') || [] - page = records.size >= page_size ? page + 1 : page - { - events: records, - next_page: page, - can_poll_more: records.size >= page_size - } - end, - - dedup: lambda do |deal| - deal['id'] - end, +new_logged_activity: { # I'm having trouble parsing the output on this + title: 'New Logged Activity', # Will need help from Workato + subtitle: 'New Logged Activity in Kizen', + description: lambda do + "New logged activity in Kizen" + end, + + input_fields: lambda do + [ + { + name: 'activities', + label: 'Activities', + control_type: 'select', + pick_list: 'activities', + optional: false + } + ] + end, + # The output is an array that needs to be split up. How can I do this? + # Need workato's help on this one + poll: lambda do |_connection, input, page| + page_size = 50 + activity_id = input['activities'] + puts activity_id + page ||= 1 + response = get("https://app.kizen.com/api/logged-activity?activity_type_id=#{activity_id}") + .params( + order_by: 'created', + order_type: 'asc', + page: page, + per_page: page_size + ) + puts response + records = response&.[]('results') || [] + page = records.size >= page_size ? page + 1 : page + { + events: records, + next_page: page, + can_poll_more: records.size >= page_size + } + end, + dedup: lambda do |deal| + deal['id'] + end, - output_fields: lambda do - [ - { name: 'id' }, - { name: 'activity_type' }, - { name: 'client' }, - { name: 'company' }, - { name: 'deal' }, - { name: 'employee' }, - { name: 'created' } - ] - end - } + output_fields: lambda do + [ + { name: 'id' }, + { name: 'activity_type' }, + { name: 'client' }, + { name: 'company' }, + { name: 'deal' }, + { name: 'employee' }, + { name: 'created' } + ] + end +} }, pick_lists: { From ab7c2cb99280f3a068e1fe8aef5d5a9f11df9ba7 Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 17:16:41 -0500 Subject: [PATCH 09/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 39 +++++++++++--------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 062ee4de..5875495d 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -1322,10 +1322,7 @@ end, }, - - - - new_scheduled_activity: { #I'm having trouble parsing the output on this one. Will need a little help from Workato, parsing an array in the output + new_scheduled_activity: { # I'm having trouble parsing the output on this one. Will need a little help from Workato, parsing an array in the output title: 'New Scheduled Activity', subtitle: 'New Scheduled Activity in Kizen', description: lambda do @@ -1334,28 +1331,26 @@ input_fields: lambda do [ - { name: 'activities',label: 'Activities', control_type: 'select', pick_list: 'activities', optional: false, toggle_hint: 'Select from list', - toggle_field:{ - name: 'activities_id', label: 'Activities id', type: :string, control_type: "text", optional:false, toggle_hint: "Use Activities ID"} + { name: 'activities', + label: 'Activities', + control_type: 'select', + pick_list: 'activities', + optional: false, }, ] end, - - poll: lambda do |_connection, input, page| page_size = 50 activity_id = input['activities'] - puts (activity_id) page ||= 1 - response = get("https://app.kizen.com/api/scheduled-activity?activity_type=#{activity_id}"). - params(order_by: 'created', - order_type: 'asc', - page: page, - per_page: page_size - ) - - + response = get("https://app.kizen.com/api/scheduled-activity?activity_type=#{activity_id}") + .params(order_by: 'created', + order_type: 'asc', + page: page, + per_page: page_size + ) + puts response records = response&.[]('results') || [] page = records.size >= page_size ? page + 1 : page @@ -1365,14 +1360,14 @@ can_poll_more: records.size >= page_size } end, - + dedup: lambda do |deal| deal['id'] end, - + output_fields: lambda do - [ - { name: "id"}, + [ + { name: "id"}, { name: "assigned_to"}, { name: "client"}, #This is an array that needs to be split up. How can I do this? #Need workato's help on this one. { name: "company"}, From 329c12d95753eee5afad9f870e23b2b1f69d6fda Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 17:21:43 -0500 Subject: [PATCH 10/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 32 ++++++++++++++------------ 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 5875495d..8b02d9fb 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -1367,18 +1367,18 @@ output_fields: lambda do [ - { name: "id"}, - { name: "assigned_to"}, - { name: "client"}, #This is an array that needs to be split up. How can I do this? #Need workato's help on this one. - { name: "company"}, - { name: "deal"}, - { name: "scheduled"} + { name: 'id' }, + { name: 'assigned_to' }, + { name: 'client' },# This is an array that needs to be split up. + { name: 'company' },# Need workato's help on this one. + { name: 'deal' }, + { name: 'scheduled' } ] - end, + end }, -updated_contact: { #This is new +updated_contact: {# This is new input_fields: ->() { }, @@ -1386,12 +1386,13 @@ poll: ->(connection, input, last_updated_since) { updated_since = last_updated_since || input['since'] || Time.now - contacts = get("https://app.kizen.com/api/client-field-revision") + contacts = get('https://app.kizen.com/api/client-field-revision') .params( - order_by: 'updated_at', + order_by: 'updated_at', order_type: 'asc', - per_page: 2, - updated_since: updated_since.to_time.utc.iso8601) + per_page: 2, + updated_since: updated_since.to_time.utc.iso8601 + ) contacts = contacts['results'] next_updated_since = contacts.last['updated_at'] unless contacts.blank? @@ -1427,7 +1428,8 @@ ] end }, -new_logged_activity: { # I'm having trouble parsing the output on this + +new_logged_activity: {# I'm having trouble parsing the output on this title: 'New Logged Activity', # Will need help from Workato subtitle: 'New Logged Activity in Kizen', description: lambda do @@ -1445,8 +1447,8 @@ } ] end, - # The output is an array that needs to be split up. How can I do this? - # Need workato's help on this one + # The output is an array that needs to be split up. How can I do this? + # Need workato's help on this one poll: lambda do |_connection, input, page| page_size = 50 activity_id = input['activities'] From 8953c01cb06375e1e38eb19687d7c9bff477d842 Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 17:25:39 -0500 Subject: [PATCH 11/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 27 +++++++++++++------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 8b02d9fb..065a2d0f 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -1319,16 +1319,16 @@ { name: "id"}, {name: "client"}, ] - end, + end }, - new_scheduled_activity: { # I'm having trouble parsing the output on this one. Will need a little help from Workato, parsing an array in the output + new_scheduled_activity: { # I'm having trouble parsing the output title: 'New Scheduled Activity', subtitle: 'New Scheduled Activity in Kizen', description: lambda do - "New scheduled activity in Kizen" + "New scheduled activity in Kizen" end, - + input_fields: lambda do [ { name: 'activities', @@ -1336,7 +1336,7 @@ control_type: 'select', pick_list: 'activities', optional: false, - }, + } ] end, @@ -1348,8 +1348,7 @@ .params(order_by: 'created', order_type: 'asc', page: page, - per_page: page_size - ) + per_page: page_size) puts response records = response&.[]('results') || [] @@ -1367,12 +1366,12 @@ output_fields: lambda do [ - { name: 'id' }, - { name: 'assigned_to' }, - { name: 'client' },# This is an array that needs to be split up. - { name: 'company' },# Need workato's help on this one. - { name: 'deal' }, - { name: 'scheduled' } + { name: 'id' }, + { name: 'assigned_to' }, + { name: 'client' }, # This is an array that needs to be split up. + { name: 'company' }, # Need workato's help on this one. + { name: 'deal' }, + { name: 'scheduled' } ] end @@ -1428,7 +1427,7 @@ ] end }, - + new_logged_activity: {# I'm having trouble parsing the output on this title: 'New Logged Activity', # Will need help from Workato subtitle: 'New Logged Activity in Kizen', From d0e058ac05f975eb9b9064d17b49c1349bf938af Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 17:28:30 -0500 Subject: [PATCH 12/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 065a2d0f..09aa9bf0 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -1295,12 +1295,12 @@ poll: lambda do |_connection, _input, page| page_size = 50 page ||= 1 - response = get("https://app.kizen.com/api/commerce/orders"). - params(order_by: 'created', - order_type: 'asc', - page: page, - per_page: page_size - ) + response = get("https://app.kizen.com/api/commerce/orders") + .params(order_by: 'created', + order_type: 'asc', + page: page, + per_page: page_size + ) records = response&.[]('results') || [] page = records.size >= page_size ? page + 1 : 1 { @@ -1315,13 +1315,13 @@ end, output_fields: lambda do - [ - { name: "id"}, - {name: "client"}, + [ + { name: "id" }, + { name: "client" }, ] end - }, + new_scheduled_activity: { # I'm having trouble parsing the output title: 'New Scheduled Activity', subtitle: 'New Scheduled Activity in Kizen', @@ -1335,8 +1335,7 @@ label: 'Activities', control_type: 'select', pick_list: 'activities', - optional: false, - } + optional: false} ] end, From 0c9ac48f4de37df95fc047dfaf6b59e3791db7d0 Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 17:32:53 -0500 Subject: [PATCH 13/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 68 +++++++++++++------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 09aa9bf0..1f6a1e70 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -1130,25 +1130,24 @@ properties: object_definitions["deal_fields_trigger_output"] } end }, - create_order: { #This is new - title: 'Create order', - - - input_fields: lambda do - [ - { name: "email", optional: false }, - { name: "order_status", optional: false, control_type: "select", pick_list: "order_status" }, - { name: "order_number", optional: false, hint: "This must be an integer" }, - { name: "created", optional: false, hint: "(YYYY-MM-DD)" }, - { name: "sku", label: "SKU",optional: false }, - { name: "name", optional: false,label:"Product Name" }, - { name: "price", optional: false }, - { name: "quantity", optional: false , hint: "This must be a number without decimal places. Example - 1.00 will not work."}, - ] - end, +create_order: { #This is new + title: 'Create order', - execute: lambda do |_connection, input| - post("https://app.kizen.com/api/commerce/orders"). + input_fields: lambda do + [ + { name: "email", optional: false }, + { name: "order_status", optional: false, control_type: "select", pick_list: "order_status" }, + { name: "order_number", optional: false, hint: "This must be an integer" }, + { name: "created", optional: false, hint: "(YYYY-MM-DD)" }, + { name: "sku", label: "SKU",optional: false }, + { name: "name", optional: false,label:"Product Name" }, + { name: "price", optional: false }, + { name: "quantity", optional: false , hint: "This must be a number without decimal places. Example - 1.00 will not work."}, + ] + end, + + execute: lambda do |_connection, input| + post("https://app.kizen.com/api/commerce/orders"). payload( 'order_status': input['order_status'], 'order_number': input['order_number'], @@ -1159,21 +1158,20 @@ {'price': input['price'], 'sku': input['sku'], 'name': input['name'], - 'quantity': input['quantity'] - } + 'quantity': input['quantity']} ] - ) - end, - - output_fields: lambda do - [ - { name: "id"}, - { name: "cart"}, - { name: "client"} - ] - end, - } - }, + ) + end, + + output_fields: lambda do + [ + { name: 'id' }, + { name: 'cart' }, + { name: 'client' } + ] + end, +} +}, triggers: { new_object: { @@ -1297,9 +1295,9 @@ page ||= 1 response = get("https://app.kizen.com/api/commerce/orders") .params(order_by: 'created', - order_type: 'asc', + order_type: 'asc', page: page, - per_page: page_size + per_page: page_size ) records = response&.[]('results') || [] page = records.size >= page_size ? page + 1 : 1 @@ -1335,7 +1333,7 @@ label: 'Activities', control_type: 'select', pick_list: 'activities', - optional: false} + optional: false } ] end, From 71dec0cc39d4c56dbc692599816afb1a9c7e9646 Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 17:38:09 -0500 Subject: [PATCH 14/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 49 ++++++++++++++------------ 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 1f6a1e70..595df524 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -1135,32 +1135,35 @@ input_fields: lambda do [ - { name: "email", optional: false }, - { name: "order_status", optional: false, control_type: "select", pick_list: "order_status" }, - { name: "order_number", optional: false, hint: "This must be an integer" }, - { name: "created", optional: false, hint: "(YYYY-MM-DD)" }, - { name: "sku", label: "SKU",optional: false }, - { name: "name", optional: false,label:"Product Name" }, - { name: "price", optional: false }, - { name: "quantity", optional: false , hint: "This must be a number without decimal places. Example - 1.00 will not work."}, + { name: 'email', optional: false }, + { name: 'order_status', + optional: false, + control_type: "select", + pick_list: "order_status" }, + { name: 'order_number', optional: false, hint: "Must be an integer" }, + { name: 'created', optional: false, hint: "(YYYY-MM-DD)" }, + { name: 'sku', label: "SKU", optional: false }, + { name: 'name', optional: false,label:"Product Name" }, + { name: 'price', optional: false }, + { name: 'quantity', optional: false , hint: "This must be a number without decimal places. Example - 1.00 will not work."}, ] end, execute: lambda do |_connection, input| - post("https://app.kizen.com/api/commerce/orders"). - payload( - 'order_status': input['order_status'], - 'order_number': input['order_number'], - 'created': input['created'], - 'client': {'email': input['email']}, - 'upload':true, - 'line_items': [ - {'price': input['price'], - 'sku': input['sku'], - 'name': input['name'], - 'quantity': input['quantity']} - ] - ) + post('https://app.kizen.com/api/commerce/orders') + .payload( + 'order_status': input['order_status'], + 'order_number': input['order_number'], + 'created': input['created'], + 'client': { 'email': input['email'] }, + 'upload': true, + 'line_items': [ + { 'price': input['price'], + 'sku': input['sku'], + 'name': input['name'], + 'quantity': input['quantity'] } + ] + ) end, output_fields: lambda do @@ -1169,7 +1172,7 @@ { name: 'cart' }, { name: 'client' } ] - end, + end } }, From 01ec349fbf31ec1feecc5f3a63895554df38c6d6 Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 18:56:36 -0500 Subject: [PATCH 15/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 467 ++++++++++++------------- 1 file changed, 229 insertions(+), 238 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 595df524..57334e31 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -861,291 +861,282 @@ .dig('results', 0) end }, - log_interaction: { #This is new + log_interaction: { # This is new title: 'Log an interaction', subtitle: 'Log an interaction', description: lambda do "Log an interaction in Kizen" end, - - input_fields: lambda do + input_fields: lambda do [ - { name: "client_id",Label: "Contact ID", optional: false}, - { name: "business_id",Label: "Business ID", optional: false}, - { name: "name",Label: "Interaction Name", optional: false}, - { name: "property_label1",Label: "Property Label 1", optional: true}, - { name: "property_label2",Label: "Property Label 2", optional: true}, - { name: "property_input1",Label: "Property Input 1", optional: true}, - { name: "property_input2",Label: "Property Input 2", optional: true}, + { name: 'client_id', Label: 'Contact ID', optional: false }, + { name: 'business_id', Label: 'Business ID', optional: false }, + { name: 'name', Label: 'Interaction Name', optional: false }, + { name: 'property_label1', Label: 'Property Label 1', optional: true }, + { name: 'property_label2', Label: 'Property Label 2', optional: true }, + { name: 'property_input1', Label: 'Property Input 1', optional: true }, + { name: 'property_input2', Label: 'Property Input 2', optional: true }, ] - end, - execute: lambda do |_connection, input| - post("https://app.kizen.com/api/interaction"). - payload( - "business_id": input["business_id"], - "client_id": input["client_id"], - "name": input["name"], - "properties": { + post('https://app.kizen.com/api/interaction') + .payload( + 'business_id': input['business_id'], + 'client_id': input['client_id'], + 'name': input['name'], + 'properties': { "#{input["property_label1"]}"=> input["property_input1"], "#{input["property_label2"]}"=> input["property_input2"]} - ) + ) end, - - - output_fields: lambda do - [ - { name: "id"} - ] - end, - - }, - - add_custom_lead_source: { #This is new - title: 'Add Custom Lead Source to a Contact', - subtitle: 'Add Custom Lead Source to a Contact', - description: lambda do - "Add Custom Lead Source to a Contact" - end, - - input_fields: lambda do + output_fields: lambda do [ - { name: "client_id",Label: "Contact ID", optional: false}, - { name: "source", Label: "Custom Lead Source", control_type: 'select',pick_list: 'lead_sources', hint: "To add Custom Lead Sources, navigate inside a contact record and add a custom source",optional: false}, - { name: "campaign",Label: "Campaign Name", optional: true}, - { name: "medium",Label: "Medium", optional: true}, - { name: "term",Label: "Term", optional: true}, - { name: "content",Label: "Content", optional: true} + { name: 'id'} ] - end, + }, - execute: lambda do |_connection, input| - post("https://app.kizen.com/api/lead-source-custom-source"). - payload( - "client": input["client_id"], - "source": input["source"], - "campaign": input["campaign"], - "medium": input["medium"], - "term": input["term"], - "content": input["content"], - ) - end, - + add_custom_lead_source: { # This is new here + title: 'Add Custom Lead Source to a Contact', + subtitle: 'Add Custom Lead Source to a Contact', + description: lambda do + "Add Custom Lead Source to a Contact" + end, + + input_fields: lambda do + [ + { name: 'client_id', Label: 'Contact ID', optional: false }, + { name: 'source', + Label: 'Custom Lead Source', + control_type: 'select', + pick_list: 'lead_sources', + hint: 'To add Custom Lead Sources, navigate inside a contact record and add a custom source', + optional: false}, + { name: 'campaign', Label: 'Campaign Name', optional: true }, + { name: 'medium', Label: 'Medium', optional: true }, + { name: 'term', Label: 'Term', optional: true }, + { name: 'content', Label: 'Content', optional: true } + ] + end, + execute: lambda do |_connection, input| + post('https://app.kizen.com/api/lead-source-custom-source') + .payload( + 'client': input['client_id'], + 'source': input['source'], + 'campaign': input['campaign'], + 'medium': input['medium'], + 'term': input['term'], + 'content': input['content'], + ) + end, output_fields: lambda do - [ - { name: "id"}, - { name: "client", Label: "Contact ID"} - ] - end, - - }, + [ + { name: 'id' }, + { name: 'client', Label: 'Contact ID' } + ] + end, + }, +log_activity: { # This is new + title: 'Log an Activity', + subtitle: 'Log an Activity', + description: lambda do + "Log an activity in Kizen" + end, - log_activity: { #This is new - title: 'Log an Activity', - subtitle: 'Log an Activity', - description: lambda do - "Log an activity in Kizen" - end, - - input_fields: lambda do |object_definitions| - object_definitions['log_activity_input'] - end, + input_fields: lambda do |object_definitions| + object_definitions['log_activity_input'] + end, - execute: lambda do |_connection, input| - format_payload = call('format_payload', input) - payload = format_payload.map do |key, value| - if key.include?('custom_fields') - custom_fields = value&.map do |k, v| - { k.split('~').last => + execute: lambda do |_connection, input| + format_payload = call('format_payload', input) + payload = format_payload.map do |key, value| + if key.include?('custom_fields') + custom_fields = value&.map do |k, v| + { k.split('~').last => { 'field_id' => k.split('~').first, 'value' => v } } + end&.inject(:merge) + { 'custom_fields' => custom_fields } + else + { key => value } + end + end.inject(:merge) + result = post('/api/logged-activity', payload) + + formatted_response = + result.map do |key, value| + if key.include?('custom_fields') + custom_fields = value.values&.map do |object| + { object['field_id'] => object['value'] } end&.inject(:merge) { 'custom_fields' => custom_fields } else { key => value } end - end.inject(:merge) - result = post('/api/logged-activity', payload) - - formatted_response = - result.map do |key, value| - if key.include?('custom_fields') - custom_fields = value.values&.map do |object| - { object['field_id'] => object['value'] } - end&.inject(:merge) - - { 'custom_fields' => custom_fields } - else - { key => value } - end - end&.inject(:merge) - call('format_response', formatted_response.compact) - end, + end&.inject(:merge) + call('format_response', formatted_response.compact) + end, - output_fields: lambda do - [ - { name: "id"} - ] - end, - }, - find_contact_by_email: { #This is new - title: 'Find contact by email', - subtitle: 'Find a contact in Kizen by email', - description: lambda do - "Find a contact contact in Kizen by email" - end, - - input_fields: lambda do - [ - { - name: 'email', - label: 'Contact Email', - optional: false - } - ] - end, + output_fields: lambda do + [ + { name: "id"} + ] + end, +}, +find_contact_by_email: { # This is new + title: 'Find contact by email', + subtitle: 'Find a contact in Kizen by email', + description: lambda do + "Find a contact contact in Kizen by email" + end, + + input_fields: lambda do + [ + { + name: 'email', + label: 'Contact Email', + optional: false + } + ] + end, - execute: lambda do |connection, input| - results = get("https://app.kizen.com/api/client?email=#{input["email"]}") - records = results["results"] - puts records - { - events: records - } - end, - - output_fields: lambda do |object_definitions| - { name: "events", type: "array", of: "object", - properties: object_definitions["contact_fields_trigger_output"] } - end - }, + execute: lambda do |connection, input| + results = get("https://app.kizen.com/api/client?email=#{input["email"]}") + records = results["results"] + puts records + { + events: records + } + end, - find_contact_by_id: { #This is new - title: 'Find contact by ID', - subtitle: 'Find a contact in Kizen by ID', - description: lambda do - "Find a contact contact in Kizen by ID" - end, + output_fields: lambda do |object_definitions| + { name: "events", type: "array", of: "object", + properties: object_definitions["contact_fields_trigger_output"] } + end +}, +find_contact_by_id: { # This is new + title: 'Find contact by ID', + subtitle: 'Find a contact in Kizen by ID', + description: lambda do + "Find a contact contact in Kizen by ID" + end, - input_fields: lambda do - [ - { - name: 'id', - label: 'Contact ID', - optional: false - } - ] - end, + input_fields: lambda do + [ + { + name: 'id', + label: 'Contact ID', + optional: false + } + ] + end, - execute: lambda do |connection, input| - result = get("https://app.kizen.com/api/client/#{input["id"]}") - - formatted_response = - result.map do |key, value| - if key.include?('custom_fields') - custom_fields = value.values&.map do |object| - { object['field_id'] => object['value'] } - end&.inject(:merge) + execute: lambda do |connection, input| + result = get('https://app.kizen.com/api/client/#{input["id"]}') - { 'custom_fields' => custom_fields } - else - { key => value } - end - end&.inject(:merge) - call('format_response', formatted_response.compact) - end, - - output_fields: lambda do |object_definitions| - object_definitions['contact_fields_output'] - end + formatted_response = + result.map do |key, value| + if key.include?('custom_fields') + custom_fields = value.values&.map do |object| + { object['field_id'] => object['value'] } + end&.inject(:merge) + { 'custom_fields' => custom_fields } + else + { key => value } + end + end&.inject(:merge) + call('format_response', formatted_response.compact) + end, - }, - - - find_company_by_name: { #This is new - title: 'Find company by name', - subtitle: 'Find a company in Kizen by name', - description: lambda do - "Find a company contact in Kizen by name" - end, + output_fields: lambda do |object_definitions| + object_definitions['contact_fields_output'] + end +}, +find_company_by_name: { # This is new + title: 'Find company by name', + subtitle: 'Find a company in Kizen by name', + description: lambda do + "Find a company contact in Kizen" + end, - input_fields: lambda do - [ - { - name: 'name', - label: 'Company Name', - optional: false - } - ] - end, + input_fields: lambda do + [ + { + name: 'name', + label: 'Company Name', + optional: false + } + ] + end, - execute: lambda do |connection, input| - results = get("https://app.kizen.com/api/company?search=#{input["name"]}") - records = results["results"] - puts records - { - events: records - } - end, + execute: lambda do |connection, input| + results = get("https://app.kizen.com/api/company?search=#{input["name"]}") + records = results["results"] + puts records + { + events: records + } + end, - output_fields: lambda do |object_definitions| - { name: "events", type: "array", of: "object", - properties: object_definitions["company_fields_trigger_output"] } - end - }, + output_fields: lambda do |object_definitions| + { name: "events", type: "array", of: "object", + properties: object_definitions["company_fields_trigger_output"] } + end +}, - find_deal_by_name: { #This is new - title: 'Find deal by name', - subtitle: 'Find a deal in Kizen by name', - description: lambda do - "Find a deal contact in Kizen by name" - end, +find_deal_by_name: { # This is new + title: 'Find deal by name', + subtitle: 'Find a deal in Kizen by name', + description: lambda do + "Find a deal contact in Kizen by name" + end, - input_fields: lambda do - [ - { - name: 'name', - label: 'Deal Name', - optional: false - } - ] - end, + input_fields: lambda do + [ + { + name: 'name', + label: 'Deal Name', + optional: false + } + ] + end, - execute: lambda do |connection, input| - results = get("https://app.kizen.com/api/deal?search=#{input["name"]}") - records = results["results"] - puts records - { - events: records - } - end, - - output_fields: lambda do |object_definitions| - { name: "events", type: "array", of: "object", - properties: object_definitions["deal_fields_trigger_output"] } - end - }, -create_order: { #This is new + execute: lambda do |connection, input| + results = get("https://app.kizen.com/api/deal?search=#{input["name"]}") + records = results["results"] + puts records + { + events: records + } + end, + + output_fields: lambda do |object_definitions| + { name: 'events', type: 'array', of: 'object', + properties: object_definitions['deal_fields_trigger_output'] } + end +}, + +create_order: { # This is new title: 'Create order', input_fields: lambda do [ { name: 'email', optional: false }, - { name: 'order_status', + { name: 'order_status', optional: false, - control_type: "select", + control_type: "select", pick_list: "order_status" }, - { name: 'order_number', optional: false, hint: "Must be an integer" }, - { name: 'created', optional: false, hint: "(YYYY-MM-DD)" }, + { name: 'order_number', optional: false, hint: 'Must be an integer' }, + { name: 'created', optional: false, hint: '(YYYY-MM-DD)' }, { name: 'sku', label: "SKU", optional: false }, - { name: 'name', optional: false,label:"Product Name" }, + { name: 'name', optional: false, label: 'Product Name' }, { name: 'price', optional: false }, - { name: 'quantity', optional: false , hint: "This must be a number without decimal places. Example - 1.00 will not work."}, + { name: 'quantity', + optional: false, + hint: 'This must be a number without decimal places. Example - 1.00 will not work.' } ] end, @@ -1159,7 +1150,7 @@ 'upload': true, 'line_items': [ { 'price': input['price'], - 'sku': input['sku'], + 'sku': input['sku'], 'name': input['name'], 'quantity': input['quantity'] } ] @@ -1296,7 +1287,7 @@ poll: lambda do |_connection, _input, page| page_size = 50 page ||= 1 - response = get("https://app.kizen.com/api/commerce/orders") + response = get('https://app.kizen.com/api/commerce/orders') .params(order_by: 'created', order_type: 'asc', page: page, @@ -1317,8 +1308,8 @@ output_fields: lambda do [ - { name: "id" }, - { name: "client" }, + { name: 'id' }, + { name: 'client' }, ] end }, From 324c2dceee51bb772e4f4ccd65687c7d25272027 Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 19:10:57 -0500 Subject: [PATCH 16/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 57334e31..941cd588 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -1002,10 +1002,10 @@ } ] end, - - execute: lambda do |connection, input| - results = get("https://app.kizen.com/api/client?email=#{input["email"]}") - records = results["results"] + + execute: lambda do |_connection, input| + results = get("https://app.kizen.com/api/client?email=#{input['email']}") + records = results['results'] puts records { events: records @@ -1091,10 +1091,10 @@ title: 'Find deal by name', subtitle: 'Find a deal in Kizen by name', description: lambda do - "Find a deal contact in Kizen by name" + "Find a deal by name" end, - - input_fields: lambda do + + input_fields: lambda do [ { name: 'name', @@ -1131,12 +1131,12 @@ pick_list: "order_status" }, { name: 'order_number', optional: false, hint: 'Must be an integer' }, { name: 'created', optional: false, hint: '(YYYY-MM-DD)' }, - { name: 'sku', label: "SKU", optional: false }, + { name: 'sku', label: 'SKU', optional: false }, { name: 'name', optional: false, label: 'Product Name' }, { name: 'price', optional: false }, - { name: 'quantity', - optional: false, - hint: 'This must be a number without decimal places. Example - 1.00 will not work.' } + { name: 'quantity', + optional: false, + hint: 'This must be a number without decimal places, 1.00 will not work.' } ] end, @@ -1288,7 +1288,7 @@ page_size = 50 page ||= 1 response = get('https://app.kizen.com/api/commerce/orders') - .params(order_by: 'created', + .params(order_by: 'created', order_type: 'asc', page: page, per_page: page_size @@ -1309,7 +1309,7 @@ output_fields: lambda do [ { name: 'id' }, - { name: 'client' }, + { name: 'client' } ] end }, From e8c77828c9a7a67337ad4c79f58d418fa64d79dc Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 19:15:19 -0500 Subject: [PATCH 17/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 941cd588..1cb73927 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -1013,8 +1013,8 @@ end, output_fields: lambda do |object_definitions| - { name: "events", type: "array", of: "object", - properties: object_definitions["contact_fields_trigger_output"] } + { name: 'events', type: 'array', of: 'object', + properties: object_definitions['contact_fields_trigger_output'] } end }, find_contact_by_id: { # This is new @@ -1033,9 +1033,9 @@ } ] end, - - execute: lambda do |connection, input| - result = get('https://app.kizen.com/api/client/#{input["id"]}') + + execute: lambda do |_connection, input| + result = get("https://app.kizen.com/api/client/#{input['id']}") formatted_response = result.map do |key, value| @@ -1050,7 +1050,7 @@ end&.inject(:merge) call('format_response', formatted_response.compact) end, - + output_fields: lambda do |object_definitions| object_definitions['contact_fields_output'] end @@ -1061,8 +1061,8 @@ description: lambda do "Find a company contact in Kizen" end, - - input_fields: lambda do + + input_fields: lambda do [ { name: 'name', @@ -1071,19 +1071,19 @@ } ] end, - - execute: lambda do |connection, input| - results = get("https://app.kizen.com/api/company?search=#{input["name"]}") - records = results["results"] + + execute: lambda do |_connection, input| + results = get("https://app.kizen.com/api/company?search=#{input['name']}") + records = results['results'] puts records { events: records } end, - + output_fields: lambda do |object_definitions| - { name: "events", type: "array", of: "object", - properties: object_definitions["company_fields_trigger_output"] } + { name: 'events', type: 'array', of: 'object', + properties: object_definitions['company_fields_trigger_output'] } end }, @@ -1136,7 +1136,7 @@ { name: 'price', optional: false }, { name: 'quantity', optional: false, - hint: 'This must be a number without decimal places, 1.00 will not work.' } + hint: 'Must be a number without decimal places, 1.00 will not work' } ] end, From a1578f27751233c73e08646dfe57f6593fed806e Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 19:19:16 -0500 Subject: [PATCH 18/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 1cb73927..d24e5964 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -900,7 +900,7 @@ title: 'Add Custom Lead Source to a Contact', subtitle: 'Add Custom Lead Source to a Contact', description: lambda do - "Add Custom Lead Source to a Contact" + "Add Custom Lead Source to a Contact" end, input_fields: lambda do @@ -935,19 +935,18 @@ { name: 'id' }, { name: 'client', Label: 'Contact ID' } ] - end, + end }, log_activity: { # This is new title: 'Log an Activity', subtitle: 'Log an Activity', description: lambda do - "Log an activity in Kizen" + "Log an activity in Kizen" end, input_fields: lambda do |object_definitions| object_definitions['log_activity_input'] end, - execute: lambda do |_connection, input| format_payload = call('format_payload', input) payload = format_payload.map do |key, value| @@ -965,7 +964,6 @@ end end.inject(:merge) result = post('/api/logged-activity', payload) - formatted_response = result.map do |key, value| if key.include?('custom_fields') @@ -979,21 +977,21 @@ end&.inject(:merge) call('format_response', formatted_response.compact) end, - + output_fields: lambda do [ - { name: "id"} + { name: 'id' } ] - end, + end }, find_contact_by_email: { # This is new title: 'Find contact by email', subtitle: 'Find a contact in Kizen by email', description: lambda do - "Find a contact contact in Kizen by email" + "Find a contact contact in Kizen by email" end, - input_fields: lambda do + input_fields: lambda do [ { name: 'email', @@ -1021,10 +1019,10 @@ title: 'Find contact by ID', subtitle: 'Find a contact in Kizen by ID', description: lambda do - "Find a contact contact in Kizen by ID" + "Find a contact contact in Kizen by ID " end, - - input_fields: lambda do + + input_fields: lambda do [ { name: 'id', From d751cd50fbfe6977a43b511bf7883968b26649ec Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 19:29:43 -0500 Subject: [PATCH 19/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index d24e5964..c818eeeb 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -910,8 +910,9 @@ Label: 'Custom Lead Source', control_type: 'select', pick_list: 'lead_sources', - hint: 'To add Custom Lead Sources, navigate inside a contact record and add a custom source', - optional: false}, + hint: 'To add Custom Lead Sources, + navigate inside a contact record and add a custom source', + optional: false }, { name: 'campaign', Label: 'Campaign Name', optional: true }, { name: 'medium', Label: 'Medium', optional: true }, { name: 'term', Label: 'Term', optional: true }, @@ -924,11 +925,11 @@ 'client': input['client_id'], 'source': input['source'], 'campaign': input['campaign'], - 'medium': input['medium'], - 'term': input['term'], - 'content': input['content'], + 'medium': input['medium'], + 'term': input['term'], + 'content': input['content'] ) - end, + end, output_fields: lambda do [ @@ -1125,8 +1126,8 @@ { name: 'email', optional: false }, { name: 'order_status', optional: false, - control_type: "select", - pick_list: "order_status" }, + control_type: 'select', + pick_list: 'order_status' }, { name: 'order_number', optional: false, hint: 'Must be an integer' }, { name: 'created', optional: false, hint: '(YYYY-MM-DD)' }, { name: 'sku', label: 'SKU', optional: false }, @@ -1307,7 +1308,7 @@ output_fields: lambda do [ { name: 'id' }, - { name: 'client' } + { name: 'client' } ] end }, From e1f11806a07bff5c62029e61f55c1388225c550c Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 19:34:16 -0500 Subject: [PATCH 20/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 31 +++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index c818eeeb..3bc8a475 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -280,7 +280,7 @@ label: field['name'], type: field['type'] } end standard_fields = [ - { name: 'id', label: 'Contact id' }, + { name: 'id', label: 'Contact id' }, { name: 'first_name' }, { name: 'last_name' }, { name: 'email' }, @@ -295,7 +295,7 @@ call('format_schema', standard_fields) end }, - + deal_fields_trigger_output: { fields: lambda do |_| custom_fields = get('/api/deal-custom-field')&. @@ -306,8 +306,8 @@ standard_fields = [ { name: 'id', type: 'integer', control_type: 'number', label: 'Deal ID' }, - { name: 'name',label: 'Deal Name' }, - { name: 'amount',type: 'float' }, + { name: 'name', label: 'Deal Name' }, + { name: 'amount', type: 'float' }, { name: 'owner' }, { name: 'stage' }, { name: 'pipeline' }, @@ -317,7 +317,7 @@ call('format_schema', standard_fields) end }, - + object_input: { fields: lambda do |_connection, config_fields| case config_fields['object'] @@ -779,7 +779,7 @@ help: lambda do |_, objects| "Create #{objects['object']&.downcase || 'object'} in Kizen." end, - + config_fields: [ { name: 'object', @@ -865,17 +865,17 @@ title: 'Log an interaction', subtitle: 'Log an interaction', description: lambda do - "Log an interaction in Kizen" + "Log an interaction in Kizen" end, input_fields: lambda do [ { name: 'client_id', Label: 'Contact ID', optional: false }, { name: 'business_id', Label: 'Business ID', optional: false }, { name: 'name', Label: 'Interaction Name', optional: false }, - { name: 'property_label1', Label: 'Property Label 1', optional: true }, - { name: 'property_label2', Label: 'Property Label 2', optional: true }, - { name: 'property_input1', Label: 'Property Input 1', optional: true }, - { name: 'property_input2', Label: 'Property Input 2', optional: true }, + { name: 'property_label1', Label: 'Property Label1', optional: true }, + { name: 'property_label2', Label: 'Property Label2', optional: true }, + { name: 'property_input1', Label: 'Property Input1', optional: true }, + { name: 'property_input2', Label: 'Property Input 2', optional: true } ] end, execute: lambda do |_connection, input| @@ -885,8 +885,9 @@ 'client_id': input['client_id'], 'name': input['name'], 'properties': { - "#{input["property_label1"]}"=> input["property_input1"], - "#{input["property_label2"]}"=> input["property_input2"]} + "#{input['property_label1']}"=> input['property_input1'], + "#{input['property_label2']}"=> input['property_input2'] + } ) end, output_fields: lambda do @@ -910,7 +911,7 @@ Label: 'Custom Lead Source', control_type: 'select', pick_list: 'lead_sources', - hint: 'To add Custom Lead Sources, + hint: 'To add Custom Lead Sources, navigate inside a contact record and add a custom source', optional: false }, { name: 'campaign', Label: 'Campaign Name', optional: true }, @@ -927,7 +928,7 @@ 'campaign': input['campaign'], 'medium': input['medium'], 'term': input['term'], - 'content': input['content'] + 'content': input['content'] ) end, From 17e22cdf277d556dcc89aadf5a6e6d1f90380ed9 Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 19:37:54 -0500 Subject: [PATCH 21/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 28 ++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 3bc8a475..2b693618 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -152,8 +152,7 @@ '__quote__' => '"' ) end, - - + format_response: lambda do |payload| if payload.is_a?(Array) payload.map do |array_value| @@ -204,7 +203,6 @@ object_definitions: { - log_activity_input: { fields: lambda do |_| custom_fields = get('/api/activity-type')&. @@ -214,17 +212,18 @@ end standard_fields = [ { name: 'client', label: 'Contact ID', optional: false }, - { name: 'activity_type_id',label: 'Activity', control_type: 'select', pick_list: 'activities', optional: false, toggle_hint: 'Select from list', - toggle_field:{ - name: 'activity_id', label: 'Activity id', type: :string, control_type: "text", optional:false, toggle_hint: "Use Activity ID"} - }, + { name: 'activity_type_id', + label: 'Activity', + control_type: 'select', + pick_list: 'activities', + optional: false }, { name: 'custom_fields', type: 'object', properties: custom_fields } ] call('format_schema', standard_fields) end }, - + contact_fields_output: { fields: lambda do |_| custom_fields = get('/api/client-field')&. @@ -249,8 +248,7 @@ call('format_schema', standard_fields) end }, - - + company_fields_trigger_output: { fields: lambda do |_| custom_fields = get('/api/company-field')&. @@ -261,7 +259,7 @@ standard_fields = [ { name: 'id', type: 'integer', control_type: 'number', label: 'Company id' }, - { name: 'name',label: 'Company Name' }, + { name: 'name', label: 'Company Name' }, { name: 'business_phone' }, { name: 'email' }, { name: 'mobile_phone' }, @@ -271,7 +269,7 @@ call('format_schema', standard_fields) end }, - + contact_fields_trigger_output: { fields: lambda do |_| custom_fields = get('/api/client-field')&. @@ -885,9 +883,9 @@ 'client_id': input['client_id'], 'name': input['name'], 'properties': { - "#{input['property_label1']}"=> input['property_input1'], - "#{input['property_label2']}"=> input['property_input2'] - } + "#{input['property_label1']}" => input['property_input1'], + "#{input['property_label2']}" => input['property_input2'] + } ) end, output_fields: lambda do From 2a22fbc9f49f266b78892df2bdca5b95db078e4b Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Wed, 20 May 2020 19:39:55 -0500 Subject: [PATCH 22/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index 2b693618..d42037b5 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -55,7 +55,7 @@ end input end, - + format_payload: lambda do |payload| if payload.is_a?(Array) payload.map do |array_value| @@ -71,7 +71,7 @@ end.inject(:merge) end end, - + format_schema: lambda do |schema| if schema.is_a?(Array) schema.map do |array_value| @@ -88,7 +88,7 @@ end.inject(:merge) end end, - + replace_special_characters: lambda do |input| input.gsub(/[-<>!@#$%^&*()+={}:;'"`~,.?|]/, '-' => '__hyp__', @@ -119,7 +119,7 @@ ':' => '__colon__', '\"' => '__quote__') end, - + inject_special_characters: lambda do |input| input.gsub( /(__hyp__|__lt__|__gt__|__excl__|__at__|__hashtag__|__dollar__|\__percent__|__pwr__|__amper__|__star__|__lbracket__|__rbracket__|__plus__|__eq__|__rcrbrack__|__lcrbrack__|__semicol__|__apost__|__bckquot__|__tilde__|__comma__|__period__|__qmark__|__pipe__|__colon__|__quote__|__slash__|__bslash__)/, From eafe5f53dc8237e036539e9582fee665194057a2 Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Tue, 26 May 2020 15:51:59 -0500 Subject: [PATCH 23/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 30 ++++---------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index d42037b5..ad7e7797 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -56,22 +56,6 @@ input end, - format_payload: lambda do |payload| - if payload.is_a?(Array) - payload.map do |array_value| - call('format_payload', array_value) - end - elsif payload.is_a?(Hash) - payload.map do |key, value| - key = call('inject_special_characters', key) - if value.is_a?(Array) || value.is_a?(Hash) - value = call('format_payload', value) - end - { key => value } - end.inject(:merge) - end - end, - format_schema: lambda do |schema| if schema.is_a?(Array) schema.map do |array_value| @@ -948,8 +932,8 @@ object_definitions['log_activity_input'] end, execute: lambda do |_connection, input| - format_payload = call('format_payload', input) - payload = format_payload.map do |key, value| + format_input = call('format_input', input) + payload = format_input.map do |key, value| if key.include?('custom_fields') custom_fields = value&.map do |k, v| { k.split('~').last => @@ -975,7 +959,7 @@ { key => value } end end&.inject(:merge) - call('format_response', formatted_response.compact) + call('format_output', formatted_response.compact) end, output_fields: lambda do @@ -1004,7 +988,6 @@ execute: lambda do |_connection, input| results = get("https://app.kizen.com/api/client?email=#{input['email']}") records = results['results'] - puts records { events: records } @@ -1046,7 +1029,7 @@ { key => value } end end&.inject(:merge) - call('format_response', formatted_response.compact) + call('fformat_output', formatted_response.compact) end, output_fields: lambda do |object_definitions| @@ -1073,7 +1056,6 @@ execute: lambda do |_connection, input| results = get("https://app.kizen.com/api/company?search=#{input['name']}") records = results['results'] - puts records { events: records } @@ -1105,7 +1087,6 @@ execute: lambda do |connection, input| results = get("https://app.kizen.com/api/deal?search=#{input["name"]}") records = results["results"] - puts records { events: records } @@ -1339,7 +1320,6 @@ page: page, per_page: page_size) - puts response records = response&.[]('results') || [] page = records.size >= page_size ? page + 1 : page { @@ -1440,7 +1420,6 @@ poll: lambda do |_connection, input, page| page_size = 50 activity_id = input['activities'] - puts activity_id page ||= 1 response = get("https://app.kizen.com/api/logged-activity?activity_type_id=#{activity_id}") .params( @@ -1449,7 +1428,6 @@ page: page, per_page: page_size ) - puts response records = response&.[]('results') || [] page = records.size >= page_size ? page + 1 : page { From 4e9f1bc0567c45cde1d31541d6944d34f77df31c Mon Sep 17 00:00:00 2001 From: doctordav011 Date: Tue, 26 May 2020 15:58:41 -0500 Subject: [PATCH 24/24] Update kizen.rb --- custom_connectors/custom_auth/kizen.rb | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/custom_connectors/custom_auth/kizen.rb b/custom_connectors/custom_auth/kizen.rb index ad7e7797..528027ac 100644 --- a/custom_connectors/custom_auth/kizen.rb +++ b/custom_connectors/custom_auth/kizen.rb @@ -137,22 +137,6 @@ ) end, - format_response: lambda do |payload| - if payload.is_a?(Array) - payload.map do |array_value| - call('format_response', array_value) - end - elsif payload.is_a?(Hash) - payload.map do |key, value| - key = call('replace_special_characters', key) - if value.is_a?(Array) || value.is_a?(Hash) - value = call('format_response', value) - end - { key => value } - end.inject(:merge) - end - end, - format_output: lambda do |result| if result['custom_fields'].present? result['custom_fields'] = result['custom_fields']