Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

REST API: Customer Session Data #1320

Closed
3 tasks done
mikejolley opened this issue Dec 4, 2019 · 1 comment · Fixed by #1417
Closed
3 tasks done

REST API: Customer Session Data #1320

mikejolley opened this issue Dec 4, 2019 · 1 comment · Fixed by #1417
Assignees
Labels
focus: rest api Work impacting REST api routes.

Comments

@mikejolley
Copy link
Member

mikejolley commented Dec 4, 2019

Stores session data for the current customer, including addresses, user ID, and email if known.

GET /customer
POST /customer

This will be used during cart and checkout to store provided address information.

Properties, adapted from core customers API:

'id'                 => array(
  'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
  'type'        => 'integer',
  'context'     => array( 'view', 'edit' ),
  'readonly'    => true,
),
'billing'            => array(
  'description' => __( 'List of billing address data.', 'woocommerce-rest-api' ),
  'type'        => 'object',
  'context'     => array( 'view', 'edit' ),
  'properties'  => array(
    'first_name' => array(
      'description' => __( 'First name.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'last_name'  => array(
      'description' => __( 'Last name.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'company'    => array(
      'description' => __( 'Company name.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'address_1'  => array(
      'description' => __( 'Address line 1', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'address_2'  => array(
      'description' => __( 'Address line 2', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'city'       => array(
      'description' => __( 'City name.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'state'      => array(
      'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'postcode'   => array(
      'description' => __( 'Postal code.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'country'    => array(
      'description' => __( 'ISO code of the country.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'email'      => array(
      'description' => __( 'Email address.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'format'      => 'email',
      'context'     => array( 'view', 'edit' ),
    ),
    'phone'      => array(
      'description' => __( 'Phone number.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
  ),
),
'shipping'           => array(
  'description' => __( 'List of shipping address data.', 'woocommerce-rest-api' ),
  'type'        => 'object',
  'context'     => array( 'view', 'edit' ),
  'properties'  => array(
    'first_name' => array(
      'description' => __( 'First name.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'last_name'  => array(
      'description' => __( 'Last name.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'company'    => array(
      'description' => __( 'Company name.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'address_1'  => array(
      'description' => __( 'Address line 1', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'address_2'  => array(
      'description' => __( 'Address line 2', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'city'       => array(
      'description' => __( 'City name.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'state'      => array(
      'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'postcode'   => array(
      'description' => __( 'Postal code.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
    'country'    => array(
      'description' => __( 'ISO code of the country.', 'woocommerce-rest-api' ),
      'type'        => 'string',
      'context'     => array( 'view', 'edit' ),
    ),
  ),
),

Questions:

  • Since this API requires no authentication, do we require additional mechanisms in place to ensure requests only come from the store?
  • How do we surface address fields for extensions to extend/add to?
  • What validation is needed for addresses etc?
  • Are we happy with /customer or would it make more sense to expose /session and include all session data from the server?

Tasks:

  • Implement schema/endpoint
  • Get customer data
  • Update customer data
@mikejolley mikejolley added the focus: rest api Work impacting REST api routes. label Dec 4, 2019
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label type: feature request to this issue, with a confidence of 0.91. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
focus: rest api Work impacting REST api routes.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant