Class: Square::SitesApi

Inherits:
BaseApi show all
Defined in:
lib/square/api/sites_api.rb

Overview

SitesApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#execute_request, #get_user_agent, #validate_parameters, #validate_parameters_types

Constructor Details

#initialize(config, http_call_back: nil) ⇒ SitesApi

Returns a new instance of SitesApi.



4
5
6
# File 'lib/square/api/sites_api.rb', line 4

def initialize(config, http_call_back: nil)
  super(config, http_call_back: http_call_back)
end

Instance Method Details

#list_sitesListSitesResponse Hash

Lists the Square Online sites that belong to a seller. Sites are listed in descending order by the `created_at` date. Note: Square Online APIs are publicly available as part of an early access program. For more information, see [Early access program for Square Online APIs](developer.squareup.com/docs/online-api#early-access-program- for-square-online-apis).

Returns:

  • (ListSitesResponse Hash)

    response from the API call



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
# File 'lib/square/api/sites_api.rb', line 16

def list_sites
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/sites'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.get(
    _query_url,
    headers: _headers
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end