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

Commit 4c984ce

Browse files
keharperdobooth
andauthored
GraphQL: Add coverage for create/updateCompany mutations (#7949)
* GraphQL: Add coverage for add/updateCompany mutations * fix broken link Co-authored-by: Donald Booth <[email protected]>
1 parent 92be285 commit 4c984ce

File tree

5 files changed

+385
-0
lines changed

5 files changed

+385
-0
lines changed

src/_data/toc/graphql.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ pages:
193193
- label: createBraintreeClientToken mutation
194194
url: /graphql/mutations/create-braintree-client-token.html
195195

196+
- label: createCompany mutation
197+
url: /graphql/mutations/create-company.html
198+
edition: b2b-only
199+
exclude_versions: ["2.3"]
200+
196201
- label: createCustomer mutation
197202
url: /graphql/mutations/create-customer.html
198203

@@ -327,6 +332,11 @@ pages:
327332
- label: updateCartItems mutation
328333
url: /graphql/mutations/update-cart-items.html
329334

335+
- label: updateCompany mutation
336+
url: /graphql/mutations/update-company.html
337+
edition: b2b-only
338+
exclude_versions: ["2.3"]
339+
330340
- label: updateCustomer mutation
331341
url: /graphql/mutations/update-customer.html
332342

src/_includes/graphql/company.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
The `Company` object can contain the following attributes:
2+
3+
Attribute | Data type | Description
4+
--- | --- | ---
5+
`acl_resources` [CompanyAclResource] | Returns the list of all resources defined within the company
6+
`company_admin` | [Customer]({{page.baseurl}}/graphql/queries/customer.html) | An object containing information about the company administrator
7+
`email` | String | The email address of the company contact
8+
`id` | ID! | The ID assigned to the company
9+
`legal_address` | CompanyLegalAddress | The address where the company is registered to conduct business
10+
`legal_name` | String | The full legal name of the company
11+
`name` | String | The name of the company
12+
`payment_methods` | [String] The list of payment methods available to a company
13+
`reseller_id` | String | The resale number that is assigned to the company for tax reporting purposes
14+
`role(id: ID!)` | CompanyRole | Returns information about the specified company role
15+
`roles(pageSize: Int = 20, currentPage: Int = 1 )` | CompanyRoles! | Returns the list of company roles
16+
`sales_representative` | CompanySalesRepresentative | The company sales representative
17+
`structure(rootId: ID = 0 depth: Int = 10 )` | CompanyStructure | Returns the company structure of teams and customers in depth-first order
18+
`team(id: ID!)` | CompanyTeam | Returns the specified company team
19+
`user(id: ID!)` | Customer | Returns the specified company user
20+
`users(filter: CompanyUsersFilterInput, pageSize: Int = 20, currentPage: Int = 1)`| CompanyUsers | Returns the company users that match the specified filter
21+
`vat_id` | String | The value-added tax number that is assigned to the company by some jurisdictions for tax reporting purposes
22+
23+
### CompanyAclResource attributes {#CompanyAclResource}
24+
25+
The `CompanyAclResource` object can contain the following attributes:
26+
27+
Attribute | Data Type | Description
28+
--- | --- | ---
29+
`children` | [CompanyAclResource!] | An array of sub-resources
30+
`id` | ID! | The ID assigned to the ACL resource
31+
`sortOrder` | Int | ACL resource sort order
32+
`text` | String | The label assigned to the ACL resource
33+
34+
### CompanyAdmin attributes {#CompanyAdmin}
35+
36+
The `CompanyAdmin` object can contain the following attributes:
37+
38+
Attribute | Data Type | Description
39+
--- | --- | ---
40+
`email` | String! | The email address of the company administrator
41+
`firstname` | String! | The company administrator's first name
42+
`gender` | Int | The company administrator's gender (Male - 1, Female - 2, Not Specified - 3)
43+
`id` | ID! | The ID assigned to the company administrator
44+
`job_title` | String | The job title of the company administrator
45+
`lastname` | String! | The company administrator's last name
46+
47+
### CompanyLegalAddress attributes {#CompanyLegalAddress}
48+
49+
The `CompanyLegalAddress` object can contain the following attributes:
50+
51+
Attribute | Data Type | Description
52+
--- | --- | ---
53+
`city` | String! | The city where the company is registered to conduct business
54+
`country_id` | CountryCodeEnum! | Company's country ID. See the [`countries` query]({{page.baseurl}}/graphql/queries/directory-countries.html)
55+
`postcode` | String! | The ZIP/postal code of the company
56+
`region` | CustomerAddressRegionInput! | An object containing the region name and/or region ID where the company is registered to conduct business
57+
`street` | [String!]! | An array of strings that define the street address where the company is registered to conduct business
58+
`telephone` | String! | The primary phone number of the company.
59+
60+
### CompanyRole attributes {#CompanyRole}
61+
62+
The `CompanyRole` object can contain the following attributes:
63+
64+
Attribute | Data Type | Description
65+
--- | --- | ---
66+
`id`| ID! | The ID assigned to the role
67+
`name` | String | The name assigned to the role
68+
`permissions` | [CompanyAclResource] | A list of permission resources defined for a role
69+
`users_count` | Int | The total number of users assigned the specified role
70+
71+
### CompanyRoles attributes {#CompanyRoles}
72+
73+
The `CompanyRoles` object can contain the following attributes:
74+
75+
Attribute | Data Type | Description
76+
--- | --- | ---
77+
`items` | [CompanyRole] | A list of company roles that match the specified filter criteria
78+
`page_info` | SearchResultPageInfo | Pagination meta data
79+
`total_count` | Int | The total number of roles matching the specified filter
80+
81+
### CompanySalesRepresentative attributes {#CompanySalesRepresentative}
82+
83+
The `CompanySalesRepresentative` object can contain the following attributes:
84+
85+
Attribute | Data Type | Description
86+
--- | --- | ---
87+
`email` | String! | The email address of the company sales representative
88+
`firstname` | String! | The company sales representative's first name
89+
`lastname` | String! | The company sales representative's last name
90+
91+
### CompanyUsers attributes {#CompanyUsers}
92+
93+
The `CompanyUsers` object can contain the following attributes:
94+
95+
Attribute | Data Type | Description
96+
--- | --- | ---
97+
`items` | [[Customer]]({{page.baseurl}}/graphql/queries/customer.html) | An array of `CompanyUser` objects that match the specified search criteria
98+
`page_info` | SearchResultPageInfo | Pagination meta data
99+
`total_count` | Int | The number of objects returned

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,13 @@ Attribute | Data Type | Description
3131
`suffix` | String | A value such as Sr., Jr., or III
3232
`taxvat` | String | The customer's Tax/VAT number (for corporate customers)
3333
`wishlist` | Wishlist! | Contains the contents of the customer's wish lists
34+
35+
For B2B, company users can have the following attributes.
36+
37+
Attribute | Data Type | Description
38+
--- | --- | ---
39+
`job_title` | String | The job title for a B2B company user
40+
`role`| CompanyRole | The role name and permissions assigned to the company user
41+
`status` | CompanyUserStatusEnum | Indicates whether the company user is ACTIVE or INACTIVE
42+
`team` | CompanyTeam | The team the company user is assigned to
43+
`telephone` | String | The phone number of the company user
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
---
2+
group: graphql
3+
title: createCompany mutation
4+
b2b_only: true
5+
---
6+
7+
The `createCompany` mutation creates a company at the request of either a customer or a guest. The company definition includes the first name, last name, and email address of the company administrator. The email address assigned to the account cannot already exist in the system. Therefore, a customer attempting to create a company cannot use the same email address they used to log in to the storefront.
8+
9+
The company administrator cannot log in or perform additional company-related tasks until a Magento administrator approves the request to create a company.
10+
11+
## Syntax
12+
13+
```graphql
14+
mutation {
15+
createCompany(
16+
input: CompanyCreateInput!
17+
) {
18+
CreateCompanyOutput
19+
}
20+
}
21+
```
22+
## Example usage
23+
24+
The following call creates a company on behalf of a guest.
25+
26+
**Request:**
27+
28+
```graphql
29+
mutation {
30+
createCompany(input: {
31+
company_name: "TestCo"
32+
company_email: "[email protected]"
33+
company_admin: {
34+
35+
firstname: "Taina"
36+
lastname:"Garofalo"
37+
}
38+
legal_name: "TestCo Inc."
39+
legal_address: {
40+
street: [
41+
"100 Big Oak Tree Dr"
42+
]
43+
city: "San Francisco"
44+
region: {
45+
region_code: "CA"
46+
}
47+
postcode: "99999"
48+
country_id: US
49+
telephone: "555 867-5309"
50+
}
51+
}){
52+
company {
53+
id
54+
name
55+
company_admin {
56+
email
57+
firstname
58+
lastname
59+
}
60+
legal_address {
61+
street
62+
city
63+
region {
64+
region_code
65+
region_id
66+
}
67+
postcode
68+
telephone
69+
}
70+
}
71+
}
72+
}
73+
```
74+
75+
**Response:**
76+
77+
```json
78+
{
79+
"data": {
80+
"createCompany": {
81+
"company": {
82+
"id": "MQ==",
83+
"name": "TestCo",
84+
"company_admin": {
85+
"email": "[email protected]",
86+
"firstname": "Taina",
87+
"lastname": "Garofalo"
88+
},
89+
"legal_address": {
90+
"street": [
91+
"100 Big Oak Tree Dr"
92+
],
93+
"city": "San Francisco",
94+
"region": {
95+
"region_code": "CA",
96+
"region_id": 12
97+
},
98+
"postcode": "99999",
99+
"telephone": "555 867-5309"
100+
}
101+
}
102+
}
103+
}
104+
}
105+
```
106+
107+
## Input attributes
108+
109+
The CompanyCreateInput object defines the schema for creating an entity.
110+
111+
Attribute | Data Type | Description
112+
--- | --- | ---
113+
`company_admin` | [CompanyAdminInput!](#CompanyAdminInput) | Defines the company administrator
114+
`company_email` | String! | The email address of the company contact
115+
`company_name` | String! | The company name
116+
`legal_address` | [CompanyLegalAddressCreateInput!](#CompanyLegalAddressCreateInput) | Defines legal address data of the company
117+
`legal_name` | String | The full legal name of the company
118+
`reseller_id` | String | The resale number that is assigned to the company for tax reporting purposes
119+
`vat_tax_id` | String | The value-added tax number that is assigned to the company by some jurisdictions for tax reporting purposes
120+
121+
### CompanyAdminInput attributes {#CompanyAdminInput}
122+
123+
The `CompanyAdminInput` object can contain the following attributes.
124+
125+
Attribute | Data Type | Description
126+
--- | --- | ---
127+
`email` | String! | The email address of the company administrator
128+
`firstname` | String! | The company administrator's first name
129+
`gender` | Int | The company administrator's gender (Male - 1, Female - 2, Not Specified - 3)
130+
`job_title` | String | The job title of the company administrator
131+
`lastname` | String! | The company administrator's last name
132+
133+
### CompanyLegalAddressCreateInput attributes {#CompanyLegalAddressCreateInput}
134+
135+
The `CompanyLegalAddressCreateInput` object can contain the following attributes.
136+
137+
Attribute | Data Type | Description
138+
--- | --- | ---
139+
`city` | String! | The city where the company is registered to conduct business
140+
`country_id` | CountryCodeEnum! | Company's country ID. See the [`countries` query]({{page.baseurl}}/graphql/queries/directory-countries.html)
141+
`postcode` | String! | The ZIP/postal code of the company
142+
`region` | CustomerAddressRegionInput! | An object containing the region name and/or region ID where the company is registered to conduct business
143+
`street` | [String!]! | An array of strings that define the street address where the company is registered to conduct business
144+
`telephone` | String! | The primary phone number of the company
145+
146+
## Output attributes
147+
148+
The `CreateCompanyOutput` object contains the `Company` object.
149+
150+
{% include graphql/company.md %}
151+
152+
## Related topics
153+
154+
* [updateCompany mutation]({{page.baseurl}}/graphql/mutations/update-company.html)

0 commit comments

Comments
 (0)