Class: WhenIWork::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/wheniwork-ruby/api/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ Api

Returns a new instance of Api.



28
29
30
# File 'lib/wheniwork-ruby/api/api.rb', line 28

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



26
27
28
# File 'lib/wheniwork-ruby/api/api.rb', line 26

def api_client
  @api_client
end

Instance Method Details

#get_positions(opts = {}) ⇒ InlineResponse200

This method allows you to get a list of all positions in your account.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :show_deleted (BOOLEAN)

    Whether to show positions that have been deleted.

Returns:



37
38
39
40
# File 'lib/wheniwork-ruby/api/api.rb', line 37

def get_positions(opts = {})
  data, _status_code, _headers = get_positions_with_http_info(opts)
  return data
end

#get_positions_with_http_info(opts = {}) ⇒ Array<(InlineResponse200, Fixnum, Hash)>

This method allows you to get a list of all positions in your account.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :show_deleted (BOOLEAN)

    Whether to show positions that have been deleted.

Returns:

  • (Array<(InlineResponse200, Fixnum, Hash)>)

    InlineResponse200 data, response status code and response headers



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/wheniwork-ruby/api/api.rb', line 47

def get_positions_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: Api.get_positions ..."
  end
  # resource path
  local_var_path = "/positions".sub('{format}','json')

  # query parameters
  query_params = {}
  query_params[:'show_deleted'] = opts[:'show_deleted'] if opts[:'show_deleted']

  # header parameters
  header_params = {}

  # HTTP header 'Accept' (if needed)
  local_header_accept = ['application/json']
  local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

  # HTTP header 'Content-Type'
  local_header_content_type = ['application/json']
  header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
        auth_names = ['apiKey']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'InlineResponse200')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: Api#get_positions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_shift(shift_id, opts = {}) ⇒ InlineResponse2002

Gets the details of an existing shift.

Parameters:

  • shift_id

    max records to return

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



93
94
95
96
# File 'lib/wheniwork-ruby/api/api.rb', line 93

def get_shift(shift_id, opts = {})
  data, _status_code, _headers = get_shift_with_http_info(shift_id, opts)
  return data
end

#get_shift_with_http_info(shift_id, opts = {}) ⇒ Array<(InlineResponse2002, Fixnum, Hash)>

Gets the details of an existing shift.

Parameters:

  • shift_id

    max records to return

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(InlineResponse2002, Fixnum, Hash)>)

    InlineResponse2002 data, response status code and response headers



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/wheniwork-ruby/api/api.rb', line 103

def get_shift_with_http_info(shift_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: Api.get_shift ..."
  end
  # verify the required parameter 'shift_id' is set
  fail ArgumentError, "Missing the required parameter 'shift_id' when calling Api.get_shift" if shift_id.nil?
  # resource path
  local_var_path = "/shifts/{shift-id}".sub('{format}','json').sub('{' + 'shift-id' + '}', shift_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}

  # HTTP header 'Accept' (if needed)
  local_header_accept = ['application/json']
  local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

  # HTTP header 'Content-Type'
  local_header_content_type = ['application/json']
  header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
        auth_names = ['apiKey']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'InlineResponse2002')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: Api#get_shift\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_shifts(opts = {}) ⇒ InlineResponse2001

Get a list of shifts.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :user_id (String)

    The ID of the user to get shifts for. For multiple users, enter a list of user IDs separated by commas (e.g. 1,5,3).

  • :start_time (DateTime)

    Start time for the search window. The default is the current date and time

  • :end_time (DateTime)

    End time for the search window. The default is exactly three days from the start time.

  • :location_id (String)

    The ID of the location to get shifts for. For multiple locations, enter a list of location IDs separated by commas.

  • :position_id (String)

    The ID of the position to get shifts for. For multiple position, enter a list of position IDs separated by commas.

  • :include_open (BOOLEAN)

    Whether to include OpenShifts in the results.

  • :include_onlyopen (BOOLEAN)

    Whether to include OpenShifts in the results.

  • :unpublished (BOOLEAN)

    Whether unpublished shifts should be included in the results.

Returns:



157
158
159
160
# File 'lib/wheniwork-ruby/api/api.rb', line 157

def get_shifts(opts = {})
  data, _status_code, _headers = get_shifts_with_http_info(opts)
  return data
end

#get_shifts_with_http_info(opts = {}) ⇒ Array<(InlineResponse2001, Fixnum, Hash)>

Get a list of shifts.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :user_id (String)

    The ID of the user to get shifts for. For multiple users, enter a list of user IDs separated by commas (e.g. 1,5,3).

  • :start_date (DateTime)

    Start time for the search window. The default is the current date and time

  • :end_date (DateTime)

    End time for the search window. The default is exactly three days from the start time.

  • :location_id (String)

    The ID of the location to get shifts for. For multiple locations, enter a list of location IDs separated by commas.

  • :position_id (String)

    The ID of the position to get shifts for. For multiple position, enter a list of position IDs separated by commas.

  • :include_open (BOOLEAN)

    Whether to include OpenShifts in the results.

  • :include_onlyopen (BOOLEAN)

    Whether to include OpenShifts in the results.

  • :unpublished (BOOLEAN)

    Whether unpublished shifts should be included in the results.

