Class: Square::TeamMembers::Client
- Inherits:
-
Object
- Object
- Square::TeamMembers::Client
- Defined in:
- lib/square/team_members/client.rb
Instance Method Summary collapse
-
#batch_create(request_options: {}, **params) ⇒ Square::Types::BatchCreateTeamMembersResponse
Creates multiple ‘TeamMember` objects.
-
#batch_update(request_options: {}, **params) ⇒ Square::Types::BatchUpdateTeamMembersResponse
Updates multiple ‘TeamMember` objects.
-
#create(request_options: {}, **params) ⇒ Square::Types::CreateTeamMemberResponse
Creates a single ‘TeamMember` object.
-
#get(request_options: {}, **params) ⇒ Square::Types::GetTeamMemberResponse
Retrieves a ‘TeamMember` object for the given `TeamMember.id`.
- #initialize(client:) ⇒ Square::TeamMembers::Client constructor
-
#search(request_options: {}, **params) ⇒ Square::Types::SearchTeamMembersResponse
Returns a paginated list of ‘TeamMember` objects for a business.
-
#update(request_options: {}, **params) ⇒ Square::Types::UpdateTeamMemberResponse
Updates a single ‘TeamMember` object.
- #wage_setting ⇒ Square::WageSetting::Client
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).
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/square/team_members/client.rb', line 48 def batch_create(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/team-members/bulk-create", body: params ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::BatchCreateTeamMembersResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end 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).
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/square/team_members/client.rb', line 76 def batch_update(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/team-members/bulk-update", body: params ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::BatchUpdateTeamMembersResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end 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 33 34 35 36 37 38 |
# File 'lib/square/team_members/client.rb', line 19 def create(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/team-members", body: Square::Types::CreateTeamMemberRequest.new(params).to_h ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::CreateTeamMemberResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end 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).
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/square/team_members/client.rb', line 127 def get(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/team-members/#{params[:team_member_id]}" ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::GetTeamMemberResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end 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.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/square/team_members/client.rb', line 102 def search(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/team-members/search", body: params ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::SearchTeamMembersResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end 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).
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/square/team_members/client.rb', line 151 def update(request_options: {}, **params) _path_param_names = ["team_member_id"] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "PUT", path: "v2/team-members/#{params[:team_member_id]}", body: params.except(*_path_param_names) ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::UpdateTeamMemberResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#wage_setting ⇒ Square::WageSetting::Client
175 176 177 |
# File 'lib/square/team_members/client.rb', line 175 def wage_setting @wage_setting ||= Square::TeamMembers::WageSetting::Client.new(client: @client) end |