Class: Io::Flow::V0::Clients::Timezones

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Timezones

Returns a new instance of Timezones.



3822
3823
3824
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3822

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#get_geolocation_and_timezones(incoming = {}) ⇒ Object

Provides timezone based on address or geolocated IP.



3827
3828
3829
3830
3831
3832
3833
3834
3835
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3827

def get_geolocation_and_timezones(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :address => (x = opts.delete(:address); x.nil? ? nil : HttpClient::Preconditions.assert_class('address', x, String)),
    :ip => (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String))
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/geolocation/timezones").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::Timezone.new(x) }
end

#get_reference_and_timezones(incoming = {}) ⇒ Object

Returns a list of timezones.



3838
3839
3840
3841
3842
3843
3844
3845
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3838

def get_reference_and_timezones(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :q => (x = opts.delete(:q); x.nil? ? nil : HttpClient::Preconditions.assert_class('q', x, String))
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/reference/timezones").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::Timezone.new(x) }
end