Class: Courier::AsyncAuthTokensClient
- Inherits:
-
Object
- Object
- Courier::AsyncAuthTokensClient
- Defined in:
- lib/trycourier/auth_tokens/client.rb
Instance Attribute Summary collapse
-
#request_client ⇒ Object
readonly
Returns the value of attribute request_client.
Instance Method Summary collapse
- #initialize(request_client:) ⇒ AsyncAuthTokensClient constructor
-
#issue_token(scope:, expires_in:, request_options: nil) ⇒ AuthTokens::IssueTokenResponse
Returns a new access token.
Constructor Details
#initialize(request_client:) ⇒ AsyncAuthTokensClient
51 52 53 54 |
# File 'lib/trycourier/auth_tokens/client.rb', line 51 def initialize(request_client:) # @type [AsyncRequestClient] @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Object (readonly)
Returns the value of attribute request_client.
47 48 49 |
# File 'lib/trycourier/auth_tokens/client.rb', line 47 def request_client @request_client end |
Instance Method Details
#issue_token(scope:, expires_in:, request_options: nil) ⇒ AuthTokens::IssueTokenResponse
Returns a new access token.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/trycourier/auth_tokens/client.rb', line 62 def issue_token(scope:, expires_in:, request_options: nil) Async do response = @request_client.conn.post("/auth/issue-token") 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 || {}), scope: scope, expires_in: expires_in }.compact end AuthTokens::IssueTokenResponse.from_json(json_object: response.body) end end |