Exemple #1
0
    def get_taxes(cls,
                  business_id,
                  start_at=None,
                  start_offset=None,
                  end_at=None,
                  limit=None):
        """
        Get a list of taxes at a business.

        Arguments:
        business_id (str): the business ID

        Keyword arguments:
        start_at (int, optional): get taxes created after this time in seconds
        start_offset (int, optional): the numeric offset to start the list (for pagination)
        end_at (int, optional): get taxes created before this time in seconds
        limit (int, optional): how many taxes to return (for pagination)
        """

        params = {}
        if start_at is not None:
            params['startAt'] = start_at
        if start_offset is not None:
            params['startOffset'] = start_offset
        if end_at is not None:
            params['endAt'] = end_at
        if limit is not None:
            params['limit'] = limit

        api = API.shared_instance()
        return api.request(
            url='/businesses/%s/taxes' % business_id,
            method='GET',
            params=params,
        )
Exemple #2
0
    def get_customers(cls,
                      business_id,
                      start_at=None,
                      start_offset=None,
                      end_at=None,
                      limit=None,
                      card_number_first_6=None,
                      card_number_last_4=None,
                      card_expiration_month=None,
                      card_expiration_year=None,
                      card_holder_first_name=None,
                      card_holder_last_name=None):
        """
        Get all customers of a business by various criteria.

        Arguments:
        business_id (str): the business ID

        Keyword arguments:
        start_at (int, optional): get customers created after this time in seconds
        start_offset (int, optional): the numeric offset to start the list (for pagination)
        end_at (int, optional): get customers created before this time in seconds
        limit (int, optional): how many customers to return (for pagination)
        card_number_first_6 (str, optional): return customers with card numbers starting with this
        card_number_last_4 (str, optional): return customers with card numbers ending with this
        card_expiration_month (str, optional): return customers with this card expiration month
        card_expiration_year (str, optional): return customers with this card expiration year
        card_holder_first_name (str, optional): return customers with first name matching this
        card_holder_last_name (str, optional): return customers with last name matching this
        """

        params = {}
        if start_at is not None:
            params['startAt'] = start_at
        if start_offset is not None:
            params['startOffset'] = start_offset
        if end_at is not None:
            params['endAt'] = end_at
        if limit is not None:
            params['limit'] = limit
        if card_number_first_6 is not None:
            params['cardNumberFirst6'] = card_number_first_6
        if card_number_last_4 is not None:
            params['cardNumberLast4'] = card_number_last_4
        if card_expiration_month is not None:
            params['cardExpirationMonth'] = card_expiration_month
        if card_expiration_year is not None:
            params['cardExpirationYear'] = card_expiration_year
        if card_holder_first_name is not None:
            params['cardHolderFirstName'] = card_holder_first_name
        if card_holder_last_name is not None:
            params['cardHolderLastName'] = card_holder_last_name

        api = API.shared_instance()
        return api.request(
            url='/businesses/%s/customers' % business_id,
            method='GET',
            params=params,
        )
Exemple #3
0
    def delete_hook(cls, hook_id):
        """
        Deletes a hook.

        Arguments:
        hook_id (str): hook ID
        """

        api = API.shared_instance()
        return api.request(url='/hooks/%s' % hook_id, method='DELETE')
Exemple #4
0
    def get_hook(cls, hook_id):
        """
        Gets a hook by ID.

        Arguments:
        hook_id (str): hook ID
        """

        api = API.shared_instance()
        return api.request(url='/hooks/%s' % hook_id, method='GET')
Exemple #5
0
    def get_business_users(cls, business_id):
        """
        Get all users at a business.

        Arguments:
        business_id (str): the business ID
        """

        api = API.shared_instance()
        return api.request(url='/businesses/%s/businessUsers' % business_id,
                           method='GET')
Exemple #6
0
    def get_tax(cls, business_id, tax_id):
        """
        Get a single tax for a business.

        Arguments:
        business_id (str): the business ID
        tax_id (str): the tax ID
        """

        api = API.shared_instance()
        return api.request(url='/businesses/%s/taxes/%s' %
                           (business_id, tax_id),
                           method='GET')
Exemple #7
0
    def get_product(cls, business_id, product_id):
        """
        Get a single product for a business.

        Arguments:
        business_id (str): the business ID
        product_id (str): the product ID
        """

        api = API.shared_instance()
        return api.request(url='/businesses/%s/products/%s' %
                           (business_id, product_id),
                           method='GET')
Exemple #8
0
    def delete_tax(cls, business_id, tax_id):
        """
        Deletes a tax.

        Arguments:
        business_id (str): the business ID
        tax_id (str): the tax ID
        """

        api = API.shared_instance()
        return api.request(url='/businesses/%s/taxes/%s' %
                           (business_id, tax_id),
                           method='DELETE')
Exemple #9
0
    def get_catalog(cls, business_id, catalog_id):
        """
        Get a single catalog for a business.

        Arguments:
        business_id (str): the business ID
        catalog_id (str): the catalog ID
        """

        api = API.shared_instance()
        return api.request(url='/businesses/%s/catalogs/%s' %
                           (business_id, catalog_id),
                           method='GET')
