Class: Square::TeamApi

Inherits:
BaseApi show all
Defined in:
lib/square/api/team_api.rb

Overview

TeamApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#execute_request, #get_user_agent, #validate_parameters, #validate_parameters_types

Constructor Details

#initialize(config, http_call_back: nil) ⇒ TeamApi

Returns a new instance of TeamApi.



4
5
6
# File 'lib/square/api/team_api.rb', line 4

def initialize(config, http_call_back: nil)
  super(config, http_call_back: http_call_back)
end

Instance Method Details

#bulk_create_team_members(body:) ⇒ BulkCreateTeamMembersResponse Hash

Creates multiple `TeamMember` objects. The created `TeamMember` objects are returned on successful creates. This process is non-transactional and processes as much of the request as possible. If one of the creates in the request cannot be successfully processed, the request is not marked as failed, but the body of the response contains explicit error information for the failed create. Learn about [Troubleshooting the Team API](developer.squareup.com/docs/team/troubleshooting#bulk-create- team-members). containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (BulkCreateTeamMembersRequest)

    Required parameter: An object

Returns:

  • (BulkCreateTeamMembersResponse Hash)

    response from the API call



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/square/api/team_api.rb', line 63

def bulk_create_team_members(body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/team-members/bulk-create'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'Content-Type' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#bulk_update_team_members(body:) ⇒ BulkUpdateTeamMembersResponse Hash

Updates multiple `TeamMember` objects. The updated `TeamMember` objects are returned on successful updates. This process is non-transactional and processes as much of the request as possible. If one of the updates in the request cannot be successfully processed, the request is not marked as failed, but the body of the response contains explicit error information for the failed update. Learn about [Troubleshooting the Team API](developer.squareup.com/docs/team/troubleshooting#bulk-update- team-members). containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (BulkUpdateTeamMembersRequest)

    Required parameter: An object

Returns:

  • (BulkUpdateTeamMembersResponse Hash)

    response from the API call



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
# File 'lib/square/api/team_api.rb', line 106

def bulk_update_team_members(body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/team-members/bulk-update'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'Content-Type' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#create_team_member(body:) ⇒ CreateTeamMemberResponse Hash

Creates a single `TeamMember` object. The `TeamMember` object is returned on successful creates. You must provide the following values in your request to this endpoint:

  • `given_name`

  • `family_name`

Learn about [Troubleshooting the Team API](developer.squareup.com/docs/team/troubleshooting#createteamme mber). containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (CreateTeamMemberRequest)

    Required parameter: An object

Returns:

  • (CreateTeamMemberResponse Hash)

    response from the API call



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/square/api/team_api.rb', line 20

def create_team_member(body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/team-members'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'Content-Type' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#retrieve_team_member(team_member_id:) ⇒ RetrieveTeamMemberResponse Hash

Retrieves a `TeamMember` object for the given `TeamMember.id`. Learn about [Troubleshooting the Team API](developer.squareup.com/docs/team/troubleshooting#retrieve-a-t eam-member). member to retrieve.

Parameters:

  • team_member_id (String)

    Required parameter: The ID of the team

Returns:

  • (RetrieveTeamMemberResponse Hash)

    response from the API call



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
# File 'lib/square/api/team_api.rb', line 179

def retrieve_team_member(team_member_id:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/team-members/{team_member_id}'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'team_member_id' => { 'value' => team_member_id, 'encode' => true }
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.get(
    _query_url,
    headers: _headers
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#retrieve_wage_setting(team_member_id:) ⇒ RetrieveWageSettingResponse Hash

Retrieves a `WageSetting` object for a team member specified by `TeamMember.id`. Learn about [Troubleshooting the Team API](developer.squareup.com/docs/team/troubleshooting#retrievewage setting). member for which to retrieve the wage setting.

Parameters:

  • team_member_id (String)

    Required parameter: The ID of the team

Returns:

  • (RetrieveWageSettingResponse Hash)

    response from the API call



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/square/api/team_api.rb', line 263

def retrieve_wage_setting(team_member_id:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/team-members/{team_member_id}/wage-setting'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'team_member_id' => { 'value' => team_member_id, 'encode' => true }
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.get(
    _query_url,
    headers: _headers
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#search_team_members(body:) ⇒ SearchTeamMembersResponse Hash

Returns a paginated list of `TeamMember` objects for a business. The list can be filtered by the following:

  • location IDs

  • `status`

containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (SearchTeamMembersRequest)

    Required parameter: An object

Returns:

  • (SearchTeamMembersResponse Hash)

    response from the API call



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/square/api/team_api.rb', line 143

def search_team_members(body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/team-members/search'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'Content-Type' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#update_team_member(team_member_id:, body:) ⇒ UpdateTeamMemberResponse Hash

Updates a single `TeamMember` object. The `TeamMember` object is returned on successful updates. Learn about [Troubleshooting the Team API](developer.squareup.com/docs/team/troubleshooting#update-a-tea m-member). member to update. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • team_member_id (String)

    Required parameter: The ID of the team

  • body (UpdateTeamMemberRequest)

    Required parameter: An object

Returns:

  • (UpdateTeamMemberResponse Hash)

    response from the API call



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/square/api/team_api.rb', line 221

def update_team_member(team_member_id:,
                       body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/team-members/{team_member_id}'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'team_member_id' => { 'value' => team_member_id, 'encode' => true }
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'Content-Type' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.put(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#update_wage_setting(team_member_id:, body:) ⇒ UpdateWageSettingResponse Hash

Creates or updates a `WageSetting` object. The object is created if a `WageSetting` with the specified `team_member_id` does not exist. Otherwise, it fully replaces the `WageSetting` object for the team member. The `WageSetting` is returned on a successful update. Learn about [Troubleshooting the Team API](developer.squareup.com/docs/team/troubleshooting#create-or-up date-a-wage-setting). member for which to update the `WageSetting` object. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • team_member_id (String)

    Required parameter: The ID of the team

  • body (UpdateWageSettingRequest)

    Required parameter: An object

Returns:

  • (UpdateWageSettingResponse Hash)

    response from the API call



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
# File 'lib/square/api/team_api.rb', line 308

def update_wage_setting(team_member_id:,
                        body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/team-members/{team_member_id}/wage-setting'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'team_member_id' => { 'value' => team_member_id, 'encode' => true }
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'Content-Type' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.put(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end