Appearance
@gethook/ruby — SDK Reference
About 777 wordsAbout 3 min
Installation
gem install gethookSetup
require 'gethook'
Gethook.configure do |config|
config.host = 'api.gethook.to'
config.api_key['ApiKeyAuth'] = 'hk_your_api_key'
endError handling
begin
sources = Gethook::SourcesApi.new.list_sources
rescue Gethook::ApiError => e
puts "Error #{e.code}: #{e.message}"
endHealth
Gethook::HealthApi.new.healthz()
Liveness check.
Returns: object
result = Gethook::HealthApi.new.healthz()Gethook::HealthApi.new.readyz()
Readiness check.
Returns: object
result = Gethook::HealthApi.new.readyz()Accounts
Gethook::AccountsApi.new.create_account(body)
Create account.
Creates a new account and returns a bootstrap API key. No authentication required.
Parameters:
bodyCreateAccountRequest— Request body
Returns: AccountBootstrapData
body = Gethook::CreateAccountRequest.new(
name: "My Company",
)
result = Gethook::AccountsApi.new.create_account(body)Auth
Gethook::AuthApi.new.login(body)
Login with email and password.
Authenticates with email/password and returns a fresh API key on success.
Parameters:
bodyLoginRequest— Request body
Returns: AccountBootstrapData
body = Gethook::LoginRequest.new(
email: "admin@example.com",
password: "supersecret",
)
result = Gethook::AuthApi.new.login(body)Gethook::AuthApi.new.register(body)
Register with email and password.
Creates a new account with email/password credentials and returns a bootstrap API key.
Parameters:
bodyRegisterRequest— Request body
Returns: AccountBootstrapData
body = Gethook::RegisterRequest.new(
email: "admin@example.com",
name: "My Company",
password: "supersecret",
)
result = Gethook::AuthApi.new.register(body)API Keys
Gethook::ApiKeysApi.new.list_api_keys()
List API keys.
Returns: APIKey[]
result = Gethook::ApiKeysApi.new.list_api_keys()Gethook::ApiKeysApi.new.create_api_key(body)
Create API key.
Creates a new API key for the authenticated account. The full key is only returned once.
Parameters:
bodyCreateAPIKeyRequest— Request body
Returns: APIKeyWithSecret
body = Gethook::CreateAPIKeyRequest.new(
name: "production",
)
result = Gethook::ApiKeysApi.new.create_api_key(body)Gethook::ApiKeysApi.new.delete_api_key("<id>")
Revoke API key.
Parameters:
id— API key UUID
Returns: void
Gethook::ApiKeysApi.new.delete_api_key("<id>")Sources
Gethook::SourcesApi.new.list_sources()
List sources.
Returns: Source[]
result = Gethook::SourcesApi.new.list_sources()Gethook::SourcesApi.new.create_source(body)
Create source.
Creates a new webhook source endpoint. Returns an ingest_url to share with the event sender.
Parameters:
bodyCreateSourceRequest— Request body
Returns: Source
body = Gethook::CreateSourceRequest.new(
name: "Stripe webhooks",
)
result = Gethook::SourcesApi.new.create_source(body)Gethook::SourcesApi.new.get_source("<id>")
Get source.
Parameters:
id— Source UUID
Returns: Source
result = Gethook::SourcesApi.new.get_source("<id>")Destinations
Gethook::DestinationsApi.new.list_destinations()
List destinations.
Returns: Destination[]
result = Gethook::DestinationsApi.new.list_destinations()Gethook::DestinationsApi.new.create_destination(body)
Create destination.
Creates a new webhook delivery destination. The signing_secret is encrypted at rest and never returned.
Parameters:
bodyCreateDestinationRequest— Request body
Returns: Destination
body = Gethook::CreateDestinationRequest.new(
name: "My endpoint",
url: "https://example.com/webhooks",
)
result = Gethook::DestinationsApi.new.create_destination(body)Gethook::DestinationsApi.new.get_destination("<id>")
Get destination.
Parameters:
id— Destination UUID
Returns: Destination
result = Gethook::DestinationsApi.new.get_destination("<id>")Gethook::DestinationsApi.new.update_destination("<id>", body)
Update destination.
Parameters:
id— Destination UUIDbodyUpdateDestinationRequest— Request body
Returns: Destination
body = Gethook::UpdateDestinationRequest.new(
active: true,
auth_config: "...",
custom_headers: "...",
)
result = Gethook::DestinationsApi.new.update_destination("<id>", body)Routes
Gethook::RoutesApi.new.list_routes()
List routes.
Returns: Route[]
result = Gethook::RoutesApi.new.list_routes()Gethook::RoutesApi.new.create_route(body)
Create route.
Creates a routing rule that forwards matching events from a source to a destination.
Parameters:
bodyCreateRouteRequest— Request body
Returns: Route
body = Gethook::CreateRouteRequest.new(
destination_id: "uuid",
)
result = Gethook::RoutesApi.new.create_route(body)Stats
Gethook::StatsApi.new.get_stats()
Get dashboard stats.
Returns: StatsData
result = Gethook::StatsApi.new.get_stats()Ingest
Gethook::IngestApi.new.ingest()
Ingest webhook event.
Accepts an inbound webhook. The path token authenticates the source — no Bearer header required.
Returns: void
Gethook::IngestApi.new.ingest()Events (Inbound)
Gethook::EventsApi.new.list_events(limit: ..., offset: ...)
List inbound events.
Parameters:
limitinteger— Max results (default 25, max 200) (optional)offsetinteger— Pagination offset (optional)
Returns: EventListData
result = Gethook::EventsApi.new.list_events(limit: ..., offset: ...)Gethook::EventsApi.new.get_event("<id>")
Get inbound event.
Parameters:
id— Event UUID
Returns: EventDetailData
result = Gethook::EventsApi.new.get_event("<id>")Gethook::EventsApi.new.replay_event("<id>")
Replay inbound event.
Creates a new queued copy of the event for re-delivery.
Parameters:
id— Event UUID
Returns: void
Gethook::EventsApi.new.replay_event("<id>")Events (Outbound)
Gethook::OutboundEventsApi.new.list_outbound_events(limit: ..., offset: ...)
List outbound events.
Parameters:
limitinteger— Max results (default 25, max 200) (optional)offsetinteger— Pagination offset (optional)
Returns: EventListData
result = Gethook::OutboundEventsApi.new.list_outbound_events(limit: ..., offset: ...)Gethook::OutboundEventsApi.new.publish_outbound_event(body)
Publish outbound event.
Queues a new outbound event for delivery to all matching route destinations.
Parameters:
bodyPublishOutboundEventRequest— Request body
Returns: PublishOutboundData
body = Gethook::PublishOutboundEventRequest.new(
payload: "{"order_id":"123"}",
)
result = Gethook::OutboundEventsApi.new.publish_outbound_event(body)Gethook::OutboundEventsApi.new.get_outbound_event("<id>")
Get outbound event.
Parameters:
id— Event UUID
Returns: EventDetailData
result = Gethook::OutboundEventsApi.new.get_outbound_event("<id>")Gethook::OutboundEventsApi.new.replay_outbound_event("<id>")
Replay outbound event.
Parameters:
id— Event UUID
Returns: void
Gethook::OutboundEventsApi.new.replay_outbound_event("<id>")Brand & White-Labeling
Gethook::BrandApi.new.get_brand_settings()
Get brand settings.
Returns: BrandSettings
result = Gethook::BrandApi.new.get_brand_settings()Gethook::BrandApi.new.upsert_brand_settings(body)
Upsert brand settings.
Creates or replaces white-label brand settings for the account.
Parameters:
bodyUpsertBrandSettingsRequest— Request body
Returns: BrandSettings
body = Gethook::UpsertBrandSettingsRequest.new(
company_name: "Acme Corp",
docs_title: "Acme Webhooks",
logo_url: "https://example.com/logo.png",
)
result = Gethook::BrandApi.new.upsert_brand_settings(body)Custom Domains
Gethook::CustomDomainsApi.new.list_custom_domains()
List custom domains.
Returns: CustomDomain[]
result = Gethook::CustomDomainsApi.new.list_custom_domains()Gethook::CustomDomainsApi.new.create_custom_domain(body)
Create custom domain.
Parameters:
bodyCreateCustomDomainRequest— Request body
Returns: CustomDomain
body = Gethook::CreateCustomDomainRequest.new(
domain: "webhooks.example.com",
)
result = Gethook::CustomDomainsApi.new.create_custom_domain(body)