Sha256: b9fafc28800f077682979ecccc65b362216c41d81bfccb3e0aaa9f587a2de8f9

Contents?: true

Size: 837 Bytes

Versions: 1

Compression:

Stored size: 837 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.0 lib/firstgiving/lookup.rb