Sha256: 564643db08da3409c5739cc578651d521206a5045df830e78bb93b48141ebd07

Contents?: true

Size: 834 Bytes

Versions: 1

Compression:

Stored size: 834 Bytes

Contents

require 'crack'
# lookup API

module FirstGiving
  class Lookup
    include Base

    module Actions
      TRANSACTION_LIST = '/transaction/list'
      TRANSACTION_DETAIL = '/transaction/detail'
    end

    def initialize
      @api_endpoint = DONATION_PRODUCTION_ENDPOINT
      @api_endpoint = DONATION_SANDBOX_ENDPOINT if FirstGiving.configuration.options[:use_staging]
    end

    def headers
      headers_json.merge!(headers_security)
    end

    def call(action, params, _headers)
      response = get_call(@api_endpoint, action, params, _headers)
      parse(response.body)
    end

    def detail(params)
      call(Actions::TRANSACTION_DETAIL, params, headers)
    end

    def list(params)
      call(Actions::TRANSACTION_LIST, params, headers)
    end

    def parse(body)
      Crack::XML.parse(body)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
firstgiving-1.0.1 lib/firstgiving/lookup.rb