Class: BerlinBuehnen::Client
- Inherits:
-
Object
- Object
- BerlinBuehnen::Client
- Includes:
- HTTMultiParty
- Defined in:
- lib/berlin_buehnen/client.rb
Constant Summary collapse
- USER_AGENT =
"ASK HELMUT BerlinBuehnen API Wrapper #{VERSION}"
- API_USERNAME_PARAM_NAME =
"username"
- API_KEY_PARAM_NAME =
"api_key"
- API_VERSION =
"v1"
- API_FORMAT =
"json"
- DEFAULT_OPTIONS =
{ site: "www.berlin-buehnen.de", language: "de" }
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #api_host ⇒ Object
- #api_key ⇒ Object
- #api_language ⇒ Object
- #api_url ⇒ Object
-
#api_username ⇒ Object
accessors for options.
- #get(path, query = {}, options = {}) ⇒ Object
- #head(path, query = {}, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #site ⇒ Object (also: #host)
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
17 18 19 20 21 |
# File 'lib/berlin_buehnen/client.rb', line 17 def initialize( = {}) () raise ArgumentError, "An api key must be present" if api_key.nil? raise ArgumentError, "An api username must be present" if api_username.nil? end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'lib/berlin_buehnen/client.rb', line 14 def @options end |
Instance Method Details
#api_host ⇒ Object
49 50 51 |
# File 'lib/berlin_buehnen/client.rb', line 49 def api_host host end |
#api_key ⇒ Object
40 41 42 |
# File 'lib/berlin_buehnen/client.rb', line 40 def api_key @options[:api_key] end |
#api_language ⇒ Object
53 54 55 |
# File 'lib/berlin_buehnen/client.rb', line 53 def api_language @options[:language] end |
#api_url ⇒ Object
57 58 59 |
# File 'lib/berlin_buehnen/client.rb', line 57 def api_url [api_host, api_language, "api", API_VERSION].join("/") end |
#api_username ⇒ Object
accessors for options
36 37 38 |
# File 'lib/berlin_buehnen/client.rb', line 36 def api_username @options[:username] end |
#get(path, query = {}, options = {}) ⇒ Object
23 24 25 26 27 |
# File 'lib/berlin_buehnen/client.rb', line 23 def get(path, query={}, ={}) handle_response { self.class.get(*construct_query_arguments(path, .merge(:query => query))) } end |
#head(path, query = {}, options = {}) ⇒ Object
29 30 31 32 33 |
# File 'lib/berlin_buehnen/client.rb', line 29 def head(path, query={}, ={}) handle_response { self.class.head(*construct_query_arguments(path, .merge(:query => query))) } end |
#site ⇒ Object Also known as: host
44 45 46 |
# File 'lib/berlin_buehnen/client.rb', line 44 def site @options[:site] end |