Class: FundAmerica::API
- Inherits:
-
Object
- Object
- FundAmerica::API
- Defined in:
- lib/fund_america/api.rb
Class Method Summary collapse
-
.clear_data ⇒ Object
End point: sandbox.fundamerica.com/api/test_mode/clear_data (POST) Usage: FundAmerica::API.clear_data Output: Clears all test data created in sandbox mode Important: Sandbox mode only method.
-
.investor_suitabilitytokens(options) ⇒ Object
End point: apps.fundamerica.com/api/investorsuitabilitytokens (POST) Usage: FundAmerica::API.investor_suitabilitytokens(options).
-
.ledger_entry(ledger_entry_id) ⇒ Object
End point: apps.fundamerica.com/api/ledger_entries/:id (GET) Usage: FundAmerica::API.ledger_entry(ledger_entry_id).
-
.request(method, uri, options = {}) ⇒ Object
This method is called from each end point method to make API requests using HTTParty gem.
Class Method Details
.clear_data ⇒ Object
End point: sandbox.fundamerica.com/api/test_mode/clear_data (POST) Usage: FundAmerica::API.clear_data Output: Clears all test data created in sandbox mode Important: Sandbox mode only method
27 28 29 |
# File 'lib/fund_america/api.rb', line 27 def clear_data API::request(:post, 'https://sandbox.fundamerica.com/api/test_mode/clear_data') end |
.investor_suitabilitytokens(options) ⇒ Object
End point: apps.fundamerica.com/api/investorsuitabilitytokens (POST) Usage: FundAmerica::API.investor_suitabilitytokens(options)
33 34 35 |
# File 'lib/fund_america/api.rb', line 33 def investor_suitabilitytokens() API::request(:post, 'investorsuitabilitytokens', ) end |
.ledger_entry(ledger_entry_id) ⇒ Object
End point: apps.fundamerica.com/api/ledger_entries/:id (GET) Usage: FundAmerica::API.ledger_entry(ledger_entry_id)
39 40 41 |
# File 'lib/fund_america/api.rb', line 39 def ledger_entry(ledger_entry_id) API::request(:get, "ledger_entries/#{ledger_entry_id}") end |
.request(method, uri, options = {}) ⇒ Object
This method is called from each end point method to make API requests using HTTParty gem. Takes the method, uri and options as input Handles response and errors
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fund_america/api.rb', line 8 def request method, uri, ={} = FundAmerica.basic_auth.merge!({:body => }) uri = FundAmerica.base_uri + uri unless uri.include?('test_mode') response = HTTParty.send(method, uri, ) parsed_response = JSON.parse(response.body) if response.code.to_i == 200 # Returns parsed_response - a hash of response body # if response is successful parsed_response else # Raises error if the response is not sucessful raise FundAmerica::Error.new(parsed_response, response.code.to_i) end end |