Sha256: 45793dae622fe088a19153c56be4c465ff9c66dbc3d078677caf15be7c8551d2

Contents?: true

Size: 581 Bytes

Versions: 2

Compression:

Stored size: 581 Bytes

Contents

require 'nestful'

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 ApiErrorFactory.new.get_api_error(e)
  end

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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
esendex-0.2.1 lib/esendex/api_connection.rb
esendex-0.2.0 lib/esendex/api_connection.rb