Часто используемые запросы при интеграции
# -*- coding: utf-8 -*- import requests import json API_URL = "https://name.priceplan.pro/api/clients/" #создание клиента data = {"values": { #настраиваемый список полей карточки клиента "2": "710600347232", "5": "300032, Тула г, Ломоносова ул., 38-5.", "23": "test@mail.ru"}, "type": 1, #тип юридическое лицо "name": "Долгополов ИП"} r = requests.post(API_URL, auth=("api-key", "password"), data=json.dumps(data)) client = json.loads(r.text)
# -*- coding: utf-8 -*- import requests import json API_URL = "https://name.priceplan.pro/api/clients/" client_id = 1 #id клиента в ПрайсПлане r = requests.get(API_URL+client_id, auth=("api-key", "password")) client = json.loads(r.text) """ {"data": {"status": None, "product": 2, "period": 4, "client": 1, "values": {"19": 1, "18": 1, "20": 0}, "id": 1}, "success": True} """
# -*- coding: utf-8 -*- import requests import json API_URL = "https://name.priceplan.pro/api/subscribes/pre" data = { "product":2, "values":{ "18":1, "19":1, "20":0 }, "period":4 } r = requests.post(API_URL, auth=("api-key", "password"), data=json.dumps(data)) subscribe = json.loads(r.text)
# -*- coding: utf-8 -*- import requests import json API_URL = "https://name.priceplan.pro/api/subscribes/" data = { "product":2, "values":{ "18":1, "19":1, "20":0 }, "period":4, "client":2 } r = requests.post(API_URL, auth=("api-key", "password"), data=json.dumps(data)) subscribe = json.loads(r.text) """ Пример ответа {"data": {"status": None, "product": 2, "period": 4, "client": 1, "values": {"19": 1, "18": 1, "20": 0}, "id": 1}, "success": True} """
# -*- coding: utf-8 -*- import requests import json API_URL = "https://name.priceplan.pro/api/subscribes/" data = { "fields": "subscribe__id,subscribe__product,subscribe__blocking,subscribe__start,client__id,product__name,subscribe__renewal", "page": 1, "pageSize": 10, "skip": 0, "take": 1 } r = requests.get(API_URL, auth=("api-key", "password"), params=data) subscribes = json.loads(r.text)
# -*- coding: utf-8 -*- import requests import json API_URL = "https://name.priceplan.pro/api/subscribes/" #запрашиваем список подписок где id клиента равно 1 data = { "fields": "subscribe__id,subscribe__product,subscribe__blocking,subscribe__start,client__id,product__name,subscribe__renewal", "filter[filters][0][field]": "client__id", "filter[filters][0][operator]": "eq", "filter[filters][0][value]": 1, "filter[logic]": "and", "page": 1, "pageSize": 10, "skip": 0, "take": 1 } r = requests.get(API_URL, auth=("api-key", "password"), params=data) subscribes = json.loads(r.text)
# -*- coding: utf-8 -*- import requests import json API_URL = "https://name.priceplan.pro/api/blocking/client/1" #Получения списка блокировок клиента data = {"take": 15, "skip": 0, "page": 1, "pageSize": 15} r = requests.get(API_URL, auth=("api-key", "password"), params=data) blocks = json.loads(r.text)