workato-connector-sdk 0.4.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +44 -24
- data/lib/workato/cli/exec_command.rb +1 -1
- data/lib/workato/cli/generate_command.rb +32 -5
- data/lib/workato/cli/main.rb +4 -2
- data/lib/workato/cli/oauth2_command.rb +2 -0
- data/lib/workato/cli/push_command.rb +2 -5
- data/lib/workato/cli/schema_command.rb +81 -0
- data/lib/workato/connector/sdk/trigger.rb +32 -12
- data/lib/workato/connector/sdk/version.rb +1 -1
- data/lib/workato/connector/sdk.rb +3 -0
- data/lib/workato/extension/string.rb +7 -14
- metadata +4 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 70241ed06aeae85f14f775ff2366ec4edbc54322aa034f0931dd987e9fd1fb2c
         | 
| 4 | 
            +
              data.tar.gz: 1a99f10c8c3c4dfe036e591cddb81504980586b0fb48cd319f7cfd5e510a1512
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b74c573b4e5c00509b955a14477a132ce01cfa6824382f21e50646bc10ce5ee44f3f2bf9bbf06ad7e565ddedfd0cce8c5017ae31e28e3b470164600abbb29d6d
         | 
| 7 | 
            +
              data.tar.gz: 1f1139718e2f18faa63087e3782c42a0bb0b3bae237086044873283bad8128f9ce42b26b3738d0a3a8ff22e529180a6d8df821f7c7eee9da68b85d3b97098340
         | 
    
        data/README.md
    CHANGED
    
    | @@ -265,27 +265,28 @@ Usage: | |
| 265 265 | 
             
              workato exec <PATH>
         | 
| 266 266 |  | 
| 267 267 | 
             
            Options:
         | 
| 268 | 
            -
              -c, [--connector=CONNECTOR] | 
| 269 | 
            -
              -s, [--settings=SETTINGS] | 
| 270 | 
            -
              -n, [--connection=CONNECTION] | 
| 271 | 
            -
              -k, [--key=KEY] | 
| 272 | 
            -
              -i, [--input=INPUT] | 
| 273 | 
            -
                  [--closure=CLOSURE] | 
| 274 | 
            -
                  [--continue=CONTINUE] | 
| 275 | 
            -
              -a, [--args=ARGS] | 
| 276 | 
            -
                  [--extended-input-schema=EXTENDED_INPUT_SCHEMA] | 
| 277 | 
            -
                  [--extended-output-schema=EXTENDED_OUTPUT_SCHEMA] | 
| 278 | 
            -
                  [--config-fields=CONFIG_FIELDS] | 
| 279 | 
            -
              -w, [--webhook-payload=WEBHOOK_PAYLOAD] | 
| 280 | 
            -
                  [--webhook-params=WEBHOOK_PARAMS] | 
| 281 | 
            -
                  [--webhook-headers=WEBHOOK_HEADERS] | 
