Class: HookBridge::Client
- Inherits:
-
Object
- Object
- HookBridge::Client
- Defined in:
- lib/hookbridge/client.rb
Constant Summary collapse
- DEFAULT_BASE_URL =
"https://api.hookbridge.io"- DEFAULT_SEND_URL =
"https://send.hookbridge.io"- DEFAULT_TIMEOUT =
30- DEFAULT_RETRIES =
3
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#retries ⇒ Object
readonly
Returns the value of attribute retries.
-
#send_url ⇒ Object
readonly
Returns the value of attribute send_url.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
- #ack_pull_events(endpoint_id, event_ids) ⇒ Object
- #cancel_retry(message_id) ⇒ Object
- #create_api_key(label: nil, mode: APIKeyMode::LIVE) ⇒ Object
- #create_endpoint(url:, description: nil, hmac_enabled: nil, rate_limit_rps: 0, burst: 0, headers: nil) ⇒ Object
- #create_endpoint_signing_key(endpoint_id) ⇒ Object
- #create_export(start_time:, end_time:, status: nil, endpoint_id: nil) ⇒ Object
- #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) ⇒ Object
- #create_inbound_signing_key(endpoint_id) ⇒ Object
- #create_pull_endpoint(name: nil, description: nil, retention_days: nil, event_type_source: nil, event_type_path: 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) ⇒ Object
- #delete_api_key(key_id) ⇒ Object
- #delete_endpoint(endpoint_id) ⇒ Object
- #delete_endpoint_signing_key(endpoint_id, key_id) ⇒ Object
- #delete_export(export_id) ⇒ Object
- #delete_inbound_endpoint(endpoint_id) ⇒ Object
- #delete_inbound_message(message_id) ⇒ Object
- #delete_inbound_messages_all(status: nil, inbound_endpoint_id: nil, received_after: nil, received_before: nil, limit: nil) ⇒ Object
- #delete_inbound_messages_batch(message_ids) ⇒ Object
- #delete_inbound_signing_key(endpoint_id, key_id) ⇒ Object
- #delete_message(message_id) ⇒ Object
- #delete_messages_all(status: nil, endpoint_id: nil, created_after: nil, created_before: nil, limit: nil) ⇒ Object
- #delete_messages_batch(message_ids) ⇒ Object
- #delete_pull_endpoint(endpoint_id) ⇒ Object
- #delete_pull_event(endpoint_id, event_id) ⇒ Object
- #delete_pull_events_all(endpoint_id, status: nil, event_type: nil, received_after: nil, received_before: nil, limit: nil) ⇒ Object
- #delete_pull_events_batch(endpoint_id, event_ids) ⇒ Object
- #download_export(export_id) ⇒ Object
- #get_dlq_messages(limit: nil, cursor: nil) ⇒ Object
- #get_endpoint(endpoint_id) ⇒ Object
- #get_export(export_id) ⇒ Object
- #get_inbound_endpoint(endpoint_id) ⇒ Object
- #get_inbound_logs(status: nil, inbound_endpoint_id: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil) ⇒ Object
- #get_inbound_message(message_id) ⇒ Object
- #get_inbound_message_attempts(message_id) ⇒ Object
- #get_inbound_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, inbound_endpoint_id: nil) ⇒ Object
- #get_inbound_timeseries_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, inbound_endpoint_id: nil) ⇒ Object
- #get_invoices(limit: 12, starting_after: nil) ⇒ Object
- #get_logs(status: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil) ⇒ Object
- #get_message(message_id) ⇒ Object
- #get_message_attempts(message_id) ⇒ Object
- #get_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS) ⇒ Object
- #get_pull_endpoint(endpoint_id) ⇒ Object
- #get_pull_event(endpoint_id, event_id, preview: false) ⇒ Object
- #get_pull_logs(pull_endpoint_id: nil, status: nil, event_type: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil) ⇒ Object
- #get_pull_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, pull_endpoint_id: nil) ⇒ Object
- #get_pull_timeseries_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, pull_endpoint_id: nil) ⇒ Object
- #get_subscription ⇒ Object
- #get_timeseries_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, endpoint_id: nil) ⇒ Object
- #get_usage_history(limit: 12, offset: 0) ⇒ Object
-
#initialize(api_key:, base_url: nil, send_url: nil, timeout: DEFAULT_TIMEOUT, retries: DEFAULT_RETRIES) ⇒ Client
constructor
A new instance of Client.
- #list_api_keys ⇒ Object
- #list_endpoint_signing_keys(endpoint_id) ⇒ Object
- #list_endpoints(limit: nil, cursor: nil) ⇒ Object
- #list_exports ⇒ Object
- #list_inbound_endpoints(limit: nil, cursor: nil) ⇒ Object
- #list_inbound_rejections(inbound_endpoint_id: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil) ⇒ Object
- #list_inbound_signing_keys(endpoint_id) ⇒ Object
- #list_pull_endpoints(limit: nil, cursor: nil) ⇒ Object
- #list_pull_events(endpoint_id, status: nil, event_type: nil, since: nil, before: nil, limit: nil, cursor: nil) ⇒ Object
- #listen_inbound_endpoint(endpoint_id, after: nil) ⇒ Object
- #lookup_actors(user_ids: nil, api_key_ids: nil) ⇒ Object
- #pause_endpoint(endpoint_id) ⇒ Object
- #pause_inbound_endpoint(endpoint_id) ⇒ Object
- #pause_pull_endpoint(endpoint_id) ⇒ Object
- #replay(message_id) ⇒ Object
- #replay_all_inbound_messages(status:, inbound_endpoint_id: nil, limit: nil) ⇒ Object
- #replay_all_messages(status:, endpoint_id: nil, limit: nil) ⇒ Object
- #replay_batch_inbound_messages(message_ids) ⇒ Object
- #replay_batch_messages(message_ids) ⇒ Object
- #replay_from_dlq(message_id) ⇒ Object
- #replay_inbound_message(message_id) ⇒ Object
- #resume_endpoint(endpoint_id) ⇒ Object
- #resume_inbound_endpoint(endpoint_id) ⇒ Object
- #resume_pull_endpoint(endpoint_id) ⇒ Object
- #retry_now(message_id) ⇒ Object
- #rotate_endpoint_secret(endpoint_id) ⇒ Object
- #send(endpoint_id:, payload:, headers: nil, idempotency_key: nil) ⇒ Object
- #update_endpoint(endpoint_id, url: nil, description: nil, hmac_enabled: nil, rate_limit_rps: nil, burst: nil, headers: nil) ⇒ Object
- #update_inbound_endpoint(endpoint_id, **attributes) ⇒ Object
- #update_pull_endpoint(endpoint_id, **attributes) ⇒ Object
Constructor Details
#initialize(api_key:, base_url: nil, send_url: nil, timeout: DEFAULT_TIMEOUT, retries: DEFAULT_RETRIES) ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/hookbridge/client.rb', line 16 def initialize(api_key:, base_url: nil, send_url: nil, timeout: DEFAULT_TIMEOUT, retries: DEFAULT_RETRIES) raise ValidationError, "API key is required" if api_key.nil? || api_key.empty? @api_key = api_key @base_url = (base_url || ENV.fetch("HOOKBRIDGE_BASE_URL", DEFAULT_BASE_URL)).chomp("/") @send_url = (send_url || ENV.fetch("HOOKBRIDGE_SEND_URL", DEFAULT_SEND_URL)).chomp("/") @timeout = timeout @retries = retries @connection = build_connection(@base_url) @send_connection = build_connection(@send_url) end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
14 15 16 |
# File 'lib/hookbridge/client.rb', line 14 def api_key @api_key end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
14 15 16 |
# File 'lib/hookbridge/client.rb', line 14 def base_url @base_url end |
#retries ⇒ Object (readonly)
Returns the value of attribute retries.
14 15 16 |
# File 'lib/hookbridge/client.rb', line 14 def retries @retries end |
#send_url ⇒ Object (readonly)
Returns the value of attribute send_url.
14 15 16 |
# File 'lib/hookbridge/client.rb', line 14 def send_url @send_url end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
14 15 16 |
# File 'lib/hookbridge/client.rb', line 14 def timeout @timeout end |
Instance Method Details
#ack_pull_events(endpoint_id, event_ids) ⇒ Object
282 283 284 285 286 |
# File 'lib/hookbridge/client.rb', line 282 def ack_pull_events(endpoint_id, event_ids) AckPullEventsResponse.new( extract_data(request(:post, "/v1/pull-endpoints/#{endpoint_id}/events/ack", { event_ids: event_ids })) ) end |
#cancel_retry(message_id) ⇒ Object
48 49 50 51 |
# File 'lib/hookbridge/client.rb', line 48 def cancel_retry() request(:post, "/v1/messages/#{}/cancel") nil end |
#create_api_key(label: nil, mode: APIKeyMode::LIVE) ⇒ Object
120 121 122 123 124 |
# File 'lib/hookbridge/client.rb', line 120 def create_api_key(label: nil, mode: APIKeyMode::LIVE) body = { mode: mode } body[:label] = label if label APIKeyCreated.new(extract_data(request(:post, "/v1/api-keys", body))) end |
#create_endpoint(url:, description: nil, hmac_enabled: nil, rate_limit_rps: 0, burst: 0, headers: nil) ⇒ Object
131 132 133 134 135 136 137 138 139 |
# File 'lib/hookbridge/client.rb', line 131 def create_endpoint(url:, description: nil, hmac_enabled: nil, rate_limit_rps: 0, burst: 0, headers: nil) body = { url: url } body[:description] = description if description body[:hmac_enabled] = hmac_enabled unless hmac_enabled.nil? body[:rate_limit_rps] = rate_limit_rps if rate_limit_rps.positive? body[:burst] = burst if burst.positive? body[:headers] = headers if headers CreateEndpointResponse.new(extract_data(request(:post, "/v1/endpoints", body))) end |
#create_endpoint_signing_key(endpoint_id) ⇒ Object
182 183 184 |
# File 'lib/hookbridge/client.rb', line 182 def create_endpoint_signing_key(endpoint_id) RotateSecretResponse.new(extract_data(request(:post, "/v1/endpoints/#{endpoint_id}/signing-keys"))) end |
#create_export(start_time:, end_time:, status: nil, endpoint_id: nil) ⇒ Object
479 480 481 482 483 484 |
# File 'lib/hookbridge/client.rb', line 479 def create_export(start_time:, end_time:, status: nil, endpoint_id: nil) body = { start_time: format_time(start_time), end_time: format_time(end_time) } body[:status] = status if status body[:endpoint_id] = endpoint_id if endpoint_id ExportRecord.new(extract_data(request(:post, "/v1/exports", body))) end |
#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) ⇒ Object
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/hookbridge/client.rb', line 329 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) body = {} body[:url] = url unless url.nil? { name: name, description: description, mode: mode, verify_static_token: verify_static_token, token_header_name: token_header_name, token_query_param: token_query_param, token_value: token_value, verify_hmac: verify_hmac, hmac_header_name: hmac_header_name, hmac_secret: hmac_secret, timestamp_header_name: , timestamp_ttl_seconds: , verify_ip_allowlist: verify_ip_allowlist, allowed_cidrs: allowed_cidrs, idempotency_header_names: idempotency_header_names, ingest_response_code: ingest_response_code, signing_enabled: signing_enabled }.each do |key, value| body[key] = value unless value.nil? end CreateInboundEndpointResponse.new(extract_data(request(:post, "/v1/inbound-endpoints", body))) end |
#create_inbound_signing_key(endpoint_id) ⇒ Object
388 389 390 |
# File 'lib/hookbridge/client.rb', line 388 def create_inbound_signing_key(endpoint_id) RotateSecretResponse.new(extract_data(request(:post, "/v1/inbound-endpoints/#{endpoint_id}/signing-keys"))) end |
#create_pull_endpoint(name: nil, description: nil, retention_days: nil, event_type_source: nil, event_type_path: 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) ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/hookbridge/client.rb', line 201 def create_pull_endpoint(name: nil, description: nil, retention_days: nil, event_type_source: nil, event_type_path: 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) body = compact_hash( name: name, description: description, retention_days: retention_days, event_type_source: event_type_source, event_type_path: event_type_path, verify_static_token: verify_static_token, token_header_name: token_header_name, token_query_param: token_query_param, token_value: token_value, verify_hmac: verify_hmac, hmac_header_name: hmac_header_name, hmac_secret: hmac_secret, timestamp_header_name: , timestamp_ttl_seconds: , verify_ip_allowlist: verify_ip_allowlist, allowed_cidrs: allowed_cidrs, idempotency_header_names: idempotency_header_names, ingest_response_code: ingest_response_code ) CreatePullEndpointResponse.new(extract_data(request(:post, "/v1/pull-endpoints", body))) end |
#delete_api_key(key_id) ⇒ Object
126 127 128 129 |
# File 'lib/hookbridge/client.rb', line 126 def delete_api_key(key_id) request(:delete, "/v1/api-keys/#{key_id}") true end |
#delete_endpoint(endpoint_id) ⇒ Object
169 170 171 172 |
# File 'lib/hookbridge/client.rb', line 169 def delete_endpoint(endpoint_id) request(:delete, "/v1/endpoints/#{endpoint_id}") true end |
#delete_endpoint_signing_key(endpoint_id, key_id) ⇒ Object
192 193 194 195 |
# File 'lib/hookbridge/client.rb', line 192 def delete_endpoint_signing_key(endpoint_id, key_id) request(:delete, "/v1/endpoints/#{endpoint_id}/signing-keys/#{key_id}") true end |
#delete_export(export_id) ⇒ Object
498 499 500 501 |
# File 'lib/hookbridge/client.rb', line 498 def delete_export(export_id) request(:delete, "/v1/exports/#{export_id}") true end |
#delete_inbound_endpoint(endpoint_id) ⇒ Object
376 377 378 |
# File 'lib/hookbridge/client.rb', line 376 def delete_inbound_endpoint(endpoint_id) DeleteResult.new(extract_data(request(:delete, "/v1/inbound-endpoints/#{endpoint_id}"))) end |
#delete_inbound_message(message_id) ⇒ Object
523 524 525 |
# File 'lib/hookbridge/client.rb', line 523 def () DeleteMessageResult.new(extract_data(request(:delete, "/v1/inbound-messages/#{}"))) end |
#delete_inbound_messages_all(status: nil, inbound_endpoint_id: nil, received_after: nil, received_before: nil, limit: nil) ⇒ Object
533 534 535 536 537 538 539 540 541 |
# File 'lib/hookbridge/client.rb', line 533 def (status: nil, inbound_endpoint_id: nil, received_after: nil, received_before: nil, limit: nil) params = {} params[:status] = status if status params[:inbound_endpoint_id] = inbound_endpoint_id if inbound_endpoint_id params[:received_after] = format_time(received_after) if received_after params[:received_before] = format_time(received_before) if received_before params[:limit] = limit if limit DeleteAllResult.new(request(:post, "/v1/inbound-messages/delete-all", nil, params)) end |
#delete_inbound_messages_batch(message_ids) ⇒ Object
527 528 529 530 531 |
# File 'lib/hookbridge/client.rb', line 527 def () DeleteBatchResult.new( extract_data(request(:post, "/v1/inbound-messages/delete-batch", { message_ids: })) ) end |
#delete_inbound_signing_key(endpoint_id, key_id) ⇒ Object
398 399 400 401 |
# File 'lib/hookbridge/client.rb', line 398 def delete_inbound_signing_key(endpoint_id, key_id) request(:delete, "/v1/inbound-endpoints/#{endpoint_id}/signing-keys/#{key_id}") true end |
#delete_message(message_id) ⇒ Object
503 504 505 |
# File 'lib/hookbridge/client.rb', line 503 def () DeleteMessageResult.new(extract_data(request(:delete, "/v1/messages/#{}"))) end |
#delete_messages_all(status: nil, endpoint_id: nil, created_after: nil, created_before: nil, limit: nil) ⇒ Object
513 514 515 516 517 518 519 520 521 |
# File 'lib/hookbridge/client.rb', line 513 def (status: nil, endpoint_id: nil, created_after: nil, created_before: nil, limit: nil) params = {} params[:status] = status if status params[:endpoint_id] = endpoint_id if endpoint_id params[:created_after] = format_time(created_after) if created_after params[:created_before] = format_time(created_before) if created_before params[:limit] = limit if limit DeleteAllResult.new(request(:post, "/v1/messages/delete-all", nil, params)) end |
#delete_messages_batch(message_ids) ⇒ Object
507 508 509 510 511 |
# File 'lib/hookbridge/client.rb', line 507 def () DeleteBatchResult.new( extract_data(request(:post, "/v1/messages/delete-batch", { message_ids: })) ) end |
#delete_pull_endpoint(endpoint_id) ⇒ Object
248 249 250 |
# File 'lib/hookbridge/client.rb', line 248 def delete_pull_endpoint(endpoint_id) DeleteResult.new(extract_data(request(:delete, "/v1/pull-endpoints/#{endpoint_id}"))) end |
#delete_pull_event(endpoint_id, event_id) ⇒ Object
543 544 545 |
# File 'lib/hookbridge/client.rb', line 543 def delete_pull_event(endpoint_id, event_id) DeleteEventResult.new(extract_data(request(:delete, "/v1/pull-endpoints/#{endpoint_id}/events/#{event_id}"))) end |
#delete_pull_events_all(endpoint_id, status: nil, event_type: nil, received_after: nil, received_before: nil, limit: nil) ⇒ Object
553 554 555 556 557 558 559 560 561 |
# File 'lib/hookbridge/client.rb', line 553 def delete_pull_events_all(endpoint_id, status: nil, event_type: nil, received_after: nil, received_before: nil, limit: nil) params = {} params[:status] = status if status params[:event_type] = event_type if event_type params[:received_after] = format_time(received_after) if received_after params[:received_before] = format_time(received_before) if received_before params[:limit] = limit if limit DeletePullEventsAllResult.new(request(:post, "/v1/pull-endpoints/#{endpoint_id}/events/delete-all", nil, params)) end |
#delete_pull_events_batch(endpoint_id, event_ids) ⇒ Object
547 548 549 550 551 |
# File 'lib/hookbridge/client.rb', line 547 def delete_pull_events_batch(endpoint_id, event_ids) DeleteEventBatchResult.new( extract_data(request(:post, "/v1/pull-endpoints/#{endpoint_id}/events/delete-batch", { message_ids: event_ids })) ) end |
#download_export(export_id) ⇒ Object
494 495 496 |
# File 'lib/hookbridge/client.rb', line 494 def download_export(export_id) request(:get, "/v1/exports/#{export_id}/download", nil, nil, allow_redirect: true) end |
#get_dlq_messages(limit: nil, cursor: nil) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/hookbridge/client.rb', line 100 def (limit: nil, cursor: nil) params = {} params[:limit] = limit if limit params[:cursor] = cursor if cursor response = request(:get, "/v1/dlq/messages", nil, params) DLQResponse.new( "data" => extract_data(response), "has_more" => extract_data(response)["has_more"] || response["has_more"], "next_cursor" => extract_data(response)["next_cursor"] || response["next_cursor"] ) end |
#get_endpoint(endpoint_id) ⇒ Object
141 142 143 |
# File 'lib/hookbridge/client.rb', line 141 def get_endpoint(endpoint_id) Endpoint.new(extract_data(request(:get, "/v1/endpoints/#{endpoint_id}"))) end |
#get_export(export_id) ⇒ Object
490 491 492 |
# File 'lib/hookbridge/client.rb', line 490 def get_export(export_id) ExportRecord.new(extract_data(request(:get, "/v1/exports/#{export_id}"))) end |
#get_inbound_endpoint(endpoint_id) ⇒ Object
368 369 370 |
# File 'lib/hookbridge/client.rb', line 368 def get_inbound_endpoint(endpoint_id) InboundEndpoint.new(extract_data(request(:get, "/v1/inbound-endpoints/#{endpoint_id}"))) end |
#get_inbound_logs(status: nil, inbound_endpoint_id: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil) ⇒ Object
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'lib/hookbridge/client.rb', line 436 def get_inbound_logs(status: nil, inbound_endpoint_id: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil) params = {} params[:status] = status if status params[:inbound_endpoint_id] = inbound_endpoint_id if inbound_endpoint_id params[:start_time] = format_time(start_time) if start_time params[:end_time] = format_time(end_time) if end_time params[:limit] = limit if limit params[:cursor] = cursor if cursor response = request(:get, "/v1/inbound-logs", nil, params) InboundLogsResponse.new( "data" => extract_data(response), "has_more" => (response)["has_more"] || response["has_more"], "next_cursor" => (response)["next_cursor"] || response["next_cursor"] ) end |
#get_inbound_message(message_id) ⇒ Object
410 411 412 |
# File 'lib/hookbridge/client.rb', line 410 def () InboundMessage.new(extract_data(request(:get, "/v1/inbound-messages/#{}"))) end |
#get_inbound_message_attempts(message_id) ⇒ Object
414 415 416 417 |
# File 'lib/hookbridge/client.rb', line 414 def () response = request(:get, "/v1/inbound-messages/#{}/attempts") AttemptsResponse.new(extract_data(response), (response)) end |
#get_inbound_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, inbound_endpoint_id: nil) ⇒ Object
452 453 454 455 456 |
# File 'lib/hookbridge/client.rb', line 452 def get_inbound_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, inbound_endpoint_id: nil) params = { window: window } params[:inbound_endpoint_id] = inbound_endpoint_id if inbound_endpoint_id InboundMetrics.new(extract_data(request(:get, "/v1/inbound-metrics", nil, params))) end |
#get_inbound_timeseries_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, inbound_endpoint_id: nil) ⇒ Object
458 459 460 461 462 |
# File 'lib/hookbridge/client.rb', line 458 def get_inbound_timeseries_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, inbound_endpoint_id: nil) params = { window: window } params[:inbound_endpoint_id] = inbound_endpoint_id if inbound_endpoint_id TimeSeriesMetrics.new(extract_data(request(:get, "/v1/inbound-metrics/timeseries", nil, params))) end |
#get_invoices(limit: 12, starting_after: nil) ⇒ Object
322 323 324 325 326 327 |
# File 'lib/hookbridge/client.rb', line 322 def get_invoices(limit: 12, starting_after: nil) params = { limit: limit } params[:starting_after] = starting_after if starting_after response = request(:get, "/v1/billing/invoices", nil, params) InvoicesResponse.new(extract_data(response), (response)) end |
#get_logs(status: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/hookbridge/client.rb', line 71 def get_logs(status: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil) params = {} params[:status] = status if status params[:start_time] = format_time(start_time) if start_time params[:end_time] = format_time(end_time) if end_time params[:limit] = limit if limit params[:cursor] = cursor if cursor response = request(:get, "/v1/logs", nil, params) LogsResponse.new( "data" => extract_data(response), "has_more" => (response)["has_more"] || response["has_more"], "next_cursor" => (response)["next_cursor"] || response["next_cursor"] ) end |
#get_message(message_id) ⇒ Object
35 36 37 |
# File 'lib/hookbridge/client.rb', line 35 def () Message.new(extract_data(request(:get, "/v1/messages/#{}"))) end |
#get_message_attempts(message_id) ⇒ Object
39 40 41 42 |
# File 'lib/hookbridge/client.rb', line 39 def () response = request(:get, "/v1/messages/#{}/attempts") AttemptsResponse.new(extract_data(response), (response)) end |
#get_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS) ⇒ Object
86 87 88 |
# File 'lib/hookbridge/client.rb', line 86 def get_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS) Metrics.new(extract_data(request(:get, "/v1/metrics", nil, { window: window }))) end |
#get_pull_endpoint(endpoint_id) ⇒ Object
240 241 242 |
# File 'lib/hookbridge/client.rb', line 240 def get_pull_endpoint(endpoint_id) PullEndpoint.new(extract_data(request(:get, "/v1/pull-endpoints/#{endpoint_id}"))) end |
#get_pull_event(endpoint_id, event_id, preview: false) ⇒ Object
276 277 278 279 280 |
# File 'lib/hookbridge/client.rb', line 276 def get_pull_event(endpoint_id, event_id, preview: false) params = {} params[:preview] = "true" if preview PullEventDetail.new(extract_data(request(:get, "/v1/pull-endpoints/#{endpoint_id}/events/#{event_id}", nil, params))) end |
#get_pull_logs(pull_endpoint_id: nil, status: nil, event_type: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil) ⇒ Object
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/hookbridge/client.rb', line 288 def get_pull_logs(pull_endpoint_id: nil, status: nil, event_type: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil) params = {} params[:pull_endpoint_id] = pull_endpoint_id if pull_endpoint_id params[:status] = status if status params[:event_type] = event_type if event_type params[:start_time] = format_time(start_time) if start_time params[:end_time] = format_time(end_time) if end_time params[:limit] = limit if limit params[:cursor] = cursor if cursor response = request(:get, "/v1/pull-logs", nil, params) PullLogsResponse.new( "data" => extract_data(response), "has_more" => (response)["has_more"] || response["has_more"], "next_cursor" => (response)["next_cursor"] || response["next_cursor"] ) end |
#get_pull_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, pull_endpoint_id: nil) ⇒ Object
305 306 307 308 309 |
# File 'lib/hookbridge/client.rb', line 305 def get_pull_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, pull_endpoint_id: nil) params = { window: window } params[:pull_endpoint_id] = pull_endpoint_id if pull_endpoint_id Metrics.new(extract_data(request(:get, "/v1/pull-metrics", nil, params))) end |
#get_pull_timeseries_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, pull_endpoint_id: nil) ⇒ Object
311 312 313 314 315 |
# File 'lib/hookbridge/client.rb', line 311 def get_pull_timeseries_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, pull_endpoint_id: nil) params = { window: window } params[:pull_endpoint_id] = pull_endpoint_id if pull_endpoint_id PullTimeSeriesMetrics.new(extract_data(request(:get, "/v1/pull-metrics/timeseries", nil, params))) end |
#get_subscription ⇒ Object
96 97 98 |
# File 'lib/hookbridge/client.rb', line 96 def get_subscription Subscription.new(extract_data(request(:get, "/v1/billing/subscription"))) end |
#get_timeseries_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, endpoint_id: nil) ⇒ Object
90 91 92 93 94 |
# File 'lib/hookbridge/client.rb', line 90 def get_timeseries_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, endpoint_id: nil) params = { window: window } params[:endpoint_id] = endpoint_id if endpoint_id TimeSeriesMetrics.new(extract_data(request(:get, "/v1/metrics/timeseries", nil, params))) end |
#get_usage_history(limit: 12, offset: 0) ⇒ Object
317 318 319 320 |
# File 'lib/hookbridge/client.rb', line 317 def get_usage_history(limit: 12, offset: 0) response = request(:get, "/v1/billing/usage-history", nil, { limit: limit, offset: offset }) UsageHistoryResponse.new(extract_data(response), (response)) end |
#list_api_keys ⇒ Object
116 117 118 |
# File 'lib/hookbridge/client.rb', line 116 def list_api_keys APIKeysResponse.new("data" => extract_data(request(:get, "/v1/api-keys"))) end |
#list_endpoint_signing_keys(endpoint_id) ⇒ Object
186 187 188 189 190 |
# File 'lib/hookbridge/client.rb', line 186 def list_endpoint_signing_keys(endpoint_id) extract_data(request(:get, "/v1/endpoints/#{endpoint_id}/signing-keys")).map do |entry| SigningKey.new(entry) end end |
#list_endpoints(limit: nil, cursor: nil) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/hookbridge/client.rb', line 145 def list_endpoints(limit: nil, cursor: nil) params = {} params[:limit] = limit if limit params[:cursor] = cursor if cursor response = request(:get, "/v1/endpoints", nil, params) ListEndpointsResponse.new( "data" => extract_data(response), "has_more" => (response)["has_more"] || response["has_more"], "next_cursor" => (response)["next_cursor"] || response["next_cursor"] ) end |
#list_exports ⇒ Object
486 487 488 |
# File 'lib/hookbridge/client.rb', line 486 def list_exports extract_data(request(:get, "/v1/exports")).map { |entry| ExportRecord.new(entry) } end |
#list_inbound_endpoints(limit: nil, cursor: nil) ⇒ Object
356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/hookbridge/client.rb', line 356 def list_inbound_endpoints(limit: nil, cursor: nil) params = {} params[:limit] = limit if limit params[:cursor] = cursor if cursor response = request(:get, "/v1/inbound-endpoints", nil, params) ListInboundEndpointsResponse.new( "data" => extract_data(response), "has_more" => (response)["has_more"] || response["has_more"], "next_cursor" => (response)["next_cursor"] || response["next_cursor"] ) end |
#list_inbound_rejections(inbound_endpoint_id: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil) ⇒ Object
464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
# File 'lib/hookbridge/client.rb', line 464 def list_inbound_rejections(inbound_endpoint_id: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil) params = {} params[:inbound_endpoint_id] = inbound_endpoint_id if inbound_endpoint_id params[:start_time] = format_time(start_time) if start_time params[:end_time] = format_time(end_time) if end_time params[:limit] = limit if limit params[:cursor] = cursor if cursor response = request(:get, "/v1/inbound-rejections", nil, params) InboundRejectionsResponse.new( "data" => extract_data(response), "has_more" => (response)["has_more"] || response["has_more"], "next_cursor" => (response)["next_cursor"] || response["next_cursor"] ) end |
#list_inbound_signing_keys(endpoint_id) ⇒ Object
392 393 394 395 396 |
# File 'lib/hookbridge/client.rb', line 392 def list_inbound_signing_keys(endpoint_id) extract_data(request(:get, "/v1/inbound-endpoints/#{endpoint_id}/signing-keys")).map do |entry| SigningKey.new(entry) end end |
#list_pull_endpoints(limit: nil, cursor: nil) ⇒ Object
229 230 231 232 233 234 235 236 237 238 |
# File 'lib/hookbridge/client.rb', line 229 def list_pull_endpoints(limit: nil, cursor: nil) params = {} params[:limit] = limit if limit params[:cursor] = cursor if cursor response = request(:get, "/v1/pull-endpoints", nil, params) ListPullEndpointsResponse.new( "data" => extract_data(response), "next_cursor" => (response)["next_cursor"] || response["next_cursor"] ) end |
#list_pull_events(endpoint_id, status: nil, event_type: nil, since: nil, before: nil, limit: nil, cursor: nil) ⇒ Object
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/hookbridge/client.rb', line 260 def list_pull_events(endpoint_id, status: nil, event_type: nil, since: nil, before: nil, limit: nil, cursor: nil) params = {} params[:status] = status if status params[:event_type] = event_type if event_type params[:since] = format_time(since) if since params[:before] = format_time(before) if before params[:limit] = limit if limit params[:cursor] = cursor if cursor response = request(:get, "/v1/pull-endpoints/#{endpoint_id}/events", nil, params) ListPullEventsResponse.new( "data" => extract_data(response), "has_more" => (response)["has_more"] || response["has_more"], "next_cursor" => (response)["next_cursor"] || response["next_cursor"] ) end |
#listen_inbound_endpoint(endpoint_id, after: nil) ⇒ Object
403 404 405 406 407 408 |
# File 'lib/hookbridge/client.rb', line 403 def listen_inbound_endpoint(endpoint_id, after: nil) params = {} params[:after] = after if after response = request(:get, "/v1/inbound-endpoints/#{endpoint_id}/listen", nil, params) ListenInboundEndpointResponse.new(response) end |
#lookup_actors(user_ids: nil, api_key_ids: nil) ⇒ Object
563 564 565 566 567 568 |
# File 'lib/hookbridge/client.rb', line 563 def lookup_actors(user_ids: nil, api_key_ids: nil) params = {} params[:user_id] = user_ids.join(",") if user_ids && !user_ids.empty? params[:api_key_id] = api_key_ids.join(",") if api_key_ids && !api_key_ids.empty? ActorLookupResult.new(extract_data(request(:get, "/v1/actors/lookup", nil, params))) end |
#pause_endpoint(endpoint_id) ⇒ Object
174 175 176 |
# File 'lib/hookbridge/client.rb', line 174 def pause_endpoint(endpoint_id) PauseState.new(extract_data(request(:post, "/v1/endpoints/#{endpoint_id}/pause"))) end |
#pause_inbound_endpoint(endpoint_id) ⇒ Object
380 381 382 |
# File 'lib/hookbridge/client.rb', line 380 def pause_inbound_endpoint(endpoint_id) PauseState.new(extract_data(request(:post, "/v1/inbound-endpoints/#{endpoint_id}/pause"))) end |
#pause_pull_endpoint(endpoint_id) ⇒ Object
252 253 254 |
# File 'lib/hookbridge/client.rb', line 252 def pause_pull_endpoint(endpoint_id) PauseState.new(extract_data(request(:post, "/v1/pull-endpoints/#{endpoint_id}/pause"))) end |
#replay(message_id) ⇒ Object
44 45 46 |
# File 'lib/hookbridge/client.rb', line 44 def replay() ReplayResponse.new(extract_data(request(:post, "/v1/messages/#{}/replay"))) end |
#replay_all_inbound_messages(status:, inbound_endpoint_id: nil, limit: nil) ⇒ Object
423 424 425 426 427 428 |
# File 'lib/hookbridge/client.rb', line 423 def (status:, inbound_endpoint_id: nil, limit: nil) params = { status: status } params[:inbound_endpoint_id] = inbound_endpoint_id if inbound_endpoint_id params[:limit] = limit if limit ReplayAllMessagesResponse.new(extract_data(request(:post, "/v1/inbound-messages/replay-all", nil, params))) end |
#replay_all_messages(status:, endpoint_id: nil, limit: nil) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/hookbridge/client.rb', line 58 def (status:, endpoint_id: nil, limit: nil) params = { status: status } params[:endpoint_id] = endpoint_id if endpoint_id params[:limit] = limit if limit ReplayAllMessagesResponse.new(extract_data(request(:post, "/v1/messages/replay-all", nil, params))) end |
#replay_batch_inbound_messages(message_ids) ⇒ Object
430 431 432 433 434 |
# File 'lib/hookbridge/client.rb', line 430 def () ReplayBatchMessagesResponse.new( extract_data(request(:post, "/v1/inbound-messages/replay-batch", { message_ids: })) ) end |
#replay_batch_messages(message_ids) ⇒ Object
65 66 67 68 69 |
# File 'lib/hookbridge/client.rb', line 65 def () ReplayBatchMessagesResponse.new( extract_data(request(:post, "/v1/messages/replay-batch", { message_ids: })) ) end |
#replay_from_dlq(message_id) ⇒ Object
112 113 114 |
# File 'lib/hookbridge/client.rb', line 112 def replay_from_dlq() ReplayResponse.new(extract_data(request(:post, "/v1/dlq/replay/#{}"))) end |
#replay_inbound_message(message_id) ⇒ Object
419 420 421 |
# File 'lib/hookbridge/client.rb', line 419 def () ReplayResponse.new(extract_data(request(:post, "/v1/inbound-messages/#{}/replay"))) end |
#resume_endpoint(endpoint_id) ⇒ Object
178 179 180 |
# File 'lib/hookbridge/client.rb', line 178 def resume_endpoint(endpoint_id) PauseState.new(extract_data(request(:post, "/v1/endpoints/#{endpoint_id}/resume"))) end |
#resume_inbound_endpoint(endpoint_id) ⇒ Object
384 385 386 |
# File 'lib/hookbridge/client.rb', line 384 def resume_inbound_endpoint(endpoint_id) PauseState.new(extract_data(request(:post, "/v1/inbound-endpoints/#{endpoint_id}/resume"))) end |
#resume_pull_endpoint(endpoint_id) ⇒ Object
256 257 258 |
# File 'lib/hookbridge/client.rb', line 256 def resume_pull_endpoint(endpoint_id) PauseState.new(extract_data(request(:post, "/v1/pull-endpoints/#{endpoint_id}/resume"))) end |
#retry_now(message_id) ⇒ Object
53 54 55 56 |
# File 'lib/hookbridge/client.rb', line 53 def retry_now() request(:post, "/v1/messages/#{}/retry-now") nil end |
#rotate_endpoint_secret(endpoint_id) ⇒ Object
197 198 199 |
# File 'lib/hookbridge/client.rb', line 197 def rotate_endpoint_secret(endpoint_id) create_endpoint_signing_key(endpoint_id) end |
#send(endpoint_id:, payload:, headers: nil, idempotency_key: nil) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/hookbridge/client.rb', line 28 def send(endpoint_id:, payload:, headers: nil, idempotency_key: nil) body = { endpoint_id: endpoint_id, payload: payload } body[:headers] = headers if headers body[:idempotency_key] = idempotency_key if idempotency_key SendResponse.new(extract_data(request(:post, "/v1/webhooks/send", body, use_send_connection: true))) end |
#update_endpoint(endpoint_id, url: nil, description: nil, hmac_enabled: nil, rate_limit_rps: nil, burst: nil, headers: nil) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/hookbridge/client.rb', line 157 def update_endpoint(endpoint_id, url: nil, description: nil, hmac_enabled: nil, rate_limit_rps: nil, burst: nil, headers: nil) body = {} body[:url] = url if url body[:description] = description if description body[:hmac_enabled] = hmac_enabled unless hmac_enabled.nil? body[:rate_limit_rps] = rate_limit_rps if rate_limit_rps body[:burst] = burst if burst body[:headers] = headers if headers request(:patch, "/v1/endpoints/#{endpoint_id}", body) nil end |
#update_inbound_endpoint(endpoint_id, **attributes) ⇒ Object
372 373 374 |
# File 'lib/hookbridge/client.rb', line 372 def update_inbound_endpoint(endpoint_id, **attributes) UpdateResult.new(extract_data(request(:patch, "/v1/inbound-endpoints/#{endpoint_id}", compact_hash(attributes)))) end |
#update_pull_endpoint(endpoint_id, **attributes) ⇒ Object
244 245 246 |
# File 'lib/hookbridge/client.rb', line 244 def update_pull_endpoint(endpoint_id, **attributes) PullEndpoint.new(extract_data(request(:patch, "/v1/pull-endpoints/#{endpoint_id}", compact_hash(attributes)))) end |