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_checkout(plan:, interval:) ⇒ 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_portal(return_url: nil) ⇒ Object
- #create_project(name:, rate_limit_default: nil) ⇒ 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_project(project_id) ⇒ 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_project(project_id) ⇒ 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_projects ⇒ 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_project(project_id, name: nil, rate_limit_default: nil) ⇒ 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
308 309 310 311 312 |
# File 'lib/hookbridge/client.rb', line 308 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_checkout(plan:, interval:) ⇒ Object
343 344 345 |
# File 'lib/hookbridge/client.rb', line 343 def create_checkout(plan:, interval:) CheckoutSession.new(extract_data(request(:post, "/v1/billing/checkout", { plan: plan, interval: interval }))) end |
#create_endpoint(url:, description: nil, hmac_enabled: nil, rate_limit_rps: 0, burst: 0, headers: nil) ⇒ Object
157 158 159 160 161 162 163 164 165 |
# File 'lib/hookbridge/client.rb', line 157 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
208 209 210 |
# File 'lib/hookbridge/client.rb', line 208 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
515 516 517 518 519 520 |
# File 'lib/hookbridge/client.rb', line 515 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
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
# File 'lib/hookbridge/client.rb', line 365 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
424 425 426 |
# File 'lib/hookbridge/client.rb', line 424 def create_inbound_signing_key(endpoint_id) RotateSecretResponse.new(extract_data(request(:post, "/v1/inbound-endpoints/#{endpoint_id}/signing-keys"))) end |
#create_portal(return_url: nil) ⇒ Object
347 348 349 350 351 |
# File 'lib/hookbridge/client.rb', line 347 def create_portal(return_url: nil) body = {} body[:return_url] = return_url if return_url PortalSession.new(extract_data(request(:post, "/v1/billing/portal", body))) end |
#create_project(name:, rate_limit_default: nil) ⇒ Object
135 136 137 138 139 |
# File 'lib/hookbridge/client.rb', line 135 def create_project(name:, rate_limit_default: nil) body = { name: name } body[:rate_limit_default] = rate_limit_default if rate_limit_default Project.new(extract_data(request(:post, "/v1/projects", body))) 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
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/hookbridge/client.rb', line 227 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
195 196 197 198 |
# File 'lib/hookbridge/client.rb', line 195 def delete_endpoint(endpoint_id) request(:delete, "/v1/endpoints/#{endpoint_id}") true end |
#delete_endpoint_signing_key(endpoint_id, key_id) ⇒ Object
218 219 220 221 |
# File 'lib/hookbridge/client.rb', line 218 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
534 535 536 537 |
# File 'lib/hookbridge/client.rb', line 534 def delete_export(export_id) request(:delete, "/v1/exports/#{export_id}") true end |
#delete_inbound_endpoint(endpoint_id) ⇒ Object
412 413 414 |
# File 'lib/hookbridge/client.rb', line 412 def delete_inbound_endpoint(endpoint_id) DeleteResult.new(extract_data(request(:delete, "/v1/inbound-endpoints/#{endpoint_id}"))) end |
#delete_inbound_message(message_id) ⇒ Object
559 560 561 |
# File 'lib/hookbridge/client.rb', line 559 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
569 570 571 572 573 574 575 576 577 |
# File 'lib/hookbridge/client.rb', line 569 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
563 564 565 566 567 |
# File 'lib/hookbridge/client.rb', line 563 def () DeleteBatchResult.new( extract_data(request(:post, "/v1/inbound-messages/delete-batch", { message_ids: })) ) end |
#delete_inbound_signing_key(endpoint_id, key_id) ⇒ Object
434 435 436 437 |
# File 'lib/hookbridge/client.rb', line 434 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
539 540 541 |
# File 'lib/hookbridge/client.rb', line 539 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
549 550 551 552 553 554 555 556 557 |
# File 'lib/hookbridge/client.rb', line 549 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
543 544 545 546 547 |
# File 'lib/hookbridge/client.rb', line 543 def () DeleteBatchResult.new( extract_data(request(:post, "/v1/messages/delete-batch", { message_ids: })) ) end |
#delete_project(project_id) ⇒ Object
152 153 154 155 |
# File 'lib/hookbridge/client.rb', line 152 def delete_project(project_id) request(:delete, "/v1/projects/#{project_id}") true end |
#delete_pull_endpoint(endpoint_id) ⇒ Object
274 275 276 |
# File 'lib/hookbridge/client.rb', line 274 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
579 580 581 |
# File 'lib/hookbridge/client.rb', line 579 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
589 590 591 592 593 594 595 596 597 |
# File 'lib/hookbridge/client.rb', line 589 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
583 584 585 586 587 |
# File 'lib/hookbridge/client.rb', line 583 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
530 531 532 |
# File 'lib/hookbridge/client.rb', line 530 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
167 168 169 |
# File 'lib/hookbridge/client.rb', line 167 def get_endpoint(endpoint_id) Endpoint.new(extract_data(request(:get, "/v1/endpoints/#{endpoint_id}"))) end |
#get_export(export_id) ⇒ Object
526 527 528 |
# File 'lib/hookbridge/client.rb', line 526 def get_export(export_id) ExportRecord.new(extract_data(request(:get, "/v1/exports/#{export_id}"))) end |
#get_inbound_endpoint(endpoint_id) ⇒ Object
404 405 406 |
# File 'lib/hookbridge/client.rb', line 404 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
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
# File 'lib/hookbridge/client.rb', line 472 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
446 447 448 |
# File 'lib/hookbridge/client.rb', line 446 def () InboundMessage.new(extract_data(request(:get, "/v1/inbound-messages/#{}"))) end |
#get_inbound_message_attempts(message_id) ⇒ Object
450 451 452 453 |
# File 'lib/hookbridge/client.rb', line 450 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
488 489 490 491 492 |
# File 'lib/hookbridge/client.rb', line 488 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
494 495 496 497 498 |
# File 'lib/hookbridge/client.rb', line 494 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
358 359 360 361 362 363 |
# File 'lib/hookbridge/client.rb', line 358 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_project(project_id) ⇒ Object
141 142 143 |
# File 'lib/hookbridge/client.rb', line 141 def get_project(project_id) Project.new(extract_data(request(:get, "/v1/projects/#{project_id}"))) end |
#get_pull_endpoint(endpoint_id) ⇒ Object
266 267 268 |
# File 'lib/hookbridge/client.rb', line 266 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
302 303 304 305 306 |
# File 'lib/hookbridge/client.rb', line 302 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
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/hookbridge/client.rb', line 314 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
331 332 333 334 335 |
# File 'lib/hookbridge/client.rb', line 331 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
337 338 339 340 341 |
# File 'lib/hookbridge/client.rb', line 337 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
353 354 355 356 |
# File 'lib/hookbridge/client.rb', line 353 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
212 213 214 215 216 |
# File 'lib/hookbridge/client.rb', line 212 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
171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/hookbridge/client.rb', line 171 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
522 523 524 |
# File 'lib/hookbridge/client.rb', line 522 def list_exports extract_data(request(:get, "/v1/exports")).map { |entry| ExportRecord.new(entry) } end |
#list_inbound_endpoints(limit: nil, cursor: nil) ⇒ Object
392 393 394 395 396 397 398 399 400 401 402 |
# File 'lib/hookbridge/client.rb', line 392 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
500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
# File 'lib/hookbridge/client.rb', line 500 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
428 429 430 431 432 |
# File 'lib/hookbridge/client.rb', line 428 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_projects ⇒ Object
131 132 133 |
# File 'lib/hookbridge/client.rb', line 131 def list_projects extract_data(request(:get, "/v1/projects")).map { |project| Project.new(project) } end |
#list_pull_endpoints(limit: nil, cursor: nil) ⇒ Object
255 256 257 258 259 260 261 262 263 264 |
# File 'lib/hookbridge/client.rb', line 255 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
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/hookbridge/client.rb', line 286 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
439 440 441 442 443 444 |
# File 'lib/hookbridge/client.rb', line 439 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
599 600 601 602 603 604 |
# File 'lib/hookbridge/client.rb', line 599 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
200 201 202 |
# File 'lib/hookbridge/client.rb', line 200 def pause_endpoint(endpoint_id) PauseState.new(extract_data(request(:post, "/v1/endpoints/#{endpoint_id}/pause"))) end |
#pause_inbound_endpoint(endpoint_id) ⇒ Object
416 417 418 |
# File 'lib/hookbridge/client.rb', line 416 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
278 279 280 |
# File 'lib/hookbridge/client.rb', line 278 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
459 460 461 462 463 464 |
# File 'lib/hookbridge/client.rb', line 459 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
466 467 468 469 470 |
# File 'lib/hookbridge/client.rb', line 466 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
455 456 457 |
# File 'lib/hookbridge/client.rb', line 455 def () ReplayResponse.new(extract_data(request(:post, "/v1/inbound-messages/#{}/replay"))) end |
#resume_endpoint(endpoint_id) ⇒ Object
204 205 206 |
# File 'lib/hookbridge/client.rb', line 204 def resume_endpoint(endpoint_id) PauseState.new(extract_data(request(:post, "/v1/endpoints/#{endpoint_id}/resume"))) end |
#resume_inbound_endpoint(endpoint_id) ⇒ Object
420 421 422 |
# File 'lib/hookbridge/client.rb', line 420 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
282 283 284 |
# File 'lib/hookbridge/client.rb', line 282 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
223 224 225 |
# File 'lib/hookbridge/client.rb', line 223 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
183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/hookbridge/client.rb', line 183 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
408 409 410 |
# File 'lib/hookbridge/client.rb', line 408 def update_inbound_endpoint(endpoint_id, **attributes) UpdateResult.new(extract_data(request(:patch, "/v1/inbound-endpoints/#{endpoint_id}", compact_hash(attributes)))) end |
#update_project(project_id, name: nil, rate_limit_default: nil) ⇒ Object
145 146 147 148 149 150 |
# File 'lib/hookbridge/client.rb', line 145 def update_project(project_id, name: nil, rate_limit_default: nil) body = {} body[:name] = name if name body[:rate_limit_default] = rate_limit_default if rate_limit_default Project.new(extract_data(request(:put, "/v1/projects/#{project_id}", body))) end |
#update_pull_endpoint(endpoint_id, **attributes) ⇒ Object
270 271 272 |
# File 'lib/hookbridge/client.rb', line 270 def update_pull_endpoint(endpoint_id, **attributes) PullEndpoint.new(extract_data(request(:patch, "/v1/pull-endpoints/#{endpoint_id}", compact_hash(attributes)))) end |