Sha256: ca3e6b3d4fab421fc3a91d80fab6201aa90c9b690e8f9af5dcd24b0a4cca2be7

Contents?: true

Size: 689 Bytes

Versions: 2

Compression:

Stored size: 689 Bytes

Contents

require 'nestful'

module Esendex
  class ApiConnection

    def initialize
      @connection = Nestful::Connection.new(Esendex::API_HOST)
      @connection.user = Esendex.username
      @connection.password = Esendex.password
      @connection.auth_type = :basic
    end

    def default_headers
      { 'User-Agent' => Esendex.user_agent }
    end

    def get(url)
      @connection.get url, default_headers
    rescue => e
      raise Esendex::ApiErrorFactory.new.get_api_error(e)
    end

    def post(url, body)
      @connection.post url, body, default_headers
    rescue => e
      raise Esendex::ApiErrorFactory.new.get_api_error(e)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
esendex-0.6.0 lib/esendex/api_connection.rb
esendex-0.5.0 lib/esendex/api_connection.rb