class Mailersend::Tokens

Tokens endpoint from MailerSend API.

Attributes

client[RW]
name[RW]
scopes[RW]
status[RW]
token_id[RW]

Public Class Methods

new(client = Mailersend::Client.new) click to toggle source
# File lib/mailersend/tokens/tokens.rb, line 12
def initialize(client = Mailersend::Client.new)
  @client = client
  @name = {}
  @scopes = []
  @token_id = {}
  @status = {}
end

Public Instance Methods

create(name:, scopes:, domain_id:) click to toggle source
# File lib/mailersend/tokens/tokens.rb, line 20
def create(name:, scopes:, domain_id:)
  json = {
    'name' => name,
    'scopes' => scopes,
    'domain_id' => domain_id
  }
  response = client.http.post("#{API_URL}/token", json: json)
  puts response
end
delete(token_id:) click to toggle source
# File lib/mailersend/tokens/tokens.rb, line 38
def delete(token_id:)
  response = client.http.delete("#{API_URL}/token/#{token_id}")
  puts response
end
update(token_id:, status:) click to toggle source
# File lib/mailersend/tokens/tokens.rb, line 30
def update(token_id:, status:)
  status = {
    status: status
  }
  response = client.http.put("#{API_URL}/token/#{token_id}/settings", json: status)
  puts response
end