def __init__(self, client: Client): """ :param Client client: A non optional Client, the client with config """ super(Authentication, self).__init__(client) Utility.non_null(client)
def __init__(self, client: Client, token: str): """ :param Client client: A non optional Client, the client with config :param str token: A non optional string, the auth token """ super(ResourceService, self).__init__(client) self.token = token Utility.non_null(client)
def __init__(self, client: Client): """ :param Client client: A non optional Client, the client with config """ self._requires_token = False Utility.non_null(client) if not client.config.get("environment"): msg = "Client does not have correct environment. Use {0} or {1}" self.message = msg.format(EnvironmentEnum.LIVE.value, EnvironmentEnum.TEST.value) raise SeerbitError(self.message) if not client.config.get("public_key"): self.message = "Client doesn\'t have a merchant public key. Set a public key using the client" raise SeerbitError(self.message) if not client.config.get("private_key"): self.message = "Client doesn\'t have a merchant private key. Set a private key using the client" raise SeerbitError(self.message) self.http_client = HttpClient() Service._client = client
def get_request(self, endpoint, token): message = "Set a field named \"api_base\" in the client configuration" Utility.require_non_null(self.client.config.get("api_base"), message) endpoint_url = str(self.client.config.get("api_base")) + endpoint json = self.http_client.get(self, endpoint_url, token) return json.json()
def client(self, client: Client): Utility.non_null(client) Service._client = client