Sha256: 48c7fc17890971ed0f8469dbedd535895061664ff9553b7c84c30939cf7e8152

Contents?: true

Size: 918 Bytes

Versions: 2

Compression:

Stored size: 918 Bytes

Contents

# frozen_string_literal: true

module Mailersend
  # Tokens endpoint from MailerSend API.
  class Tokens
    attr_accessor :client,
                  :name,
                  :scopes,
                  :token_id,
                  :status

    def initialize(client = Mailersend::Client.new)
      @client = client
      @name = {}
      @scopes = []
      @token_id = {}
      @status = {}
    end

    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

    def update(token_id:, status:)
      status = {
        status: status
      }
      client.http.put("#{MAILERSEND_API_URL}/token/#{token_id}/settings", json: status)
    end

    def delete(token_id:)
      client.http.delete("#{MAILERSEND_API_URL}/token/#{token_id}")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mailersend-ruby-2.0.3 lib/mailersend/tokens/tokens.rb
mailersend-ruby-2.0.2 lib/mailersend/tokens/tokens.rb