def get_tier_config(self, tier_id, product_id):
        """
        Gets the specified tier config data. For example, to get Tier 1 configuration data
        for one request, within the FulfillmentAutomation instance, we can do: ::

            self.get_tier_config(request.asset.tiers.tier1.id, request.asset.product.id)

        :param str tier_id: Account Id of the requested Tier Config (id with TA prefix).
        :param str product_id: Id of the product.
        :return: The requested Tier Config, or ``None`` if it was not found.
        :rtype: Optional[TierConfig]
        """
        url = self._api.urljoin(self.config.api_url, 'tier/config-requests')
        params = {
            'status': 'approved',
            'configuration__product__id': product_id,
            'configuration__account__id': tier_id,
        }
        response, _ = self._api.get(url=url, params=params)
        objects = TierConfigRequest.deserialize(response)

        if isinstance(objects, list) and len(objects) > 0:
            return objects[0].configuration
        else:
            return None
示例#2
0
 def make_object(self, data):
     from connect.models import TierConfigRequest
     return TierConfigRequest(**data)