Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

GraphQL coverage for shopper assistance #8303

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/_data/toc/graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ pages:
- label: generateCustomerToken mutation
url: /graphql/mutations/generate-customer-token.html

- label: generateCustomerTokenAsAdmin mutation
url: /graphql/mutations/generate-customer-token-as-admin.html
exclude_versions: ["2.3"]

- label: handlePayflowProResponse mutation
url: /graphql/mutations/handle-payflow-pro-response.html

Expand Down
1 change: 1 addition & 0 deletions src/_includes/graphql/customer-output-24.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Attribute | Data Type | Description
--- | --- | ---
`addresses` | {{ customeraddress_text }} | An array containing the customer's shipping and billing addresses
`allow_remote_shopping_assistance` | Boolean! | Indicates whether the customer has enabled remote shopping assistance
`created_at` | String | Timestamp indicating when the account was created
`date_of_birth` | String | The customer's date of birth
`default_billing` | String | The ID assigned to the billing address
Expand Down
27 changes: 27 additions & 0 deletions src/guides/v2.4/graphql/authorization-tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,33 @@ You can now use this token in the Authorization request header field for any que

If necessary, you also can [revoke the customer's token]({{ page.baseurl }}/graphql/mutations/revoke-customer-token.html

The [`generateCustomerTokenAsAdmin`]({{page.baseurl}}/graphql/mutations/generate-customer-token-as-admin.html) mutation generates a new customer token as an admin so that an administrator can perform remote shopping assistance.
The customer must have enabled the `allow_remote_shopping_assistance` feature while creating the customer profile. The mutation requires the customer email address in the payload, as shown in the following example.

**Request:**

```graphql
mutation{
generateCustomerTokenAsAdmin(input: {
customer_email: "[email protected]"
}){
customer_token
}
}
```

**Response:**

```json
{
"data": {
"generateCustomerTokenAsAdmin": {
"customer_token": "cr0717abzoagxty1xjn4lj13kim36r6x"
}
}
}
```

## Admin tokens

In Magento GraphQL, you specify an admin token only if you need to query products, categories, price rules, or other entities that are scheduled to be in a campaign (staged content). Staging is supported in {{site.data.var.ee}} only. See [Staging queries]({{page.baseurl}}/graphql/queries/index.html#staging) for more information.
Expand Down
1 change: 1 addition & 0 deletions src/guides/v2.4/graphql/mutations/create-customer-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The following table lists the attributes you can use as input for the `createCus

Attribute | Data Type | Description
--- | --- | ---
`allow_remote_shopping_assistance` | Boolean | Indicates whether the customer has enabled remote shopping assistance
`date_of_birth` | String | The customer’s date of birth
`dob` | String | Deprecated. Use `date_of_birth` instead. The customer’s date of birth
`email` | String! | The customer’s email address
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
group: graphql
title: generateCustomerTokenAsAdmin mutation
contributor_name: EY
---

The `generateCustomerTokenAsAdmin` mutation generates a new customer token as an admin so that an administrator can perform remote shopping assistance on behalf of the customer. For example, if a customer has asked for help adding a product into their cart, you would specify the token returned by the `generateCustomerTokenAsAdmin` mutation in the header of your [`addProductsToCart` mutation]({{page.baseurl}}/graphql/mutations/add-products-to-cart.html).

To run this mutation, the customer must have enabled the **Allow remote shopping assistance** feature. You can specify the `allow_remote_shopping_assistance` attribute in a [`customer` query]({{page.baseurl}}/graphql/queries/customer.html] to determine whether the customer enabled this feature.

## Syntax

```graphql
mutation {generateCustomerTokenAsAdmin(input: GenerateCustomerTokenAsAdminInput!) {GenerateCustomerTokenAsAdminOutput}}
```

## Example usage

The following call creates a new customer token.

**Request:**

```graphql
mutation{
generateCustomerTokenAsAdmin(input: {
customer_email: "[email protected]"
}){
customer_token
}
}
```

**Response:**

```json
{
"data": {
"generateCustomerTokenAsAdmin": {
"customer_token": "cr0717abzoagxty1xjn4lj13kim36r6x"
}
}
}
```

## Input attributes

The `generateCustomerTokenAsAdmin` mutation requires the following input attribute:

Attribute | Data Type | Description
--- | --- | ---
`customer_email` | String! | The customer's email address

## Output attributes

The `generateCustomerTokenAsAdmin` mutation returns a valid customer token as the output.

Attribute | Data Type | Description
--- | --- | ---
`customer_token` | String! | The customer token

## Related topics

* [customer query]({{page.baseurl}}/graphql/queries/customer.html)
* [revokeCustomerToken mutation]({{page.baseurl}}/graphql/mutations/revoke-customer-token.html)
1 change: 1 addition & 0 deletions src/guides/v2.4/graphql/mutations/update-customer-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ The following table lists the attributes you can use as input for the `updateCus

Attribute | Data Type | Description
--- | --- | ---
`allow_remote_shopping_assistance` | Boolean | Indicates whether the customer has enabled remote shopping assistance
`date_of_birth` | String | The customer’s date of birth
`dob` | String | Deprecated. Use `date_of_birth` instead. The customer’s date of birth
`firstname` | String | The customer’s first name
Expand Down