Class: FirstGiving::Lookup
- Inherits:
-
Object
- Object
- FirstGiving::Lookup
show all
- Includes:
- Base
- Defined in:
- lib/firstgiving/lookup.rb
Defined Under Namespace
Modules: Actions
Constant Summary
Constants included
from Base
Base::DONATION_PRODUCTION_ENDPOINT, Base::DONATION_SANDBOX_ENDPOINT, Base::SEARCH_ENDPOINT
Instance Method Summary
collapse
Methods included from Base
#headers_json, #headers_security, #logging
Constructor Details
#initialize ⇒ Lookup
Returns a new instance of Lookup.
Instance Method Details
#call(action, params, _headers) ⇒ Object
22
23
24
25
|
# File 'lib/firstgiving/lookup.rb', line 22
def call(action, params, )
response = get_call(@api_endpoint, action, params, )
parse(response.body)
end
|
18
19
20
|
# File 'lib/firstgiving/lookup.rb', line 18
def
.merge!()
end
|
#list(params) ⇒ Object
31
32
33
|
# File 'lib/firstgiving/lookup.rb', line 31
def list(params)
call(Actions::TRANSACTION_LIST, params, )
end
|
#message_from(response) ⇒ Object
45
46
47
|
# File 'lib/firstgiving/lookup.rb', line 45
def message_from(response)
response['firstGivingDonationApi']['firstGivingResponse']['verboseErrorMessage']
end
|
#params_from(response) ⇒ Object
40
41
42
43
|
# File 'lib/firstgiving/lookup.rb', line 40
def params_from(response)
params = response['firstGivingDonationApi']['firstGivingResponse']['transaction']
params ||= response['firstGivingDonationApi']['firstGivingResponse']['transactions']
end
|
#parse(body) ⇒ Object
49
50
51
52
|
# 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) ⇒ Object
35
36
37
38
|
# File 'lib/firstgiving/lookup.rb', line 35
def success_from(response)
ack = response['firstGivingDonationApi']['firstGivingResponse']['acknowledgement']
ack == 'Success' ? true : false
end
|