def __init__(self, url=URL):
        context = create_context('secp256k1')
        private_key = context.new_random_private_key()
        signer = CryptoFactory(context).new_signer(private_key)
        self.factory = SupplyChainMessageFactory(signer=signer)
        self.public_key = self.factory.public_key
        self.private_key = "encryptedKey"
        self.auth_token = None

        super().__init__(url=url, namespace=addressing.NAMESPACE)
class SupplyChainClient(RestClient):
    def __init__(self, url=URL):
        context = create_context('secp256k1')
        private_key = context.new_random_private_key()
        signer = CryptoFactory(context).new_signer(private_key)
        self.factory = SupplyChainMessageFactory(signer=signer)
        self.public_key = self.factory.public_key
        self.private_key = "encryptedKey"
        self.auth_token = None

        super().__init__(url=url, namespace=addressing.NAMESPACE)

    def _post_sc_transaction(self, transaction):
        return self.send_batches(self.factory.create_batch(transaction))


#

    def create_agent(self, name):
        return self._post_sc_transaction(self.factory.create_agent(name))

    def create_record_type(self, name, *properties):
        return self._post_sc_transaction(
            self.factory.create_record_type(name, *properties))

    def create_record(self, record_id, record_type, properties_dict):
        return self._post_sc_transaction(
            self.factory.create_record(record_id, record_type,
                                       properties_dict))

    def finalize_record(self, record_id):
        return self._post_sc_transaction(
            self.factory.finalize_record(record_id))

    def update_properties(self, record_id, properties_dict):
        return self._post_sc_transaction(
            self.factory.update_properties(record_id, properties_dict))

    def create_proposal(self,
                        record_id,
                        receiving_agent,
                        role,
                        properties=None):
        if properties is None:
            properties = []

        return self._post_sc_transaction(
            self.factory.create_proposal(record_id, receiving_agent, role,
                                         properties))

    def answer_proposal(self, record_id, role, response, receiving_agent=None):
        if receiving_agent is None:
            receiving_agent = self.public_key

        return self._post_sc_transaction(
            self.factory.answer_proposal(record_id=record_id,
                                         receiving_agent=receiving_agent,
                                         role=role,
                                         response=response))

    def revoke_reporter(self, record_id, reporter_id, properties):
        return self._post_sc_transaction(
            self.factory.revoke_reporter(record_id, reporter_id, properties))

    def send_empty_payload(self):
        return self._post_sc_transaction(
            self.factory.make_empty_payload(self.public_key))

    def get_agents(self, fields=None, omit=None):
        return self._submit_request(
            url='{}/agents{}'.format(API, make_query_string(fields, omit)))[1]

    def get_agent(self, public_key, fields=None, omit=None):
        return self._submit_request(
            url='{}/agents/{}{}'.format(API, public_key,
                                        make_query_string(fields, omit)),
            headers={'Authorization': self.auth_token},
        )[1]

    def get_records(self, fields=None, omit=None):
        return self._submit_request(url='{}/records{}'.format(
            API, make_query_string(fields, omit)),
                                    headers={'Authorization':
                                             self.auth_token})[1]

    def get_record(self, record_id, fields=None, omit=None):
        return self._submit_request(url='{}/records/{}{}'.format(
            API, record_id, make_query_string(fields, omit)),
                                    headers={'Authorization':
                                             self.auth_token})[1]

    def get_record_property(self,
                            record_id,
                            property_name,
                            fields=None,
                            omit=None):
        return self._submit_request(url='{}/records/{}/property/{}{}'.format(
            API, record_id, property_name, make_query_string(fields, omit)))[1]

    def post_user(self, username):
        response = self._submit_request(
            url=SERVER_URL + '/users',
            method='POST',
            headers={'Content-Type': 'application/json'},
            data=json.dumps({
                'username': username,
                'email': '{}@website.com'.format(username),
                'password': '******'.format(username),
                'publicKey': self.public_key,
                'encryptedKey': str(self.private_key),
            }),
        )

        if self.auth_token is None:
            self.auth_token = response[1]['authorization']