Exemple #10
0
    def get_business_application(cls, business_id):
        """
        Gets a business application

        Arguments:
        business_id (str): the business ID of the business
        """
        api = API.shared_instance()
        return api.request(
            url='/businesses/' + business_id + '/payfac-application',
            method='GET',
            app='WEB',
        )
Exemple #11
0
    def get_order(cls, business_id, order_id):
        """
        Get a single order at a business.

        Arguments:
        business_id (str): the business ID
        order_id (str): the order ID
        """

        api = API.shared_instance()
        return api.request(url='/businesses/%s/orders/%s' %
                           (business_id, order_id),
                           method='GET')
Exemple #12
0
    def get_business(cls, business_id):
        """
        Gets a business by ID.

        Arguments:
        business_id (str): the business ID to get
        """

        api = API.shared_instance()
        return api.request(
            url='/businesses/%s' % business_id,
            method='GET'
        )
Exemple #13
0
    def send_raw_cloud_message(cls, message):
        """
        Sends a cloud message by specifying the entire message object.

        Arguments:
        message (dict): the full cloud message object
        """

        api = API.shared_instance()
        return api.request(
            url='/cloudMessages',
            method='POST',
            json=message,
        )
Exemple #14
0
    def get_full_catalog(cls, business_id, catalog_id):
        """
        Get a catalog by id with all product details info embedded in
        the Catalog.

        Arguments:
        business_id (str): the business ID
        catalog_id (str): the catalog ID
        """

        api = API.shared_instance()
        return api.request(url='/businesses/%s/catalogs/%s/full' %
                           (business_id, catalog_id),
                           method='GET')
Exemple #15
0
    def delete_category(cls, business_id, catalog_id, category_id):
        """
        Deletes a category by ID.

        Arguments:
        business_id (str): the business ID
        catalog_id (str): the catalog ID
        category_id (str): the category ID
        """

        api = API.shared_instance()
        return api.request(url='/businesses/%s/catalogs/%s/categories/%s' %
                           (business_id, catalog_id, category_id),
                           method='DELETE')
Exemple #16
0
    def delete_product(cls, business_id, product_id):
        """
        Deactivates a product. Deactivated products will be removed from all
        catalog references.

        Arguments:
        business_id (str): the business ID
        product_id (str): the product ID
        """

        api = API.shared_instance()
        return api.request(url='/businesses/%s/products/%s' %
                           (business_id, product_id),
                           method='DELETE')
Exemple #17
0
    def get_store(cls, business_id, store_id):
        """
        Gets a store by ID.

        Arguments:
        business_id (str): the business ID
        store_id (str): the store ID
        """

        api = API.shared_instance()
        return api.request(
            url='/businesses/%s/stores/%s' % (business_id, store_id),
            method='GET'
        )
Exemple #18
0
    def get_business_account(cls, business_id):
        """
        Get account information related to the business

        Arguments:
        business_id (str): the business ID of the business
        """

        api = API.shared_instance()
        return api.request(
            url='/businesses/' + business_id + '/payfac-application/account',
            method='GET',
            app='WEB',
        )
Exemple #19
0
    def create_product(cls, business_id, product):
        """
        Creates a product on a business.

        Arguments:
        business_id (str): the business ID
        product (dict): the full product object
        """

        api = API.shared_instance()
        return api.request(
            url='/businesses/%s/products' % business_id,
            method='POST',
            json=product,
        )
Exemple #20
0
    def create_catalog(cls, business_id, catalog):
        """
        Creates a catalog on a business.

        Arguments:
        business_id (str): the business ID
        catalog (dict): the catalog object
        """

        api = API.shared_instance()
        return api.request(
            url='/businesses/%s/catalogs' % business_id,
            method='POST',
            json=catalog,
        )
Exemple #21
0
    def create_tax(cls, business_id, tax):
        """
        Creates a tax on a business.

        Arguments:
        business_id (str): the business ID
        tax (dict): the full tax object
        """

        api = API.shared_instance()
        return api.request(
            url='/businesses/%s/taxes' % business_id,
            method='POST',
            json=tax,
        )
Exemple #22
0
    def get_transaction(cls, business_id, transaction_id):
        """
        Get a single transaction at a business.

        Arguments:
        business_id (str): the business ID
        transaction_id (str): the transaction ID
        """

        api = API.shared_instance()
        return api.request(
            url='/businesses/%s/transactions/%s' % (
                business_id, transaction_id),
            method='GET'
        )
Exemple #23
0
    def create_full_catalog(cls, business_id, full_catalog):
        """
        Creates a catalog on a business with embedded products.
        This differs from create_catalog as you can create products
        and catalogs at the same time.

        Arguments:
        business_id (str): the business ID
        full_catalog (dict): the full catalog object
        """

        api = API.shared_instance()
        return api.request(
            url='/businesses/%s/catalogs/full' % business_id,
            method='POST',
            json=full_catalog,
        )
