Class: Timekit::Findtime::Client

Inherits:
Client
  • Object
show all
Defined in:
lib/timekit/findtime/client.rb

Overview

Client class for the findtime resource

Constant Summary collapse

API_PATH =
'/findtime'

Instance Method Summary collapse

Methods inherited from Client

#initialize

Constructor Details

This class inherits a constructor from Timekit::Client

Instance Method Details

#bulk_query(queries) ⇒ Object



40
# File 'lib/timekit/findtime/client.rb', line 40

def bulk_query(queries); end

#query(emails = nil, user_ids = nil, calendar_ids = nil, filters = {}, filtercollection_id = nil, start = nil, future = '2 days', length = '1 hour', sort = 'asc', ignore_all_day_events = false, all_solutions = false) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/timekit/findtime/client.rb', line 9

def query(
  emails = nil,
  user_ids = nil,
  calendar_ids = nil,
  filters = {},
  filtercollection_id = nil,
  start = nil,
  future = '2 days',
  length = '1 hour',
  sort = 'asc',
  ignore_all_day_events = false,
  all_solutions = false
)
  params = {}

  # All args are optional, so we can examine each arg and
  # set it as a key in the params hash if a value exists for the arg
  method(__method__).parameters.map do |_, name|
    value = binding.local_variable_get(name)
    params[name.to_sym] = value if [true, false].include?(value) ||
                                   !value.nil?
  end

  unless params[:emails] || params[:user_ids] || params[:calendar_ids]
    raise 'Entity id required to find time'\
      ' (email,user id,calendar id)'
  end

  post(API_PATH, params)
end