knockapi 0.4.7 → 0.4.8
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/.rubocop.yml +1 -1
- data/Gemfile.lock +1 -1
- data/lib/knock/objects.rb +17 -0
- data/lib/knock/users.rb +20 -0
- data/lib/knock/version.rb +1 -1
- data/lib/knock/workflows.rb +86 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f76a1fe37f883f760b872f6b52bafb40e22a870f650fb0c4cc5b40e85912888c
|
4
|
+
data.tar.gz: 7dc8c721a049b9b3a25ff67db18dc9cdca1e551f1bbcdddbf025305f6b23e582
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38e0c87a2c2e4fe46c1cc80c9a7707e1b26416f682a5de387f8725afa0e9a9599a9ee35b0b57e693b1a37897d2cf5e132c75595304497281f4b014e350946ef5
|
7
|
+
data.tar.gz: 4a3be25fd78f03bc7605fea581486950639ea333c819828e1859e30d94ea8f0e42d00807a5076ba9d97db508c48e08163dbe81f694adc49517401028b8f582f2
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
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
data/lib/knock/workflows.rb
CHANGED
@@ -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)
|
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.
|
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-
|
11
|
+
date: 2023-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|