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

Commit 39f0d89

Browse files
sathiyaaarogyarkeharper
authored
GraphQL coverage for shopper assistance (#8303)
* added graphql coverage for shopper assistance * fixed lint errors * Apply suggestions from code review changed the customer_token and customer_email to required attributes Co-authored-by: Yaroslav Rogoza <enarc@atwix.com> * Update graphql.yml * Update generate-customer-token-as-admin.md * Update generate-customer-token-as-admin.md Co-authored-by: Yaroslav Rogoza <enarc@atwix.com> Co-authored-by: Kevin Harper <keharper@users.noreply.github.com>
1 parent e5bcf8e commit 39f0d89

File tree

6 files changed

+98
-0
lines changed

6 files changed

+98
-0
lines changed

src/_data/toc/graphql.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ pages:
309309
- label: generateCustomerToken mutation
310310
url: /graphql/mutations/generate-customer-token.html
311311

312+
- label: generateCustomerTokenAsAdmin mutation
313+
url: /graphql/mutations/generate-customer-token-as-admin.html
314+
exclude_versions: ["2.3"]
315+
312316
- label: handlePayflowProResponse mutation
313317
url: /graphql/mutations/handle-payflow-pro-response.html
314318

src/_includes/graphql/customer-output-24.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Attribute | Data Type | Description
1212
--- | --- | ---
1313
`addresses` | {{ customeraddress_text }} | An array containing the customer's shipping and billing addresses
14+
`allow_remote_shopping_assistance` | Boolean! | Indicates whether the customer has enabled remote shopping assistance
1415
`created_at` | String | Timestamp indicating when the account was created
1516
`date_of_birth` | String | The customer's date of birth
1617
`default_billing` | String | The ID assigned to the billing address

src/guides/v2.4/graphql/authorization-tokens.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,33 @@ You can now use this token in the Authorization request header field for any que
4343

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

46+
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.
47+
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.
48+
49+
**Request:**
50+
51+
```graphql
52+
mutation{
53+
generateCustomerTokenAsAdmin(input: {
54+
customer_email: "customer1@mail.com"
55+
}){
56+
customer_token
57+
}
58+
}
59+
```
60+
61+
**Response:**
62+
63+
```json
64+
{
65+
"data": {
66+
"generateCustomerTokenAsAdmin": {
67+
"customer_token": "cr0717abzoagxty1xjn4lj13kim36r6x"
68+
}
69+
}
70+
}
71+
```
72+
4673
## Admin tokens
4774

4875
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.

src/guides/v2.4/graphql/mutations/create-customer-v2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ The following table lists the attributes you can use as input for the `createCus
6161

6262
Attribute | Data Type | Description
6363
--- | --- | ---
64+
`allow_remote_shopping_assistance` | Boolean | Indicates whether the customer has enabled remote shopping assistance
6465
`date_of_birth` | String | The customer’s date of birth
6566
`dob` | String | Deprecated. Use `date_of_birth` instead. The customer’s date of birth
6667
`email` | String! | The customer’s email address
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
group: graphql
3+
title: generateCustomerTokenAsAdmin mutation
4+
contributor_name: EY
5+
---
6+
7+
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).
8+
9+
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.
10+
11+
## Syntax
12+
13+
```graphql
14+
mutation {generateCustomerTokenAsAdmin(input: GenerateCustomerTokenAsAdminInput!) {GenerateCustomerTokenAsAdminOutput}}
15+
```
16+
17+
## Example usage
18+
19+
The following call creates a new customer token.
20+
21+
**Request:**
22+
23+
```graphql
24+
mutation{
25+
generateCustomerTokenAsAdmin(input: {
26+
customer_email: "customer1@mail.com"
27+
}){
28+
customer_token
29+
}
30+
}
31+
```
32+
33+
**Response:**
34+
35+
```json
36+
{
37+
"data": {
38+
"generateCustomerTokenAsAdmin": {
39+
"customer_token": "cr0717abzoagxty1xjn4lj13kim36r6x"
40+
}
41+
}
42+
}
43+
```
44+
45+
## Input attributes
46+
47+
The `generateCustomerTokenAsAdmin` mutation requires the following input attribute:
48+
49+
Attribute | Data Type | Description
50+
--- | --- | ---
51+
`customer_email` | String! | The customer's email address
52+
53+
## Output attributes
54+
55+
The `generateCustomerTokenAsAdmin` mutation returns a valid customer token as the output.
56+
57+
Attribute | Data Type | Description
58+
--- | --- | ---
59+
`customer_token` | String! | The customer token
60+
61+
## Related topics
62+
63+
* [customer query]({{page.baseurl}}/graphql/queries/customer.html)
64+
* [revokeCustomerToken mutation]({{page.baseurl}}/graphql/mutations/revoke-customer-token.html)

src/guides/v2.4/graphql/mutations/update-customer-v2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ The following table lists the attributes you can use as input for the `updateCus
5656

5757
Attribute | Data Type | Description
5858
--- | --- | ---
59+
`allow_remote_shopping_assistance` | Boolean | Indicates whether the customer has enabled remote shopping assistance
5960
`date_of_birth` | String | The customer’s date of birth
6061
`dob` | String | Deprecated. Use `date_of_birth` instead. The customer’s date of birth
6162
`firstname` | String | The customer’s first name

0 commit comments

Comments
 (0)