class AfTalk::Connection

Constants

SANDBOX_URL
URL

Public Class Methods

build() click to toggle source
# File lib/aftalk/connection.rb, line 9
def self.build
  @_connection ||= new.build
end
clear() click to toggle source
# File lib/aftalk/connection.rb, line 13
def self.clear
  @_connection = nil
end

Public Instance Methods

build() click to toggle source
# File lib/aftalk/connection.rb, line 17
def build
  Faraday.new(
    url: api_url,
    headers: { apiKey: AfTalk::Configuration.api_key,
               accept: "application/json" },
  ) do |connection|
    connection.request :url_encoded
    connection.response :json,
                        content_type: /\bjson$/,
                        parser_options: { symbolize_names: true }
    connection.adapter Faraday.default_adapter
  end
end

Private Instance Methods

api_url() click to toggle source
# File lib/aftalk/connection.rb, line 33
def api_url
  ENV["AFRICAS_TALKING_SANDBOX"] ? SANDBOX_URL : URL
end