class FirstGiving::Lookup
Public Class Methods
new()
click to toggle source
# File lib/firstgiving/lookup.rb, line 13 def initialize @api_endpoint = DONATION_PRODUCTION_ENDPOINT @api_endpoint = DONATION_SANDBOX_ENDPOINT if FirstGiving.configuration.options[:use_staging] end
Public Instance Methods
call(action, params, _headers)
click to toggle source
# File lib/firstgiving/lookup.rb, line 22 def call(action, params, _headers) response = get_call(@api_endpoint, action, params, _headers) parse(response.body) end
detail(params)
click to toggle source
# File lib/firstgiving/lookup.rb, line 27 def detail(params) call(Actions::TRANSACTION_DETAIL, params, headers) end
headers()
click to toggle source
# File lib/firstgiving/lookup.rb, line 18 def headers headers_json.merge!(headers_security) end
list(params)
click to toggle source
# File lib/firstgiving/lookup.rb, line 31 def list(params) call(Actions::TRANSACTION_LIST, params, headers) end
message_from(response)
click to toggle source
# File lib/firstgiving/lookup.rb, line 45 def message_from(response) response['firstGivingDonationApi']['firstGivingResponse']['verboseErrorMessage'] end
params_from(response)
click to toggle source
# File lib/firstgiving/lookup.rb, line 40 def params_from(response) params = response['firstGivingDonationApi']['firstGivingResponse']['transaction'] params ||= response['firstGivingDonationApi']['firstGivingResponse']['transactions'] end
parse(body)
click to toggle source
# File lib/firstgiving/lookup.rb, line 49 def parse(body) response = Crack::XML.parse(body) response = Response.new(success_from(response), message_from(response), params_from(response)) end
success_from(response)
click to toggle source
# File lib/firstgiving/lookup.rb, line 35 def success_from(response) ack = response['firstGivingDonationApi']['firstGivingResponse']['acknowledgement'] ack == 'Success' ? true : false end