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

Commit 9b7229d

Browse files
andrewbessAndrii Beziazychnyi
authored and
Andrii Beziazychnyi
committed
ISSUE-7985: The topics for the "Company User" mutations have been created
1 parent 2f1dd22 commit 9b7229d

File tree

4 files changed

+441
-0
lines changed

4 files changed

+441
-0
lines changed

src/_data/toc/graphql.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ pages:
223223
edition: b2b-only
224224
exclude_versions: ["2.3"]
225225

226+
- label: createCompanyUser mutation
227+
url: /graphql/mutations/create-company-user.html
228+
edition: b2b-only
229+
exclude_versions: ["2.3"]
230+
226231
- label: createCustomer mutation
227232
url: /graphql/mutations/create-customer.html
228233

@@ -260,6 +265,11 @@ pages:
260265
edition: b2b-only
261266
exclude_versions: ["2.3"]
262267

268+
- label: deleteCompanyUser mutation
269+
url: /graphql/mutations/delete-company-user.html
270+
edition: b2b-only
271+
exclude_versions: ["2.3"]
272+
263273
- label: deleteCustomerAddress mutation
264274
url: /graphql/mutations/delete-customer-address.html
265275

@@ -377,6 +387,11 @@ pages:
377387
edition: b2b-only
378388
exclude_versions: ["2.3"]
379389

