From 0d65c5d301f507d123c026501ce8c57a1e86abb1 Mon Sep 17 00:00:00 2001 From: KislovDM Date: Tue, 21 Dec 2021 15:53:53 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=95=D0=9F=D0=94=20(=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D1=8B=D0=B9=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- emp_mos_api/examples/read_electro_epd.py | 15 +++++------ emp_mos_api/mos.py | 34 ++++++++++++++---------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/emp_mos_api/examples/read_electro_epd.py b/emp_mos_api/examples/read_electro_epd.py index 1cbeaaa..ec0795d 100644 --- a/emp_mos_api/examples/read_electro_epd.py +++ b/emp_mos_api/examples/read_electro_epd.py @@ -48,15 +48,12 @@ print('Счет электро: ', f['electro_account']) print('Счетчик электро: ', f['electro_device']) - for x in range (1,13): - date = '10.{}.2018'.format(x) - epd = api.get_epd(f['flat_id'], date, False) - if epd == []: - epd = api.get_epd(f['flat_id'], date, False) - epd_total = epd[0]['amount'] - epd_is_paid = epd[0]['is_paid'] - print(" - Дата: {}, сумма: {}, оплачен: {}.".format(date, epd_total, epd_is_paid)) - time.sleep(1) + epds = api.get_epd(f['flat_id'], '01.01.2018', '31.12.2018') + for epd in epds: + period = epd['period'] + epd_total = epd['amount'] + epd_is_paid = epd['payment_status'] == 'PAID' + print(" - Дата: {}, сумма: {}, оплачен: {}.".format(period, epd_total, epd_is_paid)) if f['electro_account'] != "": electro = api.get_electrocounters(f['flat_id']) diff --git a/emp_mos_api/mos.py b/emp_mos_api/mos.py index 6adc0c4..88798a2 100644 --- a/emp_mos_api/mos.py +++ b/emp_mos_api/mos.py @@ -9,7 +9,7 @@ API_V1_0 = 'https://emp.mos.ru/v1.0' API_V1_1 = 'https://emp.mos.ru/v1.1' - +API_V1_2 = 'https://emp.mos.ru/v1.2' class AuthException(Exception): pass @@ -579,21 +579,27 @@ def send_electrocounters(self, flat_id, counters_data): self.raise_for_status(response) return response['result'] - def get_epd(self, flat_id, period, is_debt=True): + def get_epd(self, flat_id, begin_period, end_period): """ :param flat_id: unicode string from flat_response response[0]['flat_id'] :param period: unicode string represents date in 27.09.2018 format :param is_debt: True/False - :return: - { - "is_debt": true, - "is_paid": true, - "amount": 2982.77, - "service_code": "emp.zkh", - "insurance": 61.93, - "ammount_insurance": 3044.7 - } + :return: array of + [{ + "uin": "234234234234234234234234", + "insurance_amount": null, + "period": "01.12.2021", + "epd_type": "REGULAR", + "payment_amount": "3316,73", + "payment_date": "01.12.2021", + "payment_status": "PAID", + "initiator": "MFC", + "create_date": "11.12.2021 19:34", + "penalty_amount": "0,00", + "amount": "3316,73", + "amount_with_insurance": null + }] """ assert self.session_id wheaders = deepcopy(self.headers) @@ -605,11 +611,11 @@ def get_epd(self, flat_id, period, is_debt=True): wcrequest = deepcopy(self.post_request_data) wcrequest.update({ 'flat_id': flat_id, - 'period': period, - 'is_debt': is_debt, + 'begin_period': begin_period, + 'end_period': end_period }) - ret = self.session.post(API_V1_1 + '/epd/get', + ret = self.session.post(API_V1_2 + '/epd/get', params={'token': self.token}, headers=wheaders, verify=self.verify, From 8354c406578c01d8a054f6b9956e98c93d521548 Mon Sep 17 00:00:00 2001 From: KislovDM Date: Tue, 21 Dec 2021 16:01:54 +0300 Subject: [PATCH 2/2] Fix usage in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28efa1f..abac40c 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ api.send_electrocounters(flat_id, new_values) ``` ### Получить епд ``` -epd = api.get_epd(flat_id, period, is_debit) +epd = api.get_epd(flat_id, begin_period, end_period) ``` ### Получить штрафы ```