Class: Mailtrap::ApiTokensAPI
- Inherits:
-
Object
- Object
- Mailtrap::ApiTokensAPI
- Includes:
- BaseAPI
- Defined in:
- lib/mailtrap/api_tokens_api.rb
Instance Attribute Summary
Attributes included from BaseAPI
Instance Method Summary collapse
-
#create(options) ⇒ ApiToken
Creates a new API token.
-
#delete(token_id) ⇒ Object
Permanently deletes an API token.
-
#get(token_id) ⇒ ApiToken
Retrieves a single API token by ID.
-
#list ⇒ Array<ApiToken>
Lists API tokens visible to the current API token.
-
#reset(token_id, options = {}) ⇒ ApiToken
Expires the requested token and returns a new one with the same permissions.
Methods included from BaseAPI
Instance Method Details
#create(options) ⇒ ApiToken
Creates a new API token. The full token value is returned ONLY ONCE — store it securely.
41 42 43 |
# File 'lib/mailtrap/api_tokens_api.rb', line 41 def create() base_create() end |
#delete(token_id) ⇒ Object
Permanently deletes an API token
67 68 69 |
# File 'lib/mailtrap/api_tokens_api.rb', line 67 def delete(token_id) base_delete(token_id) end |
#get(token_id) ⇒ ApiToken
Retrieves a single API token by ID
26 27 28 |
# File 'lib/mailtrap/api_tokens_api.rb', line 26 def get(token_id) base_get(token_id) end |
#list ⇒ Array<ApiToken>
Lists API tokens visible to the current API token
17 18 19 |
# File 'lib/mailtrap/api_tokens_api.rb', line 17 def list base_list end |
#reset(token_id, options = {}) ⇒ ApiToken
Expires the requested token and returns a new one with the same permissions.
The old token stops working after a short grace period. The new token value is
returned ONLY ONCE — store it securely
56 57 58 59 60 61 |
# File 'lib/mailtrap/api_tokens_api.rb', line 56 def reset(token_id, = {}) (, %i[expires_at]) # An empty hash must not be sent as a body — the endpoint historically takes no body response = client.post("#{base_path}/#{token_id}/reset", .empty? ? nil : ) handle_response(response) end |