| 282 | 
            -
                  [--webhook- | 
| 283 | 
            -
             | 
| 284 | 
            -
             | 
| 285 | 
            -
                  [-- | 
| 286 | 
            -
                  [-- | 
| 287 | 
            -
                  [-- | 
| 288 | 
            -
                  [-- | 
| 268 | 
            +
              -c, [--connector=CONNECTOR]                                # Path to connector source code
         | 
| 269 | 
            +
              -s, [--settings=SETTINGS]                                  # Path to plain or encrypted file with connection configs, passwords, tokens, secrets etc
         | 
| 270 | 
            +
              -n, [--connection=CONNECTION]                              # Connection name if settings file contains multiple settings
         | 
| 271 | 
            +
              -k, [--key=KEY]                                            # Path to file with encrypt/decrypt key. NOTE: key from WORKATO_CONNECTOR_MASTER_KEY has higher priority
         | 
| 272 | 
            +
              -i, [--input=INPUT]                                        # Path to file with input JSON
         | 
| 273 | 
            +
                  [--closure=CLOSURE]                                    # Path to file with next poll closure JSON
         | 
| 274 | 
            +
                  [--continue=CONTINUE]                                  # Path to file with next multistep action continue closure JSON
         | 
| 275 | 
            +
              -a, [--args=ARGS]                                          # Path to file with method arguments JSON
         | 
| 276 | 
            +
                  [--extended-input-schema=EXTENDED_INPUT_SCHEMA]        # Path to file with extended input schema definition JSON
         | 
| 277 | 
            +
                  [--extended-output-schema=EXTENDED_OUTPUT_SCHEMA]      # Path to file with extended output schema definition JSON
         | 
| 278 | 
            +
                  [--config-fields=CONFIG_FIELDS]                        # Path to file with config fields JSON
         | 
| 279 | 
            +
              -w, [--webhook-payload=WEBHOOK_PAYLOAD]                    # Path to file with webhook payload JSON
         | 
| 280 | 
            +
                  [--webhook-params=WEBHOOK_PARAMS]                      # Path to file with webhook params JSON
         | 
| 281 | 
            +
                  [--webhook-headers=WEBHOOK_HEADERS]                    # Path to file with webhook headers JSON
         | 
| 282 | 
            +
                  [--webhook-subscribe-output=WEBHOOK_SUBSCRIBE_OUTPUT]  # Path to file with webhook subscribe output JSON
         | 
| 283 | 
            +
                  [--webhook-url=WEBHOOK_URL]                            # Webhook URL for automatic webhook subscription
         | 
| 284 | 
            +
              -o, [--output=OUTPUT]                                      # Write output to JSON file
         | 
| 285 | 
            +
                  [--oauth2-code=OAUTH2_CODE]                            # OAuth2 code exchange to tokens pair
         | 
| 286 | 
            +
                  [--redirect-url=REDIRECT_URL]                          # OAuth2 callback url
         | 
| 287 | 
            +
                  [--refresh-token=REFRESH_TOKEN]                        # OAuth2 refresh token
         | 
| 288 | 
            +
                  [--debug], [--no-debug]
         | 
| 289 | 
            +
                  [--verbose], [--no-verbose]                    
         | 
| 289 290 |  | 
| 290 291 | 
             
            Description:
         | 
| 291 292 | 
             
              The 'workato exec' executes connector's lambda block at <PATH>. Lambda's parameters can be provided if needed, see options part.
         | 
| @@ -319,7 +320,26 @@ Commands: | |
| 319 320 | 
             
              workato generate test            # Generate empty test for connector
         | 
| 320 321 | 
             
            ```
         | 
| 321 322 |  | 
| 322 | 
            -
             | 
| 323 | 
            +
            ### 3.4.1 workato generate schema
         | 
| 324 | 
            +
            Use command to generate Workato Schema from a sample file. Supported inputs csv, json
         | 
| 325 | 
            +
             | 
| 326 | 
            +
            ```
         | 
| 327 | 
            +
            workato generate help schema
         | 
| 328 | 
            +
             | 
| 329 | 
            +
            Usage:
         | 
| 330 | 
            +
              workato generate schema
         | 
| 331 | 
            +
             | 
| 332 | 
            +
            Options:
         | 
| 333 | 
            +
              [--json=JSON]            # Path to JSON sample file
         | 
| 334 | 
            +
              [--csv=CSV]              # Path to CSV sample file
         | 
| 335 | 
            +
              [--col-sep=COL_SEP]      # Use separator for CSV converter
         | 
| 336 | 
            +
                                       # Default: comma
         | 
| 337 | 
            +
                                       # Possible values: comma, space, tab, colon, semicolon, pipe
         | 
| 338 | 
            +
              [--api-email=API_EMAIL]  # Email for accessing Workato API or set WORKATO_API_EMAIL environment variable
         | 
| 339 | 
            +
              [--api-token=API_TOKEN]  # Token for accessing Workato API or set WORKATO_API_TOKEN environment variable
         | 
| 340 | 
            +
            ```
         | 
| 341 | 
            +
             | 
| 342 | 
            +
            ### 3.4.2 workato generate test
         | 
| 323 343 |  | 
| 324 344 | 
             
            - Use `workato generate test` to generate tests based on your connector.rb file.
         | 
| 325 345 |  | 
| @@ -400,8 +420,8 @@ Options: | |
| 400 420 | 
             
              -l, [--logo=LOGO]                # Path to connector logo: png or jpeg file
         | 
| 401 421 | 
             
              -n, [--notes=NOTES]              # Release notes
         | 
| 402 422 | 
             
              -c, [--connector=CONNECTOR]      # Path to connector source code
         | 
| 403 | 
            -
                  [--api-email=API_EMAIL]      # Email for accessing Workato API or set WORKATO_API_EMAIL  | 
| 404 | 
            -
                  [--api-token=API_TOKEN]      # Token for accessing Workato API or set WORKATO_API_TOKEN  | 
| 423 | 
            +
                  [--api-email=API_EMAIL]      # Email for accessing Workato API or set WORKATO_API_EMAIL environment variable
         | 
| 424 | 
            +
                  [--api-token=API_TOKEN]      # Token for accessing Workato API or set WORKATO_API_TOKEN environment variable
         | 
| 405 425 | 
             
                  [--environment=ENVIRONMENT]  # Server to push connector code to
         | 
| 406 426 | 
             
                                               # Default: live
         | 
| 407 427 | 
             
                                               # Possible values: preview, preview-eu, live, live-eu
         | 
| @@ -50,7 +50,7 @@ module Workato | |
| 50 50 | 
             
                      settings: settings,
         | 
| 51 51 | 
             
                      input: from_json(options[:input]),
         | 
| 52 52 | 
             
                      output: from_json(options[:input]),
         | 
| 53 | 
            -
                      webhook_subscribe_output: from_json(options[: | 
| 53 | 
            +
                      webhook_subscribe_output: from_json(options[:webhook_subscribe_output]).presence,
         | 
| 54 54 | 
             
                      args: from_json(options[:args]).presence || [],
         | 
| 55 55 | 
             
                      extended_input_schema: from_json(options[:extended_input_schema]).presence || [],
         | 
| 56 56 | 
             
                      extended_output_schema: from_json(options[:extended_output_schema]).presence || [],
         | 
| @@ -39,12 +39,39 @@ module Workato | |
| 39 39 | 
             
                    create_spec_files
         | 
| 40 40 | 
             
                  end
         | 
| 41 41 |  | 
| 42 | 
            -
                  desc 'schema', 'Generate schema  | 
| 42 | 
            +
                  desc 'schema', 'Generate schema from example'
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  method_option :json, type: :string, desc: 'Path to JSON sample file'
         | 
| 45 | 
            +
                  method_option :csv, type: :string, desc: 'Path to CSV sample file'
         | 
| 46 | 
            +
                  method_option :col_sep,
         | 
| 47 | 
            +
                                type: :string,
         | 
| 48 | 
            +
                                desc: 'Use separator for CSV converter',
         | 
| 49 | 
            +
                                enum: SchemaCommand::CSV_SEPARATORS,
         | 
| 50 | 
            +
                                default: 'comma'
         | 
| 51 | 
            +
                  method_option :api_email,
         | 
| 52 | 
            +
                                type: :string,
         | 
| 53 | 
            +
                                desc: 'Email for accessing Workato API or '\
         | 
| 54 | 
            +
                                      "set #{Workato::Connector::Sdk::WORKATO_API_EMAIL_ENV} environment variable"
         | 
| 55 | 
            +
                  method_option :api_token,
         | 
| 56 | 
            +
                                type: :string,
         | 
| 57 | 
            +
                                desc: 'Token for accessing Workato API or ' \
         | 
| 58 | 
            +
                                      "set #{Workato::Connector::Sdk::WORKATO_API_TOKEN_ENV} environment variable"
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  long_desc <<~HELP
         | 
| 61 | 
            +
                    The 'workato generate schema' command generates Workato Schema from a sample file.
         | 
| 62 | 
            +
                    Supported inputs #{SchemaCommand::SAMPLE_TO_SCHEMA_SUPPORT_TYPES.join(', ')}
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                    Example:
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                      workato generate schema --csv=input.csv --col-sep=semicolon # This generates a schema from CSV file.
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                      workato generate schema --json=input.json
         | 
| 69 | 
            +
                  HELP
         | 
| 70 | 
            +
             | 
| 43 71 | 
             
                  def schema
         | 
| 44 | 
            -
                     | 
| 45 | 
            -
                       | 
| 46 | 
            -
             | 
| 47 | 
            -
                    HELP
         | 
| 72 | 
            +
                    SchemaCommand.new(
         | 
| 73 | 
            +
                      options: options
         | 
| 74 | 
            +
                    ).call
         | 
| 48 75 | 
             
                  end
         | 
| 49 76 |  | 
| 50 77 | 
             
                  private
         | 
    
        data/lib/workato/cli/main.rb
    CHANGED
    
    | @@ -4,6 +4,7 @@ require 'thor' | |
| 4 4 | 
             
            require 'workato/connector/sdk'
         | 
| 5 5 | 
             
            require_relative './exec_command'
         | 
| 6 6 | 
             
            require_relative './edit_command'
         | 
| 7 | 
            +
            require_relative './schema_command'
         | 
| 7 8 | 
             
            require_relative './generate_command'
         | 
| 8 9 | 
             
            require_relative './push_command'
         | 
| 9 10 | 
             
            require_relative './oauth2_command'
         | 
| @@ -53,6 +54,7 @@ module Workato | |
| 53 54 | 
             
                  method_option :webhook_payload, type: :string, aliases: '-w', desc: 'Path to file with webhook payload JSON'
         | 
| 54 55 | 
             
                  method_option :webhook_params, type: :string, desc: 'Path to file with webhook params JSON'
         | 
| 55 56 | 
             
                  method_option :webhook_headers, type: :string, desc: 'Path to file with webhook headers JSON'
         | 
| 57 | 
            +
                  method_option :webhook_subscribe_output, type: :string, desc: 'Path to file with webhook subscribe output JSON'
         | 
| 56 58 | 
             
                  method_option :webhook_url, type: :string, desc: 'Webhook URL for automatic webhook subscription'
         | 
| 57 59 | 
             
                  method_option :output, type: :string, aliases: '-o', desc: 'Write output to JSON file'
         | 
| 58 60 | 
             
                  method_option :oauth2_code, type: :string, desc: 'OAuth2 code exchange to tokens pair'
         | 
| @@ -125,11 +127,11 @@ module Workato | |
| 125 127 | 
             
                  method_option :api_email,
         | 
| 126 128 | 
             
                                type: :string,
         | 
| 127 129 | 
             
                                desc: 'Email for accessing Workato API or '\
         | 
| 128 | 
            -
                                      "set #{Workato:: | 
| 130 | 
            +
                                      "set #{Workato::Connector::Sdk::WORKATO_API_EMAIL_ENV} environment variable"
         | 
| 129 131 | 
             
                  method_option :api_token,
         | 
| 130 132 | 
             
                                type: :string,
         | 
| 131 133 | 
             
                                desc: 'Token for accessing Workato API or ' \
         | 
| 132 | 
            -
                                      "set #{Workato:: | 
| 134 | 
            +
                                      "set #{Workato::Connector::Sdk::WORKATO_API_TOKEN_ENV} environment variable"
         | 
| 133 135 | 
             
                  method_option :environment,
         | 
| 134 136 | 
             
                                type: :string,
         | 
| 135 137 | 
             
                                enum: Workato::CLI::PushCommand::ENVIRONMENTS.keys,
         | 
| @@ -1,5 +1,6 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            +
            require 'securerandom'
         | 
| 3 4 | 
             
            require 'workato/web/app'
         | 
| 4 5 |  | 
| 5 6 | 
             
            module Workato
         | 
| @@ -112,6 +113,7 @@ module Workato | |
| 112 113 | 
             
                    @authorize_url =
         | 
| 113 114 | 
             
                      if (authorization_url = connector.connection.authorization.authorization_url(settings))
         | 
| 114 115 | 
             
                        params = {
         | 
| 116 | 
            +
                          state: SecureRandom.hex(8),
         | 
| 115 117 | 
             
                          client_id: connector.connection.authorization.client_id(settings),
         | 
| 116 118 | 
             
                          redirect_uri: redirect_url
         | 
| 117 119 | 
             
                        }
         | 
| @@ -10,9 +10,6 @@ module Workato | |
| 10 10 | 
             
                class PushCommand
         | 
| 11 11 | 
             
                  include Thor::Shell
         | 
| 12 12 |  | 
| 13 | 
            -
                  WORKATO_API_TOKEN_ENV = 'WORKATO_API_TOKEN'
         | 
| 14 | 
            -
                  WORKATO_API_EMAIL_ENV = 'WORKATO_API_EMAIL'
         | 
| 15 | 
            -
             | 
| 16 13 | 
             
                  ENVIRONMENTS = {
         | 
| 17 14 | 
             
                    'preview' => 'https://app.preview.workato.com',
         | 
| 18 15 | 
             
                    'preview-eu' => 'https://app.preview.eu.workato.com',
         | 
| @@ -35,8 +32,8 @@ module Workato | |
| 35 32 | 
             
                  def initialize(options:)
         | 
| 36 33 | 
             
                    @options = options
         | 
| 37 34 | 
             
                    @api_base_url = ENVIRONMENTS.fetch(options[:environment])
         | 
| 38 | 
            -
                    @api_email = options[:api_email] || ENV[WORKATO_API_EMAIL_ENV]
         | 
| 39 | 
            -
                    @api_token = options[:api_token] || ENV[WORKATO_API_TOKEN_ENV]
         | 
| 35 | 
            +
                    @api_email = options[:api_email] || ENV[Workato::Connector::Sdk::WORKATO_API_EMAIL_ENV]
         | 
| 36 | 
            +
                    @api_token = options[:api_token] || ENV[Workato::Connector::Sdk::WORKATO_API_TOKEN_ENV]
         | 
| 40 37 | 
             
                    @folder_id = options[:folder]
         | 
| 41 38 | 
             
                  end
         | 
| 42 39 |  | 
| @@ -0,0 +1,81 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Workato
         | 
| 4 | 
            +
              module CLI
         | 
| 5 | 
            +
                class SchemaCommand
         | 
| 6 | 
            +
                  include Thor::Shell
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  SAMPLE_TO_SCHEMA_SUPPORT_TYPES = %w[csv json].freeze
         | 
| 9 | 
            +
                  CSV_SEPARATORS = %w[comma space tab colon semicolon pipe].freeze
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  WORKATO_BASE_URL = ENV['WORKATO_BASE_URL'] || 'https://app.workato.com'
         | 
| 12 | 
            +
                  API_GENERATE_SCHEMA_PATH = '/api/sdk/generate_schema'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def initialize(options:)
         | 
| 15 | 
            +
                    @api_email = options[:api_email] || ENV[Workato::Connector::Sdk::WORKATO_API_EMAIL_ENV]
         | 
| 16 | 
            +
                    @api_token = options[:api_token] || ENV[Workato::Connector::Sdk::WORKATO_API_TOKEN_ENV]
         | 
| 17 | 
            +
                    @options = options
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def call
         | 
| 21 | 
            +
                    if verbose?
         | 
| 22 | 
            +
                      say('INPUT')
         | 
| 23 | 
            +
                      say sample[:sample]
         | 
| 24 | 
            +
                    end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                    schema = sample_to_schema(sample)
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                    say('SCHEMA') if verbose?
         | 
| 29 | 
            +
                    jj schema
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  private
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  attr_reader :options,
         | 
| 35 | 
            +
                              :api_token,
         | 
| 36 | 
            +
                              :api_email
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  def verbose?
         | 
| 39 | 
            +
                    @options[:verbose]
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  def sample
         | 
| 43 | 
            +
                    return @sample if @sample
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                    @sample = if options[:json]
         | 
| 46 | 
            +
                                { sample: File.read(options[:json]), type: :json }
         | 
| 47 | 
            +
                              elsif options[:csv]
         | 
| 48 | 
            +
                                { sample: File.read(options[:csv]), type: :csv, col_sep: options[:col_sep] }
         | 
| 49 | 
            +
                              else
         | 
| 50 | 
            +
                                { sample: {}, type: :json }
         | 
| 51 | 
            +
                              end
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                  def sample_to_schema(sample)
         | 
| 55 | 
            +
                    url = "#{WORKATO_BASE_URL}#{API_GENERATE_SCHEMA_PATH}/#{sample.delete(:type)}"
         | 
| 56 | 
            +
                    response = RestClient.post(
         | 
| 57 | 
            +
                      url,
         | 
| 58 | 
            +
                      sample.to_json,
         | 
| 59 | 
            +
                      {
         | 
| 60 | 
            +
                        content_type: :json,
         | 
| 61 | 
            +
                        accept: :json
         | 
| 62 | 
            +
                      }.merge(auth_headers)
         | 
| 63 | 
            +
                    )
         | 
| 64 | 
            +
                    JSON.parse(response.body)
         | 
| 65 | 
            +
                  rescue RestClient::ExceptionWithResponse => e
         | 
| 66 | 
            +
                    message = JSON.parse(e.response.body).fetch('message') rescue e.message
         | 
| 67 | 
            +
                    raise "Failed to generate schema: #{message}"
         | 
| 68 | 
            +
                  end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  def auth_headers
         | 
| 71 | 
            +
                    {
         | 
| 72 | 
            +
                      'x-user-email' => api_email,
         | 
| 73 | 
            +
                      'x-user-token' => api_token
         | 
| 74 | 
            +
                    }
         | 
| 75 | 
            +
                  end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                  private_constant :API_GENERATE_SCHEMA_PATH,
         | 
| 78 | 
            +
                                   :WORKATO_BASE_URL
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
              end
         | 
| 81 | 
            +
            end
         | 
| @@ -56,8 +56,16 @@ module Workato | |
| 56 56 | 
             
                      trigger[:dedup].call(input)
         | 
| 57 57 | 
             
                    end
         | 
| 58 58 |  | 
| 59 | 
            -
                    def webhook_notification( | 
| 60 | 
            -
             | 
| 59 | 
            +
                    def webhook_notification(
         | 
| 60 | 
            +
                      input = {},
         | 
| 61 | 
            +
                      payload = {},
         | 
| 62 | 
            +
                      extended_input_schema = [],
         | 
| 63 | 
            +
                      extended_output_schema = [],
         | 
| 64 | 
            +
                      headers = {},
         | 
| 65 | 
            +
                      params = {},
         | 
| 66 | 
            +
                      settings = nil,
         | 
| 67 | 
            +
                      webhook_subscribe_output = {}
         | 
| 68 | 
            +
                    )
         | 
| 61 69 | 
             
                      Dsl::WithDsl.execute(
         | 
| 62 70 | 
             
                        input.with_indifferent_access,
         | 
| 63 71 | 
             
                        payload.with_indifferent_access,
         | 
| @@ -65,6 +73,8 @@ module Workato | |
| 65 73 | 
             
                        extended_output_schema.map(&:with_indifferent_access),
         | 
| 66 74 | 
             
                        headers.with_indifferent_access,
         | 
| 67 75 | 
             
                        params.with_indifferent_access,
         | 
| 76 | 
            +
                        (settings || @settings).with_indifferent_access,
         | 
| 77 | 
            +
                        webhook_subscribe_output.with_indifferent_access,
         | 
| 68 78 | 
             
                        &trigger[:webhook_notification]
         | 
| 69 79 | 
             
                      )
         | 
| 70 80 | 
             
                    end
         | 
| @@ -89,23 +99,33 @@ module Workato | |
| 89 99 | 
             
                      end
         | 
| 90 100 | 
             
                    end
         | 
| 91 101 |  | 
| 92 | 
            -
                    def invoke(input = {}, payload = {}, headers = {}, params = {})
         | 
| 102 | 
            +
                    def invoke(input = {}, payload = {}, headers = {}, params = {}, webhook_subscribe_output = {})
         | 
| 93 103 | 
             
                      extended_schema = extended_schema(nil, input)
         | 
| 94 104 | 
             
                      config_schema = Schema.new(schema: config_fields_schema)
         | 
| 95 105 | 
             
                      input_schema = Schema.new(schema: extended_schema[:input])
         | 
| 96 106 | 
             
                      output_schema = Schema.new(schema: extended_schema[:output])
         | 
| 97 107 |  | 
| 98 108 | 
             
                      input = apply_input_schema(input, config_schema + input_schema)
         | 
| 99 | 
            -
                       | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 105 | 
            -
             | 
| 109 | 
            +
                      if webhook_notification?
         | 
| 110 | 
            +
                        webhook_notification(
         | 
| 111 | 
            +
                          input,
         | 
| 112 | 
            +
                          payload,
         | 
| 113 | 
            +
                          input_schema,
         | 
| 114 | 
            +
                          output_schema,
         | 
| 115 | 
            +
                          headers,
         | 
| 116 | 
            +
                          params,
         | 
| 117 | 
            +
                          nil,
         | 
| 118 | 
            +
                          webhook_subscribe_output
         | 
| 119 | 
            +
                        ).tap do |event|
         | 
| 120 | 
            +
                          apply_output_schema(event, output_schema)
         | 
| 121 | 
            +
                        end
         | 
| 122 | 
            +
                      else
         | 
| 123 | 
            +
                        output = poll(nil, input, nil, input_schema, output_schema)
         | 
| 124 | 
            +
                        output[:events].each do |event|
         | 
| 125 | 
            +
                          apply_output_schema(event, output_schema)
         | 
| 126 | 
            +
                        end
         | 
| 127 | 
            +
                        output
         | 
| 106 128 | 
             
                      end
         | 
| 107 | 
            -
             | 
| 108 | 
            -
                      output
         | 
| 109 129 | 
             
                    end
         | 
| 110 130 |  | 
| 111 131 | 
             
                    private
         | 
| @@ -229,6 +229,10 @@ module Workato | |
| 229 229 | 
             
                    self
         | 
| 230 230 | 
             
                  end
         | 
| 231 231 |  | 
| 232 | 
            +
                  def to_json(_options = nil)
         | 
| 233 | 
            +
                    summary
         | 
| 234 | 
            +
                  end
         | 
| 235 | 
            +
             | 
| 232 236 | 
             
                  def binary?
         | 
| 233 237 | 
             
                    true
         | 
| 234 238 | 
             
                  end
         | 
| @@ -245,19 +249,12 @@ module Workato | |
| 245 249 | 
             
                    as_string('utf-8')
         | 
| 246 250 | 
             
                  end
         | 
| 247 251 |  | 
| 248 | 
            -
                  # representation in event title
         | 
| 249 | 
            -
                  def title
         | 
| 250 | 
            -
                    if length.positive?
         | 
| 251 | 
            -
                      "0x#{byteslice(0, TITLE_LENGTH).unpack1('H*')}#{bytesize > TITLE_LENGTH ? '…' : ''}"
         | 
| 252 | 
            -
                    else
         | 
| 253 | 
            -
                      ''
         | 
| 254 | 
            -
                    end
         | 
| 255 | 
            -
                  end
         | 
| 256 | 
            -
             | 
| 257 252 | 
             
                  def sha1
         | 
| 258 253 | 
             
                    Binary.new(::Digest::SHA1.digest(self))
         | 
| 259 254 | 
             
                  end
         | 
| 260 255 |  | 
| 256 | 
            +
                  private
         | 
| 257 | 
            +
             | 
| 261 258 | 
             
                  def summary
         | 
| 262 259 | 
             
                    if length.positive?
         | 
| 263 260 | 
             
                      left = "0x#{byteslice(0, SUMMARY_LENGTH).unpack1('H*')}"
         | 
| @@ -267,12 +264,8 @@ module Workato | |
| 267 264 | 
             
                      ''
         | 
| 268 265 | 
             
                    end
         | 
| 269 266 | 
             
                  end
         | 
| 270 | 
            -
             | 
| 271 | 
            -
                  def self.from_base64(base64str)
         | 
| 272 | 
            -
                    new(Base64.strict_decode64(base64str))
         | 
| 273 | 
            -
                  end
         | 
| 274 267 | 
             
                end
         | 
| 275 268 | 
             
              end
         | 
| 276 269 | 
             
            end
         | 
| 277 270 |  | 
| 278 | 
            -
            String. | 
| 271 | 
            +
            String.prepend(Workato::Extension::String)
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: workato-connector-sdk
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 1.0.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Pavel Abolmasov
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2022- | 
| 11 | 
            +
            date: 2022-05-16 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         | 
| @@ -380,6 +380,7 @@ files: | |
| 380 380 | 
             
            - lib/workato/cli/main.rb
         | 
| 381 381 | 
             
            - lib/workato/cli/oauth2_command.rb
         | 
| 382 382 | 
             
            - lib/workato/cli/push_command.rb
         | 
| 383 | 
            +
            - lib/workato/cli/schema_command.rb
         | 
| 383 384 | 
             
            - lib/workato/connector/sdk.rb
         | 
| 384 385 | 
             
            - lib/workato/connector/sdk/account_properties.rb
         | 
| 385 386 | 
             
            - lib/workato/connector/sdk/action.rb
         | 
| @@ -468,7 +469,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 468 469 | 
             
                - !ruby/object:Gem::Version
         | 
| 469 470 | 
             
                  version: '0'
         | 
| 470 471 | 
             
            requirements: []
         | 
| 471 | 
            -
            rubygems_version: 3. | 
| 472 | 
            +
            rubygems_version: 3.2.3
         | 
| 472 473 | 
             
            signing_key:
         | 
| 473 474 | 
             
            specification_version: 4
         | 
| 474 475 | 
             
            summary: Gem for running adapter's code outside Workato infrastructure
         |