class Io::Flow::Reference::V0::Client

Attributes

url[R]

Public Class Methods

at_base_url(opts={}) click to toggle source

Creates an instance of the client using the base url specified in the API spec.

# File lib/flow_reference_v0_client.rb, line 49
def Client.at_base_url(opts={})
  Client.new(Constants::BASE_URL, opts)
end
new(url, opts={}) click to toggle source
# File lib/flow_reference_v0_client.rb, line 37
def initialize(url, opts={})
  @url = HttpClient::Preconditions.assert_class('url', url, String)
  @base_url = URI(url)
  @authorization = HttpClient::Preconditions.assert_class_or_nil('authorization', opts.delete(:authorization), HttpClient::Authorization)
  @default_headers = HttpClient::Preconditions.assert_class('default_headers', opts.delete(:default_headers) || {}, Hash)
  @http_handler = opts.delete(:http_handler) || HttpClient::DefaultHttpHandler.new

  HttpClient::Preconditions.assert_empty_opts(opts)
  HttpClient::Preconditions.check_state(url.match(/http.+/i), "URL[%s] must start with http" % url)
end

Public Instance Methods

countries() click to toggle source
# File lib/flow_reference_v0_client.rb, line 68
def countries
  @countries ||= ::Io::Flow::Reference::V0::Clients::Countries.new(self)
end
currencies() click to toggle source
# File lib/flow_reference_v0_client.rb, line 72
def currencies
  @currencies ||= ::Io::Flow::Reference::V0::Clients::Currencies.new(self)
end
languages() click to toggle source
# File lib/flow_reference_v0_client.rb, line 76
def languages
  @languages ||= ::Io::Flow::Reference::V0::Clients::Languages.new(self)
end
locales() click to toggle source
# File lib/flow_reference_v0_client.rb, line 80
def locales
  @locales ||= ::Io::Flow::Reference::V0::Clients::Locales.new(self)
end
payment_methods() click to toggle source
# File lib/flow_reference_v0_client.rb, line 84
def payment_methods
  @payment_methods ||= ::Io::Flow::Reference::V0::Clients::PaymentMethods.new(self)
end
provinces() click to toggle source
# File lib/flow_reference_v0_client.rb, line 88
def provinces
  @provinces ||= ::Io::Flow::Reference::V0::Clients::Provinces.new(self)
end
regions() click to toggle source
# File lib/flow_reference_v0_client.rb, line 92
def regions
  @regions ||= ::Io::Flow::Reference::V0::Clients::Regions.new(self)
end
request(path=nil) click to toggle source
# File lib/flow_reference_v0_client.rb, line 53
def request(path=nil)
  HttpClient::Preconditions.assert_class_or_nil('path', path, String)
  request = HttpClient::Request.new(@http_handler, @base_url, path.to_s).with_header('User-Agent', Constants::USER_AGENT).with_header('X-Apidoc-Version', Constants::VERSION).with_header('X-Apidoc-Version-Major', Constants::VERSION_MAJOR)

  @default_headers.each do |key, value|
    request = request.with_header(key, value)
  end

  if @authorization
    request = request.with_auth(@authorization)
  end

  request
end
timezones() click to toggle source
# File lib/flow_reference_v0_client.rb, line 96
def timezones
  @timezones ||= ::Io::Flow::Reference::V0::Clients::Timezones.new(self)
end