diff --git a/.env.example b/.env.example index cbf89a6..238afcb 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,5 @@ APP_TOKEN='12345679' POS_TOKEN='123456' -MERCHANT_ID='123456789' PRODUCTION=1 +CURRENCY='RUS' +DRY_RUN=1 \ No newline at end of file diff --git a/README.md b/README.md index c00a83b..f3521da 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,15 @@ # bonus-import-tools - Приложение для импорта бонусных баллов. +## Пример файла + +```csv +nickname, card, phone, summ_total, summ_discount, sum_with_discount, bonus_amount, transaction_date, transaction_time, +Иван Петров,654897321321,+78906543210,12345.67,123.56,12222.11,121,,, +Иван Иванов,654897321123,+78906233212,345.67,45.00,300.67,12,,, +``` + + + ## Типы установки - через python VENV (для разработки) diff --git a/app.py b/app.py index fdfe0a1..c2cc950 100644 --- a/app.py +++ b/app.py @@ -11,6 +11,7 @@ APP_TOKEN = os.getenv('APP_TOKEN') POS_TOKEN = os.getenv('POS_TOKEN') MERCHANT_ID = os.getenv('MERCHANT_ID') is_prod = bool(os.getenv('PRODUCTION', False)) +CURRENCY = os.getenv('CURRENCY', 'RUB') if is_prod: API_URI = 'https://pos-api.dinect.com/20130701/' diff --git a/dinect_api.py b/dinect_api.py index cde8b8a..24dda69 100644 --- a/dinect_api.py +++ b/dinect_api.py @@ -3,7 +3,6 @@ # __author__ = 'szhdanoff@gmail.com' import os import json -import httpx # local imports import app import requests @@ -72,7 +71,7 @@ def get_user(search_id, get_type='auto', headers=None): return False, r.json() -def new_user(headers=None): +def new_user(nickname, phone, foreign_card=None, headers=None): """ A function that creates a new user with optional headers. @@ -83,13 +82,20 @@ def new_user(headers=None): tuple: A tuple containing a boolean indicating the success of the request and the JSON response. If the request is successful, the boolean is True and the JSON response is returned. If the request is unsuccessful, the boolean is False and the JSON response is returned. + :param foreign_card: + :param headers: + :param phone: + :param nickname : """ if headers is None: headers = HEADERS base_url = url + '/users/' - params = {} + params = { + "name": nickname , + "phone": phone, + } r = requests.post(base_url, headers=headers, json=params) if r.status_code == 201: diff --git a/examples/example.csv b/examples/example.csv new file mode 100644 index 0000000..3751d6b --- /dev/null +++ b/examples/example.csv @@ -0,0 +1,3 @@ +nickname, card, phone, summ_total, summ_discount, sum_with_discount, bonus_amount, transaction_date, transaction_time, +Иван Петров,654897321321,+78906543210,12345.67,123.56,12222.11,121,,, +Иван Иванов,654897321123,+78906233212,345.67,45.00,300.67,12,,, \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 884e9b9..6f17605 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ -httpx~=0.27.0 +# httpx~=0.27.0 python-dotenv~=1.0.0 +requests \ No newline at end of file