Class: Reservix::Client
- Inherits:
-
Object
- Object
- Reservix::Client
- Includes:
- HTTMultiParty
- Defined in:
- lib/reservix/client.rb
Constant Summary collapse
- USER_AGENT =
"ASK HELMUT Reservix API Wrapper #{VERSION}"
- API_KEY_PARAM_NAME =
"api-key"
- API_SUBHOST =
"api"
- API_VERSION =
"1"
- DEFAULT_OPTIONS =
{ site: "reservix.de", use_ssl: true, api_module: "sale" }
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #api_host ⇒ Object
-
#api_key ⇒ Object
accessors for options.
- #api_module ⇒ Object
- #api_url ⇒ Object
- #delete(path, query = {}, options = {}) ⇒ Object
- #get(path, query = {}, options = {}) ⇒ Object
- #head(path, query = {}, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #post(path, body = {}, options = {}) ⇒ Object
- #put(path, body = {}, options = {}) ⇒ Object
- #site ⇒ Object (also: #host)
- #use_ssl? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
17 18 19 20 |
# File 'lib/reservix/client.rb', line 17 def initialize( = {}) () raise ArgumentError, "An api key must be present" if api_key.nil? end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'lib/reservix/client.rb', line 14 def @options end |
Instance Method Details
#api_host ⇒ Object
70 71 72 |
# File 'lib/reservix/client.rb', line 70 def api_host [API_SUBHOST, host].join(".") end |
#api_key ⇒ Object
accessors for options
53 54 55 |
# File 'lib/reservix/client.rb', line 53 def api_key @options[:api_key] end |
#api_module ⇒ Object
61 62 63 |
# File 'lib/reservix/client.rb', line 61 def api_module @options[:api_module] end |
#api_url ⇒ Object
74 75 76 |
# File 'lib/reservix/client.rb', line 74 def api_url [api_host, API_VERSION, api_module].join("/") end |
#delete(path, query = {}, options = {}) ⇒ Object
40 41 42 43 44 |
# File 'lib/reservix/client.rb', line 40 def delete(path, query={}, ={}) handle_response { self.class.delete(*construct_query_arguments(path, .merge(:query => query))) } end |
#get(path, query = {}, options = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/reservix/client.rb', line 22 def get(path, query={}, ={}) handle_response { self.class.get(*construct_query_arguments(path, .merge(:query => query))) } end |
#head(path, query = {}, options = {}) ⇒ Object
46 47 48 49 50 |
# File 'lib/reservix/client.rb', line 46 def head(path, query={}, ={}) handle_response { self.class.head(*construct_query_arguments(path, .merge(:query => query))) } end |
#post(path, body = {}, options = {}) ⇒ Object
28 29 30 31 32 |
# File 'lib/reservix/client.rb', line 28 def post(path, body={}, ={}) handle_response { self.class.post(*construct_query_arguments(path, .merge(:body => body), :body)) } end |
#put(path, body = {}, options = {}) ⇒ Object
34 35 36 37 38 |
# File 'lib/reservix/client.rb', line 34 def put(path, body={}, ={}) handle_response { self.class.put(*construct_query_arguments(path, .merge(:body => body), :body)) } end |
#site ⇒ Object Also known as: host
65 66 67 |
# File 'lib/reservix/client.rb', line 65 def site @options[:site] end |
#use_ssl? ⇒ Boolean
57 58 59 |
# File 'lib/reservix/client.rb', line 57 def use_ssl? @options[:use_ssl] end |