Class: Mailersend::Tokens

Inherits:
Object
  • Object
show all
Defined in:
lib/mailersend/tokens/tokens.rb

Overview

Tokens endpoint from MailerSend API.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clientObject

Returns the value of attribute client.



6
7
8
# File 'lib/mailersend/tokens/tokens.rb', line 6

def client
  @client
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/mailersend/tokens/tokens.rb', line 6

def name
  @name
end

#scopesObject

Returns the value of attribute scopes.



6
7
8
# File 'lib/mailersend/tokens/tokens.rb', line 6

def scopes
  @scopes
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/mailersend/tokens/tokens.rb', line 6

def status
  @status
end

#token_idObject

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