# Customer API

# 获取当前 Member 的 Customer 列表

请求
query {
  customers(first: 10) {
    nodes {
      id
      # 这个 Customer 的创建者所属的 Client ID
      clientId
      # 当前 Customer 的创建者ID
      clientMemberId
      firstName
      lastName
      phoneNumber
      email
      createdAt
      updatedAt
      address {
        id
        firstName
        lastName
        address1
        address2
        city
        provinceId
        countryId
        zip
      }
      billingAddress {
        id
        firstName
        lastName
        address1
        address2
        city
        provinceId
        countryId
        zip
      }
      # pricingPackage: PricingPackage!
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
返回
{
  "data": {
    "customers": {
      "nodes": [
        {
          "id": "3",
          "clientId": "1",
          "clientMemberId": "73",
          "firstName": "Songhua",
          "lastName": "Yang",
          "phoneNumber": "123456789",
          "email": "hans@ventmere.com",
          "createdAt": "2020-04-30T14:54:47.652156+00:00",
          "updatedAt": "2020-06-25T18:48:46.940931+00:00",
          "address": {
            "id": "3",
            "firstName": "Songhua",
            "lastName": "Yang",
            "address1": "2015 Sheppard Ave E",
            "address2": "1205",
            "city": "North York",
            "provinceId": "ON",
            "countryId": "CA",
            "zip": "M2J 0B3"
          },
          "billingAddress": null
        },
        {
          "id": "107",
          "clientId": "1",
          "clientMemberId": "73",
          "firstName": "jamieson",
          "lastName": "daniels",
          "phoneNumber": "4161111111",
          "email": "djjd@gmail.com",
          "createdAt": "2020-06-26T19:30:15.412197+00:00",
          "updatedAt": "2020-06-26T19:30:15.412197+00:00",
          "address": {
            "id": "400",
            "firstName": "jamieson",
            "lastName": "daniels",
            "address1": "123 Yellow Submarine",
            "address2": "",
            "city": "Toronto",
            "provinceId": "ON",
            "countryId": "CA",
            "zip": "M1M 1M1"
          },
          "billingAddress": null
        }
      ],
      "pageInfo": {
        "hasNextPage": false,
        "endCursor": "MTA3"
      }
    }
  }
}

# 获取单个 Customer 详情

请求
query {
  customer(id: "3") {
    id
    # 这个 Customer 的创建者所属的 Client ID
    clientId
    # 当前 Customer 的创建者ID
    clientMemberId
    firstName
    lastName
    phoneNumber
    email
    createdAt
    updatedAt
    address {
      id
      firstName
      lastName
      address1
      address2
      city
      provinceId
      countryId
      zip
    }
    billingAddress {
      id
      firstName
      lastName
      address1
      address2
      city
      provinceId
      countryId
      zip
    }
    # pricingPackage: PricingPackage!
  }
}
返回
{
  "data": {
    "customer": {
      "id": "3",
      "clientId": "1",
      "clientMemberId": "73",
      "firstName": "Songhua",
      "lastName": "Yang",
      "phoneNumber": "123456789",
      "email": "hans@ventmere.com",
      "createdAt": "2020-04-30T14:54:47.652156+00:00",
      "updatedAt": "2020-06-25T18:48:46.940931+00:00",
      "address": {
        "id": "3",
        "firstName": "Songhua",
        "lastName": "Yang",
        "address1": "2015 Sheppard Ave E",
        "address2": "1205",
        "city": "North York",
        "provinceId": "ON",
        "countryId": "CA",
        "zip": "M2J 0B3"
      },
      "billingAddress": null
    }
  }
}

# 更新 Customer

请求
mutation {
  updateCustomer(
    input: {
      id: "3"
      firstName: "Songhua"
      lastName: "Yang"
      phoneNumber: "123456789"
      email: "hans@ventmere.com"
      address: {
        address1: "2015 Sheppard Ave E"
        address2: "1205"
        city: "North York"
        provinceId: "ON"
        countryId: "CA"
        zip: "M2J 0B3"
      }
      billingAddress: null
    }
  ) {
    customer {
      id
    }
  }
}
返回
{
  "data": {
    "customer": {
      "id": "3"
    }
  }
}