Skip to content

Commit f772f1b

Browse files
authored
[EWF-444] Catch hook (#3)
* catch hook * bump verion * upgrade ruby * upgrade ruby * fix lint job
1 parent 878a5c8 commit f772f1b

File tree

8 files changed

+47
-18
lines changed

8 files changed

+47
-18
lines changed

.github/workflows/ruby.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@ jobs:
2222
runs-on: ubuntu-latest
2323
strategy:
2424
matrix:
25-
ruby-version: ['2.6', '2.7', '3.0']
25+
ruby-version: ["2.7", "3.0", "3.1", "3.2"]
2626

2727
steps:
2828
- uses: actions/checkout@v3
2929
- name: Set up Ruby
30-
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
31-
# change this to (see https://github.com/ruby/setup-ruby#versioning):
32-
# uses: ruby/setup-ruby@v1
33-
uses: ruby/setup-ruby@2b019609e2b0f1ea1a2bc8ca11cb82ab46ada124
30+
uses: ruby/setup-ruby@v1
3431
with:
3532
ruby-version: ${{ matrix.ruby-version }}
3633
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
@@ -44,7 +41,7 @@ jobs:
4441
- name: Checkout code
4542
uses: actions/checkout@v3
4643
- name: Install Ruby and gems
47-
uses: ruby/setup-ruby@8f312efe1262fb463d906e9bf040319394c18d3e # v1.92
44+
uses: ruby/setup-ruby@v1
4845
with:
4946
bundler-cache: true
5047
# Add or replace any other lints here

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.6.5
1+
3.2.5

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
embed_workflow (0.0.1)
4+
embed_workflow (0.1.0)
55

66
GEM
77
remote: https://rubygems.org/

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ EmbedWorkflow::Actions.activities(hashid: "7l0al")
111111

112112
```ruby
113113
config = {
114-
primary_color: "#333333",
115-
logo_url: "https://embedworkflow.com/assets/logo-dark-ac3f24918e46816034763925e7e2272381c18907601677ffa9e842f46555e80d.png",
116114
user_data: {
117115
foo: "bar"
118116
},
@@ -130,3 +128,9 @@ EmbedWorkflow::Users.upsert(name: "Jane Smith", id: user["id"], config: config)
130128
```ruby
131129
EmbedWorkflow::Users.fetch(key: "api-user-1")
132130
```
131+
132+
### Catch a webhook
133+
134+
```ruby
135+
EmbedWorkflow.catch_hook(user_key: "main", hook_id: "70e59f4d-1dc4-4720-b0bb-46929dc48d47", anything: "else", you: "need")
136+
```

lib/embed_workflow.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def self.skey!
2222
autoload :Actions, "embed_workflow/actions"
2323
autoload :Executions, "embed_workflow/executions"
2424
autoload :Trigger, "embed_workflow/trigger"
25+
autoload :CatchHook, "embed_workflow/catch_hook"
2526
autoload :Users, "embed_workflow/users"
2627
autoload :Workflows, "embed_workflow/workflows"
2728

@@ -32,4 +33,8 @@ def self.skey!
3233
def self.trigger(**args)
3334
Trigger.create(**args)
3435
end
36+
37+
def self.catch_hook(**args)
38+
CatchHook.create(**args)
39+
end
3540
end

lib/embed_workflow/catch_hook.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
require "net/http"
4+
require "uri"
5+
6+
module EmbedWorkflow
7+
module CatchHook
8+
class << self
9+
include Base
10+
include Client
11+
12+
RESOURCE_BASE_PATH = "#{BASE_API_PATH}/hooks".freeze
13+
14+
def create(hook_id:, user_key:, **rest)
15+
attrs = { user_key: user_key }.merge(rest).compact
16+
17+
post_request(
18+
path: "#{RESOURCE_BASE_PATH}/#{hook_id}/catch",
19+
body: attrs
20+
)
21+
end
22+
end
23+
end
24+
end

lib/embed_workflow/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module EmbedWorkflow
4-
VERSION = "0.0.1"
4+
VERSION = "0.1.0"
55
end

lib/embed_workflow/workflows.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ class << self
1111

1212
RESOURCE_BASE_PATH = "#{BASE_API_PATH}/workflows"
1313

14-
def create(name:, template: nil, context: nil, auto_start: nil, tenant_key: nil)
14+
def create(name:, template: nil, user_key: nil, event_trigger: nil, trigger_conditions: nil)
1515
attrs = {
1616
name: name,
1717
template: template,
18-
auto_start: auto_start,
19-
tenant_key: tenant_key,
20-
context: context
18+
event_trigger: event_trigger,
19+
trigger_conditions: trigger_conditions,
20+
user_key: user_key
2121
}
2222

2323
post_request(
@@ -32,12 +32,11 @@ def fetch(hashid: nil, key: nil)
3232
)
3333
end
3434

35-
def update(hashid:, name: nil, template: nil, tenant_key: nil, context: nil, auto_start: nil)
35+
def update(hashid:, name: nil, template: nil, user_key: nil)
3636
attrs = {
3737
name: name,
3838
template: template,
39-
tenant_key: tenant_key,
40-
context: context
39+
user_key: user_key
4140
}.compact
4241

4342
put_request(

0 commit comments

Comments
 (0)