knockapi 0.4.8 → 0.4.10

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: f76a1fe37f883f760b872f6b52bafb40e22a870f650fb0c4cc5b40e85912888c
4
- data.tar.gz: 7dc8c721a049b9b3a25ff67db18dc9cdca1e551f1bbcdddbf025305f6b23e582
3
+ metadata.gz: 4beed298674955de29028de2c873e1ca06c6985ed1a39616002acdc6eff25c1f
4
+ data.tar.gz: f8917065b45cb5e3fb5bda5c695adcc2920b1a81f6b87350f2290c8931196196
5
5
  SHA512:
6
- metadata.gz: 38e0c87a2c2e4fe46c1cc80c9a7707e1b26416f682a5de387f8725afa0e9a9599a9ee35b0b57e693b1a37897d2cf5e132c75595304497281f4b014e350946ef5
7
- data.tar.gz: 4a3be25fd78f03bc7605fea581486950639ea333c819828e1859e30d94ea8f0e42d00807a5076ba9d97db508c48e08163dbe81f694adc49517401028b8f582f2
6
+ metadata.gz: '06358ec03b771befae371a2593af671d5722333cfe49b0e50366b86cad6a5ba3924e650e44064d152ea976251422c90092cfb8fd0bcf1303f5b46ba781f79f75'
7
+ data.tar.gz: 5153f8795549916a076b33f0650a15206f832f6415d71ea4b1737e0f713af5f28151538633f883f9f34410b3f078b4b0dadbdf27128403b3ec39ce668a5dbf5b
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.2.2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- knockapi (0.4.8)
4
+ knockapi (0.4.10)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -34,7 +34,7 @@ Knock.key = 'sk_12345'
34
34
  ### Identifying users
35
35
 
36
36
  ```ruby
37
- require "knockapi"
37
+ require "knock"
38
38
 
39
39
  Knock.key = "sk_12345"
40
40
 
@@ -50,7 +50,7 @@ Knock::Users.identify(
50
50
  ### Sending notifies (triggering workflows)
51
51
 
52
52
  ```ruby
53
- require "knockapi"
53
+ require "knock"
54
54
 
55
55
  Knock.key = "sk_12345"
56
56
 
