knockapi 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb2117c38dcd672ea551af82b0803b141576d46ba155bbb345e3dd3136c8ad13
4
- data.tar.gz: eebda102aea7791d7b664f244dadb26b98d529d4eb197227684dcb1f64bbdfe4
3
+ metadata.gz: 829d797080c6841ef0bda6f2e775e17d45f4c30c466f2b0e1b8ea2abb7e8602e
4
+ data.tar.gz: 34bfb3a3bcad22f326a3195d67f879d57e746c1eaef1bb8fd5be490a5eac1058
5
5
  SHA512:
6
- metadata.gz: 7f56c9b141388fbf5793b1699a958b71b321593acc86f19afaadb96c15425c3ce0895e47d2e7f229d36a0a512a55a77cad90ae8da5e5c9e812833d035db93eb1
7
- data.tar.gz: a1837d1bc86cecf3250ac99286e0a46c8ea6f3bc5b7c07cca6f806fe6b443a02ee7996daa7009f39169065ba377b5acce24c337ad7fc9a05d37cad7f383be1d7
6
+ metadata.gz: 8da11f98837db48e400a3387a081f2309fc7302029b592b6990293127302fd9c17c8c50747e6786943ede84a6cbda9b9496dce58cca25f8f603d016b844d4c8c
7
+ data.tar.gz: fc8224278dc1ef927eed734a5e55877d9d934a204a8cf22bd11b32ddeee3d04281bbff1195da500755fb1e248e30f30f28967d42e010f79da96ae4f53cbf3436
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,31 @@
1
+ # Contributing
2
+
3
+ ## Getting Started
4
+
5
+ 1. Install [asdf](https://asdf-vm.com)
6
+ 2. Install the asdf Ruby plugin
7
+
8
+ ```bash
9
+ asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git # Visit that repository to see installation prerequisites
10
+ ```
11
+
12
+ 3. Run `asdf install` to install the version of Ruby specified in the [.ruby-version](.ruby-version) file
13
+ 4. Run `bundle install` to install the Ruby dependencies
14
+
15
+ ## Running the tests
16
+
17
+ ```bash
18
+ bundle exec rspec
19
+ ```
20
+
21
+ ## Running the linter
22
+
23
+ ```bash
24
+ bundle exec rubocop
25
+ ```
26
+
27
+ ## Formatting
28
+
29
+ ```bash
30
+ bundle exec rubocop -a
31
+ ```
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- knockapi (0.4.6)
4
+ knockapi (0.4.7)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/knock/client.rb CHANGED
@@ -37,11 +37,12 @@ module Knock
37
37
  request
38
38
  end
39
39
 
40
- def post_request(path:, auth: false, _idempotency_key: nil, body: nil)
40
+ def post_request(path:, auth: false, idempotency_key: nil, body: nil)
41
41
  request = Net::HTTP::Post.new(path, 'Content-Type' => 'application/json')
42
42
  request.body = body.to_json if body
43
43
  request['Authorization'] = "Bearer #{Knock.key!}" if auth
44
44
  request['User-Agent'] = user_agent
45
+ request['Idempotency-Key'] = idempotency_key if idempotency_key
45
46
  request
46
47
  end
47
48
 
@@ -60,11 +61,12 @@ module Knock
60
61
  request
61
62
  end
62
63
 
63
- def put_request(path:, auth: false, _idempotency_key: nil, body: nil)
64
+ def put_request(path:, auth: false, idempotency_key: nil, body: nil)
64
65
  request = Net::HTTP::Put.new(path, 'Content-Type' => 'application/json')
65
66
  request.body = body.to_json if body
66
67
  request['Authorization'] = "Bearer #{Knock.key!}" if auth
67
68
  request['User-Agent'] = user_agent
69
+ request['Idempotency-Key'] = idempotency_key if idempotency_key
68
70
  request
69
71
  end
70
72
 
data/lib/knock/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Knock
4
- VERSION = '0.4.6'
4
+ VERSION = '0.4.7'
5
5
  end
@@ -19,9 +19,11 @@ module Knock
19
19
  # @param [String] cancellation_key An optional key to identify this workflow
20
20
  # invocation for cancelling
21
21
  # @param [String] tenant An optional tenant identifier
22
+ # @param [String] idempotency_key An optional idempotency key to prevent
23
+ # duplicate workflow invocations
22
24
  #
23
25
  # @return [Hash] A workflow trigger result
24
- def trigger(key:, actor:, recipients:, data: {}, cancellation_key: nil, tenant: nil)
26
+ def trigger(key:, actor:, recipients:, data: {}, cancellation_key: nil, tenant: nil, idempotency_key: nil) # rubocop:disable Metrics/ParameterLists
25
27
  attrs = {
26
28
  actor: actor,
27
29
  recipients: recipients,
@@ -33,7 +35,8 @@ module Knock
33
35
  request = post_request(
34
36
  auth: true,
35
37
  path: "/v1/workflows/#{key}/trigger",
36
- body: attrs
38
+ body: attrs,
39
+ idempotency_key: idempotency_key
37
40
  )
38
41
 
39
42
  execute_request(request: request)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knockapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Knock Labs, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-28 00:00:00.000000000 Z
11
+ date: 2023-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,7 @@ files:
66
66
  - ".gitignore"
67
67
  - ".rubocop.yml"
68
68
  - ".ruby-version"
69
+ - CONTRIBUTING.md
69
70
  - Gemfile
70
71
  - Gemfile.lock
71
72
  - LICENSE
@@ -106,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
107
  - !ruby/object:Gem::Version
107
108
  version: '0'
108
109
  requirements: []
109
- rubygems_version: 3.4.6
110
+ rubygems_version: 3.4.10
110
111
  signing_key:
111
112
  specification_version: 4
112
113
  summary: API client for Knock