Class: Aladtec::Client
- Inherits:
-
Object
- Object
- Aladtec::Client
- Defined in:
- lib/aladtec/client.rb
Instance Method Summary collapse
-
#auth(username, password) ⇒ Object
Public: Authenticate member.
-
#events(options = {}) ⇒ Object
Public: Get a list of events for a date or range of dates.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#members ⇒ Object
Public: Get a list of members.
-
#scheduled_now(options = {}) ⇒ Object
Public: Get list of members scheduled now.
-
#scheduled_range(options = {}) ⇒ Object
Public: Get list of members scheduled in a time range.
-
#schedules ⇒ Object
Public: Get a list of schedules.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 21 22 |
# File 'lib/aladtec/client.rb', line 16 def initialize(={}) = Aladtec..merge() Configuration::VALID_CONFIG_KEYS.each do |key| public_send("#{key}=", [key]) end end |
Instance Method Details
#auth(username, password) ⇒ Object
Public: Authenticate member
49 50 51 52 |
# File 'lib/aladtec/client.rb', line 49 def auth(username, password) body = request(:authenticateMember, memun: username, mempw: password) Authentication.new(body["results"]["authentication"]) end |
#events(options = {}) ⇒ Object
Public: Get a list of events for a date or range of dates
options - The Hash options used to refine the selection (default: {}):
:begin_date - The begin date to return events for (required).
:end_date - The end date to return events for (optional).
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/aladtec/client.rb', line 29 def events( = {}) bd = .fetch(:begin_date) { raise ArgumentError, "You must supply a :begin_date option!"} ed = .fetch(:end_date, nil) bd = bd.is_a?(Date) ? bd.iso8601 : Date.parse(bd).iso8601 if ed ed = ed.is_a?(Date) ? ed.iso8601 : Date.parse(ed).iso8601 end body = request(:getEvents, bd: bd, ed: ed) fetch_map(body, "events", "event", Event) end |
#members ⇒ Object
Public: Get a list of members
42 43 44 45 |
# File 'lib/aladtec/client.rb', line 42 def members body = request(:getMembers, ia: 'all') fetch_map(body, "members", "member", Member) end |
#scheduled_now(options = {}) ⇒ Object
Public: Get list of members scheduled now
62 63 64 65 |
# File 'lib/aladtec/client.rb', line 62 def scheduled_now( = {}) body = request(:getScheduledTimeNow, {isp: 1}.merge()) fetch_map(body, "schedules", "schedule", Schedule) end |
#scheduled_range(options = {}) ⇒ Object
Public: Get list of members scheduled in a time range
options - The Hash options used to refine the selection (default: {}):
:begin_time - The begin time to return events for (required).
:end_time - The end time to return events for (required).
:sch - Array of schedule ids to fetch
73 74 75 76 77 78 79 80 81 |
# File 'lib/aladtec/client.rb', line 73 def scheduled_range( = {}) bt = .fetch(:begin_time) { raise ArgumentError, "You must supply a :begin_time!"} et = .fetch(:end_time) { raise ArgumentError, "You must supply an :end_time!"} sch = Array(.fetch(:sch, "all")).join(",") bt = bt.is_a?(Time) ? bt.clone.utc.iso8601 : Time.parse(bt).utc.iso8601 et = et.is_a?(Time) ? et.clone.utc.iso8601 : Time.parse(et).utc.iso8601 body = request(:getScheduledTimeRanges, bt: bt, et: et, isp: 1, sch: sch) fetch_map(body, "ranges", "range", Range) end |
#schedules ⇒ Object
Public: Get a list of schedules
56 57 58 59 |
# File 'lib/aladtec/client.rb', line 56 def schedules body = request(:getSchedules, isp: 1) fetch_map(body, "schedules", "schedule", Schedule) end |