hookbridge 1.6.0 → 1.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b5c43ea6d4f602bbe765fda06433a5dba02afd8907b36bd3911934315ed75a7
4
- data.tar.gz: d83dfdab5ae8ccc6e17a7743ad4c653787c27889eeea6d4f4856de1300fbd838
3
+ metadata.gz: 3eb78782e81c381238fa55e447688e3e58b437d1aeb531629b0c6d8388149f9b
4
+ data.tar.gz: 2343289ec20d2df8397137e7281dcce2d0d1920c1f1fad8e606071000c0eb26e
5
5
  SHA512:
6
- metadata.gz: ce5a62d25e7ed153478d173afa953fcc38f639f3be61ed1d09229d1601a30361173bf80532bf8a5eeb4357faba22f07cc890412f7d9eb7280beef9ab60a52a27
7
- data.tar.gz: 53c666698c37c8500059f98e6dde44bb72e90caffcadaa5211cd6eeb011bdedc8d3a72103bd9c6999ec501215bf827f00438172ca50de958e7b90c732889751b
6
+ metadata.gz: ddb04a28ba7ed43bfa39ed780e7d193793335498d8f9f40835720d05951395ebc78f6b1df4bfae9467a1c42fc8e573404c5742f77b2295391f26c03954bbf842
7
+ data.tar.gz: 439ffca58ae0d59f14f19efc0e7021279a4938152e2807e6a543cca6a7dc5597764d641072b5ef61a2a261981032232342a06a3bb2a2d4a1bdc7b60caa3744d2
@@ -224,6 +224,122 @@ 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, preview: false)
303
+ params = {}
304
+ params[:preview] = "true" if preview
305
+ PullEventDetail.new(extract_data(request(:get, "/v1/pull-endpoints/#{endpoint_id}/events/#{event_id}", nil, params)))
306
+ end
307
+
308
+ def ack_pull_events(endpoint_id, event_ids)
309
+ AckPullEventsResponse.new(
310
+ extract_data(request(:post, "/v1/pull-endpoints/#{endpoint_id}/events/ack", { event_ids: event_ids }))
311
+ )
312
+ end
313
+
314
+ def get_pull_logs(pull_endpoint_id: nil, status: nil, event_type: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil)
315
+ params = {}
316
+ params[:pull_endpoint_id] = pull_endpoint_id if pull_endpoint_id
317
+ params[:status] = status if status
318
+ params[:event_type] = event_type if event_type
319
+ params[:start_time] = format_time(start_time) if start_time
320
+ params[:end_time] = format_time(end_time) if end_time
321
+ params[:limit] = limit if limit
322
+ params[:cursor] = cursor if cursor
323
+ response = request(:get, "/v1/pull-logs", nil, params)
324
+ PullLogsResponse.new(
325
+ "data" => extract_data(response),
326
+ "has_more" => extract_meta(response)["has_more"] || response["has_more"],
327
+ "next_cursor" => extract_meta(response)["next_cursor"] || response["next_cursor"]
328
+ )
329
+ end
330
+
331
+ def get_pull_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, pull_endpoint_id: nil)
332
+ params = { window: window }
333
+ params[:pull_endpoint_id] = pull_endpoint_id if pull_endpoint_id
334
+ Metrics.new(extract_data(request(:get, "/v1/pull-metrics", nil, params)))
335
+ end
336
+
337
+ def get_pull_timeseries_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, pull_endpoint_id: nil)
338
+ params = { window: window }
339
+ params[:pull_endpoint_id] = pull_endpoint_id if pull_endpoint_id
340
+ PullTimeSeriesMetrics.new(extract_data(request(:get, "/v1/pull-metrics/timeseries", nil, params)))
341
+ end
342
+
227
343
  def create_checkout(plan:, interval:)
228
344
  CheckoutSession.new(extract_data(request(:post, "/v1/billing/checkout", { plan: plan, interval: interval })))
