Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.5
3.2.5
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
embed_workflow (0.0.1)
embed_workflow (0.1.0)

GEM
remote: https://rubygems.org/
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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")
```
5 changes: 5 additions & 0 deletions lib/embed_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
24 changes: 24 additions & 0 deletions lib/embed_workflow/catch_hook.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion lib/embed_workflow/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module EmbedWorkflow
VERSION = "0.0.1"
VERSION = "0.1.0"
end
13 changes: 6 additions & 7 deletions lib/embed_workflow/workflows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
Loading