class PerfectMoneyMerchant::Api

Constants

API_URL
METHODS

Public Instance Methods

method_missing(*args, &block) click to toggle source
Calls superclass method
# File lib/perfect_money_merchant/api.rb, line 25
def method_missing(*args, &block)
        if METHODS.include?(args[0])
                response_hash = api_call(METHODS[args[0]][:path], args[1])
                if METHODS[args[0]][:donwcase_params]
                        response_hash.map { |k, v| [k.downcase, v] }.inject(Hashie::Mash.new) { |hash, param| hash.merge!(param[0] => param[1]) }
                else
                        Hashie::Mash.new(response_hash)
                end
        else
                super
        end
end

Private Instance Methods

api_call(path, params) click to toggle source
# File lib/perfect_money_merchant/api.rb, line 40
def api_call(path, params)
        @response = connection.post(path, params)
        @response.body
end
connection() click to toggle source
# File lib/perfect_money_merchant/api.rb, line 45
def connection
        @connection ||= ::Faraday.new(url: API_URL.dup) do |faraday|
                faraday.request :url_encoded
                faraday.response :parse_pm_response
                faraday.adapter Faraday.default_adapter
        end
end