hookbridge 1.7.0 → 2.0.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 +86 -38
- data/lib/hookbridge/types.rb +98 -19
- data/lib/hookbridge/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e43edda9d74a75ca6005e9841c11e15c4b86e754672e5b32a25e86a89fa05a61
|
|
4
|
+
data.tar.gz: 2a63f65079ca7b8d6534c172a046c18ffa76440383364360fa3e06c7ef2a52b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b658a40aacb1fda031c62c597afdd5fba906ddce885168657a2fd2468dedf66d9e2d1f6754b10f5213e5e0f10ca646d09387390e4cf82ebd5b1f8de83ba6d28
|
|
7
|
+
data.tar.gz: 295eeb0da5480e9cdc8daf9c5e26feace41721e39b460b4320a3098c51780cc9ef497d59700c690b7e684d43abeba46322800d9e2f74d549c3d3bb111adc6f11
|
data/lib/hookbridge/client.rb
CHANGED
|
@@ -128,32 +128,6 @@ module HookBridge
|
|
|
128
128
|
true
|
|
129
129
|
end
|
|
130
130
|
|
|
131
|
-
def list_projects
|
|
132
|
-
extract_data(request(:get, "/v1/projects")).map { |project| Project.new(project) }
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
def create_project(name:, rate_limit_default: nil)
|
|
136
|
-
body = { name: name }
|
|
137
|
-
body[:rate_limit_default] = rate_limit_default if rate_limit_default
|
|
138
|
-
Project.new(extract_data(request(:post, "/v1/projects", body)))
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
def get_project(project_id)
|
|
142
|
-
Project.new(extract_data(request(:get, "/v1/projects/#{project_id}")))
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
def update_project(project_id, name: nil, rate_limit_default: nil)
|
|
146
|
-
body = {}
|
|
147
|
-
body[:name] = name if name
|
|
148
|
-
body[:rate_limit_default] = rate_limit_default if rate_limit_default
|
|
149
|
-
Project.new(extract_data(request(:put, "/v1/projects/#{project_id}", body)))
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def delete_project(project_id)
|
|
153
|
-
request(:delete, "/v1/projects/#{project_id}")
|
|
154
|
-
true
|
|
155
|
-
end
|
|
156
|
-
|
|
157
131
|
def create_endpoint(url:, description: nil, hmac_enabled: nil, rate_limit_rps: 0, burst: 0, headers: nil)
|
|
158
132
|
body = { url: url }
|
|
159
133
|
body[:description] = description if description
|
|
@@ -299,8 +273,10 @@ module HookBridge
|
|
|
299
273
|
)
|
|
300
274
|
end
|
|
301
275
|
|
|
302
|
-
def get_pull_event(endpoint_id, event_id)
|
|
303
|
-
|
|
276
|
+
def get_pull_event(endpoint_id, event_id, preview: false)
|
|
277
|
+
params = {}
|
|
278
|
+
params[:preview] = "true" if preview
|
|
279
|
+
PullEventDetail.new(extract_data(request(:get, "/v1/pull-endpoints/#{endpoint_id}/events/#{event_id}", nil, params)))
|
|
304
280
|
end
|
|
305
281
|
|
|
306
282
|
def ack_pull_events(endpoint_id, event_ids)
|
|
@@ -338,16 +314,6 @@ module HookBridge
|
|
|
338
314
|
PullTimeSeriesMetrics.new(extract_data(request(:get, "/v1/pull-metrics/timeseries", nil, params)))
|
|
339
315
|
end
|
|
340
316
|
|
|
341
|
-
def create_checkout(plan:, interval:)
|
|
342
|
-
CheckoutSession.new(extract_data(request(:post, "/v1/billing/checkout", { plan: plan, interval: interval })))
|
|
343
|
-
end
|
|
344
|
-
|
|
345
|
-
def create_portal(return_url: nil)
|
|
346
|
-
body = {}
|
|
347
|
-
body[:return_url] = return_url if return_url
|
|
348
|
-
PortalSession.new(extract_data(request(:post, "/v1/billing/portal", body)))
|
|
349
|
-
end
|
|
350
|
-
|
|
351
317
|
def get_usage_history(limit: 12, offset: 0)
|
|
352
318
|
response = request(:get, "/v1/billing/usage-history", nil, { limit: limit, offset: offset })
|
|
353
319
|
UsageHistoryResponse.new(extract_data(response), extract_meta(response))
|
|
@@ -419,6 +385,21 @@ module HookBridge
|
|
|
419
385
|
PauseState.new(extract_data(request(:post, "/v1/inbound-endpoints/#{endpoint_id}/resume")))
|
|
420
386
|
end
|
|
421
387
|
|
|
388
|
+
def create_inbound_signing_key(endpoint_id)
|
|
389
|
+
RotateSecretResponse.new(extract_data(request(:post, "/v1/inbound-endpoints/#{endpoint_id}/signing-keys")))
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
def list_inbound_signing_keys(endpoint_id)
|
|
393
|
+
extract_data(request(:get, "/v1/inbound-endpoints/#{endpoint_id}/signing-keys")).map do |entry|
|
|
394
|
+
SigningKey.new(entry)
|
|
395
|
+
end
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
def delete_inbound_signing_key(endpoint_id, key_id)
|
|
399
|
+
request(:delete, "/v1/inbound-endpoints/#{endpoint_id}/signing-keys/#{key_id}")
|
|
400
|
+
true
|
|
401
|
+
end
|
|
402
|
+
|
|
422
403
|
def listen_inbound_endpoint(endpoint_id, after: nil)
|
|
423
404
|
params = {}
|
|
424
405
|
params[:after] = after if after
|
|
@@ -519,6 +500,73 @@ module HookBridge
|
|
|
519
500
|
true
|
|
520
501
|
end
|
|
521
502
|
|
|
503
|
+
def delete_message(message_id)
|
|
504
|
+
DeleteMessageResult.new(extract_data(request(:delete, "/v1/messages/#{message_id}")))
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
def delete_messages_batch(message_ids)
|
|
508
|
+
DeleteBatchResult.new(
|
|
509
|
+
extract_data(request(:post, "/v1/messages/delete-batch", { message_ids: message_ids }))
|
|
510
|
+
)
|
|
511
|
+
end
|
|
512
|
+
|
|
513
|
+
def delete_messages_all(status: nil, endpoint_id: nil, created_after: nil, created_before: nil, limit: nil)
|
|
514
|
+
params = {}
|
|
515
|
+
params[:status] = status if status
|
|
516
|
+
params[:endpoint_id] = endpoint_id if endpoint_id
|
|
517
|
+
params[:created_after] = format_time(created_after) if created_after
|
|
518
|
+
params[:created_before] = format_time(created_before) if created_before
|
|
519
|
+
params[:limit] = limit if limit
|
|
520
|
+
DeleteAllResult.new(request(:post, "/v1/messages/delete-all", nil, params))
|
|
521
|
+
end
|
|
522
|
+
|
|
523
|
+
def delete_inbound_message(message_id)
|
|
524
|
+
DeleteMessageResult.new(extract_data(request(:delete, "/v1/inbound-messages/#{message_id}")))
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
def delete_inbound_messages_batch(message_ids)
|
|
528
|
+
DeleteBatchResult.new(
|
|
529
|
+
extract_data(request(:post, "/v1/inbound-messages/delete-batch", { message_ids: message_ids }))
|
|
530
|
+
)
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
def delete_inbound_messages_all(status: nil, inbound_endpoint_id: nil, received_after: nil, received_before: nil, limit: nil)
|
|
534
|
+
params = {}
|
|
535
|
+
params[:status] = status if status
|
|
536
|
+
params[:inbound_endpoint_id] = inbound_endpoint_id if inbound_endpoint_id
|
|
537
|
+
params[:received_after] = format_time(received_after) if received_after
|
|
538
|
+
params[:received_before] = format_time(received_before) if received_before
|
|
539
|
+
params[:limit] = limit if limit
|
|
540
|
+
DeleteAllResult.new(request(:post, "/v1/inbound-messages/delete-all", nil, params))
|
|
541
|
+
end
|
|
542
|
+
|
|
543
|
+
def delete_pull_event(endpoint_id, event_id)
|
|
544
|
+
DeleteEventResult.new(extract_data(request(:delete, "/v1/pull-endpoints/#{endpoint_id}/events/#{event_id}")))
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
def delete_pull_events_batch(endpoint_id, event_ids)
|
|
548
|
+
DeleteEventBatchResult.new(
|
|
549
|
+
extract_data(request(:post, "/v1/pull-endpoints/#{endpoint_id}/events/delete-batch", { message_ids: event_ids }))
|
|
550
|
+
)
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
def delete_pull_events_all(endpoint_id, status: nil, event_type: nil, received_after: nil, received_before: nil, limit: nil)
|
|
554
|
+
params = {}
|
|
555
|
+
params[:status] = status if status
|
|
556
|
+
params[:event_type] = event_type if event_type
|
|
557
|
+
params[:received_after] = format_time(received_after) if received_after
|
|
558
|
+
params[:received_before] = format_time(received_before) if received_before
|
|
559
|
+
params[:limit] = limit if limit
|
|
560
|
+
DeletePullEventsAllResult.new(request(:post, "/v1/pull-endpoints/#{endpoint_id}/events/delete-all", nil, params))
|
|
561
|
+
end
|
|
562
|
+
|
|
563
|
+
def lookup_actors(user_ids: nil, api_key_ids: nil)
|
|
564
|
+
params = {}
|
|
565
|
+
params[:user_id] = user_ids.join(",") if user_ids && !user_ids.empty?
|
|
566
|
+
params[:api_key_id] = api_key_ids.join(",") if api_key_ids && !api_key_ids.empty?
|
|
567
|
+
ActorLookupResult.new(extract_data(request(:get, "/v1/actors/lookup", nil, params)))
|
|
568
|
+
end
|
|
569
|
+
|
|
522
570
|
private
|
|
523
571
|
|
|
524
572
|
def build_connection(url)
|
data/lib/hookbridge/types.rb
CHANGED
|
@@ -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
|
|
|
@@ -217,18 +217,6 @@ module HookBridge
|
|
|
217
217
|
end
|
|
218
218
|
end
|
|
219
219
|
|
|
220
|
-
class Project < BaseModel
|
|
221
|
-
def initialize(data)
|
|
222
|
-
super(data, time_fields: %w[created_at])
|
|
223
|
-
end
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
class CheckoutSession < BaseModel
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
class PortalSession < BaseModel
|
|
230
|
-
end
|
|
231
|
-
|
|
232
220
|
class UsageHistoryRow < BaseModel
|
|
233
221
|
def initialize(data)
|
|
234
222
|
super(data, date_fields: %w[period_start period_end])
|
|
@@ -402,15 +390,22 @@ module HookBridge
|
|
|
402
390
|
end
|
|
403
391
|
end
|
|
404
392
|
|
|
393
|
+
class PullTimingBreakdown < BaseModel
|
|
394
|
+
end
|
|
395
|
+
|
|
405
396
|
class PullEventSummary < BaseModel
|
|
406
397
|
def initialize(data)
|
|
407
|
-
|
|
398
|
+
attributes = (data || {}).dup
|
|
399
|
+
attributes["timing"] = PullTimingBreakdown.new(attributes["timing"]) if attributes["timing"].is_a?(Hash)
|
|
400
|
+
super(attributes, time_fields: %w[received_at fetched_at delivered_at deleted_at])
|
|
408
401
|
end
|
|
409
402
|
end
|
|
410
403
|
|
|
411
404
|
class PullEventDetail < BaseModel
|
|
412
405
|
def initialize(data)
|
|
413
|
-
|
|
406
|
+
attributes = (data || {}).dup
|
|
407
|
+
attributes["timing"] = PullTimingBreakdown.new(attributes["timing"]) if attributes["timing"].is_a?(Hash)
|
|
408
|
+
super(attributes, time_fields: %w[received_at fetched_at delivered_at deleted_at])
|
|
414
409
|
end
|
|
415
410
|
end
|
|
416
411
|
|
|
@@ -429,7 +424,9 @@ module HookBridge
|
|
|
429
424
|
|
|
430
425
|
class PullLogEntry < BaseModel
|
|
431
426
|
def initialize(data)
|
|
432
|
-
|
|
427
|
+
attributes = (data || {}).dup
|
|
428
|
+
attributes["timing"] = PullTimingBreakdown.new(attributes["timing"]) if attributes["timing"].is_a?(Hash)
|
|
429
|
+
super(attributes, time_fields: %w[received_at fetched_at delivered_at deleted_at])
|
|
433
430
|
end
|
|
434
431
|
end
|
|
435
432
|
|
|
@@ -445,7 +442,7 @@ module HookBridge
|
|
|
445
442
|
|
|
446
443
|
class InboundLogEntry < BaseModel
|
|
447
444
|
def initialize(data)
|
|
448
|
-
super(data, time_fields: %w[received_at delivered_at])
|
|
445
|
+
super(data, time_fields: %w[received_at delivered_at deleted_at])
|
|
449
446
|
end
|
|
450
447
|
end
|
|
451
448
|
|
|
@@ -492,7 +489,7 @@ module HookBridge
|
|
|
492
489
|
|
|
493
490
|
class InboundMessage < BaseModel
|
|
494
491
|
def initialize(data)
|
|
495
|
-
super(data, time_fields: %w[received_at updated_at next_attempt_at delivered_at failed_at])
|
|
492
|
+
super(data, time_fields: %w[received_at updated_at next_attempt_at delivered_at failed_at deleted_at])
|
|
496
493
|
end
|
|
497
494
|
end
|
|
498
495
|
|
|
@@ -508,4 +505,86 @@ module HookBridge
|
|
|
508
505
|
])
|
|
509
506
|
end
|
|
510
507
|
end
|
|
508
|
+
|
|
509
|
+
class DeleteMessageResult < BaseModel
|
|
510
|
+
def initialize(data)
|
|
511
|
+
super(data, time_fields: %w[deleted_at])
|
|
512
|
+
end
|
|
513
|
+
end
|
|
514
|
+
|
|
515
|
+
class DeleteEventResult < BaseModel
|
|
516
|
+
def initialize(data)
|
|
517
|
+
super(data, time_fields: %w[deleted_at])
|
|
518
|
+
end
|
|
519
|
+
end
|
|
520
|
+
|
|
521
|
+
class DeleteBatchItemResult < BaseModel
|
|
522
|
+
def initialize(data)
|
|
523
|
+
super(data, time_fields: %w[deleted_at])
|
|
524
|
+
end
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
class DeleteBatchResult
|
|
528
|
+
attr_reader :results, :deleted_count, :already_deleted_count, :not_found_count
|
|
529
|
+
|
|
530
|
+
def initialize(data)
|
|
531
|
+
@results = (data["results"] || []).map { |item| DeleteBatchItemResult.new(item) }
|
|
532
|
+
@deleted_count = data["deleted_count"]
|
|
533
|
+
@already_deleted_count = data["already_deleted_count"]
|
|
534
|
+
@not_found_count = data["not_found_count"]
|
|
535
|
+
end
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
class DeleteEventBatchItemResult < BaseModel
|
|
539
|
+
def initialize(data)
|
|
540
|
+
super(data, time_fields: %w[deleted_at])
|
|
541
|
+
end
|
|
542
|
+
end
|
|
543
|
+
|
|
544
|
+
class DeleteEventBatchResult
|
|
545
|
+
attr_reader :results, :deleted_count, :already_deleted_count, :not_found_count
|
|
546
|
+
|
|
547
|
+
def initialize(data)
|
|
548
|
+
@results = (data["results"] || []).map { |item| DeleteEventBatchItemResult.new(item) }
|
|
549
|
+
@deleted_count = data["deleted_count"]
|
|
550
|
+
@already_deleted_count = data["already_deleted_count"]
|
|
551
|
+
@not_found_count = data["not_found_count"]
|
|
552
|
+
end
|
|
553
|
+
end
|
|
554
|
+
|
|
555
|
+
class DeletePartialError < BaseModel
|
|
556
|
+
end
|
|
557
|
+
|
|
558
|
+
class DeleteAllResult
|
|
559
|
+
attr_reader :deleted, :deleted_message_ids, :error
|
|
560
|
+
|
|
561
|
+
def initialize(response)
|
|
562
|
+
data = response["data"] || {}
|
|
563
|
+
@deleted = data["deleted"]
|
|
564
|
+
@deleted_message_ids = data["deleted_message_ids"] || []
|
|
565
|
+
err = response["error"]
|
|
566
|
+
@error = err ? DeletePartialError.new(err) : nil
|
|
567
|
+
end
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
class DeletePullEventsAllResult
|
|
571
|
+
attr_reader :deleted, :deleted_event_ids, :error
|
|
572
|
+
|
|
573
|
+
def initialize(response)
|
|
574
|
+
data = response["data"] || {}
|
|
575
|
+
@deleted = data["deleted"]
|
|
576
|
+
@deleted_event_ids = data["deleted_event_ids"] || []
|
|
577
|
+
err = response["error"]
|
|
578
|
+
@error = err ? DeletePartialError.new(err) : nil
|
|
579
|
+
end
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
class ActorLookupResult
|
|
583
|
+
attr_reader :users, :api_keys
|
|
584
|
+
|
|
585
|
+
def initialize(data)
|
|
586
|
+
@users = data["users"]
|
|
587
|
+
@api_keys = data["api_keys"]
|
|
588
|
+
end
|
|
589
|
+
end
|
|
511
590
|
end
|
data/lib/hookbridge/version.rb
CHANGED