def fetch_subscription_discounts(self, subscription_id, options = {}): """Get the discounts applied to the subscription. Keyword argument: subscription_id -- ID of the subscription options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/subscriptions/" + quote_plus(subscription_id) + "/discounts" data = { } response = Response(request.get(path, data, options)) return_values = [] a = [] body = response.body for v in body['discounts']: tmp = processout.Discount(self._client) tmp.fill_with_data(v) a.append(tmp) return_values.append(a) return return_values[0]
def find(self, subscription_id, discount_id, options = {}): """Find a subscription's discount by its ID. Keyword argument: subscription_id -- ID of the subscription on which the discount was applied discount_id -- ID of the discount options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/subscriptions/" + quote_plus(subscription_id) + "/discounts/" + quote_plus(discount_id) + "" data = { } response = Response(request.get(path, data, options)) return_values = [] body = response.body body = body["discount"] obj = processout.Discount(self._client) return_values.append(obj.fill_with_data(body)) return return_values[0]
def discounts(self, val): """Set discounts Keyword argument: val -- New discounts value""" if val is None: self._discounts = [] return self if len(val) > 0 and isinstance(val[0], processout.Discount): self._discounts = val else: l = [] for v in val: obj = processout.Discount(self._client) obj.fill_with_data(v) l.append(obj) self._discounts = l return self
def new_discount(self, prefill=None): """Create a new Discount instance Keyword argument: prefill -- Data used to prefill the object (optional)""" return processout.Discount(self, prefill)