class Square::TeamApi

TeamApi

Public Class Methods

new(config, http_call_back: nil) click to toggle source
Calls superclass method Square::BaseApi::new
# 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

Public Instance Methods

bulk_create_team_members(body:) click to toggle source

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). @param [BulkCreateTeamMembersRequest] body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. @return [BulkCreateTeamMembersResponse Hash] response from the API call

# 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:) click to toggle source

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). @param [BulkUpdateTeamMembersRequest] body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. @return [BulkUpdateTeamMembersResponse Hash] response from the API call

# 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:) click to toggle source

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). @param [CreateTeamMemberRequest] body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. @return [CreateTeamMemberResponse Hash] response from the API call

# 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:) click to toggle source

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). @param [String] team_member_id Required parameter: The ID of the team member to retrieve. @return [RetrieveTeamMemberResponse Hash] response from the API call

# 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:) click to toggle source

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). @param [String] team_member_id Required parameter: The ID of the team member for which to retrieve the wage setting. @return [RetrieveWageSettingResponse Hash] response from the API call

# 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:) click to toggle source

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

  • location IDs

  • ‘status`

@param [SearchTeamMembersRequest] body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. @return [SearchTeamMembersResponse Hash] response from the API call

# 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:) click to toggle source

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). @param [String] team_member_id Required parameter: The ID of the team member to update. @param [UpdateTeamMemberRequest] body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. @return [UpdateTeamMemberResponse Hash] response from the API call

# 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:) click to toggle source

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). @param [String] team_member_id Required parameter: The ID of the team member for which to update the `WageSetting` object. @param [UpdateWageSettingRequest] body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. @return [UpdateWageSettingResponse Hash] response from the API call

# 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