Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
12 kB
3
Indexable
Never
async def write_new_items(order_id, items):
    url = f'{RETAILCRM_SITE}/api/v5/orders/{int(order_id)}/edit?apiKey={RETAILCRM_TOKEN}'
    print('\n\n\n', items)
    try:
        json_object = json.loads(items)
        print("Переменная является допустимой строкой JSON")
    except json.JSONDecodeError:
        print("Переменная не является допустимой строкой JSON")
    data = {
        'by': 'id',
        'site': 'shop-marcandandre-com',
        'order': json.dumps([{"items": items}]),
        'apiKey': RETAILCRM_TOKEN
    }
    response = await client.post(url=url, json=data)
    json_response = response.json()
    print('\n\n\n', json_response)
    return json_response


@@@@@
items [{"bonusesChargeTotal": 0, "bonusesCreditTotal": 0, "markingCodes": [], "id": 68359, "priceType": {"code": "price"}, "initialPrice": 4990, "discounts": [], "discountTotal": 0, "prices": [{"price": 4990, "quantity": 1}], "vatRate": "none", "createdAt": "2023-10-26 10:13:52", "quantity": 1, "status": "new", "offer": {"displayName": "A7-1144-WF Bra (75_C)", "id": 93349, "externalId": "220843", "xmlId": "a04b21f1-e678-11e6-bb50-00155d640c14#4d009bd3-a6f6-11e0-9573-98870324d0a2", "name": "\u0422\u043e\u043f \u0431\u0435\u0441\u0448\u043e\u0432\u043d\u044b\u0439", "article": "A7-1144-WF", "vatRate": "none", "properties": {"gtin": "3340684892612"}, "unit": {"code": "pc", "name": "\u0428\u0442\u0443\u043a\u0430", "sym": "\u0448\u0442."}}, "properties": [], "purchasePrice": 0, "ordering": 100}, {"bonusesChargeTotal": 0, "bonusesCreditTotal": 0, "markingCodes": [], "id": 68360, "priceType": {"code": "price"}, "initialPrice": 4990, "discounts": [], "discountTotal": 0, "prices": [{"price": 4990, "quantity": 1}], "vatRate": "none", "createdAt": "2023-10-26 10:13:52", "quantity": 1, "status": "new", "offer": {"displayName": "A7-1144-WF Bra (80_C)", "id": 93351, "externalId": "220845", "xmlId": "a04b21f1-e678-11e6-bb50-00155d640c14#4d009bd6-a6f6-11e0-9573-98870324d0a2", "name": "\u0422\u043e\u043f \u0431\u0435\u0441\u0448\u043e\u0432\u043d\u044b\u0439", "article": "A7-1144-WF", "vatRate": "none", "properties": {"gtin": "3340684893718"}, "unit": {"code": "pc", "name": "\u0428\u0442\u0443\u043a\u0430", "sym": "\u0448\u0442."}}, "properties": [], "purchasePrice": 0, "ordering": 200}, {"bonusesChargeTotal": 0, "bonusesCreditTotal": 0, "markingCodes": [], "id": 68361, "priceType": {"code": "price"}, "initialPrice": 4990, "discounts": [], "discountTotal": 0, "prices": [{"price": 4990, "quantity": 1}], "vatRate": "none", "createdAt": "2023-10-26 10:13:52", "quantity": 1, "status": "new", "offer": {"displayName": "A7-1144-WF Bra (75_B)", "id": 93353, "externalId": "220847", "xmlId": "a04b21f1-e678-11e6-bb50-00155d640c14#1a00118e-b12f-11e0-aa43-1c6f653d990f", "name": "\u0422\u043e\u043f \u0431\u0435\u0441\u0448\u043e\u0432\u043d\u044b\u0439", "article": "A7-1144-WF", "vatRate": "none", "properties": {"gtin": "3340684892605"}, "unit": {"code": "pc", "name": "\u0428\u0442\u0443\u043a\u0430", "sym": "\u0448\u0442."}}, "properties": [], "purchasePrice": 0, "ordering": 300}, {"bonusesChargeTotal": 0, "bonusesCreditTotal": 0, "markingCodes": [], "id": 68362, "priceType": {"code": "price"}, "initialPrice": 4990, "discounts": [], "discountTotal": 0, "prices": [{"price": 4990, "quantity": 1}], "vatRate": "none", "createdAt": "2023-10-26 10:13:52", "quantity": 1, "status": "zabral-nikita", "offer": {"displayName": "A7-1144-WF Bra (75_D)", "id": 93354, "externalId": "220848", "xmlId": "a04b21f1-e678-11e6-bb50-00155d640c14#1a001193-b12f-11e0-aa43-1c6f653d990f", "name": "\u0422\u043e\u043f \u0431\u0435\u0441\u0448\u043e\u0432\u043d\u044b\u0439", "article": "A7-1144-WF", "vatRate": "none", "properties": {"gtin": "3340684892629"}, "unit": {"code": "pc", "name": "\u0428\u0442\u0443\u043a\u0430", "sym": "\u0448\u0442."}}, "properties": [], "purchasePrice": 0, "ordering": 400}, {"bonusesChargeTotal": 0, "bonusesCreditTotal": 0, "markingCodes": [], "id": 68363, "priceType": {"code": "price"}, "initialPrice": 4990, "discounts": [], "discountTotal": 0, "prices": [{"price": 4990, "quantity": 1}], "vatRate": "none", "createdAt": "2023-10-26 10:13:52", "quantity": 1, "status": "new", "offer": {"displayName": "A7-1144-WF Bra (85_C)", "id": 93352, "externalId": "220846", "xmlId": "a04b21f1-e678-11e6-bb50-00155d640c14#4d009bd7-a6f6-11e0-9573-98870324d0a2", "name": "\u0422\u043e\u043f \u0431\u0435\u0441\u0448\u043e\u0432\u043d\u044b\u0439", "article": "A7-1144-WF", "vatRate": "none", "properties": {"gtin": "3340684894678"}, "unit": {"code": "pc", "name": "\u0428\u0442\u0443\u043a\u0430", "sym": "\u0448\u0442."}}, "properties": [], "purchasePrice": 0, "ordering": 500}, {"bonusesChargeTotal": 0, "bonusesCreditTotal": 0, "markingCodes": [], "id": 68364, "priceType": {"code": "price"}, "initialPrice": 4990, "discounts": [], "discountTotal": 0, "prices": [{"price": 4990, "quantity": 1}], "vatRate": "none", "createdAt": "2023-10-26 10:13:52", "quantity": 1, "status": "zabral-evgenii", "offer": {"displayName": "A7-1144-WF Bra (80_B)", "id": 93350, "externalId": "220844", "xmlId": "a04b21f1-e678-11e6-bb50-00155d640c14#4d009bd4-a6f6-11e0-9573-98870324d0a2", "name": "\u0422\u043e\u043f \u0431\u0435\u0441\u0448\u043e\u0432\u043d\u044b\u0439", "article": "A7-1144-WF", "vatRate": "none", "properties": {"gtin": "3340684893701"}, "unit": {"code": "pc", "name": "\u0428\u0442\u0443\u043a\u0430", "sym": "\u0448\u0442."}}, "properties": [], "purchasePrice": 0, "ordering": 600}]
Переменная является допустимой строкой JSON


