Class: Airwallex::Rate

Inherits:
APIResource show all
Extended by:
APIOperations::List, APIOperations::Retrieve
Defined in:
lib/airwallex/resources/rate.rb

Overview

Rate resource for real-time exchange rates

Get indicative exchange rates for currency pairs. Rates are real-time but not locked - use Quote for guaranteed rates.

Examples:

Get current rate

rate = Airwallex::Rate.retrieve(buy_currency: 'EUR', sell_currency: 'USD')
puts "1 USD = #{rate.client_rate} EUR"

Get multiple rates (Note: API may not support multiple at once)

rate = Airwallex::Rate.retrieve(
  buy_currency: 'EUR',
  sell_currency: 'USD'
)

Instance Attribute Summary

Attributes inherited from APIResource

#attributes, #id

Class Method Summary collapse

Methods included from APIOperations::Retrieve

retrieve

Methods included from APIOperations::List

list

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_pathObject



23
24
25
# File 'lib/airwallex/resources/rate.rb', line 23

def self.resource_path
  "/api/v1/fx/rates/current"
end

.retrieve(params = {}) ⇒ Object

Override retrieve to handle query parameters instead of ID



28
29
30
31
# File 'lib/airwallex/resources/rate.rb', line 28

def self.retrieve(params = {})
  response = Airwallex.client.get(resource_path, params)
  new(response)
end