229
345
  end
@@ -305,6 +421,21 @@ module HookBridge
305
421
  PauseState.new(extract_data(request(:post, "/v1/inbound-endpoints/#{endpoint_id}/resume")))
306
422
  end
307
423
 
424
+ def create_inbound_signing_key(endpoint_id)
425
+ RotateSecretResponse.new(extract_data(request(:post, "/v1/inbound-endpoints/#{endpoint_id}/signing-keys")))
426
+ end
427
+
428
+ def list_inbound_signing_keys(endpoint_id)
429
+ extract_data(request(:get, "/v1/inbound-endpoints/#{endpoint_id}/signing-keys")).map do |entry|
430
+ SigningKey.new(entry)
431
+ end
432
+ end
433
+
434
+ def delete_inbound_signing_key(endpoint_id, key_id)
435
+ request(:delete, "/v1/inbound-endpoints/#{endpoint_id}/signing-keys/#{key_id}")
436
+ true
437
+ end
438
+
308
439
  def listen_inbound_endpoint(endpoint_id, after: nil)
309
440
  params = {}
310
441
  params[:after] = after if after
@@ -405,6 +536,73 @@ module HookBridge
405
536
  true
406
537
  end
407
538
 
539
+ def delete_message(message_id)
540
+ DeleteMessageResult.new(extract_data(request(:delete, "/v1/messages/#{message_id}")))
541
+ end
542
+
543
+ def delete_messages_batch(message_ids)
544
+ DeleteBatchResult.new(
545
+ extract_data(request(:post, "/v1/messages/delete-batch", { message_ids: message_ids }))
546
+ )
547
+ end
548
+
549
+ def delete_messages_all(status: nil, endpoint_id: nil, created_after: nil, created_before: nil, limit: nil)
550
+ params = {}
551
+ params[:status] = status if status
552
+ params[:endpoint_id] = endpoint_id if endpoint_id
553
+ params[:created_after] = format_time(created_after) if created_after
554
+ params[:created_before] = format_time(created_before) if created_before
555
+ params[:limit] = limit if limit
556
+ DeleteAllResult.new(request(:post, "/v1/messages/delete-all", nil, params))
557
+ end
558
+
559
+ def delete_inbound_message(message_id)
560
+ DeleteMessageResult.new(extract_data(request(:delete, "/v1/inbound-messages/#{message_id}")))
561
+ end
562
+
563
+ def delete_inbound_messages_batch(message_ids)
564
+ DeleteBatchResult.new(
565
+ extract_data(request(:post, "/v1/inbound-messages/delete-batch", { message_ids: message_ids }))
566
+ )
567
+ end
568
+
569
+ def delete_inbound_messages_all(status: nil, inbound_endpoint_id: nil, received_after: nil, received_before: nil, limit: nil)
570
+ params = {}
571
+ params[:status] = status if status
572
+ params[:inbound_endpoint_id] = inbound_endpoint_id if inbound_endpoint_id
573
+ params[:received_after] = format_time(received_after) if received_after
574
+ params[:received_before] = format_time(received_before) if received_before
575
+ params[:limit] = limit if limit
576
+ DeleteAllResult.new(request(:post, "/v1/inbound-messages/delete-all", nil, params))
577
+ end
578
+
579
+ def delete_pull_event(endpoint_id, event_id)
580
+ DeleteEventResult.new(extract_data(request(:delete, "/v1/pull-endpoints/#{endpoint_id}/events/#{event_id}")))
581
+ end
582
+
583
+ def delete_pull_events_batch(endpoint_id, event_ids)
584
+ DeleteEventBatchResult.new(
585
+ extract_data(request(:post, "/v1/pull-endpoints/#{endpoint_id}/events/delete-batch", { message_ids: event_ids }))
586
+ )
587
+ end
588
+
589
+ def delete_pull_events_all(endpoint_id, status: nil, event_type: nil, received_after: nil, received_before: nil, limit: nil)
590
+ params = {}
591
+ params[:status] = status if status
592
+ params[:event_type] = event_type if event_type
593
+ params[:received_after] = format_time(received_after) if received_after
594
+ params[:received_before] = format_time(received_before) if received_before
595
+ params[:limit] = limit if limit
596
+ DeletePullEventsAllResult.new(request(:post, "/v1/pull-endpoints/#{endpoint_id}/events/delete-all", nil, params))
597
+ end
598
+
599
+ def lookup_actors(user_ids: nil, api_key_ids: nil)
600
+ params = {}
601
+ params[:user_id] = user_ids.join(",") if user_ids && !user_ids.empty?
602
+ params[:api_key_id] = api_key_ids.join(",") if api_key_ids && !api_key_ids.empty?
603
+ ActorLookupResult.new(extract_data(request(:get, "/v1/actors/lookup", nil, params)))
604
+ end
605
+
408
606
  private
