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) ``` ### Получить штрафы ``` 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,