-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/version-14-hotfix' into versio…
…n-14
- Loading branch information
Showing
4 changed files
with
31 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,49 @@ | ||
# Copyright (c) 2023, ALYF GmbH and contributors | ||
# For license information, please see license.txt | ||
import json | ||
import requests | ||
|
||
|
||
class AdminRequest: | ||
def __init__( | ||
self, | ||
ip_address: str, | ||
user_agent: str, | ||
api_token: str, | ||
url: str, | ||
customer_id: str, | ||
) -> None: | ||
self.ip_address = ip_address | ||
self.user_agent = user_agent | ||
self.api_token = api_token | ||
self.url = url | ||
self.base_url = url | ||
self.customer_id = customer_id | ||
|
||
@property | ||
def headers(self): | ||
return {"Alyf-Banking-Authorization": f"Token {self.api_token}"} | ||
|
||
@property | ||
def data(self): | ||
return { | ||
"ip_address": self.ip_address, | ||
"user_agent": self.user_agent, | ||
"customer_id": self.customer_id, | ||
} | ||
def request(self, method: str, endpoint: str, data: dict | None = None): | ||
return requests.request( | ||
method=method, | ||
url=f"{self.base_url}/api/method/{endpoint}", | ||
headers={ | ||
"Alyf-Banking-Authorization": f"Token {self.api_token}", | ||
"Alyf-Customer-Id": self.customer_id, | ||
}, | ||
json=data, | ||
) | ||
|
||
def fetch_subscription(self): | ||
method = "banking_admin.api.fetch_subscription_details" | ||
return requests.post( | ||
url=self.url + method, headers=self.headers, data=json.dumps(self.data) | ||
) | ||
return self.request("GET", "banking_admin.api.fetch_subscription_details") | ||
|
||
def get_customer_portal(self): | ||
method = "banking_admin.api.get_customer_portal" | ||
return requests.get(url=self.url + method) | ||
return self.request("GET", "banking_admin.api.get_customer_portal") | ||
|
||
def get_fintech_license(self): | ||
method = "banking_admin.ebics_api.get_fintech_license" | ||
return requests.post( | ||
url=self.url + method, headers=self.headers, json=self.data.copy() | ||
) | ||
|
||
def register_ebics_user(self, host_id: str, partner_id: str, user_id: str): | ||
data = self.data | ||
data.update({"host_id": host_id, "partner_id": partner_id, "user_id": user_id}) | ||
method = "banking_admin.ebics_api.register_ebics_user" | ||
return requests.post( | ||
url=self.url + method, | ||
headers=self.headers, | ||
json=data, | ||
) | ||
|
||
def remove_ebics_user(self, host_id: str, partner_id: str, user_id: str): | ||
data = self.data | ||
data.update({"host_id": host_id, "partner_id": partner_id, "user_id": user_id}) | ||
method = "banking_admin.ebics_api.remove_ebics_user" | ||
return requests.post( | ||
url=self.url + method, | ||
headers=self.headers, | ||
json=data, | ||
return self.request("GET", "banking_admin.ebics_api.get_fintech_license") | ||
|
||
def register_ebics_user( | ||
self, host_id: str, partner_id: str, user_id: str, remove: bool = False | ||
): | ||
if remove: | ||
endpoint = "banking_admin.ebics_api.remove_ebics_user" | ||
else: | ||
endpoint = "banking_admin.ebics_api.register_ebics_user" | ||
|
||
return self.request( | ||
"POST", | ||
endpoint, | ||
{"host_id": host_id, "partner_id": partner_id, "user_id": user_id}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.