lib/xe_client/client.rb in xe_client-0.2.1 vs lib/xe_client/client.rb in xe_client-1.0.0
- old
+ new
@@ -1,31 +1,19 @@
module XEClient
class Client
- DEFAULT_URL = "https://xecdapi.xe.com"
-
- include Virtus.model
+ include APIClientBase::Client.module(default_opts: :default_opts)
+ attribute :host, String
attribute :account_id, String
attribute :api_key, String
- attribute :url, String, default: DEFAULT_URL
- include ActiveModel::Validations
- validates :account_id, :api_key, presence: true
+ api_action :convert_from
+ api_action :historic_rate_period
- def convert_from(base_currency, counter_currencies, amount)
- args = default_args.merge(
- base_currency: base_currency,
- counter_currencies: counter_currencies,
- amount: amount,
- )
- raw_response = ConvertFromRequest.(args)
- ConvertFromResponse.(raw_response)
- end
-
private
- def default_args
- attributes.slice(:account_id, :api_key, :url)
+ def default_opts
+ { host: host, account_id: account_id, api_key: api_key }
end
end
end