knockapi 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/knock/client.rb +2 -1
- data/lib/knock/objects.rb +52 -0
- data/lib/knock/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb2117c38dcd672ea551af82b0803b141576d46ba155bbb345e3dd3136c8ad13
|
4
|
+
data.tar.gz: eebda102aea7791d7b664f244dadb26b98d529d4eb197227684dcb1f64bbdfe4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f56c9b141388fbf5793b1699a958b71b321593acc86f19afaadb96c15425c3ce0895e47d2e7f229d36a0a512a55a77cad90ae8da5e5c9e812833d035db93eb1
|
7
|
+
data.tar.gz: a1837d1bc86cecf3250ac99286e0a46c8ea6f3bc5b7c07cca6f806fe6b443a02ee7996daa7009f39169065ba377b5acce24c337ad7fc9a05d37cad7f383be1d7
|
data/Gemfile.lock
CHANGED
data/lib/knock/client.rb
CHANGED
@@ -45,7 +45,7 @@ module Knock
|
|
45
45
|
request
|
46
46
|
end
|
47
47
|
|
48
|
-
def delete_request(path:, auth: false, params: {})
|
48
|
+
def delete_request(path:, auth: false, params: {}, body: nil)
|
49
49
|
uri = URI(path)
|
50
50
|
uri.query = URI.encode_www_form(params) if params
|
51
51
|
|
@@ -54,6 +54,7 @@ module Knock
|
|
54
54
|
'Content-Type' => 'application/json'
|
55
55
|
)
|
56
56
|
|
57
|
+
request.body = body.to_json if body
|
57
58
|
request['Authorization'] = "Bearer #{Knock.key!}" if auth
|
58
59
|
request['User-Agent'] = user_agent
|
59
60
|
request
|
data/lib/knock/objects.rb
CHANGED
@@ -306,6 +306,58 @@ module Knock
|
|
306
306
|
|
307
307
|
execute_request(request: request)
|
308
308
|
end
|
309
|
+
|
310
|
+
# Lists all subscriptiopns for the given object
|
311
|
+
#
|
312
|
+
# @param [String] collection The collection the object is in
|
313
|
+
# @param [String] id The object id
|
314
|
+
# @param [Hash] options Options to pass to the subscriptions endpoint
|
315
|
+
#
|
316
|
+
# @return [Hash] Paginated subscriptions response
|
317
|
+
def list_subscriptions(collection:, id:, options: {})
|
318
|
+
request = get_request(
|
319
|
+
auth: true,
|
320
|
+
path: "/v1/objects/#{collection}/#{id}/subscriptions",
|
321
|
+
params: options
|
322
|
+
)
|
323
|
+
|
324
|
+
execute_request(request: request)
|
325
|
+
end
|
326
|
+
|
327
|
+
# Creates a set of subscriptions for the recipients on the object
|
328
|
+
#
|
329
|
+
# @param [String] collection The collection the object is in
|
330
|
+
# @param [String] id The object id
|
331
|
+
# @param [Array<String, Hash>] recipients An array of recipients
|
332
|
+
# @param [Hash] properties A set of custom properties to set on the subscriptions
|
333
|
+
#
|
334
|
+
# @return [Array<Hash>] List of created subscriptions
|
335
|
+
def add_subscriptions(collection:, id:, recipients: [], properties: {})
|
336
|
+
request = post_request(
|
337
|
+
auth: true,
|
338
|
+
path: "/v1/objects/#{collection}/#{id}/subscriptions",
|
339
|
+
body: { recipients: recipients, properties: properties }
|
340
|
+
)
|
341
|
+
|
342
|
+
execute_request(request: request)
|
343
|
+
end
|
344
|
+
|
345
|
+
# Removes subscriptions for the recipients on the object
|
346
|
+
#
|
347
|
+
# @param [String] collection The collection the object is in
|
348
|
+
# @param [String] id The object id
|
349
|
+
# @param [Array<String, Hash>] recipients An array of recipients
|
350
|
+
#
|
351
|
+
# @return [Array<Hash>] List of deleted subscriptions
|
352
|
+
def delete_subscriptions(collection:, id:, recipients: [])
|
353
|
+
request = delete_request(
|
354
|
+
auth: true,
|
355
|
+
path: "/v1/objects/#{collection}/#{id}/subscriptions",
|
356
|
+
body: { recipients: recipients }
|
357
|
+
)
|
358
|
+
|
359
|
+
execute_request(request: request)
|
360
|
+
end
|
309
361
|
end
|
310
362
|
end
|
311
363
|
# rubocop:enable Metrics/ModuleLength
|
data/lib/knock/version.rb
CHANGED
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.
|
4
|
+
version: 0.4.6
|
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:
|
11
|
+
date: 2023-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
109
|
+
rubygems_version: 3.4.6
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: API client for Knock
|