Returns:

  • (Array<(InlineResponse2001, Fixnum, Hash)>)

    InlineResponse2001 data, response status code and response headers



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/wheniwork-ruby/api/api.rb', line 174

def get_shifts_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: Api.get_shifts ..."
  end
  # resource path
  local_var_path = "/shifts".sub('{format}','json')

  # query parameters
  query_params = {}
  query_params[:'user_id'] = opts[:'user_id'] if opts[:'user_id']
  query_params[:'start'] = opts[:'start_date'] if opts[:'start_date']
  query_params[:'end'] = opts[:'end_date'] if opts[:'end_date']
  query_params[:'location_id'] = opts[:'location_id'] if opts[:'location_id']
  query_params[:'position_id'] = opts[:'position_id'] if opts[:'position_id']
  query_params[:'include_open'] = opts[:'include_open'] if opts[:'include_open']
  query_params[:'include_onlyopen'] = opts[:'include_onlyopen'] if opts[:'include_onlyopen']
  query_params[:'unpublished'] = opts[:'unpublished'] if opts[:'unpublished']

  # header parameters
  header_params = {}

  # HTTP header 'Accept' (if needed)
  local_header_accept = ['application/json']
  local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

  # HTTP header 'Content-Type'
  local_header_content_type = ['application/json']
  header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
        auth_names = ['apiKey']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'InlineResponse2001')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: Api#get_shifts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_user(user_id, opts = {}) ⇒ InlineResponse2003

Get a specific user by their ID.

Parameters:

  • user_id

    The user identifier number

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



227
228
229
230
# File 'lib/wheniwork-ruby/api/api.rb', line 227

def get_user(user_id, opts = {})
  data, _status_code, _headers = get_user_with_http_info(user_id, opts)
  return data
end

#get_user_with_http_info(user_id, opts = {}) ⇒ Array<(InlineResponse2003, Fixnum, Hash)>

Get a specific user by their ID.

Parameters:

  • user_id

    The user identifier number

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(InlineResponse2003, Fixnum, Hash)>)

    InlineResponse2003 data, response status code and response headers



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/wheniwork-ruby/api/api.rb', line 237

def get_user_with_http_info(user_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: Api.get_user ..."
  end
  # verify the required parameter 'user_id' is set
  fail ArgumentError, "Missing the required parameter 'user_id' when calling Api.get_user" if user_id.nil?
  # resource path
  local_var_path = "/users/{user-id}".sub('{format}','json').sub('{' + 'user-id' + '}', user_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}

  # HTTP header 'Accept' (if needed)
  local_header_accept = ['application/json']
  local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

  # HTTP header 'Content-Type'
  local_header_content_type = ['application/json']
  header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
        auth_names = ['apiKey']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'InlineResponse2003')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: Api#get_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_users(opts = {}) ⇒ InlineResponse2003

Get a list of users.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :ids (String)

    The IDs of the users to retrieve, as a comma-separated list (e.g. 9,17,42).

  • :location_id (String)

    The ID of the location to get users for. For multiple locations, enter a list of location IDs separated by commas.

  • :show_deleted (BOOLEAN)

    Whether to include deleted users in the results. Defaults to false.

Returns:



286
287
288
289
# File 'lib/wheniwork-ruby/api/api.rb', line 286

def get_users(opts = {})
  data, status_code, headers = get_users_with_http_info(opts)
  return data
end

#get_users_with_http_info(opts = {}) ⇒ Array<(InlineResponse2003, Fixnum, Hash)>

Get a list of users.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :ids (String)

    The IDs of the users to retrieve, as a comma-separated list (e.g. 9,17,42).

  • :location_id (String)

    The ID of the location to get users for. For multiple locations, enter a list of location IDs separated by commas.

  • :show_deleted (BOOLEAN)

    Whether to include deleted users in the results. Defaults to false.

Returns:

  • (Array<(InlineResponse2003, Fixnum, Hash)>)

    InlineResponse2003 data, response status code and response headers



298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/wheniwork-ruby/api/api.rb', line 298

def get_users_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: DefaultApi#get_users ..."
  end

  # resource path
  local_var_path = "/users".sub('{format}','json')

  # query parameters
  query_params = {}
  query_params[:'ids'] = opts[:'ids'] if opts[:'ids']
  query_params[:'location_id'] = opts[:'location_id'] if opts[:'location_id']
  query_params[:'show_deleted'] = opts[:'show_deleted'] if opts[:'show_deleted']

  # header parameters
  header_params = {}

  # HTTP header 'Accept' (if needed)
  _header_accept = ['application/json']
  _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result

  # HTTP header 'Content-Type'
  _header_content_type = ['application/json']
  header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil

  auth_names = ['apiKey']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'InlineResponse2003')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#get_users\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end