# Path: launchkey/factories/organization.py
# class OrganizationFactory(BaseFactory):
#     """
#     Factory for creating clients when representing a LaunchKey Organization
#     """
# 
#     def __init__(self, organization_id, private_key, url=LAUNCHKEY_PRODUCTION,
#                  testing=False, transport=None):
#         """
#         :param organization_id: UUID for the requesting organization
#         :param private_key: PEM formatted private key string
#         :param url: URL for the LaunchKey API
#         :param testing: Boolean stating whether testing mode is being used.
#         This will determine whether SSL validation occurs.
#         :param: transport: Instantiated transport object. The default and
#         currently only supported transport is
#         launchkey.transports.JOSETransport. If you wish to set encryption or
#         hashing algorithms, this is where you would do it. IE:
#         JOSETransport(jwt_algorithm="RS512", jwe_cek_encryption="RSA-OAEP",
#         jwe_claims_encryption="A256CBC-HS512", content_hash_algorithm="S256")
#         """
#         super().__init__('org', organization_id,
#                          private_key, url, testing,
#                          transport)
# 
#     def make_directory_client(self, directory_id):
#         """
#         Retrieves a client to make directory calls.
#         :param directory_id: Directory id
#         :return: launchkey.clients.DirectoryClient
#         """
#         return DirectoryClient(directory_id, self._transport)
# 
#     def make_organization_client(self):
#         """
#         Retrieves a client to make organization calls.
#         :return: launchkey.clients.OrganizationClient
#         """
#         return OrganizationClient(self._issuer_id, self._transport)
# 
#     def make_service_client(self, service_id):
#         """
#         Retrieves a client to make service calls.
#         :param service_id: Service id
#         :return: launchkey.clients.ServiceClient
#         """
#         return ServiceClient(service_id, self._transport)


from launchkey.factories import OrganizationFactory
        self.organization_client = organization_factory.\
            make_organization_client()
        self.directory_client = organization_factory.make_directory_client(
            directory_id
        )
        self.service_client = organization_factory.make_service_client(
            service_id
        )

        self.use_advanced_webhooks = use_advanced_webhooks

    def update_directory_webhook_url(self, webhook_url):
        self.organization_client.update_directory(
            self.directory_id,
            webhook_url=webhook_url
        )

    def update_service_webhook_url(self, webhook_url):
        self.directory_client.update_service(
            self.service_id,
            callback_url=webhook_url
        )

    def link_device(self, username):
        return self.directory_client.link_device(username)

    def authorization_request(self, username):
        return self.service_client.authorization_request(username)

    def cancel_authorization_request(self, auth_request_id):

# Path: launchkey/factories/organization.py
# class OrganizationFactory(BaseFactory):
#     """
#     Factory for creating clients when representing a LaunchKey Organization
#     """
# 
#     def __init__(self, organization_id, private_key, url=LAUNCHKEY_PRODUCTION,
#                  testing=False, transport=None):
#         """
#         :param organization_id: UUID for the requesting organization
#         :param private_key: PEM formatted private key string
#         :param url: URL for the LaunchKey API
#         :param testing: Boolean stating whether testing mode is being used.
#         This will determine whether SSL validation occurs.
#         :param: transport: Instantiated transport object. The default and
#         currently only supported transport is
#         launchkey.transports.JOSETransport. If you wish to set encryption or
#         hashing algorithms, this is where you would do it. IE:
#         JOSETransport(jwt_algorithm="RS512", jwe_cek_encryption="RSA-OAEP",
#         jwe_claims_encryption="A256CBC-HS512", content_hash_algorithm="S256")
#         """
#         super().__init__('org', organization_id,
#                          private_key, url, testing,
#                          transport)
# 
#     def make_directory_client(self, directory_id):
#         """
#         Retrieves a client to make directory calls.
#         :param directory_id: Directory id
#         :return: launchkey.clients.DirectoryClient
#         """
#         return DirectoryClient(directory_id, self._transport)
# 
#     def make_organization_client(self):
#         """
#         Retrieves a client to make organization calls.
#         :return: launchkey.clients.OrganizationClient
#         """
#         return OrganizationClient(self._issuer_id, self._transport)
# 
#     def make_service_client(self, service_id):
#         """
#         Retrieves a client to make service calls.
#         :param service_id: Service id
#         :return: launchkey.clients.ServiceClient
#         """
#         return ServiceClient(service_id, self._transport)


# Path: examples/flask-webhooks-example/launchkey_example_app/services/launchkey_service.py
from launchkey.factories import OrganizationFactory

        self.organization_client = organization_factory.\
            make_organization_client()
        self.directory_client = organization_factory.make_directory_client(
            directory_id
        )
        self.service_client = organization_factory.make_service_client(
            service_id
        )

        self.use_advanced_webhooks = use_advanced_webhooks

    def update_directory_webhook_url(self, webhook_url):
        self.organization_client.update_directory(
            self.directory_id,
            webhook_url=webhook_url
        )

    def update_service_webhook_url(self, webhook_url):
        self.directory_client.update_service(
            self.service_id,
            callback_url=webhook_url
        )

    def link_device(self, username):
        return self.directory_client.link_device(username)

    def authorization_request(self, username):
        return self.service_client.authorization_request(username)

    def cancel_authorization_request(self, auth_request_id):

        self.service_client.cancel_authorization_request(