Class: Square::Locations::Client
- Inherits:
-
Object
- Object
- Square::Locations::Client
- Defined in:
- lib/square/locations/client.rb
Instance Method Summary collapse
-
#checkouts(request_options: {}, **params) ⇒ Square::Types::CreateCheckoutResponse
Links a ‘checkoutId` to a `checkout_page_url` that customers are directed to in order to provide their payment information using a payment processing workflow hosted on connect.squareup.com.
-
#create(request_options: {}, **params) ⇒ Square::Types::CreateLocationResponse
Creates a [location](developer.squareup.com/docs/locations-api).
- #custom_attribute_definitions ⇒ Square::CustomAttributeDefinitions::Client
- #custom_attributes ⇒ Square::CustomAttributes::Client
-
#get(request_options: {}, **params) ⇒ Square::Types::GetLocationResponse
Retrieves details of a single location.
- #initialize(client:) ⇒ Square::Locations::Client constructor
-
#list(request_options: {}, **_params) ⇒ Square::Types::ListLocationsResponse
Provides details about all of the seller’s [locations](developer.squareup.com/docs/locations-api), including those with an inactive status.
- #transactions ⇒ Square::Transactions::Client
-
#update(request_options: {}, **params) ⇒ Square::Types::UpdateLocationResponse
Updates a [location](developer.squareup.com/docs/locations-api).
Constructor Details
#initialize(client:) ⇒ Square::Locations::Client
7 8 9 |
# File 'lib/square/locations/client.rb', line 7 def initialize(client:) @client = client end |
Instance Method Details
#checkouts(request_options: {}, **params) ⇒ Square::Types::CreateCheckoutResponse
Links a ‘checkoutId` to a `checkout_page_url` that customers are directed to in order to provide their payment information using a payment processing workflow hosted on connect.squareup.com.
NOTE: The Checkout API has been updated with new features. For more information, see [Checkout API highlights](developer.squareup.com/docs/checkout-api#checkout-api-highlights).
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/square/locations/client.rb', line 124 def checkouts(request_options: {}, **params) _path_param_names = ["location_id"] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/locations/#{params[:location_id]}/checkouts", 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::CreateCheckoutResponse.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::CreateLocationResponse
Creates a [location](developer.squareup.com/docs/locations-api). Creating new locations allows for separate configuration of receipt layouts, item prices, and sales reports. Developers can use locations to separate sales activity through applications that integrate with Square from sales activity elsewhere in a seller’s account. Locations created programmatically with the Locations API last forever and are visible to the seller for their own management. Therefore, ensure that each location has a sensible and unique name.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/square/locations/client.rb', line 44 def create(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/locations", 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::CreateLocationResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#custom_attribute_definitions ⇒ Square::CustomAttributeDefinitions::Client
148 149 150 |
# File 'lib/square/locations/client.rb', line 148 def custom_attribute_definitions @custom_attribute_definitions ||= Square::Locations::CustomAttributeDefinitions::Client.new(client: @client) end |
#custom_attributes ⇒ Square::CustomAttributes::Client
153 154 155 |
# File 'lib/square/locations/client.rb', line 153 def custom_attributes @custom_attributes ||= Square::Locations::CustomAttributes::Client.new(client: @client) end |
#get(request_options: {}, **params) ⇒ Square::Types::GetLocationResponse
Retrieves details of a single location. Specify “main” as the location ID to retrieve details of the [main location](developer.squareup.com/docs/locations-api#about-the-main-location).
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/square/locations/client.rb', line 69 def get(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/locations/#{params[:location_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::GetLocationResponse.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::ListLocationsResponse
Provides details about all of the seller’s [locations](developer.squareup.com/docs/locations-api), including those with an inactive status. Locations are listed alphabetically by ‘name`.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/square/locations/client.rb', line 15 def list(request_options: {}, **_params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/locations" ) 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::ListLocationsResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#transactions ⇒ Square::Transactions::Client
158 159 160 |
# File 'lib/square/locations/client.rb', line 158 def transactions @transactions ||= Square::Locations::Transactions::Client.new(client: @client) end |
#update(request_options: {}, **params) ⇒ Square::Types::UpdateLocationResponse
Updates a [location](developer.squareup.com/docs/locations-api).
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/square/locations/client.rb', line 92 def update(request_options: {}, **params) _path_param_names = ["location_id"] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "PUT", path: "v2/locations/#{params[:location_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::UpdateLocationResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |