Class: Courier::AsyncClient
- Inherits:
-
Object
- Object
- Courier::AsyncClient
- Defined in:
- lib/trycourier.rb
Instance Attribute Summary collapse
-
#audiences ⇒ Object
readonly
Returns the value of attribute audiences.
-
#audit_events ⇒ Object
readonly
Returns the value of attribute audit_events.
-
#auth_tokens ⇒ Object
readonly
Returns the value of attribute auth_tokens.
-
#automations ⇒ Object
readonly
Returns the value of attribute automations.
-
#brands ⇒ Object
readonly
Returns the value of attribute brands.
-
#bulk ⇒ Object
readonly
Returns the value of attribute bulk.
-
#lists ⇒ Object
readonly
Returns the value of attribute lists.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#notifications ⇒ Object
readonly
Returns the value of attribute notifications.
-
#profiles ⇒ Object
readonly
Returns the value of attribute profiles.
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
-
#tenants ⇒ Object
readonly
Returns the value of attribute tenants.
-
#translations ⇒ Object
readonly
Returns the value of attribute translations.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Instance Method Summary collapse
- #initialize(authorization_token:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil) ⇒ AsyncClient constructor
-
#send(message:, request_options: nil) ⇒ SendMessageResponse
Use the send API to send a message to one or more recipients.
Constructor Details
#initialize(authorization_token:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil) ⇒ AsyncClient
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/trycourier.rb', line 85 def initialize(authorization_token:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil) @async_request_client = AsyncRequestClient.new(environment: environment, max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, authorization_token: ) @audiences = AsyncAudiencesClient.new(request_client: @async_request_client) @audit_events = AsyncAuditEventsClient.new(request_client: @async_request_client) @auth_tokens = AsyncAuthTokensClient.new(request_client: @async_request_client) @automations = AsyncAutomationsClient.new(request_client: @async_request_client) @brands = AsyncBrandsClient.new(request_client: @async_request_client) @bulk = AsyncBulkClient.new(request_client: @async_request_client) @lists = AsyncListsClient.new(request_client: @async_request_client) @messages = AsyncMessagesClient.new(request_client: @async_request_client) @notifications = AsyncNotificationsClient.new(request_client: @async_request_client) @profiles = AsyncProfilesClient.new(request_client: @async_request_client) @templates = AsyncTemplatesClient.new(request_client: @async_request_client) @tenants = AsyncTenantsClient.new(request_client: @async_request_client) @translations = AsyncTranslationsClient.new(request_client: @async_request_client) @users = Users::AsyncClient.new(request_client: @async_request_client) end |
Instance Attribute Details
#audiences ⇒ Object (readonly)
Returns the value of attribute audiences.
77 78 79 |
# File 'lib/trycourier.rb', line 77 def audiences @audiences end |
#audit_events ⇒ Object (readonly)
Returns the value of attribute audit_events.
77 78 79 |
# File 'lib/trycourier.rb', line 77 def audit_events @audit_events end |
#auth_tokens ⇒ Object (readonly)
Returns the value of attribute auth_tokens.
77 78 79 |
# File 'lib/trycourier.rb', line 77 def auth_tokens @auth_tokens end |
#automations ⇒ Object (readonly)
Returns the value of attribute automations.
77 78 79 |
# File 'lib/trycourier.rb', line 77 def automations @automations end |
#brands ⇒ Object (readonly)
Returns the value of attribute brands.
77 78 79 |
# File 'lib/trycourier.rb', line 77 def brands @brands end |
#bulk ⇒ Object (readonly)
Returns the value of attribute bulk.
77 78 79 |
# File 'lib/trycourier.rb', line 77 def bulk @bulk end |
#lists ⇒ Object (readonly)
Returns the value of attribute lists.
77 78 79 |
# File 'lib/trycourier.rb', line 77 def lists @lists end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
77 78 79 |
# File 'lib/trycourier.rb', line 77 def @messages end |
#notifications ⇒ Object (readonly)
Returns the value of attribute notifications.
77 78 79 |
# File 'lib/trycourier.rb', line 77 def notifications @notifications end |
#profiles ⇒ Object (readonly)
Returns the value of attribute profiles.
77 78 79 |
# File 'lib/trycourier.rb', line 77 def profiles @profiles end |
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
77 78 79 |
# File 'lib/trycourier.rb', line 77 def templates @templates end |
#tenants ⇒ Object (readonly)
Returns the value of attribute tenants.
77 78 79 |
# File 'lib/trycourier.rb', line 77 def tenants @tenants end |
#translations ⇒ Object (readonly)
Returns the value of attribute translations.
77 78 79 |
# File 'lib/trycourier.rb', line 77 def translations @translations end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
77 78 79 |
# File 'lib/trycourier.rb', line 77 def users @users end |
Instance Method Details
#send(message:, request_options: nil) ⇒ SendMessageResponse
Use the send API to send a message to one or more recipients.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/trycourier.rb', line 110 def send(message:, request_options: nil) response = @async_request_client.conn.post("/send") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers["Idempotency-Key"] = .idempotency_key unless &.idempotency_key.nil? unless &.idempotency_expiry.nil? req.headers["X-Idempotency-Expiration"] = .idempotency_expiry end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(&.additional_body_parameters || {}), message: }.compact end SendMessageResponse.from_json(json_object: response.body) end |