409
607
 
410
608
  def build_connection(url)
@@ -75,13 +75,13 @@ module HookBridge
75
75
 
76
76
  class Message < BaseModel
77
77
  def initialize(data)
78
- super(data, time_fields: %w[next_attempt_at created_at updated_at])
78
+ super(data, time_fields: %w[next_attempt_at created_at updated_at deleted_at])
79
79
  end
80
80
  end
81
81
 
82
82
  class MessageSummary < BaseModel
83
83
  def initialize(data)
84
- super(data, time_fields: %w[created_at delivered_at next_attempt_at])
84
+ super(data, time_fields: %w[created_at delivered_at next_attempt_at deleted_at])
85
85
  end
86
86
  end
87
87
 
@@ -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
 
@@ -357,9 +372,89 @@ module HookBridge
357
372
  class PauseState < BaseModel
358
373
  end
359
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 PullTimingBreakdown < BaseModel
406
+ end
407
+
408
+ class PullEventSummary < BaseModel
409
+ def initialize(data)
410
+ attributes = (data || {}).dup
411
+ attributes["timing"] = PullTimingBreakdown.new(attributes["timing"]) if attributes["timing"].is_a?(Hash)
412
+ super(attributes, time_fields: %w[received_at fetched_at delivered_at deleted_at])
413
+ end
414
+ end
415
+
416
+ class PullEventDetail < BaseModel
417
+ def initialize(data)
418
+ attributes = (data || {}).dup
419
+ attributes["timing"] = PullTimingBreakdown.new(attributes["timing"]) if attributes["timing"].is_a?(Hash)
420
+ super(attributes, time_fields: %w[received_at fetched_at delivered_at deleted_at])
421
+ end
422
+ end
423
+
424
+ class ListPullEventsResponse
425
+ attr_reader :events, :has_more, :next_cursor
426
+
427
+ def initialize(data)
428
+ @events = (data["data"] || data || []).map { |entry| PullEventSummary.new(entry) }
429
+ @has_more = data["has_more"] || false
430
+ @next_cursor = data["next_cursor"]
431
+ end
432
+ end
433
+
434
+ class AckPullEventsResponse < BaseModel
435
+ end
436
+
437
+ class PullLogEntry < BaseModel
438
+ def initialize(data)
439
+ attributes = (data || {}).dup
440
+ attributes["timing"] = PullTimingBreakdown.new(attributes["timing"]) if attributes["timing"].is_a?(Hash)
441
+ super(attributes, time_fields: %w[received_at fetched_at delivered_at deleted_at])
442
+ end
443
+ end
444
+
445
+ class PullLogsResponse
446
+ attr_reader :entries, :has_more, :next_cursor
447
+
448
+ def initialize(data)
449
+ @entries = (data["data"] || data || []).map { |entry| PullLogEntry.new(entry) }
450
+ @has_more = data["has_more"] || false
451
+ @next_cursor = data["next_cursor"]
452
+ end
453
+ end
454
+
360
455
  class InboundLogEntry < BaseModel
