Class: Square::TeamMembers::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/square/team_members/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Square::TeamMembers::Client



7
8
9
# File 'lib/square/team_members/client.rb', line 7

def initialize(client:)
  @client = client
end

Instance Method Details

#batch_create(request_options: {}, **params) ⇒ Square::Types::BatchCreateTeamMembersResponse

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).



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/square/team_members/client.rb', line 42

def batch_create(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/team-members/bulk-create",
    body: params
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::BatchCreateTeamMembersResponse.load(_response.body)
  end

  raise _response.body
end

#batch_update(request_options: {}, **params) ⇒ Square::Types::BatchUpdateTeamMembersResponse

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).



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/square/team_members/client.rb', line 64

def batch_update(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/team-members/bulk-update",
    body: params
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::BatchUpdateTeamMembersResponse.load(_response.body)
  end

  raise _response.body
end

#create(request_options: {}, **params) ⇒ Square::Types::CreateTeamMemberResponse

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#createteammember).



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/square/team_members/client.rb', line 19

def create(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/team-members",
    body: Square::Types::CreateTeamMemberRequest.new(params).to_h
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::CreateTeamMemberResponse.load(_response.body)
  end

  raise _response.body
end

#get(request_options: {}, **params) ⇒ Square::Types::GetTeamMemberResponse

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



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/square/team_members/client.rb', line 103

def get(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "GET",
    path: "v2/team-members/#{params[:team_member_id]}"
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::GetTeamMemberResponse.load(_response.body)
  end

  raise _response.body
end

#search(request_options: {}, **params) ⇒ Square::Types::SearchTeamMembersResponse

Returns a paginated list of ‘TeamMember` objects for a business. The list can be filtered by location IDs, `ACTIVE` or `INACTIVE` status, or whether the team member is the Square account owner.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/square/team_members/client.rb', line 84

def search(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/team-members/search",
    body: params
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::SearchTeamMembersResponse.load(_response.body)
  end

  raise _response.body
end

#update(request_options: {}, **params) ⇒ Square::Types::UpdateTeamMemberResponse

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-team-member).



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/square/team_members/client.rb', line 121

def update(request_options: {}, **params)
  _path_param_names = ["team_member_id"]

  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "PUT",
    path: "v2/team-members/#{params[:team_member_id]}",
    body: params.except(*_path_param_names)
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::UpdateTeamMemberResponse.load(_response.body)
  end

  raise _response.body
end

#wage_settingSquare::WageSetting::Client

Returns:

  • (Square::WageSetting::Client)


139
140
141
# File 'lib/square/team_members/client.rb', line 139

def wage_setting
  @wage_setting ||= Square::TeamMembers::WageSetting::Client.new(client: @client)
end