Sha256: 95c6935d00d902b2c7f9a28171f95f6be27858bf91fe8033f9bb2199598d7935

Contents?: true

Size: 741 Bytes

Versions: 2

Compression:

Stored size: 741 Bytes

Contents

# frozen_string_literal: true

require 'http'

MAILERSEND_API_URL = 'https://api.mailersend.com/v1'
MAILERSEND_API_BASE_HOST = 'api.mailersend.com'

# mailersend-ruby is a gem that integrates all endpoints from MailerSend API
module Mailersend
  attr_reader :api_token

  # Inits the client.
  class Client
    def initialize(api_token = ENV.fetch('MAILERSEND_API_TOKEN', nil))
      raise ArgumentError, 'API token is not provided' if api_token.nil?

      @api_token = api_token
    end

    def http
      HTTP
        .timeout(connect: 15, read: 30)
        .auth("Bearer #{@api_token}")
        .headers('User-Agent' => "MailerSend-client-ruby/#{Mailersend::VERSION}",
                 'Accept' => 'application/json')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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