Class: Square::TeamMembers::WageSetting::Client
- Inherits:
-
Object
- Object
- Square::TeamMembers::WageSetting::Client
- Defined in:
- lib/square/team_members/wage_setting/client.rb
Instance Method Summary collapse
-
#get(request_options: {}, **params) ⇒ Square::Types::GetWageSettingResponse
Retrieves a ‘WageSetting` object for a team member specified by `TeamMember.id`.
- #initialize(client:) ⇒ void constructor
-
#update(request_options: {}, **params) ⇒ Square::Types::UpdateWageSettingResponse
Creates or updates a ‘WageSetting` object.
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/square/team_members/wage_setting/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#get(request_options: {}, **params) ⇒ Square::Types::GetWageSettingResponse
Retrieves a ‘WageSetting` object for a team member specified by `TeamMember.id`. For more information, see [Troubleshooting the Team API](developer.squareup.com/docs/team/troubleshooting#retrievewagesetting).
Square recommends using [RetrieveTeamMember](api-endpoint:Team-RetrieveTeamMember) or [SearchTeamMembers](api-endpoint:Team-SearchTeamMembers) to get this information directly from the ‘TeamMember.wage_setting` field.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/square/team_members/wage_setting/client.rb', line 32 def get(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/team-members/#{params[:team_member_id]}/wage-setting", request_options: ) 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::GetWageSettingResponse.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::UpdateWageSettingResponse
Creates or updates a ‘WageSetting` object. The object is created if a `WageSetting` with the specified `team_member_id` doesn’t exist. Otherwise, it fully replaces the ‘WageSetting` object for the team member. The `WageSetting` is returned on a successful update. For more information, see [Troubleshooting the Team API](developer.squareup.com/docs/team/troubleshooting#create-or-update-a-wage-setting).
Square recommends using [CreateTeamMember](api-endpoint:Team-CreateTeamMember) or [UpdateTeamMember](api-endpoint:Team-UpdateTeamMember) to manage the ‘TeamMember.wage_setting` field directly.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/square/team_members/wage_setting/client.rb', line 75 def update(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request_data = Square::TeamMembers::WageSetting::Types::UpdateWageSettingRequest.new(params).to_h non_body_param_names = ["team_member_id"] body = request_data.except(*non_body_param_names) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "v2/team-members/#{params[:team_member_id]}/wage-setting", body: body, request_options: ) 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::UpdateWageSettingResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |