Class: Mailersend::Tokens
- Inherits:
-
Object
- Object
- Mailersend::Tokens
- Defined in:
- lib/mailersend/tokens/tokens.rb
Overview
Tokens endpoint from MailerSend API.
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#name ⇒ Object
Returns the value of attribute name.
-
#scopes ⇒ Object
Returns the value of attribute scopes.
-
#status ⇒ Object
Returns the value of attribute status.
-
#token_id ⇒ Object
Returns the value of attribute token_id.
Instance Method Summary collapse
- #create(name:, scopes:, domain_id:) ⇒ Object
- #delete(token_id:) ⇒ Object
-
#initialize(client = Mailersend::Client.new) ⇒ Tokens
constructor
A new instance of Tokens.
- #update(token_id:, status:) ⇒ Object
Constructor Details
#initialize(client = Mailersend::Client.new) ⇒ Tokens
Returns a new instance of Tokens.
12 13 14 15 16 17 18 |
# File 'lib/mailersend/tokens/tokens.rb', line 12 def initialize(client = Mailersend::Client.new) @client = client @name = {} @scopes = [] @token_id = {} @status = {} end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6 7 8 |
# File 'lib/mailersend/tokens/tokens.rb', line 6 def client @client end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/mailersend/tokens/tokens.rb', line 6 def name @name end |
#scopes ⇒ Object
Returns the value of attribute scopes.
6 7 8 |
# File 'lib/mailersend/tokens/tokens.rb', line 6 def scopes @scopes end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/mailersend/tokens/tokens.rb', line 6 def status @status end |
#token_id ⇒ Object
Returns the value of attribute token_id.
6 7 8 |
# File 'lib/mailersend/tokens/tokens.rb', line 6 def token_id @token_id end |
Instance Method Details
#create(name:, scopes:, domain_id:) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/mailersend/tokens/tokens.rb', line 20 def create(name:, scopes:, domain_id:) json = { 'name' => name, 'scopes' => scopes, 'domain_id' => domain_id } client.http.post("#{MAILERSEND_API_URL}/token", json: json) end |
#delete(token_id:) ⇒ Object
36 37 38 |
# File 'lib/mailersend/tokens/tokens.rb', line 36 def delete(token_id:) client.http.delete("#{MAILERSEND_API_URL}/token/#{token_id}") end |
#update(token_id:, status:) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/mailersend/tokens/tokens.rb', line 29 def update(token_id:, status:) status = { status: status } client.http.put("#{MAILERSEND_API_URL}/token/#{token_id}/settings", json: status) end |