diff --git a/samples.md b/samples.md index 4b1f873..bbaf11a 100644 --- a/samples.md +++ b/samples.md @@ -39,6 +39,7 @@ * [Get All Node Subnets](#get-all-node-subnets) * [Get All Node Transactions](#get-all-node-transactions) * [Get All Node Statements](#get-all-node-statements) + * [Generate Node Statements](#generate-node-ondemand-statement) + [Subnets](#subnets) * [Create Subnet](#create-subnet) * [Get Subnet](#get-subnet) @@ -375,6 +376,19 @@ user.get_all_node_trans(node_id, page=4, per_page=10) node_id = '594e606212e17a002f2e3251' user.get_statements(node_id, page=4, per_page=10) ``` + +##### Generate Node Ondemand Statement +```python +node_id = '594e606212e17a002f2e3251' +body = { + "date_start": 1525132800000, + "date_end": 1525132800000, + "webhook": "https://wh.synapsefi.com/gen_me_statement_001" +} +user.generate_node_statements(node_id, body) +``` + + ### Subnets ##### Create Subnet ```python diff --git a/setup.py b/setup.py index 89788f4..5f704a0 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version='1.2.11', # new version number goes here + version='1.2.12', # new version number goes here description='SynapseFi Python Library', diff --git a/synapsepy/user.py b/synapsepy/user.py index a478151..ccf1622 100644 --- a/synapsepy/user.py +++ b/synapsepy/user.py @@ -236,6 +236,28 @@ def get_node_statements(self, node_id, page=None, per_page=None): ) return response + def generate_node_statements(self, node_id, body): + '''Generates ad-hoc statements + Args: + node_id (str): ID of the from Node + body: includes the start and end date for the ondemand statement in epoch time in milliseconds + Returns: + {'node_id': '', 'status': 'Statement requested', 'success': True, 'webhook': ''} + ''' + self.logger.debug("Generating on demand statements\n" + json.dumps(body, indent=2)) + path = ( + paths['users'] + + '/' + + self.id + + paths['nodes'] + + '/' + + node_id + + '/' + + paths['statem'] + ) + response = self._do_request(self.http.post, path, body) + return response + def update_node(self, node_id, body): '''Updates a node's info in the database Args: