Class: Courier::AuthTokens
- Inherits:
-
Object
- Object
- Courier::AuthTokens
- Defined in:
- lib/trycourier/auth_tokens.rb
Constant Summary collapse
- KEY =
"/auth"
Instance Method Summary collapse
-
#initialize(session) ⇒ AuthTokens
constructor
A new instance of AuthTokens.
- #issue_token(scope:, expires_in: nil, data: nil, profile: nil, recipient: nil, template: nil) ⇒ Object
Constructor Details
#initialize(session) ⇒ AuthTokens
Returns a new instance of AuthTokens.
5 6 7 |
# File 'lib/trycourier/auth_tokens.rb', line 5 def initialize(session) @session = session end |
Instance Method Details
#issue_token(scope:, expires_in: nil, data: nil, profile: nil, recipient: nil, template: nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/trycourier/auth_tokens.rb', line 9 def issue_token(scope:, expires_in: nil, data: nil, profile: nil, recipient: nil, template: nil) path = "#{KEY}/issue-token" payload = { "scope": scope } if expires_in payload["expires_in"] = expires_in end res = @session.send(path, "POST", body: payload, headers: {}) ErrorHandler.check_err(res) end |