forked from square/square-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsites_api.py
More file actions
55 lines (45 loc) · 2.07 KB
/
sites_api.py
File metadata and controls
55 lines (45 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
from square.api_helper import APIHelper
from square.http.api_response import ApiResponse
from square.api.base_api import BaseApi
from apimatic_core.request_builder import RequestBuilder
from apimatic_core.response_handler import ResponseHandler
from apimatic_core.types.parameter import Parameter
from square.http.http_method_enum import HttpMethodEnum
from apimatic_core.authentication.multiple.single_auth import Single
class SitesApi(BaseApi):
"""A Controller to access Endpoints in the square API."""
def __init__(self, config):
super(SitesApi, self).__init__(config)
def list_sites(self):
"""Does a GET request to /v2/sites.
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](https://developer.squareup.com/docs/online-api#early-access-progr
am-for-square-online-apis).
Returns:
ApiResponse: An object with the response value as well as other
useful information such as status codes and headers. Success
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
return super().new_api_call_builder.request(
RequestBuilder().server('default')
.path('/v2/sites')
.http_method(HttpMethodEnum.GET)
.header_param(Parameter()
.key('accept')
.value('application/json'))
.auth(Single('global'))
).response(
ResponseHandler()
.deserializer(APIHelper.json_deserialize)
.is_api_response(True)
.convertor(ApiResponse.create)
).execute()