Class: FatZebra::APIResource
- Inherits:
-
FatZebraObject
- Object
- FatZebraObject
- FatZebra::APIResource
- Includes:
- APIHelper
- Defined in:
- lib/fat_zebra/api_resource.rb
Overview
FatZebra API Resource
Define the API requests methods
Direct Known Subclasses
Authenticate, BankAccount, Batch, Card, Customer, DirectCredit, DirectDebit, Information, PaymentPlan, Paypal::Authorization, Paypal::BillingAgreement, Paypal::Capture, Paypal::Order, Paypal::Refund, Purchase, Refund, Utilities::ApplePay::Domain, Utilities::Mastercard::ClickToPay::Registration, WebHook
Instance Attribute Summary
Attributes inherited from FatZebraObject
Attributes included from ObjectHelper
Class Method Summary collapse
- .base_path ⇒ Object
-
.request(method, path, payload = {}, options = {}) ⇒ Hash
Send a request to the API.
Methods included from APIHelper
included, #request, #resource_name, #resource_path
Methods inherited from FatZebraObject
initialize_from, #load_response_api, #update_from
Methods included from Validation
#errors, #valid!, #valid?, #validates
Methods included from ObjectHelper
#[], #[]=, #add_accessor, #add_accessors, #add_data, #initialize, #inspect, #keys, #method_missing, #remove_accessor, #to_hash, #to_json, #update_attributes
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class FatZebra::ObjectHelper
Class Method Details
.base_path ⇒ Object
13 14 15 |
# File 'lib/fat_zebra/api_resource.rb', line 13 def base_path "#{configurations.api_version}/" end |
.request(method, path, payload = {}, options = {}) ⇒ Hash
Send a request to the API
rubocop:disable Metrics/AbcSize
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fat_zebra/api_resource.rb', line 28 def request(method, path, payload = {}, = {}) payload[:test] = true if configurations.test_mode payload = Util.format_dates_in_hash(payload) url_params = Util.encode_parameters(payload) if method == :get uri = build_endpoint_url(configurations.gateway, path, url_params, http_secure: configurations.http_secure) = Util.compact( method: method, url: uri.to_s, payload: payload, proxy: configurations.proxy, use_ssl: configurations.http_secure ).merge(authentication).merge(default_headers).merge(configurations.).merge() Request.execute().body rescue FatZebra::RequestError => e return e.http_body if e.http_status == 422 raise end |