Class: Square::LocationsApi
- Defined in:
- lib/square/api/locations_api.rb
Overview
LocationsApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#create_location(body:) ⇒ ApiResponse
Creates a [location](developer.squareup.com/docs/locations-api).
-
#list_locations ⇒ ApiResponse
Provides details about all of the seller’s [locations](developer.squareup.com/docs/locations-api), including those with an inactive status.
-
#retrieve_location(location_id:) ⇒ ApiResponse
Retrieves details of a single location.
-
#update_location(location_id:, body:) ⇒ ApiResponse
Updates a [location](developer.squareup.com/docs/locations-api).
Methods inherited from BaseApi
#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from Square::BaseApi
Instance Method Details
#create_location(body:) ⇒ ApiResponse
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. containing the fields to POST for the request. See the corresponding object definition for field details.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/square/api/locations_api.rb', line 37 def create_location(body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/locations', 'default') .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#list_locations ⇒ ApiResponse
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`.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/square/api/locations_api.rb', line 9 def list_locations new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/locations', 'default') .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#retrieve_location(location_id:) ⇒ ApiResponse
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). retrieve. Specify the string “main” to return the main location.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/square/api/locations_api.rb', line 61 def retrieve_location(location_id:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/locations/{location_id}', 'default') .template_param(new_parameter(location_id, key: 'location_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#update_location(location_id:, body:) ⇒ ApiResponse
Updates a [location](developer.squareup.com/docs/locations-api). update. containing the fields to POST for the request. See the corresponding object definition for field details.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/square/api/locations_api.rb', line 84 def update_location(location_id:, body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::PUT, '/v2/locations/{location_id}', 'default') .template_param(new_parameter(location_id, key: 'location_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |