knockapi 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81cfa3f6f13dddad567058c6c1bf837d41fbf4227247e6d5f7cd4bcedf94cb2b
4
- data.tar.gz: 18ed9ffaed543083c5edcb5c2a0274919b10fca298938e324f96d2514c2dfa81
3
+ metadata.gz: bb2117c38dcd672ea551af82b0803b141576d46ba155bbb345e3dd3136c8ad13
4
+ data.tar.gz: eebda102aea7791d7b664f244dadb26b98d529d4eb197227684dcb1f64bbdfe4
5
5
  SHA512:
6
- metadata.gz: 8e2e848f8d590fff5367f1a805c671fc9ad0643fc6b14e1300d362d99007de94922fe56a74dc1a9bf73e4d4aa79002239b9f7171d25aef68cea6ef3c261304e8
7
- data.tar.gz: c4c4ee1372ed47fea5d4fa4c7fddeb1daf4d101959214101b671c1ea8408c7144f98f0e263c0c785639cc8978b2639d438a38b1a97974eab1333fde9fa2d7fc4
6
+ metadata.gz: 7f56c9b141388fbf5793b1699a958b71b321593acc86f19afaadb96c15425c3ce0895e47d2e7f229d36a0a512a55a77cad90ae8da5e5c9e812833d035db93eb1
7
+ data.tar.gz: a1837d1bc86cecf3250ac99286e0a46c8ea6f3bc5b7c07cca6f806fe6b443a02ee7996daa7009f39169065ba377b5acce24c337ad7fc9a05d37cad7f383be1d7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- knockapi (0.4.5)
4
+ knockapi (0.4.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Knock
4
- VERSION = '0.4.5'
4
+ VERSION = '0.4.6'
5
5
  end
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.5
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: 2022-12-22 00:00:00.000000000 Z
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.3.26
109
+ rubygems_version: 3.4.6
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: API client for Knock