@@@@@
 response {'success': True, 'id': 25938, 'order': {'slug': 25938, 'bonusesCreditTotal': 0, 'bonusesChargeTotal': 0, 'id': 25938, 'number': '25938C', 'orderType': 'eshop-individual', 'orderMethod': 'phone', 'privilegeType': 'none', 'countryIso': 'RU', 'createdAt': '2023-10-26 10:13:52', 'statusUpdatedAt': '2023-10-26 14:18:54', 'summ': 29940, 'totalSumm': 29940, 'prepaySum': 0, 'purchaseSumm': 0, 'markDatetime': '2023-10-26 10:13:52', 'firstName': 'sdasdasdasd', 'call': False, 'expired': False, 'managerId': 12, 'customer': {'type': 'customer', 'id': 14905, 'isContact': False, 'createdAt': '2023-10-26 10:13:52', 'managerId': 12, 'vip': False, 'bad': False, 'site': 'shop-marcandandre-com', 'contragent': {'contragentType': 'individual'}, 'tags': [], 'customFields': {'sp_action': 'update', 'sp_points': 0, 'sms_delivering': 'active', 'sp_spent_points': '0', 'email_distributing': 'active_email', 'registration_success': True, 'sp_not_confirmed_points': '0'}, 'marginSumm': 0, 'totalSumm': 0, 'averageSumm': 0, 'ordersCount': 0, 'costSumm': 0, 'personalDiscount': 0, 'segments': [], 'firstName': 'sdasdasdasd', 'phones': [], 'mgCustomers': []}, 'contact': {'type': 'customer', 'id': 14905, 'isContact': False, 'createdAt': '2023-10-26 10:13:52', 'managerId': 12, 'vip': False, 'bad': False, 'site': 'shop-marcandandre-com', 'contragent': {'contragentType': 'individual'}, 'tags': [], 'customFields': {'sp_action': 'update', 'sp_points': 0, 'sms_delivering': 'active', 'sp_spent_points': '0', 'email_distributing': 'active_email', 'registration_success': True, 'sp_not_confirmed_points': '0'}, 'marginSumm': 0, 'totalSumm': 0, 'averageSumm': 0, 'ordersCount': 0, 'costSumm': 0, 'personalDiscount': 0, 'segments': [], 'firstName': 'sdasdasdasd', 'phones': [], 'mgCustomers': []}, 'contragent': {'contragentType': 'individual'}, 'delivery': {'cost': 0, 'netCost': 0, 'address': {'countryIso': 'RU'}}, 'site': 'shop-marcandandre-com', 'status': 'otmena-testovyi-zakaz', 'statusComment': '', 'items': [{'bonusesChargeTotal': 0, 'bonusesCreditTotal': 0, 'markingCodes': [], 'id': 68359, 'priceType': {'code': 'price'}, 'initialPrice': 4990, 'discounts': [], 'discountTotal': 0, 'prices': [{'price': 4990, 'quantity': 1}], 'vatRate': 'none', 'createdAt': '2023-10-26 10:13:52', 'quantity': 1, 'status': 'new', 'offer': {'displayName': 'A7-1144-WF Bra (75_C)', 'id': 93349, 'externalId': '220843', 'xmlId': 'a04b21f1-e678-11e6-bb50-00155d640c14#4d009bd3-a6f6-11e0-9573-98870324d0a2', 'name': 'Топ бесшовный', 'article': 'A7-1144-WF', 'vatRate': 'none', 'properties': {'gtin': '3340684892612'}, 'unit': {'code': 'pc', 'name': 'Штука', 'sym': 'шт.'}}, 'properties': [], 'purchasePrice': 0, 'ordering': 100}, {'bonusesChargeTotal': 0, 'bonusesCreditTotal': 0, 'markingCodes': [], 'id': 68360, 'priceType': {'code': 'price'}, 'initialPrice': 4990, 'discounts': [], 'discountTotal': 0, 'prices': [{'price': 4990, 'quantity': 1}], 'vatRate': 'none', 'createdAt': '2023-10-26 10:13:52', 'quantity': 1, 'status': 'new', 'offer': {'displayName': 'A7-1144-WF Bra (80_C)', 'id': 93351, 'externalId': '220845', 'xmlId': 'a04b21f1-e678-11e6-bb50-00155d640c14#4d009bd6-a6f6-11e0-9573-98870324d0a2', 'name': 'Топ бесшовный', 'article': 'A7-1144-WF', 'vatRate': 'none', 'properties': {'gtin': '3340684893718'}, 'unit': {'code': 'pc', 'name': 'Штука', 'sym': 'шт.'}}, 'properties': [], 'purchasePrice': 0, 'ordering': 200}, {'bonusesChargeTotal': 0, 'bonusesCreditTotal': 0, 'markingCodes': [], 'id': 68361, 'priceType': {'code': 'price'}, 'initialPrice': 4990, 'discounts': [], 'discountTotal': 0, 'prices': [{'price': 4990, 'quantity': 1}], 'vatRate': 'none', 'createdAt': '2023-10-26 10:13:52', 'quantity': 1, 'status': 'new', 'offer': {'displayName': 'A7-1144-WF Bra (75_B)', 'id': 93353, 'externalId': '220847', 'xmlId': 'a04b21f1-e678-11e6-bb50-00155d640c14#1a00118e-b12f-11e0-aa43-1c6f653d990f', 'name': 'Топ бесшовный', 'article': 'A7-1144-WF', 'vatRate': 'none', 'properties': {'gtin': '3340684892605'}, 'unit': {'code': 'pc', 'name': 'Штука', 'sym': 'шт.'}}, 'properties': [], 'purchasePrice': 0, 'ordering': 300}, {'bonusesChargeTotal': 0, 'bonusesCreditTotal': 0, 'markingCodes': [], 'id': 68362, 'priceType': {'code': 'price'}, 'initialPrice': 4990, 'discounts': [], 'discountTotal': 0, 'prices': [{'price': 4990, 'quantity': 1}], 'vatRate': 'none', 'createdAt': '2023-10-26 10:13:52', 'quantity': 1, 'status': 'peremeshchenie', 'offer': {'displayName': 'A7-1144-WF Bra (75_D)', 'id': 93354, 'externalId': '220848', 'xmlId': 'a04b21f1-e678-11e6-bb50-00155d640c14#1a001193-b12f-11e0-aa43-1c6f653d990f', 'name': 'Топ бесшовный', 'article': 'A7-1144-WF', 'vatRate': 'none', 'properties': {'gtin': '3340684892629'}, 'unit': {'code': 'pc', 'name': 'Штука', 'sym': 'шт.'}}, 'properties': [], 'purchasePrice': 0, 'ordering': 400}, {'bonusesChargeTotal': 0, 'bonusesCreditTotal': 0, 'markingCodes': [], 'id': 68363, 'priceType': {'code': 'price'}, 'initialPrice': 4990, 'discounts': [], 'discountTotal': 0, 'prices': [{'price': 4990, 'quantity': 1}], 'vatRate': 'none', 'createdAt': '2023-10-26 10:13:52', 'quantity': 1, 'status': 'new', 'offer': {'displayName': 'A7-1144-WF Bra (85_C)', 'id': 93352, 'externalId': '220846', 'xmlId': 'a04b21f1-e678-11e6-bb50-00155d640c14#4d009bd7-a6f6-11e0-9573-98870324d0a2', 'name': 'Топ бесшовный', 'article': 'A7-1144-WF', 'vatRate': 'none', 'properties': {'gtin': '3340684894678'}, 'unit': {'code': 'pc', 'name': 'Штука', 'sym': 'шт.'}}, 'properties': [], 'purchasePrice': 0, 'ordering': 500}, {'bonusesChargeTotal': 0, 'bonusesCreditTotal': 0, 'markingCodes': [], 'id': 68364, 'priceType': {'code': 'price'}, 'initialPrice': 4990, 'discounts': [], 'discountTotal': 0, 'prices': [{'price': 4990, 'quantity': 1}], 'vatRate': 'none', 'createdAt': '2023-10-26 10:13:52', 'quantity': 1, 'status': 'peremeshchenie', 'offer': {'displayName': 'A7-1144-WF Bra (80_B)', 'id': 93350, 'externalId': '220844', 'xmlId': 'a04b21f1-e678-11e6-bb50-00155d640c14#4d009bd4-a6f6-11e0-9573-98870324d0a2', 'name': 'Топ бесшовный', 'article': 'A7-1144-WF', 'vatRate': 'none', 'properties': {'gtin': '3340684893701'}, 'unit': {'code': 'pc', 'name': 'Штука', 'sym': 'шт.'}}, 'properties': [], 'purchasePrice': 0, 'ordering': 600}], 'payments': {}, 'fromApi': False, 'weight': 500, 'length': 200, 'width': 150, 'height': 300, 'shipmentStore': 'svobod_sclad', 'shipped': False, 'customFields': {'dostavkak': False, 'return_goods': False, 'peremecshenie': True, 'vernut_dostavku': False}, 'currency': 'RUB'}}