hookbridge 1.5.0 → 1.7.0
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/lib/hookbridge/client.rb +125 -2
- data/lib/hookbridge/types.rb +101 -0
- data/lib/hookbridge/version.rb +1 -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: 5a3ef380402beb61c7cbbca77fd98b1797aa086d052b6a9461300329bf7f26f9
|
|
4
|
+
data.tar.gz: 2932a270e9649ce1f26117122867c1c473566fdf6e6ebec04d2edcb630233fff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e2262aa8ce2ac43a6d468f9a1158ade14ea7667c201225b8e1b462876a7d9d85c105501f50252726f4f40285290260493593d446b86d14be406cfe0e87c1f4a1
|
|
7
|
+
data.tar.gz: 62effea4fc77737a93a938a918d307dde0ce1a553c25fc4627cb6857f25c2e68865c8fec4e1eac011aa02ab3c2b8e337a5ddb7fcb93f5625a7478662ced184f0
|
data/lib/hookbridge/client.rb
CHANGED
|
@@ -224,6 +224,120 @@ module HookBridge
|
|
|
224
224
|
create_endpoint_signing_key(endpoint_id)
|
|
225
225
|
end
|
|
226
226
|
|
|
227
|
+
def create_pull_endpoint(name: nil, description: nil, retention_days: nil, event_type_source: nil, event_type_path: nil,
|
|
228
|
+
verify_static_token: nil, token_header_name: nil, token_query_param: nil, token_value: nil,
|
|
229
|
+
verify_hmac: nil, hmac_header_name: nil, hmac_secret: nil, timestamp_header_name: nil,
|
|
230
|
+
timestamp_ttl_seconds: nil, verify_ip_allowlist: nil, allowed_cidrs: nil,
|
|
231
|
+
idempotency_header_names: nil, ingest_response_code: nil)
|
|
232
|
+
body = compact_hash(
|
|
233
|
+
name: name,
|
|
234
|
+
description: description,
|
|
235
|
+
retention_days: retention_days,
|
|
236
|
+
event_type_source: event_type_source,
|
|
237
|
+
event_type_path: event_type_path,
|
|
238
|
+
verify_static_token: verify_static_token,
|
|
239
|
+
token_header_name: token_header_name,
|
|
240
|
+
token_query_param: token_query_param,
|
|
241
|
+
token_value: token_value,
|
|
242
|
+
verify_hmac: verify_hmac,
|
|
243
|
+
hmac_header_name: hmac_header_name,
|
|
244
|
+
hmac_secret: hmac_secret,
|
|
245
|
+
timestamp_header_name: timestamp_header_name,
|
|
246
|
+
timestamp_ttl_seconds: timestamp_ttl_seconds,
|
|
247
|
+
verify_ip_allowlist: verify_ip_allowlist,
|
|
248
|
+
allowed_cidrs: allowed_cidrs,
|
|
249
|
+
idempotency_header_names: idempotency_header_names,
|
|
250
|
+
ingest_response_code: ingest_response_code
|
|
251
|
+
)
|
|
252
|
+
CreatePullEndpointResponse.new(extract_data(request(:post, "/v1/pull-endpoints", body)))
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def list_pull_endpoints(limit: nil, cursor: nil)
|
|
256
|
+
params = {}
|
|
257
|
+
params[:limit] = limit if limit
|
|
258
|
+
params[:cursor] = cursor if cursor
|
|
259
|
+
response = request(:get, "/v1/pull-endpoints", nil, params)
|
|
260
|
+
ListPullEndpointsResponse.new(
|
|
261
|
+
"data" => extract_data(response),
|
|
262
|
+
"next_cursor" => extract_meta(response)["next_cursor"] || response["next_cursor"]
|
|
263
|
+
)
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
def get_pull_endpoint(endpoint_id)
|
|
267
|
+
PullEndpoint.new(extract_data(request(:get, "/v1/pull-endpoints/#{endpoint_id}")))
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def update_pull_endpoint(endpoint_id, **attributes)
|
|
271
|
+
PullEndpoint.new(extract_data(request(:patch, "/v1/pull-endpoints/#{endpoint_id}", compact_hash(attributes))))
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def delete_pull_endpoint(endpoint_id)
|
|
275
|
+
DeleteResult.new(extract_data(request(:delete, "/v1/pull-endpoints/#{endpoint_id}")))
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def pause_pull_endpoint(endpoint_id)
|
|
279
|
+
PauseState.new(extract_data(request(:post, "/v1/pull-endpoints/#{endpoint_id}/pause")))
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def resume_pull_endpoint(endpoint_id)
|
|
283
|
+
PauseState.new(extract_data(request(:post, "/v1/pull-endpoints/#{endpoint_id}/resume")))
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def list_pull_events(endpoint_id, status: nil, event_type: nil, since: nil, before: nil, limit: nil, cursor: nil)
|
|
287
|
+
params = {}
|
|
288
|
+
params[:status] = status if status
|
|
289
|
+
params[:event_type] = event_type if event_type
|
|
290
|
+
params[:since] = format_time(since) if since
|
|
291
|
+
params[:before] = format_time(before) if before
|
|
292
|
+
params[:limit] = limit if limit
|
|
293
|
+
params[:cursor] = cursor if cursor
|
|
294
|
+
response = request(:get, "/v1/pull-endpoints/#{endpoint_id}/events", nil, params)
|
|
295
|
+
ListPullEventsResponse.new(
|
|
296
|
+
"data" => extract_data(response),
|
|
297
|
+
"has_more" => extract_meta(response)["has_more"] || response["has_more"],
|
|
298
|
+
"next_cursor" => extract_meta(response)["next_cursor"] || response["next_cursor"]
|
|
299
|
+
)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def get_pull_event(endpoint_id, event_id)
|
|
303
|
+
PullEventDetail.new(extract_data(request(:get, "/v1/pull-endpoints/#{endpoint_id}/events/#{event_id}")))
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def ack_pull_events(endpoint_id, event_ids)
|
|
307
|
+
AckPullEventsResponse.new(
|
|
308
|
+
extract_data(request(:post, "/v1/pull-endpoints/#{endpoint_id}/events/ack", { event_ids: event_ids }))
|
|
309
|
+
)
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def get_pull_logs(pull_endpoint_id: nil, status: nil, event_type: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil)
|
|
313
|
+
params = {}
|
|
314
|
+
params[:pull_endpoint_id] = pull_endpoint_id if pull_endpoint_id
|
|
315
|
+
params[:status] = status if status
|
|
316
|
+
params[:event_type] = event_type if event_type
|
|
317
|
+
params[:start_time] = format_time(start_time) if start_time
|
|
318
|
+
params[:end_time] = format_time(end_time) if end_time
|
|
319
|
+
params[:limit] = limit if limit
|
|
320
|
+
params[:cursor] = cursor if cursor
|
|
321
|
+
response = request(:get, "/v1/pull-logs", nil, params)
|
|
322
|
+
PullLogsResponse.new(
|
|
323
|
+
"data" => extract_data(response),
|
|
324
|
+
"has_more" => extract_meta(response)["has_more"] || response["has_more"],
|
|
325
|
+
"next_cursor" => extract_meta(response)["next_cursor"] || response["next_cursor"]
|
|
326
|
+
)
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
def get_pull_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, pull_endpoint_id: nil)
|
|
330
|
+
params = { window: window }
|
|
331
|
+
params[:pull_endpoint_id] = pull_endpoint_id if pull_endpoint_id
|
|
332
|
+
Metrics.new(extract_data(request(:get, "/v1/pull-metrics", nil, params)))
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def get_pull_timeseries_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, pull_endpoint_id: nil)
|
|
336
|
+
params = { window: window }
|
|
337
|
+
params[:pull_endpoint_id] = pull_endpoint_id if pull_endpoint_id
|
|
338
|
+
PullTimeSeriesMetrics.new(extract_data(request(:get, "/v1/pull-metrics/timeseries", nil, params)))
|
|
339
|
+
end
|
|
340
|
+
|
|
227
341
|
def create_checkout(plan:, interval:)
|
|
228
342
|
CheckoutSession.new(extract_data(request(:post, "/v1/billing/checkout", { plan: plan, interval: interval })))
|
|
229
343
|
end
|
|
@@ -246,11 +360,13 @@ module HookBridge
|
|
|
246
360
|
InvoicesResponse.new(extract_data(response), extract_meta(response))
|
|
247
361
|
end
|
|
248
362
|
|
|
249
|
-
def create_inbound_endpoint(url
|
|
250
|
-
body = {
|
|
363
|
+
def create_inbound_endpoint(url: nil, name: nil, description: nil, mode: nil, verify_static_token: nil, token_header_name: nil, token_query_param: nil, token_value: nil, verify_hmac: nil, hmac_header_name: nil, hmac_secret: nil, timestamp_header_name: nil, timestamp_ttl_seconds: nil, verify_ip_allowlist: nil, allowed_cidrs: nil, idempotency_header_names: nil, ingest_response_code: nil, signing_enabled: nil)
|
|
364
|
+
body = {}
|
|
365
|
+
body[:url] = url unless url.nil?
|
|
251
366
|
{
|
|
252
367
|
name: name,
|
|
253
368
|
description: description,
|
|
369
|
+
mode: mode,
|
|
254
370
|
verify_static_token: verify_static_token,
|
|
255
371
|
token_header_name: token_header_name,
|
|
256
372
|
token_query_param: token_query_param,
|
|
@@ -303,6 +419,13 @@ module HookBridge
|
|
|
303
419
|
PauseState.new(extract_data(request(:post, "/v1/inbound-endpoints/#{endpoint_id}/resume")))
|
|
304
420
|
end
|
|
305
421
|
|
|
422
|
+
def listen_inbound_endpoint(endpoint_id, after: nil)
|
|
423
|
+
params = {}
|
|
424
|
+
params[:after] = after if after
|
|
425
|
+
response = request(:get, "/v1/inbound-endpoints/#{endpoint_id}/listen", nil, params)
|
|
426
|
+
ListenInboundEndpointResponse.new(response)
|
|
427
|
+
end
|
|
428
|
+
|
|
306
429
|
def get_inbound_message(message_id)
|
|
307
430
|
InboundMessage.new(extract_data(request(:get, "/v1/inbound-messages/#{message_id}")))
|
|
308
431
|
end
|
data/lib/hookbridge/types.rb
CHANGED
|
@@ -283,6 +283,21 @@ module HookBridge
|
|
|
283
283
|
end
|
|
284
284
|
end
|
|
285
285
|
|
|
286
|
+
class PullTimeSeriesBucket < BaseModel
|
|
287
|
+
def initialize(data)
|
|
288
|
+
super(data, time_fields: %w[timestamp])
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
class PullTimeSeriesMetrics
|
|
293
|
+
attr_reader :window, :buckets
|
|
294
|
+
|
|
295
|
+
def initialize(data)
|
|
296
|
+
@window = data["window"]
|
|
297
|
+
@buckets = (data["buckets"] || []).map { |entry| PullTimeSeriesBucket.new(entry) }
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
|
|
286
301
|
class SubscriptionLimits < BaseModel
|
|
287
302
|
end
|
|
288
303
|
|
|
@@ -333,6 +348,21 @@ module HookBridge
|
|
|
333
348
|
end
|
|
334
349
|
end
|
|
335
350
|
|
|
351
|
+
class ListenMessage < BaseModel
|
|
352
|
+
def initialize(data)
|
|
353
|
+
super(data, time_fields: %w[received_at])
|
|
354
|
+
end
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
class ListenInboundEndpointResponse
|
|
358
|
+
attr_reader :messages, :next_cursor
|
|
359
|
+
|
|
360
|
+
def initialize(data)
|
|
361
|
+
@messages = (data["data"] || []).map { |entry| ListenMessage.new(entry) }
|
|
362
|
+
@next_cursor = data.dig("meta", "next_cursor")
|
|
363
|
+
end
|
|
364
|
+
end
|
|
365
|
+
|
|
336
366
|
class UpdateResult < BaseModel
|
|
337
367
|
end
|
|
338
368
|
|
|
@@ -342,6 +372,77 @@ module HookBridge
|
|
|
342
372
|
class PauseState < BaseModel
|
|
343
373
|
end
|
|
344
374
|
|
|
375
|
+
class PullEndpointCounts < BaseModel
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
class PullEndpoint < BaseModel
|
|
379
|
+
def initialize(data)
|
|
380
|
+
attributes = (data || {}).dup
|
|
381
|
+
attributes["counts"] = PullEndpointCounts.new(attributes["counts"]) if attributes["counts"].is_a?(Hash)
|
|
382
|
+
super(attributes, time_fields: %w[created_at updated_at])
|
|
383
|
+
end
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
class CreatePullEndpointResponse < PullEndpoint
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
class PullEndpointSummary < BaseModel
|
|
390
|
+
def initialize(data)
|
|
391
|
+
super(data, time_fields: %w[created_at])
|
|
392
|
+
end
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
class ListPullEndpointsResponse
|
|
396
|
+
attr_reader :endpoints, :has_more, :next_cursor
|
|
397
|
+
|
|
398
|
+
def initialize(data)
|
|
399
|
+
@endpoints = (data["data"] || data || []).map { |entry| PullEndpointSummary.new(entry) }
|
|
400
|
+
@has_more = !data["next_cursor"].nil? && data["next_cursor"] != ""
|
|
401
|
+
@next_cursor = data["next_cursor"]
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
class PullEventSummary < BaseModel
|
|
406
|
+
def initialize(data)
|
|
407
|
+
super(data, time_fields: %w[received_at fetched_at delivered_at])
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
class PullEventDetail < BaseModel
|
|
412
|
+
def initialize(data)
|
|
413
|
+
super(data, time_fields: %w[received_at fetched_at delivered_at])
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
class ListPullEventsResponse
|
|
418
|
+
attr_reader :events, :has_more, :next_cursor
|
|
419
|
+
|
|
420
|
+
def initialize(data)
|
|
421
|
+
@events = (data["data"] || data || []).map { |entry| PullEventSummary.new(entry) }
|
|
422
|
+
@has_more = data["has_more"] || false
|
|
423
|
+
@next_cursor = data["next_cursor"]
|
|
424
|
+
end
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
class AckPullEventsResponse < BaseModel
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
class PullLogEntry < BaseModel
|
|
431
|
+
def initialize(data)
|
|
432
|
+
super(data, time_fields: %w[received_at fetched_at delivered_at])
|
|
433
|
+
end
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
class PullLogsResponse
|
|
437
|
+
attr_reader :entries, :has_more, :next_cursor
|
|
438
|
+
|
|
439
|
+
def initialize(data)
|
|
440
|
+
@entries = (data["data"] || data || []).map { |entry| PullLogEntry.new(entry) }
|
|
441
|
+
@has_more = data["has_more"] || false
|
|
442
|
+
@next_cursor = data["next_cursor"]
|
|
443
|
+
end
|
|
444
|
+
end
|
|
445
|
+
|
|
345
446
|
class InboundLogEntry < BaseModel
|
|
346
447
|
def initialize(data)
|
|
347
448
|
super(data, time_fields: %w[received_at delivered_at])
|
data/lib/hookbridge/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hookbridge
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- HookBridge
|
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
180
180
|
- !ruby/object:Gem::Version
|
|
181
181
|
version: '0'
|
|
182
182
|
requirements: []
|
|
183
|
-
rubygems_version: 4.0.
|
|
183
|
+
rubygems_version: 4.0.9
|
|
184
184
|
specification_version: 4
|
|
185
185
|
summary: Ruby SDK for HookBridge - Guaranteed webhook delivery
|
|
186
186
|
test_files: []
|