File: customer.py

package info (click to toggle)
python-shopifyapi 12.7.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 560 kB
  • sloc: python: 1,752; sh: 10; makefile: 9
file content (29 lines) | stat: -rw-r--r-- 1,039 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from ..base import ShopifyResource
from shopify import mixins
from .customer_invite import CustomerInvite
from .order import Order


class Customer(ShopifyResource, mixins.Metafields):
    @classmethod
    def search(cls, **kwargs):
        """
        Search for customers matching supplied query

        Args:
           order: Field and direction to order results by (default: last_order_date DESC)
           query: Text to search for customers
           page: Page to show (default: 1)
           limit: Amount of results (default: 50) (maximum: 250)
           fields: comma-separated list of fields to include in the response
        Returns:
           A Collection of customers.
        """
        return cls._build_collection(cls.get("search", **kwargs))

    def send_invite(self, customer_invite=CustomerInvite()):
        resource = self.post("send_invite", customer_invite.encode())
        return CustomerInvite(Customer.format.decode(resource.body))

    def orders(self):
        return Order.find(customer_id=self.id)