Class: Airwallex::Quote
- Inherits:
-
APIResource
- Object
- APIResource
- Airwallex::Quote
- Extended by:
- APIOperations::Create, APIOperations::Retrieve
- Defined in:
- lib/airwallex/resources/quote.rb
Overview
Quote resource for locked exchange rates
Create quotes to lock exchange rates for a short period (typically 30-60 seconds). Use quotes to guarantee the rate when executing conversions.
Instance Attribute Summary
Attributes inherited from APIResource
Class Method Summary collapse
Instance Method Summary collapse
-
#expired? ⇒ Boolean
Check if quote has expired.
-
#seconds_until_expiration ⇒ Integer?
Get seconds until expiration.
Methods included from APIOperations::Create
Methods included from APIOperations::Retrieve
Methods inherited from APIResource
#changed_attributes, #dirty?, #initialize, #inspect, #method_missing, #refresh, #refresh_from, resource_name, #respond_to_missing?, #to_hash, #to_json, #to_s
Constructor Details
This class inherits a constructor from Airwallex::APIResource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Airwallex::APIResource
Class Method Details
.resource_path ⇒ Object
24 25 26 |
# File 'lib/airwallex/resources/quote.rb', line 24 def self.resource_path "/api/v1/fx/quotes" end |
Instance Method Details
#expired? ⇒ Boolean
Check if quote has expired
31 32 33 34 35 36 37 |
# File 'lib/airwallex/resources/quote.rb', line 31 def expired? return false unless respond_to?(:expires_at) && expires_at Time.parse(expires_at) < Time.now rescue ArgumentError true end |
#seconds_until_expiration ⇒ Integer?
Get seconds until expiration
42 43 44 45 46 47 48 49 |
# File 'lib/airwallex/resources/quote.rb', line 42 def seconds_until_expiration return nil unless respond_to?(:expires_at) && expires_at remaining = Time.parse(expires_at) - Time.now [remaining.to_i, 0].max rescue ArgumentError 0 end |