Sha256: 57fdb60e690c5b78c6b2f4c4bc265159b54f8f08a0d2ac233472c5776d7a4bc2

Contents?: true

Size: 978 Bytes

Versions: 3

Compression:

Stored size: 978 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
      }
      response = client.http.post("#{API_URL}/token", json: json)
      puts response
    end

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

    def delete(token_id:)
      response = client.http.delete("#{API_URL}/token/#{token_id}")
      puts response
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mailersend-ruby-0.2.0 lib/mailersend/tokens/tokens.rb
mailersend-ruby-0.1.9 lib/mailersend/tokens/tokens.rb
mailersend-ruby-0.1.8 lib/mailersend/tokens/tokens.rb