class Subscription(object):
    """ This class allows manage billing request and recurring asset,
    :param Config config: Config object or ``None`` to use environment config (default).
    """

    _config = None  # type: Config

    def __init__(self, config=None):
        self._config = config or Config.get_instance()
        self._billing_request = BillingRequestResource(config=self._config)
        self._recurring_asset = RecurringAssetResource(config=self._config)

    def create_billing_request(self, obj):
        return self._billing_request.create(obj)

    def update_billing_request(self, id_br, body):
        return self._billing_request.update(id_br, body)
Esempio n. 2
0
    def test_add_billing_request(self, post_mock):
        # type: (Mock) -> None
        post_mock.return_value = Response(True, add_billing_request_response,
                                          200)
        body = add_billing_request_body
        request = BillingRequestResource(config=self.config)
        billing_request = request.create(body)

        post_mock.assert_called_with(
            headers={
                'Content-Type': 'application/json',
                'Authorization': 'ApiKey XXXX:YYYYY'
            },
            json=body,
            timeout=300,
            url='http://localhost:8080/api/public/v1/subscriptions/requests')
        assert isinstance(billing_request, BillingRequest)
        assert billing_request.id == 'BRP-6750-9514-7931-0001'