class FXStreet::Client
Attributes
client_id[R]
client_secret[R]
Public Class Methods
new(options={})
click to toggle source
# File lib/fx_street/client.rb, line 10 def initialize(options={}) @client_id = options.fetch(:client_id) { ENV["FX_STREET_CLIENT_ID"] } @client_secret = options.fetch(:client_secret) { ENV["FX_STREET_CLIENT_SECRET"] } end
Public Instance Methods
event_dates(params={})
click to toggle source
# File lib/fx_street/client.rb, line 15 def event_dates(params={}) get("eventdate/", params) end
Private Instance Methods
connection()
click to toggle source
# File lib/fx_street/client.rb, line 21 def connection @connection ||= Faraday.new(host) do |conn| conn.request :json conn.response :rashify conn.response :stripify conn.response :json, content_type: /\bjson$/ conn.adapter Faraday.default_adapter end end
default_params()
click to toggle source
# File lib/fx_street/client.rb, line 33 def default_params { f: "json", k: client_id, s: sha, t: timestamp, view: "day" } end
get(url, params={})
click to toggle source
# File lib/fx_street/client.rb, line 43 def get(url, params={}) connection.get(url, default_params.merge(params)).body end
host()
click to toggle source
# File lib/fx_street/client.rb, line 47 def host "http://calendar.fxstreet.com/" end
sha()
click to toggle source
# File lib/fx_street/client.rb, line 51 def sha Digest::SHA1.hexdigest(client_secret + timestamp) end
timestamp()
click to toggle source
# File lib/fx_street/client.rb, line 55 def timestamp @time ||= Time.now.utc.strftime("%Y%m%d%H%M") end