Exemple #24
0
    def lookup_products(cls, business_id, product_ids):
        """
        Get a list of products by ID.

        Arguments:
        business_id (str): the business ID
        product_ids (list of str): a list of product ids
        """

        params = {'ids': product_ids}

        api = API.shared_instance()
        return api.request(
            url='/businesses/%s/products/lookup' % business_id,
            method='GET',
            params=params,
        )
Exemple #25
0
    def get_business_by_device_id(cls, device_id):
        """
        Get a business by a device id.

        Arguments:
        device_id (str): the device ID to get a business for
        """

        params = {
            'storeDeviceId': device_id
        }

        api = API.shared_instance()
        return api.request(
            url='/businesses',
            method='GET',
            params=params
        )
Exemple #26
0
    def get_hooks(cls, business_id):
        """
        Gets a list of hooks currently subscribed to.

        Arguments:
        business_id (str): use a merchant business ID to see what webhooks your app
                           is subscribed to for that merchant. use your own organization
                           ID to see your app billing webhooks, etc.
        """

        params = {'businessId': business_id}

        api = API.shared_instance()
        return api.request(
            url='/hooks',
            method='GET',
            params=params,
        )
Exemple #27
0
    def get_reports(cls, business_id, store_id=None, device_id=None, timezone=None, page=1, limit=25, report_type=None,
                    user_id=None, including_date=None):
        """
        Get reports at a business.

        Arguments:
        business_id (str): the business ID

        Keyword arguments:
        store_id (str, optional): the store ID
        device_id (str, optional): the device ID
        timezone (str, optional): the timezone
        page (int, optional): the page of reports to load. defaults to 1
        limit (int, optional): the number of reports to load per page. defaults to 25
        report_type (str, optional): report types to filter by
        user_id (str, optional): user id to filter by
        including_date (str, optional): show only reports whose time range overlaps to this date
        """

        params = {}
        if store_id is not None:
          params['storeId'] = store_id
        if device_id is not None:
          params['deviceId'] = device_id
        if timezone is not None:
          params['timezone'] = timezone
        if page is not None:
          params['page'] = page
        if limit is not None:
          params['limit'] = limit
        if report_type is not None:
          params['reportType'] = report_type
        if user_id is not None:
          params['userId'] = user_id
        if including_date is not None:
          params['includingDate'] = including_date

        api = API.shared_instance()
        return api.request(
            url='/businesses/%s/reports' % business_id,
            method='GET',
            params=params,
            app='WEB',
        )
Exemple #28
0
    def lookup_categories(cls, business_id, catalog_id, category_ids):
        """
        Gets multiple categories on a catalog by IDs.

        Arguments:
        business_id (str): the business ID
        catalog_id (str): the catalog ID
        category_ids (list of str): a list of category ids
        """

        params = {'ids': category_ids}

        api = API.shared_instance()
        return api.request(
            url='/businesses/%s/catalogs/%s/categories/lookup' %
            (business_id, catalog_id),
            method='GET',
            params=params,
        )
Exemple #29
0
    def update_category(cls,
                        business_id,
                        catalog_id,
                        category_id,
                        category=None,
                        patch=None,
                        no_remove=True):
        """
        Updates a category by ID. Can either specify the whole category, or an array
        of JSON Patch instructions.

        Arguments:
        business_id (str): the business ID
        catalog_id (str): the catalog ID
        category_id (str): the category ID

        Keyword arguments:
        category (dict): the category object
        patch (list of dict): JSON Patch update instructions
        no_remove (boolean, optional): don't remove any keys from old category in the patch.
                                       safer this way. defaults to True
        """

        # get patch instructions if only category is specified
        if patch is None:
            if category is None:
                raise ValueError("Either patch or category must be specified")

            old_category, status_code = cls.get_category(
                business_id, catalog_id, category_id)
            if status_code >= 300 or old_category is None:
                raise RuntimeError("Category to patch not found")

            patch = json_patch(old_category, category, no_remove=no_remove)

        api = API.shared_instance()
        return api.request(
            url='/businesses/%s/catalogs/%s/categories/%s' %
            (business_id, catalog_id, category_id),
            method='PATCH',
            json=patch,
        )
Exemple #30
0
    def create_hook(cls,
                    business_id,
                    delivery_url,
                    secret=None,
                    event_type=None,
                    event_types=None):
        """
        Subscribes to a webhook.

        Arguments:
        business_id (str): the business ID to subscribe to a hook for. Use a merchant
                           business ID to subscribe to their e.g. transaction hooks;
                           use your own organization ID to subscribe to app billing, etc.
        delivery_url (str): the URL to deliver webhooks to.

        Keyword arguments:
        secret (str, optional): used to sign the webhook event, so you can verify.
        event_type (str, optional): a single event type to subscribe to webhooks for.
        event_types (list of str, optional): a list of event types to subscribe to webhooks for.
        """

        api = API.shared_instance()

        json = {
            'applicationId': api.application_id,
            'businessId': business_id,
            'deliveryUrl': delivery_url,
        }
        if secret is not None:
            json['secret'] = secret
        if event_types is not None:
            json['eventTypes'] = event_types
        elif event_type is not None:
            json['eventTypes'] = [event_type]

        return api.request(
            url='/hooks',
            method='POST',
            json=json,
        )