390+
- label: updateCompanyUser mutation
391+
url: /graphql/mutations/update-company-user.html
392+
edition: b2b-only
393+
exclude_versions: ["2.3"]
394+
380395
- label: updateCustomer mutation
381396
url: /graphql/mutations/update-customer.html
382397

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
---
2+
group: graphql
3+
title: createCompanyUser mutation
4+
contributor_name: Atwix
5+
contributor_link: https://www.atwix.com/
6+
b2b_only: true
7+
---
8+
9+
Use the `createCompanyUser` mutation to create a new company user or add a user from the existing customer for your company.
10+
11+
The `target_id` input attribute allows you to specify which node in the company structure will be the parent node of the company user. If you do not specify a value, the user will be assigned to the top-level (root) node of the company structure.
12+
13+
You can get the `target_id` and the `role_id` with the [`company`]({{page.baseurl}}/graphql/queries/company.html) query.
14+
15+
## Syntax
16+
17+
```graphql
18+
mutation {
19+
createCompanyUser(
20+
input: CompanyUserCreateInput!
21+
) {
22+
CreateCompanyUserOutput
23+
}
24+
}
25+
```
26+
27+
## Example usage
28+
29+
The following example shows the minimal payload for adding a new customer to a customer's company.
30+
31+
**Request:**
32+
33+
```graphql
34+
mutation {
35+
createCompanyUser(
36+
input: {
37+
38+
firstname: "John"
39+
lastname: "Doe"
40+
job_title: "User"
41+
role_id: "MQ=="
42+
status: ACTIVE
43+
telephone: "1234567890"
44+
}
45+
) {
46+
user {
47+
created_at
48+
email
49+
}
50+
}
51+
}
52+
```
53+
54+
**Response:**
55+
56+
```json
57+
{
58+
"data": {
59+
"createCompanyUser": {
60+
"user": {
61+
"created_at": "2020-10-15 23:33:49",
62+
"email": "[email protected]"
63+
}
64+
}
65+
}
66+
}
67+
```
68+
69+
This example creates a new company user of the parent company team specified in the `target_id` field.
70+
71+
**Request:**
72+
73+
```graphql
74+
mutation {
75+
createCompanyUser(
76+
input: {
77+
78+
firstname: "Jane"
79+
lastname: "Doe3"
80+
job_title: "User"
81+
role_id: "NTc="
82+
status: ACTIVE
83+
telephone: "1234567890"
84+
target_id: "OA=="
85+
}
86+
) {
87+
user {
88+
created_at
89+
email
90+
firstname
91+
lastname
92+
job_title
93+
role {
94+
id
95+
name
96+
}
97+
team {
98+
id
99+
name
100+
structure_id
101+
}
102+
status
103+
telephone
104+
}
105+
}
106+
}
107+
```
108+
109+
**Response:**
110+
111+
```json
112+
{
113+
"data": {
114+
"createCompanyUser": {
115+
"user": {
116+
"created_at": "2020-10-15 23:39:11",
117+
"email": "[email protected]",
118+
"firstname": "Jane",
119+
"lastname": "Doe",
120+
"job_title": "User",
121+
"role": {
122+
"id": "NTc=",
123+
"name": "Default User"
124+
},
125+
"team": {
126+
"id": "MQ==",
127+
"name": "Test Team",
128+
"structure_id": "Mg=="
129+
},
130+
"status": "ACTIVE",
131+
"telephone": "1234567890"
132+
}
133+
}
134+
}
135+
}
136+
```
137+
138+
## Input attributes
139+
140+
The `CompanyUserCreateInput` input object defines the company user data.
141+
142+
### CompanyUserCreateInput attributes {#CompanyUserCreateInput}
143+
144+
The `CompanyUserCreateInput` object contains the following attributes:
145+
146+
Attribute | Data Type | Description
147+
--- | --- | ---
148+
`email` | String! | Company user's email address
149+
`firstname` | String! | Company user's first name
150+
`lastname` | String! | Company user's last name
151+
`job_title` | String! | Company user's job title
152+
`role_id` | ID! | Company user's role ID
153+
`status` | CompanyUserStatusEnum! | Indicates whether the company user is ACTIVE or INACTIVE
154+
`telephone` | String! | Company user's phone number
155+
`target_id` | ID | The ID of a node within a company's structure. This ID will be the parent of the created company user
156+
157+
## Output attributes
158+
159+
The `CreateCompanyUserOutput` output object contains the following attribute:
160+
161+
Attribute | Data Type | Description
162+
--- | --- | ---
163+
`user` | Customer! | Contains company user data
164+
165+
### Customer attributes {#Customer}
166+
167+
{% include graphql/customer-output-24.md %}
168+
169+
## Errors
170+
171+
Error | Description
172+
--- | ---
173+
`Invitation was sent to an existing customer, they will be added to your organization once they accept the invitation.` | The customer with email provided in the `input`.`email` argument belongs to an existing customer. The invitation was sent to an existing customer. The customer will assign to the company after accepting the invitation.
174+
`A customer with the same email already assigned to company.` | The email provided in the `input`.`email` argument belongs to an existing customer and the customer has already assigned to the company.
175+
`"Email" is not a valid email address.` | The value provided in the `input`.`email` argument has an invalid format.
176+
`Field "createCompanyUser" argument "input" requires type String!, found xxx.` | The value specified in the one of the `input` arguments has an invalid type.
177+
`Field "xxx" is not defined by type CompanyUserCreateInput.` | The `input`.`xxx` argument is undefined.
178+
`Required parameters are missing: xxx` | The `input`.`xxx` argument was omitted or contains an empty value.
179+
`No such entity with roleId = xxx` | The company role with ID `xxx` doesn't exist.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
group: graphql
3+
title: deleteCompanyUser mutation
4+
contributor_name: Atwix
5+
contributor_link: https://www.atwix.com/
6+
b2b_only: true
7+
---
8+
9+
Use the `deleteCompanyUser` mutation to deactivate a company user by ID.
10+
11+
You can get the user ID with the [`company`]({{page.baseurl}}/graphql/queries/company.html) query.
12+
13+
## Syntax
14+
15+
```graphql
16+
mutation {
17+
deleteCompanyUser(
18+
id: ID!
19+
) {
20+
DeleteCompanyUserOutput
21+
}
22+
}
23+
```
24+
25+
## Example usage
26+
27+
The following example deactivates the user specified in ID.
28+
29+
**Request:**
30+
31+
```graphql
32+
mutation {
33+
deleteCompanyUser(
34+
id: "Mg=="
35+
) {
36+
success
37+
}
38+
}
39+
```
40+
41+
**Response:**
42+
43+
```json
44+
{
45+
"data": {
46+
"deleteCompanyUser": {
47+
"success": true
48+
}
49+
}
50+
}
51+
```
52+
53+
## Input attributes
54+
55+
The `deleteCompanyUser` mutation requires the following input:
56+
57+
Attribute | Data Type | Description
58+
--- | --- | ---
59+
`id` | ID! | The encoded user ID to deactivate
60+
61+
## Output attributes
62+
63+
The `deleteCompanyUser` mutation returns a Boolean value that indicates whether the operation was successful.
64+
65+
Attribute | Data Type | Description
66+
--- | --- | ---
67+
`success` | Boolean! | A value of `true` indicates the company user has been deactivated successfully, otherwise a value returns `false`
68+
69+
## Errors
70+
71+
Error | Description
72+
--- | ---
73+
`You do not have authorization to perform this action.` | The user with ID provided in the `input`.`id` argument not available to your company or you have no permissions for this operation.
74+
`You cannot delete yourself.` | You have no a possibility to deactivate yourself.
75+
`A customer with the same email address already exists in an associated website` | The email provided in the `input`.`email` argument has already exist to another user.
76+
`The user XXX is the company admin and cannot be set to inactive. You must set another user as the company admin first.` | The company owner cannot be deactivated. You must set another user as the company admin first.

0 commit comments

Comments
 (0)