added examples csv

This commit is contained in:
Sergey
2024-08-06 20:15:56 +03:00
parent 50155cd4d6
commit fb01ebd1e5
6 changed files with 27 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
APP_TOKEN='12345679' APP_TOKEN='12345679'
POS_TOKEN='123456' POS_TOKEN='123456'
MERCHANT_ID='123456789'
PRODUCTION=1 PRODUCTION=1
CURRENCY='RUS'
DRY_RUN=1

View File

@@ -1,5 +1,15 @@
# bonus-import-tools - Приложение для импорта бонусных баллов. # 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 (для разработки) - через python VENV (для разработки)

1
app.py
View File

@@ -11,6 +11,7 @@ APP_TOKEN = os.getenv('APP_TOKEN')
POS_TOKEN = os.getenv('POS_TOKEN') POS_TOKEN = os.getenv('POS_TOKEN')
MERCHANT_ID = os.getenv('MERCHANT_ID') MERCHANT_ID = os.getenv('MERCHANT_ID')
is_prod = bool(os.getenv('PRODUCTION', False)) is_prod = bool(os.getenv('PRODUCTION', False))
CURRENCY = os.getenv('CURRENCY', 'RUB')
if is_prod: if is_prod:
API_URI = 'https://pos-api.dinect.com/20130701/' API_URI = 'https://pos-api.dinect.com/20130701/'

View File

@@ -3,7 +3,6 @@
# __author__ = 'szhdanoff@gmail.com' # __author__ = 'szhdanoff@gmail.com'
import os import os
import json import json
import httpx
# local imports # local imports
import app import app
import requests import requests
@@ -72,7 +71,7 @@ def get_user(search_id, get_type='auto', headers=None):
return False, r.json() 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. 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. 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 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. 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: if headers is None:
headers = HEADERS headers = HEADERS
base_url = url + '/users/' base_url = url + '/users/'
params = {} params = {
"name": nickname ,
"phone": phone,
}
r = requests.post(base_url, headers=headers, json=params) r = requests.post(base_url, headers=headers, json=params)
if r.status_code == 201: if r.status_code == 201:

3
examples/example.csv Normal file
View File

@@ -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,,,
1 nickname card phone summ_total summ_discount sum_with_discount bonus_amount transaction_date transaction_time
2 Иван Петров 654897321321 +78906543210 12345.67 123.56 12222.11 121
3 Иван Иванов 654897321123 +78906233212 345.67 45.00 300.67 12

View File

@@ -1,2 +1,3 @@
httpx~=0.27.0 # httpx~=0.27.0
python-dotenv~=1.0.0 python-dotenv~=1.0.0
requests