Class: BookingAutomation::JSONClient
- Inherits:
-
Object
- Object
- BookingAutomation::JSONClient
- Includes:
- HTTParty
- Defined in:
- lib/booking_automation/json_client.rb
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
Instance Method Summary collapse
- #get_bookings(prop_key, options = {}) ⇒ Object
- #get_properties ⇒ Object
- #get_property(prop_key, options = {}) ⇒ Object
-
#initialize(auth_token) ⇒ JSONClient
constructor
A new instance of JSONClient.
Constructor Details
#initialize(auth_token) ⇒ JSONClient
Returns a new instance of JSONClient.
8 9 10 |
# File 'lib/booking_automation/json_client.rb', line 8 def initialize(auth_token) @auth_token = auth_token end |
Instance Attribute Details
#auth_token ⇒ Object
Returns the value of attribute auth_token.
6 7 8 |
# File 'lib/booking_automation/json_client.rb', line 6 def auth_token @auth_token end |
Instance Method Details
#get_bookings(prop_key, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/booking_automation/json_client.rb', line 35 def get_bookings(prop_key, ={}) response = self.class.post( '/getBookings', body: payload(prop_key, Constants::DEFAULT_BOOKING_OPTIONS.merge()) ) parse! response rescue Oj::ParseError raise Error, Constants::PARSE_ERROR_MSG rescue APIError => e e.response end |
#get_properties ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/booking_automation/json_client.rb', line 12 def get_properties response = self.class.post('/getProperties', body: authentication.to_json) json = parse! response json['getProperties'] rescue Oj::ParseError raise Error, Constants::PARSE_ERROR_MSG rescue APIError => e e.response end |
#get_property(prop_key, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/booking_automation/json_client.rb', line 22 def get_property(prop_key, ={}) response = self.class.post( '/getProperty', body: payload(prop_key, Constants::DEFAULT_PROPERTY_OPTIONS.merge()) ) json = parse! response json['getProperty'].first rescue Oj::ParseError raise Error, Constants::PARSE_ERROR_MSG rescue APIError => e e.response end |