Class: FirstGiving::Donation

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/firstgiving/donation.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

#initializeDonation

Returns a new instance of Donation.



13
14
15
16
# File 'lib/firstgiving/donation.rb', line 13

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

Instance Method Details

#creditcard(params) ⇒ Object



22
23
24
25
# File 'lib/firstgiving/donation.rb', line 22

def creditcard(params)
  response = post_call(@api_endpoint, Actions::CREDITCARD, params, headers)
  parse(response.body)
end

#headersObject



18
19
20
# File 'lib/firstgiving/donation.rb', line 18

def headers
  headers_json.merge!(headers_security)
end

#parse(body) ⇒ Object



36
37
38
# File 'lib/firstgiving/donation.rb', line 36

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

#recurring_creditcard_profile(params) ⇒ Object



32
33
34
# File 'lib/firstgiving/donation.rb', line 32

def recurring_creditcard_profile(params)
  call(Actions::RECURRING_CREDITCARD_PROFILE, params, headers)
end

#verify(params) ⇒ Object



27
28
29
30
# File 'lib/firstgiving/donation.rb', line 27

def verify(params)
  response = get_call(@api_endpoint, Actions::VERIFY, params, headers)
  parse(response.body)
end