knockapi 0.4.4 → 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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/knock/client.rb +2 -1
- data/lib/knock/messages.rb +5 -0
- data/lib/knock/objects.rb +55 -0
- data/lib/knock/users.rb +5 -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/messages.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'json'
|
3
4
|
require 'net/http'
|
4
5
|
require 'uri'
|
5
6
|
|
@@ -16,6 +17,8 @@ module Knock
|
|
16
17
|
#
|
17
18
|
# @return [Hash] Paginated list of Message records
|
18
19
|
def list(options: {})
|
20
|
+
options[:trigger_data] = JSON.generate(options[:trigger_data]) if options[:trigger_data]
|
21
|
+
|
19
22
|
request = get_request(
|
20
23
|
auth: true,
|
21
24
|
path: '/v1/messages',
|
@@ -60,6 +63,8 @@ module Knock
|
|
60
63
|
#
|
61
64
|
# @return [Hash] Paginated Message's activities
|
62
65
|
def get_activities(id:, options: {})
|
66
|
+
options[:trigger_data] = JSON.generate(options[:trigger_data]) if options[:trigger_data]
|
67
|
+
|
63
68
|
request = get_request(
|
64
69
|
auth: true,
|
65
70
|
path: "/v1/messages/#{id}/activities",
|
data/lib/knock/objects.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'json'
|
3
4
|
require 'net/http'
|
4
5
|
require 'uri'
|
5
6
|
|
@@ -150,6 +151,8 @@ module Knock
|
|
150
151
|
#
|
151
152
|
# @return [Hash] Paginated messages response
|
152
153
|
def get_messages(collection:, id:, options: {})
|
154
|
+
options[:trigger_data] = JSON.generate(options[:trigger_data]) if options[:trigger_data]
|
155
|
+
|
153
156
|
request = get_request(
|
154
157
|
auth: true,
|
155
158
|
path: "/v1/objects/#{collection}/#{id}/messages",
|
@@ -303,6 +306,58 @@ module Knock
|
|
303
306
|
|
304
307
|
execute_request(request: request)
|
305
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
|
306
361
|
end
|
307
362
|
end
|
308
363
|
# rubocop:enable Metrics/ModuleLength
|
data/lib/knock/users.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'json'
|
3
4
|
require 'net/http'
|
4
5
|
require 'uri'
|
5
6
|
|
@@ -95,6 +96,8 @@ module Knock
|
|
95
96
|
#
|
96
97
|
# @return [Hash] the feed response
|
97
98
|
def get_feed(id:, channel_id:, options: {})
|
99
|
+
options[:trigger_data] = JSON.generate(options[:trigger_data]) if options[:trigger_data]
|
100
|
+
|
98
101
|
request = get_request(
|
99
102
|
auth: true,
|
100
103
|
path: "/v1/users/#{id}/feeds/#{channel_id}",
|
@@ -345,6 +348,8 @@ module Knock
|
|
345
348
|
#
|
346
349
|
# @return [Hash] Paginated messages response
|
347
350
|
def get_messages(id:, options: {})
|
351
|
+
options[:trigger_data] = JSON.generate(options[:trigger_data]) if options[:trigger_data]
|
352
|
+
|
348
353
|
request = get_request(
|
349
354
|
auth: true,
|
350
355
|
path: "/v1/users/#{id}/messages",
|
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
|