Conversation
|
@doctordav011 Could you fix the hound comments first! |
| order_status: lambda do |connection| | ||
| [ | ||
| # Display name, value | ||
| ['paid', 'paid'] |
There was a problem hiding this comment.
Style/WordArray: Use %w or %W for an array of words.
| url = 'https://app.kizen.com/api/lead-source-custom-source-type' | ||
| get(url)['results'].pluck('name', 'id') | ||
| }, | ||
|
|
There was a problem hiding this comment.
Layout/TrailingWhitespace: Trailing whitespace detected.
| url = 'https://app.kizen.com/api/activity-type?fields=id,name,created' | ||
| get(url).pluck('name', 'id') | ||
| }, | ||
|
|
There was a problem hiding this comment.
Layout/TrailingWhitespace: Trailing whitespace detected.
| activity_id = input['activities'] | ||
| puts activity_id | ||
| page ||= 1 | ||
| response = get("https://app.kizen.com/api/logged-activity?activity_type_id=#{activity_id}") |
There was a problem hiding this comment.
Metrics/LineLength: Line is too long. [95/80]
| contacts = get("https://app.kizen.com/api/client-field-revision") | ||
| .params( | ||
| order_by: 'updated_at', | ||
| order_type: 'asc', |
There was a problem hiding this comment.
Layout/TrailingWhitespace: Trailing whitespace detected.
| input_fields: ->() { | ||
| }, | ||
|
|
||
| poll: ->(connection, input, last_updated_since) { |
There was a problem hiding this comment.
Style/Lambda: Use the lambda method for multiline lambdas.
Lint/UnusedBlockArgument: Unused block argument - connection. If it's necessary, use _ or _connection as an argument name to indicate that it won't be used.
|
|
||
| updated_contact: { #This is new | ||
|
|
||
| input_fields: ->() { |
There was a problem hiding this comment.
Style/Lambda: Use the lambda method for multiline lambdas.
Style/EmptyLambdaParameter: Omit parentheses for the empty lambda parameters.
Layout/SpaceInsideBlockBraces: Space inside empty braces detected.
| end | ||
| }, | ||
|
|
||
| new_logged_activity: {# I'm having trouble parsing the output on this |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
Layout/SpaceBeforeComment: Put a space before an end-of-line comment.
|
|
||
| }, | ||
|
|
||
| updated_contact: {# This is new |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
Layout/SpaceBeforeComment: Put a space before an end-of-line comment.
| response = get("https://app.kizen.com/api/scheduled-activity?activity_type=#{activity_id}") | ||
| .params(order_by: 'created', | ||
| order_type: 'asc', | ||
| page: page, |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
| page ||= 1 | ||
| response = get("https://app.kizen.com/api/scheduled-activity?activity_type=#{activity_id}") | ||
| .params(order_by: 'created', | ||
| order_type: 'asc', |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
| page_size = 50 | ||
| activity_id = input['activities'] | ||
| page ||= 1 | ||
| response = get("https://app.kizen.com/api/scheduled-activity?activity_type=#{activity_id}") |
There was a problem hiding this comment.
Metrics/LineLength: Line is too long. [99/80]
| dedup: lambda do |contact| | ||
| contact['id'] | ||
| end, | ||
|
|
There was a problem hiding this comment.
Layout/TrailingWhitespace: Trailing whitespace detected.
| can_poll_more: records.size >= page_size | ||
| } | ||
| end, | ||
|
|
There was a problem hiding this comment.
Layout/TrailingWhitespace: Trailing whitespace detected.
| per_page: page_size | ||
| ) | ||
| records = response&.[]('results') || [] | ||
| page = records.size >= page_size ? page + 1 : 1 |
There was a problem hiding this comment.
Layout/TrailingWhitespace: Trailing whitespace detected.
| title: 'New Order', | ||
| subtitle: 'New Order in Kizen', | ||
| description: lambda do | ||
| "New <span class='provider'>Order</span> in <span class='provider'>Kizen</span>" |
There was a problem hiding this comment.
Metrics/LineLength: Line is too long. [88/80]
| .dig('results', 0) | ||
| end | ||
| }, | ||
| new_order: { |
There was a problem hiding this comment.
Layout/TrailingWhitespace: Trailing whitespace detected.
| .params(order_by: 'created', | ||
| order_type: 'asc', | ||
| page: page, | ||
| per_page: page_size) |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
| order_type: 'asc', | ||
| page: page, | ||
| per_page: page_size | ||
| ) |
There was a problem hiding this comment.
Layout/ClosingParenthesisIndentation: Align ) with (.
Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the same line as the last argument when opening brace is on the same line as the first argument.
| response = get("https://app.kizen.com/api/commerce/orders") | ||
| .params(order_by: 'created', | ||
| order_type: 'asc', | ||
| page: page, |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
| .params(order_by: 'created', | ||
| order_type: 'asc', | ||
| page: page, | ||
| per_page: page_size |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
| page ||= 1 | ||
| response = get("https://app.kizen.com/api/commerce/orders") | ||
| .params(order_by: 'created', | ||
| order_type: 'asc', |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
| ] | ||
| end | ||
| } | ||
| }, |
There was a problem hiding this comment.
Layout/IndentHash: Indent the right brace the same as the start of the line where the left brace is.
| [ | ||
| { name: 'email', optional: false }, | ||
| { name: 'order_status', | ||
| optional: false, |
There was a problem hiding this comment.
Layout/TrailingWhitespace: Trailing whitespace detected.
| 'created': input['created'], | ||
| 'client': { 'email': input['email'] }, | ||
| 'upload': true, | ||
| 'line_items': [ |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
| 'order_number': input['order_number'], | ||
| 'created': input['created'], | ||
| 'client': { 'email': input['email'] }, | ||
| 'upload': true, |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
| end | ||
| }, | ||
|
|
||
| create_order: { # This is new |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
|
|
||
| execute: lambda do |connection, input| | ||
| results = get("https://app.kizen.com/api/deal?search=#{input["name"]}") | ||
| records = results["results"] |
There was a problem hiding this comment.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
| end, | ||
|
|
||
| execute: lambda do |connection, input| | ||
| results = get("https://app.kizen.com/api/deal?search=#{input["name"]}") |
There was a problem hiding this comment.
Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.
| ] | ||
| end, | ||
|
|
||
| execute: lambda do |connection, input| |
There was a problem hiding this comment.
Lint/UnusedBlockArgument: Unused block argument - connection. If it's necessary, use _ or _connection as an argument name to indicate that it won't be used.
| } | ||
| ] | ||
| end, | ||
|
|
There was a problem hiding this comment.
Layout/TrailingWhitespace: Trailing whitespace detected.
| end | ||
| }, | ||
|
|
||
| find_deal_by_name: { # This is new |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
| object_definitions['contact_fields_output'] | ||
| end | ||
| }, | ||
| find_company_by_name: { # This is new |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
| properties: object_definitions['contact_fields_trigger_output'] } | ||
| end | ||
| }, | ||
| find_contact_by_id: { # This is new |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
| ] | ||
| end, | ||
| }, | ||
| find_contact_by_email: { # This is new |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
| object_definitions['log_activity_input'] | ||
| end, | ||
|
|
||
| execute: lambda do |_connection, input| |
There was a problem hiding this comment.
Metrics/BlockLength: Block has too many lines. [28/25]
| ] | ||
| end, | ||
| }, | ||
| log_activity: { # This is new |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
| end, | ||
| execute: lambda do |_connection, input| | ||
| post('https://app.kizen.com/api/lead-source-custom-source') | ||
| .payload( |
There was a problem hiding this comment.
Layout/MultilineMethodCallIndentation: Use 2 (not 5) spaces for indenting an expression spanning multiple lines.
| [ | ||
| { name: 'client_id', Label: 'Contact ID', optional: false }, | ||
| { name: 'source', | ||
| Label: 'Custom Lead Source', |
There was a problem hiding this comment.
Layout/TrailingWhitespace: Trailing whitespace detected.
| input_fields: lambda do | ||
| [ | ||
| { name: 'client_id', Label: 'Contact ID', optional: false }, | ||
| { name: 'source', |
There was a problem hiding this comment.
Layout/TrailingWhitespace: Trailing whitespace detected.
| end, | ||
| }, | ||
|
|
||
| add_custom_lead_source: { # This is new here |
There was a problem hiding this comment.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
| [ | ||
| { name: 'id'} | ||
| ] | ||
| end, |
There was a problem hiding this comment.
Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.
| end, | ||
| output_fields: lambda do | ||
| [ | ||
| { name: 'id'} |
There was a problem hiding this comment.
Layout/SpaceInsideHashLiteralBraces: Space inside } missing.
| "#{input["property_label1"]}"=> input["property_input1"], | ||
| "#{input["property_label2"]}"=> input["property_input2"]} | ||
| ) | ||
| end, |
There was a problem hiding this comment.
Layout/TrailingWhitespace: Trailing whitespace detected.
|
|
||
| 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__)/, |
There was a problem hiding this comment.
Metrics/LineLength: Line is too long. [306/80]
| 'name': input['name'], | ||
| 'properties': { | ||
| "#{input['property_label1']}" => input['property_input1'], | ||
| "#{input['property_label2']}" => input['property_input2'] |
There was a problem hiding this comment.
Style/UnneededInterpolation: Prefer to_s over string interpolation.
| 'client_id': input['client_id'], | ||
| 'name': input['name'], | ||
| 'properties': { | ||
| "#{input['property_label1']}" => input['property_input1'], |
There was a problem hiding this comment.
Style/UnneededInterpolation: Prefer to_s over string interpolation.
| '\"' => '__quote__') | ||
| end, | ||
|
|
||
| inject_special_characters: lambda do |input| |
There was a problem hiding this comment.
Metrics/BlockLength: Block has too many lines. [30/25]
| end | ||
| end, | ||
|
|
||
| replace_special_characters: lambda do |input| |
There was a problem hiding this comment.
Metrics/BlockLength: Block has too many lines. [28/25]
bennettgo
left a comment
There was a problem hiding this comment.
Please try to fix some of the hound comments and there are some alignment issues!
| 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, |
There was a problem hiding this comment.
This has been replaced with the format_input method
There was a problem hiding this comment.
deleted format_payload method and changed to format_input
| 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, |
There was a problem hiding this comment.
We have done away with this method. This can be seen in the object_input method as standard input fields do not have special characters anyway.
There was a problem hiding this comment.
If I change these references to object_input, the object input method does not have the correct 'cases' for the other objects(activities, interactions, etc.).
| end | ||
| end, | ||
|
|
||
| replace_special_characters: lambda do |input| |
There was a problem hiding this comment.
We do not need this method anymore. Instead, we do a simple replacement of -s with _s when we retrieve custom fields in the get_custom_fields method. When we are preparing the payload, we use format_input to switch everything back. Could your actions and triggers use format_input and get_custom_fields instead?
There was a problem hiding this comment.
I'm not sure how to do this.
| '\"' => '__quote__') | ||
| end, | ||
|
|
||
| inject_special_characters: lambda do |input| |
There was a problem hiding this comment.
I'm not sure how to do this.
| ) | ||
| end, | ||
|
|
||
| format_response: lambda do |payload| |
There was a problem hiding this comment.
This has been replaced with the format_output method. Could we use format_output in the new actions and triggers?
There was a problem hiding this comment.
Deleted format_response and changed references to format_output
| end | ||
| } | ||
| }, | ||
| log_interaction: { # This is new |
There was a problem hiding this comment.
Can we group log activity and log interaction together? into log event action. This can be easily done by following the patterns in the create_object and update_object steps
There was a problem hiding this comment.
I don't really want to do this. It is important to have all possible actions shown to the end user on the very first screen(https://www.workato.com/integrations/kizen) so they can see how many actions and triggers are possible.
| ] | ||
| end | ||
| }, | ||
| find_contact_by_email: { # This is new |
There was a problem hiding this comment.
Can we group Find contact by email,Find contact by id, Find company by name and Find deal by name into a single Search object action? This can be easily done by following the patterns in the create_object and update_object steps
It could be Search objects with object selection for
- Contact by ID
- Contact by email
- Company by name
- Deal by name
There was a problem hiding this comment.
I don't really want to do this. It is important to have all possible actions shown to the end user on the very first screen(https://www.workato.com/integrations/kizen) so they can see how many actions and triggers are possible.
| execute: lambda do |_connection, input| | ||
| results = get("https://app.kizen.com/api/client?email=#{input['email']}") | ||
| records = results['results'] | ||
| puts records |
Added 4 new triggers and 8 new actions