Class: Square::Team::Client
- Inherits:
-
Object
- Object
- Square::Team::Client
- Defined in:
- lib/square/team/client.rb
Instance Method Summary collapse
-
#create_job(request_options: {}, **params) ⇒ Square::Types::CreateJobResponse
Creates a job in a seller account.
- #initialize(client:) ⇒ Square::Team::Client constructor
-
#list_jobs(request_options: {}, **params) ⇒ Square::Types::ListJobsResponse
Lists jobs in a seller account.
-
#retrieve_job(request_options: {}, **params) ⇒ Square::Types::RetrieveJobResponse
Retrieves a specified job.
-
#update_job(request_options: {}, **params) ⇒ Square::Types::UpdateJobResponse
Updates the title or tip eligibility of a job.
Constructor Details
#initialize(client:) ⇒ Square::Team::Client
7 8 9 |
# File 'lib/square/team/client.rb', line 7 def initialize(client:) @client = client end |
Instance Method Details
#create_job(request_options: {}, **params) ⇒ Square::Types::CreateJobResponse
Creates a job in a seller account. A job defines a title and tip eligibility. Note that compensation is defined in a [job assignment](entity:JobAssignment) in a team member’s wage setting.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/square/team/client.rb', line 46 def create_job(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/team-members/jobs", 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::CreateJobResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#list_jobs(request_options: {}, **params) ⇒ Square::Types::ListJobsResponse
Lists jobs in a seller account. Results are sorted by title in ascending order.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/square/team/client.rb', line 14 def list_jobs(request_options: {}, **params) _query_param_names = [ ["cursor"], %i[cursor] ].flatten _query = params.slice(*_query_param_names) params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/team-members/jobs", query: _query ) 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::ListJobsResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#retrieve_job(request_options: {}, **params) ⇒ Square::Types::RetrieveJobResponse
Retrieves a specified job.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/square/team/client.rb', line 70 def retrieve_job(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/team-members/jobs/#{params[:job_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::RetrieveJobResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#update_job(request_options: {}, **params) ⇒ Square::Types::UpdateJobResponse
Updates the title or tip eligibility of a job. Changes to the title propagate to all ‘JobAssignment`, `Shift`, and `TeamMemberWage` objects that reference the job ID. Changes to tip eligibility propagate to all `TeamMemberWage` objects that reference the job ID.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/square/team/client.rb', line 95 def update_job(request_options: {}, **params) _path_param_names = ["job_id"] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "PUT", path: "v2/team-members/jobs/#{params[:job_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::UpdateJobResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |