def wrapper(self, api, post_data='', host='', headers=None): if headers is None: headers = {} if not host: host = self.url if self.api_key: headers = {"X-API-Key": self.api_key} if post_data: r = requests.post('%s%s' % (host, api), data=post_data, headers=crypto.merge_dicts(headers, {'content-type': 'application/json'})) else: r = requests.get('%s%s' % (host, api), headers=headers) if r.status_code != 200: method = 'POST' if post_data else 'GET' try: error = json.loads(r.text) except: error = r.text raise Exception( '{} {}{} responded with {} {}'.format(method, host, api, r.status_code, r.reason), error ) r.raise_for_status() return r.json()
def to_json(self): return (crypto.merge_dicts({ "id": self.id if self.id else "", "type": self.TYPE, "version": self.version, "sender": self.sender, "senderKeyType": self.sender_key_type, "senderPublicKey": self.sender_public_key, "recipient": self.recipient, "timestamp": self.timestamp, "fee": self.tx_fee, "proofs": self.proofs, "height": self.height if self.height else "" }, self._sponsor_json()))
def to_json(self): return (crypto.merge_dicts( { "id": self.id if self.id else "", "type": self.TYPE, "version": self.version, "sender": self.sender, "senderKeyType": self.sender_key_type, "senderPublicKey": self.sender_public_key, "fee": self.tx_fee, "timestamp": self.timestamp, "data": list(map(lambda entry: entry.to_json(), self.data)), "proofs": self.proofs, "height": self.height if self.height else "" }, self._sponsor_json()))
def to_json(self): return (crypto.merge_dicts( { "id": self.id if self.id else "", "type": self.TYPE, "version": self.version, "sender": self.sender, "senderKeyType": self.sender_key_type, "senderPublicKey": self.sender_public_key, "fee": self.tx_fee, "timestamp": self.timestamp, "anchors": list(map(lambda anchor: base58.b58encode(crypto.str2bytes(anchor)), self.anchors)), "proofs": self.proofs, "height": self.height if self.height else "" }, self._sponsor_json()))
def to_json(self): return (crypto.merge_dicts( { "id": self.id if self.id else "", "type": self.TYPE, "version": self.version, "sender": self.sender, "senderKeyType": self.sender_key_type, "senderPublicKey": self.sender_public_key, "recipient": self.recipient, "associationType": self.association_type, "hash": base58.b58encode(crypto.str2bytes(self.anchor)), "timestamp": self.timestamp, "fee": self.tx_fee, "proofs": self.proofs, "height": self.height if self.height else "" }, self._sponsor_json()))