Class: Datelist
- Inherits:
-
Object
- Object
- Datelist
- Defined in:
- lib/datelist.rb
Instance Method Summary collapse
-
#initialize(api_key) ⇒ Datelist
constructor
A new instance of Datelist.
- #list_booked_slots(filters = {}) ⇒ Object
- #list_calendars(filters = {}) ⇒ Object
- #list_products(filters = {}) ⇒ Object
- #update_booked_slot(id, data) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ Datelist
Returns a new instance of Datelist.
4 5 6 7 8 9 10 11 |
# File 'lib/datelist.rb', line 4 def initialize(api_key) @api_key = api_key @headers = { 'Accept': 'application/json', 'Authorization': @api_key, 'Content-type': 'application/json' } end |
Instance Method Details
#list_booked_slots(filters = {}) ⇒ Object
23 24 25 26 |
# File 'lib/datelist.rb', line 23 def list_booked_slots(filters={}) url = 'https://datelist.io/api/booked_slots?' + URI.encode_www_form(filters.to_a) JSON.parse(HTTParty.get(url, headers: @headers).response.body) end |
#list_calendars(filters = {}) ⇒ Object
13 14 15 16 |
# File 'lib/datelist.rb', line 13 def list_calendars(filters={}) url = 'https://datelist.io/api/calendars?' + URI.encode_www_form(filters.to_a) JSON.parse(HTTParty.get(url, headers: @headers).response.body) end |
#list_products(filters = {}) ⇒ Object
18 19 20 21 |
# File 'lib/datelist.rb', line 18 def list_products(filters={}) url = 'https://datelist.io/api/products?' + URI.encode_www_form(filters.to_a) JSON.parse(HTTParty.get(url, headers: @headers).response.body) end |
#update_booked_slot(id, data) ⇒ Object
28 29 30 31 |
# File 'lib/datelist.rb', line 28 def update_booked_slot(id, data) url = 'https://datelist.io/api/booked_slots/' + id.to_s JSON.parse(HTTParty.patch(url, body: data.to_json, headers: @headers).response.body) end |