diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 10dda2e..5c5269c 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -22,15 +22,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['2.6', '2.7', '3.0'] + ruby-version: ["2.7", "3.0", "3.1", "3.2"] steps: - uses: actions/checkout@v3 - name: Set up Ruby - # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, - # change this to (see https://github.com/ruby/setup-ruby#versioning): - # uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@2b019609e2b0f1ea1a2bc8ca11cb82ab46ada124 + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically @@ -44,7 +41,7 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - name: Install Ruby and gems - uses: ruby/setup-ruby@8f312efe1262fb463d906e9bf040319394c18d3e # v1.92 + uses: ruby/setup-ruby@v1 with: bundler-cache: true # Add or replace any other lints here diff --git a/.ruby-version b/.ruby-version index 6816713..448ada3 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.5 \ No newline at end of file +3.2.5 \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 13ca384..65fc41e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - embed_workflow (0.0.1) + embed_workflow (0.1.0) GEM remote: https://rubygems.org/ diff --git a/README.md b/README.md index c2c1866..741c7cb 100644 --- a/README.md +++ b/README.md @@ -111,8 +111,6 @@ EmbedWorkflow::Actions.activities(hashid: "7l0al") ```ruby config = { - primary_color: "#333333", - logo_url: "https://embedworkflow.com/assets/logo-dark-ac3f24918e46816034763925e7e2272381c18907601677ffa9e842f46555e80d.png", user_data: { foo: "bar" }, @@ -130,3 +128,9 @@ EmbedWorkflow::Users.upsert(name: "Jane Smith", id: user["id"], config: config) ```ruby EmbedWorkflow::Users.fetch(key: "api-user-1") ``` + +### Catch a webhook + +```ruby +EmbedWorkflow.catch_hook(user_key: "main", hook_id: "70e59f4d-1dc4-4720-b0bb-46929dc48d47", anything: "else", you: "need") +``` diff --git a/lib/embed_workflow.rb b/lib/embed_workflow.rb index 35c1547..8080b30 100644 --- a/lib/embed_workflow.rb +++ b/lib/embed_workflow.rb @@ -22,6 +22,7 @@ def self.skey! autoload :Actions, "embed_workflow/actions" autoload :Executions, "embed_workflow/executions" autoload :Trigger, "embed_workflow/trigger" + autoload :CatchHook, "embed_workflow/catch_hook" autoload :Users, "embed_workflow/users" autoload :Workflows, "embed_workflow/workflows" @@ -32,4 +33,8 @@ def self.skey! def self.trigger(**args) Trigger.create(**args) end + + def self.catch_hook(**args) + CatchHook.create(**args) + end end diff --git a/lib/embed_workflow/catch_hook.rb b/lib/embed_workflow/catch_hook.rb new file mode 100644 index 0000000..fd154dc --- /dev/null +++ b/lib/embed_workflow/catch_hook.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require "net/http" +require "uri" + +module EmbedWorkflow + module CatchHook + class << self + include Base + include Client + + RESOURCE_BASE_PATH = "#{BASE_API_PATH}/hooks".freeze + + def create(hook_id:, user_key:, **rest) + attrs = { user_key: user_key }.merge(rest).compact + + post_request( + path: "#{RESOURCE_BASE_PATH}/#{hook_id}/catch", + body: attrs + ) + end + end + end +end diff --git a/lib/embed_workflow/version.rb b/lib/embed_workflow/version.rb index 88db537..45d9c8b 100644 --- a/lib/embed_workflow/version.rb +++ b/lib/embed_workflow/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module EmbedWorkflow - VERSION = "0.0.1" + VERSION = "0.1.0" end diff --git a/lib/embed_workflow/workflows.rb b/lib/embed_workflow/workflows.rb index 7728937..aa1f58e 100644 --- a/lib/embed_workflow/workflows.rb +++ b/lib/embed_workflow/workflows.rb @@ -11,13 +11,13 @@ class << self RESOURCE_BASE_PATH = "#{BASE_API_PATH}/workflows" - def create(name:, template: nil, context: nil, auto_start: nil, tenant_key: nil) + def create(name:, template: nil, user_key: nil, event_trigger: nil, trigger_conditions: nil) attrs = { name: name, template: template, - auto_start: auto_start, - tenant_key: tenant_key, - context: context + event_trigger: event_trigger, + trigger_conditions: trigger_conditions, + user_key: user_key } post_request( @@ -32,12 +32,11 @@ def fetch(hashid: nil, key: nil) ) end - def update(hashid:, name: nil, template: nil, tenant_key: nil, context: nil, auto_start: nil) + def update(hashid:, name: nil, template: nil, user_key: nil) attrs = { name: name, template: template, - tenant_key: tenant_key, - context: context + user_key: user_key }.compact put_request(