Class: Io::Flow::Reference::V0::Client
- Inherits:
-
Object
- Object
- Io::Flow::Reference::V0::Client
- Defined in:
- lib/io_flow_reference_v0.rb
Defined Under Namespace
Modules: Constants
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
-
.at_base_url(opts = {}) ⇒ Object
Creates an instance of the client using the base url specified in the API spec.
Instance Method Summary collapse
- #countries ⇒ Object
- #currencies ⇒ Object
-
#initialize(url, opts = {}) ⇒ Client
constructor
A new instance of Client.
- #languages ⇒ Object
- #locales ⇒ Object
- #regions ⇒ Object
- #request(path = nil) ⇒ Object
- #timezones ⇒ Object
Constructor Details
#initialize(url, opts = {}) ⇒ Client
Returns a new instance of Client.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/io_flow_reference_v0.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 |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
35 36 37 |
# File 'lib/io_flow_reference_v0.rb', line 35 def url @url end |
Class Method Details
Instance Method Details
#countries ⇒ Object
68 69 70 |
# File 'lib/io_flow_reference_v0.rb', line 68 def countries @countries ||= ::Io::Flow::Reference::V0::Clients::Countries.new(self) end |
#currencies ⇒ Object
72 73 74 |
# File 'lib/io_flow_reference_v0.rb', line 72 def currencies @currencies ||= ::Io::Flow::Reference::V0::Clients::Currencies.new(self) end |
#languages ⇒ Object
76 77 78 |
# File 'lib/io_flow_reference_v0.rb', line 76 def languages @languages ||= ::Io::Flow::Reference::V0::Clients::Languages.new(self) end |
#locales ⇒ Object
80 81 82 |
# File 'lib/io_flow_reference_v0.rb', line 80 def locales @locales ||= ::Io::Flow::Reference::V0::Clients::Locales.new(self) end |
#regions ⇒ Object
84 85 86 |
# File 'lib/io_flow_reference_v0.rb', line 84 def regions @regions ||= ::Io::Flow::Reference::V0::Clients::Regions.new(self) end |
#request(path = nil) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/io_flow_reference_v0.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 |