Listen to events of ingredient write-offs and mark them as written off.
git clone https://github.com/goretsky-integration/write-offs-marker
cd write-offs-marker
poetry env use python3.11
poetry shell
poetry install --without dev
cp config.example.toml config.toml
Set up timezone.
credentials_file_path
- path to the file with google service account credentials.
How to get credentials?
A service account is a special type of Google account intended to represent a non-human user that needs to authenticate and be authorized to access data in Google APIs.
Since it’s a separate account, by default it does not have access to any spreadsheet until you share it with this account. Just like any other Google account.
-
Enable API Access for a Project if you haven’t done it yet.
🤔 How do I enable API Access?
Enable API Access for a Project Head to Google Developers Console and create a new project (or select the one you already have).In the box labeled “Search for APIs and Services”, search for “Google Drive API” and enable it.
In the box labeled “Search for APIs and Services”, search for “Google Sheets API” and enable it.
-
Go to “APIs & Services > Credentials” and choose “Create credentials > Service account key”.
-
Fill out the form
-
Click “Create” and “Done”.
-
Press “Manage service accounts” above Service Accounts.
-
Press on ⋮ near recently created service account and select “Manage keys” and then click on “ADD KEY > Create new key”.
-
Select JSON key type and press “Create”.
You will automatically download a JSON file with credentials. It may look like this:
{
"type": "service_account",
"project_id": "api-project-XXX",
"private_key_id": "2cd … ba4",
"private_key": "-----BEGIN PRIVATE KEY-----\nNrDyLw … jINQh/9\n-----END PRIVATE KEY-----\n",
"client_email": "[email protected]",
"client_id": "473 … hd.apps.googleusercontent.com"
}
Remember the path to the downloaded credentials file. Also, in the next step you’ll need the value of client_email from this file.
Very important! Go to your spreadsheet and share it with a client_email from the step above. Just like you do with any other Google account.
If you don’t do this, you’ll get a gspread.exceptions.SpreadsheetNotFound
exception when trying to
access this spreadsheet from your application or a script.
spreadsheet_key
- you can get it from the URL of spreadsheet.
[google_sheets]
credentials_file_path = "/file/to/credentials.json"
spreadsheet_key = "jfsodijfiosdjijsfigjfg"
URL of the message queue which will be listened to events.
[message_queue]
url = "amqp://localhost:5672"
Telegram bot token for answering to callback queries.
[telegram_bot]
token = "12345:gkdfgifdjgifdjgfdg"
cd src
faststream run main:app