Class: Takeout::Client
- Inherits:
-
Object
- Object
- Takeout::Client
- Defined in:
- lib/takeout/client.rb
Constant Summary collapse
- FAILURES =
A constant specifying the kind of event callbacks to raise errors for
[:failure, :missing, :redirect]
Instance Attribute Summary collapse
-
#debug ⇒ Boolean
A boolean specifying whether or not to run curl with teh verbose setting.
-
#endpoints ⇒ Hash
The hash containing the endpoints by request type to generate methods for.
-
#extension ⇒ String
A string with the extension to be appended on each request.
-
#headers ⇒ Hash
A hash specifying the headers to apply to each request.
-
#options ⇒ Hash
A hash specifying the global options to apply to each request.
-
#schemas ⇒ Hash
A hash specifying the custom per-endpoint schema templates.
-
#ssl ⇒ Boolean
A boolean to specify whether or not SSL is turned on.
-
#uri ⇒ String
The uri to send requests to.
Instance Method Summary collapse
-
#disable_ssl ⇒ Object
Flips the @ssl instance variable to false.
-
#enable_ssl ⇒ Object
Flips the @ssl instance variable to true.
-
#initialize(options = {}) ⇒ Client
constructor
The main client initialization method.
-
#ssl? ⇒ Boolean
Check if SSL is enabled.
Constructor Details
#initialize(options = {}) ⇒ Client
The main client initialization method.
Attributes
-
options- The main atrtibute and extra global options to set for the client
Options
-
:uri- A string defining the URI for the API to call. -
:endpoints- A hash containing the endpoints by request type to generate methods for -
:headers- A hash specifying the headers to apply to each request -
:ssl- A boolean to specify whether or not SSL is turned on -
:schemas- A hash specifying the custom per-endpoint schema templates -
:extension- A string with the extension to be appended on each request
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/takeout/client.rb', line 48 def initialize(={}) if block_given? yield self else # Set instance variables @uri = [:uri] ? [:uri] : '' self.endpoints = [:endpoints] ? [:endpoints] : {} @headers = [:headers] ? [:headers] : {} @debug = [:debug] ? [:debug] : false @ssl = [:ssl] ? [:ssl] : false @schemas = [:schemas] ? [:schemas] : {} @extension = [:extension] ? [:extension] : nil # Clean instance variables out of options hash and set that as options instance variable [:uri, :endpoints, :headers, :debug, :ssl, :schemas, :extension].each { |v| .delete(v) } @options = end end |
Instance Attribute Details
#debug ⇒ Boolean
Returns a boolean specifying whether or not to run curl with teh verbose setting.
10 11 12 |
# File 'lib/takeout/client.rb', line 10 def debug @debug end |
#endpoints ⇒ Hash
Returns the hash containing the endpoints by request type to generate methods for.
31 32 33 |
# File 'lib/takeout/client.rb', line 31 def endpoints @endpoints end |
#extension ⇒ String
Returns a string with the extension to be appended on each request.
19 20 21 |
# File 'lib/takeout/client.rb', line 19 def extension @extension end |
#headers ⇒ Hash
Returns a hash specifying the headers to apply to each request.
16 17 18 |
# File 'lib/takeout/client.rb', line 16 def headers @headers end |
#options ⇒ Hash
Returns a hash specifying the global options to apply to each request.
13 14 15 |
# File 'lib/takeout/client.rb', line 13 def @options end |
#schemas ⇒ Hash
Returns a hash specifying the custom per-endpoint schema templates.
25 26 27 |
# File 'lib/takeout/client.rb', line 25 def schemas @schemas end |
#ssl ⇒ Boolean
Returns a boolean to specify whether or not SSL is turned on.
22 23 24 |
# File 'lib/takeout/client.rb', line 22 def ssl @ssl end |
#uri ⇒ String
Returns the uri to send requests to.
28 29 30 |
# File 'lib/takeout/client.rb', line 28 def uri @uri end |
Instance Method Details
#disable_ssl ⇒ Object
Flips the @ssl instance variable to false
86 87 88 |
# File 'lib/takeout/client.rb', line 86 def disable_ssl @ssl=false end |
#enable_ssl ⇒ Object
Flips the @ssl instance variable to true
81 82 83 |
# File 'lib/takeout/client.rb', line 81 def enable_ssl @ssl=true end |
#ssl? ⇒ Boolean
Check if SSL is enabled.
69 70 71 |
# File 'lib/takeout/client.rb', line 69 def ssl? return @ssl end |