@@ -74,7 +74,7 @@ Knock::Workflows.trigger(
74
74
  ### Retrieving users
75
75
 
76
76
  ```ruby
77
- require "knockapi"
77
+ require "knock"
78
78
 
79
79
  Knock.key = "sk_12345"
80
80
 
@@ -84,7 +84,7 @@ Knock::Users.get(id: "jhammond")
84
84
  ### Deleting users
85
85
 
86
86
  ```ruby
87
- require "knockapi"
87
+ require "knock"
88
88
 
89
89
  Knock.key = "sk_12345"
90
90
 
@@ -94,7 +94,7 @@ Knock::Users.delete(id: "jhammond")
94
94
  ### Preferences
95
95
 
96
96
  ```ruby
97
- require "knockapi"
97
+ require "knock"
98
98
  Knock.key = "sk_12345"
99
99
 
100
100
  # Set an entire preference set
@@ -115,7 +115,7 @@ Knock::Users.get_preferences(user_id: "jhammond")
115
115
  ### Getting and setting channel data
116
116
 
117
117
  ```ruby
118
- require "knockapi"
118
+ require "knock"
119
119
  Knock.key = "sk_12345"
120
120
 
121
121
  # Set channel data for an APNS
@@ -134,7 +134,7 @@ Knock::Users.get_channel_data(user_id: "jhammond", channel_id: KNOCK_APNS_CHANNE
134
134
  ### Cancelling workflows
135
135
 
136
136
  ```ruby
137
- require "knockapi"
137
+ require "knock"
138
138
  Knock.key = "sk_12345"
139
139
 
140
140
  Knock::Workflows.cancel(
data/lib/knock/objects.rb CHANGED
@@ -29,6 +29,23 @@ module Knock
29
29
  execute_request(request: request)
30
30
  end
31
31
 
32
+ # Retrieves paginated objects in a collection for the provided environment
33
+ #
34
+ # @param [Hash] options Options to pass to the paginated users endpoint query.
35
+ # These include:
36
+ # - page_size: size of page to be returned (max: 50)
37
+ # - after: after cursor for pagination
38
+ # - before: before cursor for pagination
39
+ def list(collection:, options: {})
40
+ request = get_request(
41
+ auth: true,
42
+ path: "/v1/objects/#{collection}",
43
+ params: options
44
+ )
45
+
46
+ execute_request(request: request)
47
+ end
48
+
32
49
  # Upserts an Object in a collection
33
50
  #
34
51
  # @param [String] collection The collection the object is in
@@ -312,6 +329,10 @@ module Knock
312
329
  # @param [String] collection The collection the object is in
313
330
  # @param [String] id The object id
314
331
  # @param [Hash] options Options to pass to the subscriptions endpoint
332
+ # These include:
333
+ # - page_size: size of page to be returned (max: 50)
334
+ # - after: after cursor for pagination
335
+ # - before: before cursor for pagination
315
336
  #
316
337
  # @return [Hash] Paginated subscriptions response
317
338
  def list_subscriptions(collection:, id:, options: {})
@@ -375,6 +396,29 @@ module Knock
375
396
 
376
397
  execute_request(request: request)
377
398
  end
399
+
400
+ # Get object's subscriptions as recipient
401
+ #
402
+ # @param [String] collection The collection the object is in
403
+ # @param [String] id The object id
404
+ # @param [Hash] options Options to pass to the subscriptions endpoint query
405
+ # These include:
406
+ # - page_size: size of page to be returned (max: 50)
407
+ # - after: after cursor for pagination
408
+ # - before: before cursor for pagination
409
+ #
410
+ # @return [Hash] Paginated subscriptions response
411
+ def get_subscriptions(collection:, id:, options: {})
412
+ options[:mode] = 'recipient'
413
+
414
+ request = get_request(
415
+ auth: true,
416
+ path: "/v1/objects/#{collection}/#{id}/subscriptions",
417
+ params: options
418
+ )
419
+
420
+ execute_request(request: request)
421
+ end
378
422
  end
379
423
  end
380
424
  # rubocop:enable Metrics/ModuleLength
data/lib/knock/users.rb CHANGED
@@ -45,6 +45,23 @@ module Knock
45
45
  execute_request(request: request)
46
46
  end
47
47
 
48
+ # Retrieves paginated users for the provided environment
49
+ #
50
+ # @param [Hash] options Options to pass to the paginated users endpoint query.
51
+ # These include:
52
+ # - page_size: size of page to be returned (max: 50)
53
+ # - after: after cursor for pagination
54
+ # - before: before cursor for pagination
55
+ def list(options: {})
56
+ request = get_request(
57
+ auth: true,
58
+ path: '/v1/users',
59
+ params: options
60
+ )
61
+
62
+ execute_request(request: request)
63
+ end
64
+
48
65
  # Retrieves the given user
49
66
  #
50
67
  # @param [String] id The user ID
@@ -378,6 +395,26 @@ module Knock
378
395
 
379
396
  execute_request(request: request)
380
397
  end
398
+
399
+ ##
400
+ # Subscriptions
401
+ ##
402
+
403
+ # Get user's subscriptions
404
+ #
405
+ # @param [String] id the user ID
406
+ # @param [Hash] options Options to pass to the subscriptions endpoint query
407
+ #
408
+ # @return [Hash] Paginated subscriptions response
409
+ def get_subscriptions(id:, options: {})
410
+ request = get_request(
411
+ auth: true,
412
+ path: "/v1/users/#{id}/subscriptions",
413
+ params: options
414
+ )
415
+
416
+ execute_request(request: request)
417
+ end
381
418
  end
382
419
  end
383
420
  # 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.8'
4
+ VERSION = '0.4.10'
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.8
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Knock Labs, Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-14 00:00:00.000000000 Z
11
+ date: 2023-06-16 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
+ - ".tool-versions"
69
70
  - CONTRIBUTING.md
70
71
  - Gemfile
71
72
  - Gemfile.lock
@@ -92,7 +93,7 @@ licenses:
92
93
  - MIT
93
94
  metadata:
94
95
  documentation_uri: https://docs.knock.app
95
- post_install_message:
96
+ post_install_message:
96
97
  rdoc_options: []
97
98
  require_paths:
98
99
  - lib
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  version: '0'
109
110
  requirements: []
110
111
  rubygems_version: 3.4.10
111
- signing_key:
112
+ signing_key:
112
113
  specification_version: 4
113
114
  summary: API client for Knock
114
115
  test_files: