Пример #1
0
    def customer(self, val):
        """Set customer
        Keyword argument:
        val -- New customer value"""
        if val is None:
            self._customer = val
            return self

        if isinstance(val, dict):
            obj = processout.Customer(self._client)
            obj.fill_with_data(val)
            self._customer = obj
        else:
            self._customer = val
        return self
Пример #2
0
    def fetch_customer(self, options={}):
        """Get the customer owning the subscription.
        Keyword argument:
        
        options -- Options for the request"""
        self.fill_with_data(options)

        request = Request(self._client)
        path = "/subscriptions/" + quote_plus(self.id) + "/customers"
        data = {}

        response = Response(request.get(path, data, options))
        return_values = []

        body = response.body
        body = body["customer"]
        customer = processout.Customer(self._client)
        return_values.append(customer.fill_with_data(body))

        return return_values[0]
Пример #3
0
    def find(self, customer_id, options={}):
        """Find a customer by its ID.
        Keyword argument:
        customer_id -- ID of the customer
        options -- Options for the request"""
        self.fill_with_data(options)

        request = Request(self._client)
        path = "/customers/" + quote_plus(customer_id) + ""
        data = {}

        response = Response(request.get(path, data, options))
        return_values = []

        body = response.body
        body = body["customer"]

        obj = processout.Customer(self._client)
        return_values.append(obj.fill_with_data(body))

        return return_values[0]
Пример #4
0
    def assign_customer(self, customer_id, options = {}):
        """Assign a customer to the invoice.
        Keyword argument:
        customer_id -- ID of the customer to be linked to the invoice
        options -- Options for the request"""
        self.fill_with_data(options)

        request = Request(self._client)
        path    = "/invoices/" + quote_plus(self.id) + "/customers"
        data    = {
            'customer_id': customer_id
        }

        response = Response(request.post(path, data, options))
        return_values = []
        
        body = response.body
        body = body["customer"]
        customer = processout.Customer(self._client)
        return_values.append(customer.fill_with_data(body))

        
        return return_values[0]
Пример #5
0
    def all(self, options={}):
        """Get all the customers.
        Keyword argument:
        
        options -- Options for the request"""
        self.fill_with_data(options)

        request = Request(self._client)
        path = "/customers"
        data = {}

        response = Response(request.get(path, data, options))
        return_values = []

        a = []
        body = response.body
        for v in body['customers']:
            tmp = processout.Customer(self._client)
            tmp.fill_with_data(v)
            a.append(tmp)

        return_values.append(a)

        return return_values[0]
Пример #6
0
 def new_customer(self, prefill=None):
     """Create a new Customer instance
     Keyword argument:
     prefill -- Data used to prefill the object (optional)"""
     return processout.Customer(self, prefill)