361
456
  def initialize(data)
362
- super(data, time_fields: %w[received_at delivered_at])
457
+ super(data, time_fields: %w[received_at delivered_at deleted_at])
363
458
  end
364
459
  end
365
460
 
@@ -406,7 +501,7 @@ module HookBridge
406
501
 
407
502
  class InboundMessage < BaseModel
408
503
  def initialize(data)
409
- super(data, time_fields: %w[received_at updated_at next_attempt_at delivered_at failed_at])
504
+ super(data, time_fields: %w[received_at updated_at next_attempt_at delivered_at failed_at deleted_at])
410
505
  end
411
506
  end
412
507
 
@@ -422,4 +517,86 @@ module HookBridge
422
517
  ])
423
518
  end
424
519
  end
520
+
521
+ class DeleteMessageResult < BaseModel
522
+ def initialize(data)
523
+ super(data, time_fields: %w[deleted_at])
524
+ end
525
+ end
526
+
527
+ class DeleteEventResult < BaseModel
528
+ def initialize(data)
529
+ super(data, time_fields: %w[deleted_at])
530
+ end
531
+ end
532
+
533
+ class DeleteBatchItemResult < BaseModel
534
+ def initialize(data)
535
+ super(data, time_fields: %w[deleted_at])
536
+ end
537
+ end
538
+
539
+ class DeleteBatchResult
540
+ attr_reader :results, :deleted_count, :already_deleted_count, :not_found_count
541
+
542
+ def initialize(data)
543
+ @results = (data["results"] || []).map { |item| DeleteBatchItemResult.new(item) }
544
+ @deleted_count = data["deleted_count"]
545
+ @already_deleted_count = data["already_deleted_count"]
546
+ @not_found_count = data["not_found_count"]
547
+ end
548
+ end
549
+
550
+ class DeleteEventBatchItemResult < BaseModel
551
+ def initialize(data)
552
+ super(data, time_fields: %w[deleted_at])
553
+ end
554
+ end
555
+
556
+ class DeleteEventBatchResult
557
+ attr_reader :results, :deleted_count, :already_deleted_count, :not_found_count
558
+
559
+ def initialize(data)
560
+ @results = (data["results"] || []).map { |item| DeleteEventBatchItemResult.new(item) }
561
+ @deleted_count = data["deleted_count"]
562
+ @already_deleted_count = data["already_deleted_count"]
563
+ @not_found_count = data["not_found_count"]
564
+ end
565
+ end
566
+
567
+ class DeletePartialError < BaseModel
568
+ end
569
+
570
+ class DeleteAllResult
571
+ attr_reader :deleted, :deleted_message_ids, :error
572
+
573
+ def initialize(response)
574
+ data = response["data"] || {}
575
+ @deleted = data["deleted"]
576
+ @deleted_message_ids = data["deleted_message_ids"] || []
577
+ err = response["error"]
578
+ @error = err ? DeletePartialError.new(err) : nil
579
+ end
580
+ end
581
+
582
+ class DeletePullEventsAllResult
583
+ attr_reader :deleted, :deleted_event_ids, :error
584
+
585
+ def initialize(response)
586
+ data = response["data"] || {}
587
+ @deleted = data["deleted"]
588
+ @deleted_event_ids = data["deleted_event_ids"] || []
589
+ err = response["error"]
590
+ @error = err ? DeletePartialError.new(err) : nil
591
+ end
592
+ end
593
+
594
+ class ActorLookupResult
595
+ attr_reader :users, :api_keys
596
+
597
+ def initialize(data)
598
+ @users = data["users"]
599
+ @api_keys = data["api_keys"]
600
+ end
601
+ end
425
602
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HookBridge
4
- VERSION = "1.6.0"
4
+ VERSION = "1.8.0"
5
5
  end
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.6.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - HookBridge