Class: Square::Sites::Client
- Inherits:
-
Object
- Object
- Square::Sites::Client
- Defined in:
- lib/square/sites/client.rb
Instance Method Summary collapse
- #initialize(client:) ⇒ Square::Sites::Client constructor
-
#list(request_options: {}, **_params) ⇒ Square::Types::ListSitesResponse
Lists the Square Online sites that belong to a seller.
Constructor Details
#initialize(client:) ⇒ Square::Sites::Client
7 8 9 |
# File 'lib/square/sites/client.rb', line 7 def initialize(client:) @client = client end |
Instance Method Details
#list(request_options: {}, **_params) ⇒ Square::Types::ListSitesResponse
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).
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/square/sites/client.rb', line 17 def list(request_options: {}, **_params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/sites" ) 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::ListSitesResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |