knockapi 0.4.7 → 0.4.8

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: 829d797080c6841ef0bda6f2e775e17d45f4c30c466f2b0e1b8ea2abb7e8602e
4
- data.tar.gz: 34bfb3a3bcad22f326a3195d67f879d57e746c1eaef1bb8fd5be490a5eac1058
3
+ metadata.gz: f76a1fe37f883f760b872f6b52bafb40e22a870f650fb0c4cc5b40e85912888c
4
+ data.tar.gz: 7dc8c721a049b9b3a25ff67db18dc9cdca1e551f1bbcdddbf025305f6b23e582
5
5
  SHA512:
6
- metadata.gz: 8da11f98837db48e400a3387a081f2309fc7302029b592b6990293127302fd9c17c8c50747e6786943ede84a6cbda9b9496dce58cca25f8f603d016b844d4c8c
7
- data.tar.gz: fc8224278dc1ef927eed734a5e55877d9d934a204a8cf22bd11b32ddeee3d04281bbff1195da500755fb1e248e30f30f28967d42e010f79da96ae4f53cbf3436
6
+ metadata.gz: 38e0c87a2c2e4fe46c1cc80c9a7707e1b26416f682a5de387f8725afa0e9a9599a9ee35b0b57e693b1a37897d2cf5e132c75595304497281f4b014e350946ef5
7
+ data.tar.gz: 4a3be25fd78f03bc7605fea581486950639ea333c819828e1859e30d94ea8f0e42d00807a5076ba9d97db508c48e08163dbe81f694adc49517401028b8f582f2
data/.rubocop.yml CHANGED
@@ -5,4 +5,4 @@ Metrics/LineLength:
5
5
  Metrics/MethodLength:
6
6
  Max: 35
7
7
  Metrics/ParameterLists:
8
- Max: 6
8
+ Max: 7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- knockapi (0.4.7)
4
+ knockapi (0.4.8)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/knock/objects.rb CHANGED
@@ -358,6 +358,23 @@ module Knock
358
358
 
359
359
  execute_request(request: request)
360
360
  end
361
+
362
+ # Get object's schedules
363
+ #
364
+ # @param [String] collection The collection the object is in
365
+ # @param [String] id The object id
366
+ # @param [Hash] options Options to pass to the schedules endpoint query
367
+ #
368
+ # @return [Hash] Paginated schedules response
369
+ def get_schedules(collection:, id:, options: {})
370
+ request = get_request(
371
+ auth: true,
372
+ path: "/v1/objects/#{collection}/#{id}/schedules",
373
+ params: options
374
+ )
375
+
376
+ execute_request(request: request)
377
+ end
361
378
  end
362
379
  end
363
380
  # rubocop:enable Metrics/ModuleLength
data/lib/knock/users.rb CHANGED
@@ -358,6 +358,26 @@ module Knock
358
358
 
359
359
  execute_request(request: request)
360
360
  end
361
+
362
+ ##
363
+ # Schedules
364
+ ##
365
+
366
+ # Get user's schedules
367
+ #
368
+ # @param [String] id the user ID
369
+ # @param [Hash] options Options to pass to the schedules endpoint query
370
+ #
371
+ # @return [Hash] Paginated schedules response
372
+ def get_schedules(id:, options: {})
373
+ request = get_request(
374
+ auth: true,
375
+ path: "/v1/users/#{id}/schedules",
376
+ params: options
377
+ )
378
+
379
+ execute_request(request: request)
380
+ end
361
381
  end
362
382
  end
363
383
  # 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.7'
4
+ VERSION = '0.4.8'
5
5
  end
@@ -23,7 +23,7 @@ module Knock
23
23
  # duplicate workflow invocations
24
24
  #
25
25
  # @return [Hash] A workflow trigger result
26
- def trigger(key:, actor:, recipients:, data: {}, cancellation_key: nil, tenant: nil, idempotency_key: nil) # rubocop:disable Metrics/ParameterLists
26
+ def trigger(key:, actor:, recipients:, data: {}, cancellation_key: nil, tenant: nil, idempotency_key: nil)
27
27
  attrs = {
28
28
  actor: actor,
29
29
  recipients: recipients,
@@ -63,6 +63,91 @@ module Knock
63
63
 
64
64
  execute_request(request: request)
65
65
  end
66
+
67
+ # Creates schedule instances for all recipients for the given
68
+ # workflow.
69
+ #
70
+ # @param [String] key The workflow key
71
+ # @param [String, Hash] actor An optional actor identifier to be used when trigger the workflow
72
+ # @param [Array<String, Hash>] recipients The recipient identifiers
73
+ # @param [Array<Hash>] repeats The repeat rules for when to schedule the workflow run
74
+ # @param [Hash] data Parameters to be used as variables on the workflow run
75
+ # @param [String] tenant An optional tenant identifier
76
+
77
+ def create_schedules(key:, recipients:, repeats:, scheduled_at: nil, data: {}, actor: nil, tenant: nil)
78
+ attrs = {
79
+ workflow: key,
80
+ actor: actor,
81
+ recipients: recipients,
82
+ repeats: repeats,
83
+ data: data,
84
+ tenant: tenant,
85
+ scheduled_at: scheduled_at
86
+ }
87
+
88
+ request = post_request(
89
+ auth: true,
90
+ path: '/v1/schedules',
91
+ body: attrs
92
+ )
93
+
94
+ execute_request(request: request)
95
+ end
96
+
97
+ # Updates schedule instances with the attributes passed as params
98
+ #
99
+ # @param [Array<String>] schedule_ids The ids of the schedules to be updated
100
+ # @param [Hash] schedule_attrs The attributes to be used to update the schedules
101
+ # Possible attributes: actor, repeats, data and tenant
102
+
103
+ def update_schedules(schedule_ids:, schedule_attrs:)
104
+ attrs = {
105
+ schedule_ids: schedule_ids
106
+ }
107
+
108
+ attrs = attrs.merge(schedule_attrs)
109
+
110
+ request = put_request(
111
+ auth: true,
112
+ path: '/v1/schedules',
113
+ body: attrs
114
+ )
115
+
116
+ execute_request(request: request)
117
+ end
118
+
119
+ # Get paginated workflow schedules
120
+ #
121
+ # @param [String] key The workflow key
122
+ # @param [Hash] opts Options to filter the results: recipients, tenant and pagination params
123
+ def list_schedules(key:, opts: {})
124
+ attrs = opts.merge(workflow: key)
125
+
126
+ request = get_request(
127
+ auth: true,
128
+ path: '/v1/schedules',
129
+ params: attrs
130
+ )
131
+
132
+ execute_request(request: request)
133
+ end
134
+
135
+ # Delete schedule instances
136
+ #
137
+ # @param [Array<String>] schedule_ids The ids of the schedules to be deleted
138
+ def delete_schedules(schedule_ids:)
139
+ attrs = {
140
+ schedule_ids: schedule_ids
141
+ }
142
+
143
+ request = delete_request(
144
+ auth: true,
145
+ path: '/v1/schedules',
146
+ body: attrs
147
+ )
148
+
149
+ execute_request(request: request)
150
+ end
66
151
  end
67
152
  end
68
153
  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.7
4
+ version: 0.4.8
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-04-10 00:00:00.000000000 Z
11
+ date: 2023-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler