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

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from Square::BaseApi

Instance Method Details

#bulk_create_team_members(body:) ⇒ ApiResponse

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:

  • (ApiResponse)

    the complete http response with raw body and status code.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/square/api/team_api.rb', line 47

def bulk_create_team_members(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/team-members/bulk-create',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#bulk_update_team_members(body:) ⇒ ApiResponse

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:

  • (ApiResponse)

    the complete http response with raw body and status code.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/square/api/team_api.rb', line 78

def bulk_update_team_members(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/team-members/bulk-update',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#create_team_member(body:) ⇒ ApiResponse

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:

  • (ApiResponse)

    the complete http response with raw body and status code.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/square/api/team_api.rb', line 16

def create_team_member(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/team-members',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_team_member(team_member_id:) ⇒ ApiResponse

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:

  • (ApiResponse)

    the complete http response with raw body and status code.



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/square/api/team_api.rb', line 127

def retrieve_team_member(team_member_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/team-members/{team_member_id}',
                                 'default')
               .template_param(new_parameter(team_member_id, key: 'team_member_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_wage_setting(team_member_id:) ⇒ ApiResponse

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:

  • (ApiResponse)

    the complete http response with raw body and status code.



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/square/api/team_api.rb', line 182

def retrieve_wage_setting(team_member_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/team-members/{team_member_id}/wage-setting',
                                 'default')
               .template_param(new_parameter(team_member_id, key: 'team_member_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#search_team_members(body:) ⇒ ApiResponse

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:

  • (ApiResponse)

    the complete http response with raw body and status code.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/square/api/team_api.rb', line 103

def search_team_members(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/team-members/search',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#update_team_member(team_member_id:, body:) ⇒ ApiResponse

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:

  • (ApiResponse)

    the complete http response with raw body and status code.



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/square/api/team_api.rb', line 154

def update_team_member(team_member_id:,
                       body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/v2/team-members/{team_member_id}',
                                 'default')
               .template_param(new_parameter(team_member_id, key: 'team_member_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#update_wage_setting(team_member_id:, body:) ⇒ ApiResponse

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:

  • (ApiResponse)

    the complete http response with raw body and status code.



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/square/api/team_api.rb', line 212

def update_wage_setting(team_member_id:,
                        body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/v2/team-members/{team_member_id}/wage-setting',
                                 'default')
               .template_param(new_parameter(team_member_id, key: 'team_member_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end