Class: Square::CashDrawers::Shifts::Client
- Inherits:
-
Object
- Object
- Square::CashDrawers::Shifts::Client
- Defined in:
- lib/square/cash_drawers/shifts/client.rb
Instance Method Summary collapse
-
#get(request_options: {}, **params) ⇒ Square::Types::GetCashDrawerShiftResponse
Provides the summary details for a single cash drawer shift.
- #initialize(client:) ⇒ Square::CashDrawers::Shifts::Client constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListCashDrawerShiftsResponse
Provides the details for all of the cash drawer shifts for a location in a date range.
-
#list_events(request_options: {}, **params) ⇒ Square::Types::ListCashDrawerShiftEventsResponse
Provides a paginated list of events for a single cash drawer shift.
Constructor Details
#initialize(client:) ⇒ Square::CashDrawers::Shifts::Client
8 9 10 |
# File 'lib/square/cash_drawers/shifts/client.rb', line 8 def initialize(client:) @client = client end |
Instance Method Details
#get(request_options: {}, **params) ⇒ Square::Types::GetCashDrawerShiftResponse
Provides the summary details for a single cash drawer shift. See [ListCashDrawerShiftEvents](api-endpoint:CashDrawers-ListCashDrawerShiftEvents) for a list of cash drawer shift events.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/square/cash_drawers/shifts/client.rb', line 48 def get(request_options: {}, **params) _query_param_names = [ ["location_id"], %i[location_id] ].flatten _query = params.slice(*_query_param_names) params = params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/cash-drawers/shifts/#{params[:shift_id]}", 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::GetCashDrawerShiftResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#list(request_options: {}, **params) ⇒ Square::Types::ListCashDrawerShiftsResponse
Provides the details for all of the cash drawer shifts for a location in a date range.
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 41 42 |
# File 'lib/square/cash_drawers/shifts/client.rb', line 16 def list(request_options: {}, **params) _query_param_names = [ %w[location_id sort_order begin_time end_time limit cursor], %i[location_id sort_order begin_time end_time limit 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/cash-drawers/shifts", 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::ListCashDrawerShiftsResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#list_events(request_options: {}, **params) ⇒ Square::Types::ListCashDrawerShiftEventsResponse
Provides a paginated list of events for a single cash drawer shift.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/square/cash_drawers/shifts/client.rb', line 79 def list_events(request_options: {}, **params) _query_param_names = [ %w[location_id limit cursor], %i[location_id limit cursor] ].flatten _query = params.slice(*_query_param_names) params = params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/cash-drawers/shifts/#{params[:shift_id]}/events", 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::ListCashDrawerShiftEventsResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |