-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
200 additions
and
151 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
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import requests | ||
|
||
from flask import current_app | ||
from app.config import Config | ||
|
||
token_url = f"{Config.ORGBOOK_PUBLISHER_BASE_URL}/auth/token" | ||
cred_publish_url = f"{Config.ORGBOOK_PUBLISHER_BASE_URL}/credentials/publish" | ||
|
||
|
||
class OrgbookPublisherService(): | ||
### class to manage API calls to the Orgbook Publisher, it's a service that will sign and publish data to Orgbook. The data is currently UNTP Digital Conformity Credentials that prove business have mines act permits. | ||
token: str | ||
|
||
def __init__(self): | ||
self.token = self.get_new_token() | ||
|
||
def get_headers(self): | ||
return {"Authorization": f"Bearer {self.token}"} | ||
|
||
def get_new_token(self): | ||
payload = { | ||
"client_id": Config.CHIEF_PERMITTING_OFFICER_DID_WEB, | ||
"client_secret": Config.ORGBOOK_PUBLISHER_CLIENT_SECRET | ||
} | ||
token_resp = requests.post(token_url, json=payload) | ||
token_resp.raise_for_status() | ||
return token_resp.json()["access_token"] | ||
|
||
def publish_cred(self, payload: dict) -> requests.Response: | ||
return requests.post(cred_publish_url, json=payload, headers=self.get_headers()) |
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
Oops, something went wrong.