hookbridge 1.7.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: 5a3ef380402beb61c7cbbca77fd98b1797aa086d052b6a9461300329bf7f26f9
4
- data.tar.gz: 2932a270e9649ce1f26117122867c1c473566fdf6e6ebec04d2edcb630233fff
3
+ metadata.gz: 3eb78782e81c381238fa55e447688e3e58b437d1aeb531629b0c6d8388149f9b
4
+ data.tar.gz: 2343289ec20d2df8397137e7281dcce2d0d1920c1f1fad8e606071000c0eb26e
5
5
  SHA512:
6
- metadata.gz: e2262aa8ce2ac43a6d468f9a1158ade14ea7667c201225b8e1b462876a7d9d85c105501f50252726f4f40285290260493593d446b86d14be406cfe0e87c1f4a1
7
- data.tar.gz: 62effea4fc77737a93a938a918d307dde0ce1a553c25fc4627cb6857f25c2e68865c8fec4e1eac011aa02ab3c2b8e337a5ddb7fcb93f5625a7478662ced184f0
6
+ metadata.gz: ddb04a28ba7ed43bfa39ed780e7d193793335498d8f9f40835720d05951395ebc78f6b1df4bfae9467a1c42fc8e573404c5742f77b2295391f26c03954bbf842
7
+ data.tar.gz: 439ffca58ae0d59f14f19efc0e7021279a4938152e2807e6a543cca6a7dc5597764d641072b5ef61a2a261981032232342a06a3bb2a2d4a1bdc7b60caa3744d2
@@ -299,8 +299,10 @@ module HookBridge
299
299
  )
300
300
  end
301
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}")))
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)))
304
306
  end
305
307
 
306
308
  def ack_pull_events(endpoint_id, event_ids)
@@ -419,6 +421,21 @@ module HookBridge
419
421
  PauseState.new(extract_data(request(:post, "/v1/inbound-endpoints/#{endpoint_id}/resume")))
420
422
  end
421
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
+
422
439
  def listen_inbound_endpoint(endpoint_id, after: nil)
423
440
  params = {}
424
441
  params[:after] = after if after
@@ -519,6 +536,73 @@ module HookBridge
519
536
  true
520
537
  end
521
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
+
522
606
  private
523
607
 
524
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
 
@@ -402,15 +402,22 @@ module HookBridge
402
402
  end
403
403
  end
404
404
 
405
+ class PullTimingBreakdown < BaseModel
406
+ end
407
+
405
408
  class PullEventSummary < BaseModel
406
409
  def initialize(data)
407
- super(data, time_fields: %w[received_at fetched_at delivered_at])
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])
408
413
  end
409
414
  end
410
415
 
411
416
  class PullEventDetail < BaseModel
412
417
  def initialize(data)
413
- super(data, time_fields: %w[received_at fetched_at delivered_at])
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])
414
421
  end
415
422
  end
416
423
 
@@ -429,7 +436,9 @@ module HookBridge
429
436
 
430
437
  class PullLogEntry < BaseModel
431
438
  def initialize(data)
432
- super(data, time_fields: %w[received_at fetched_at delivered_at])
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])
433
442
  end
434
443
  end
435
444
 
@@ -445,7 +454,7 @@ module HookBridge
445
454
 
446
455
  class InboundLogEntry < BaseModel
447
456
  def initialize(data)
448
- super(data, time_fields: %w[received_at delivered_at])
457
+ super(data, time_fields: %w[received_at delivered_at deleted_at])
449
458
  end
450
459
  end
451
460
 
@@ -492,7 +501,7 @@ module HookBridge
492
501
 
493
502
  class InboundMessage < BaseModel
494
503
  def initialize(data)
495
- 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])
496
505
  end
497
506
  end
498
507
 
@@ -508,4 +517,86 @@ module HookBridge
508
517
  ])
509
518
  end
510
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
511
602
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HookBridge
4
- VERSION = "1.7.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.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - HookBridge