Skip to content

Commit 46e6e23

Browse files
committed
Added user API examples
1 parent eb653bd commit 46e6e23

8 files changed

Lines changed: 107 additions & 1 deletion

File tree

app/Auth/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
7272
*/
7373
protected $hidden = [
7474
'password', 'remember_token', 'system_name', 'email_confirmed', 'external_auth_id', 'email',
75-
'created_at', 'updated_at', 'image_id', 'roles', 'avatar',
75+
'created_at', 'updated_at', 'image_id', 'roles', 'avatar', 'user_id',
7676
];
7777

7878
/**

app/Http/Controllers/Api/UserApiController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function list()
8181

8282
/**
8383
* Create a new user in the system.
84+
* Requires permission to manage users.
8485
*/
8586
public function create(Request $request)
8687
{
@@ -111,6 +112,7 @@ public function read(string $id)
111112

112113
/**
113114
* Update an existing user in the system.
115+
* Requires permission to manage users.
114116
* @throws UserUpdateException
115117
*/
116118
public function update(Request $request, string $id)

dev/api/requests/users-create.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "Dan Brown",
3+
"email": "dannyb@example.com",
4+
"roles": [1],
5+
"language": "fr",
6+
"send_invite": true
7+
}

dev/api/requests/users-update.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "Dan Spaggleforth",
3+
"email": "dspaggles@example.com",
4+
"roles": [2],
5+
"language": "de",
6+
"password": "hunter2000"
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"id": 1,
3+
"name": "Dan Brown",
4+
"email": "dannyb@example.com",
5+
"created_at": "2022-02-03T16:27:55.000000Z",
6+
"updated_at": "2022-02-03T16:27:55.000000Z",
7+
"external_auth_id": "abc123456",
8+
"slug": "dan-brown",
9+
"last_activity_at": "2022-02-03T16:27:55.000000Z",
10+
"profile_url": "https://docs.example.com/user/dan-brown",
11+
"edit_url": "https://docs.example.com/settings/users/1",
12+
"avatar_url": "https://docs.example.com/uploads/images/user/2021-10/thumbs-50-50/profile-2021.jpg",
13+
"roles": [
14+
{
15+
"id": 1,
16+
"display_name": "Admin"
17+
}
18+
]
19+
}

dev/api/responses/users-list.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"data": [
3+
{
4+
"id": 1,
5+
"name": "Dan Brown",
6+
"email": "dannyb@example.com",
7+
"created_at": "2022-02-03T16:27:55.000000Z",
8+
"updated_at": "2022-02-03T16:27:55.000000Z",
9+
"external_auth_id": "abc123456",
10+
"slug": "dan-brown",
11+
"user_id": 1,
12+
"last_activity_at": "2022-02-03T16:27:55.000000Z",
13+
"profile_url": "https://docs.example.com/user/dan-brown",
14+
"edit_url": "https://docs.example.com/settings/users/1",
15+
"avatar_url": "https://docs.example.com/uploads/images/user/2021-10/thumbs-50-50/profile-2021.jpg"
16+
},
17+
{
18+
"id": 2,
19+
"name": "Benny",
20+
"email": "benny@example.com",
21+
"created_at": "2022-01-31T20:39:24.000000Z",
22+
"updated_at": "2021-11-18T17:10:58.000000Z",
23+
"external_auth_id": "",
24+
"slug": "benny",
25+
"user_id": 2,
26+
"last_activity_at": "2022-01-31T20:39:24.000000Z",
27+
"profile_url": "https://docs.example.com/user/benny",
28+
"edit_url": "https://docs.example.com/settings/users/2",
29+
"avatar_url": "https://docs.example.com/uploads/images/user/2021-11/thumbs-50-50/guest.jpg"
30+
}
31+
],
32+
"total": 28
33+
}

dev/api/responses/users-read.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"id": 1,
3+
"name": "Dan Brown",
4+
"email": "dannyb@example.com",
5+
"created_at": "2022-02-03T16:27:55.000000Z",
6+
"updated_at": "2022-02-03T16:27:55.000000Z",
7+
"external_auth_id": "abc123456",
8+
"slug": "dan-brown",
9+
"last_activity_at": "2022-02-03T16:27:55.000000Z",
10+
"profile_url": "https://docs.example.com/user/dan-brown",
11+
"edit_url": "https://docs.example.com/settings/users/1",
12+
"avatar_url": "https://docs.example.com/uploads/images/user/2021-10/thumbs-50-50/profile-2021.jpg",
13+
"roles": [
14+
{
15+
"id": 1,
16+
"display_name": "Admin"
17+
}
18+
]
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"id": 1,
3+
"name": "Dan Spaggleforth",
4+
"email": "dspaggles@example.com",
5+
"created_at": "2022-02-03T16:27:55.000000Z",
6+
"updated_at": "2022-02-03T16:27:55.000000Z",
7+
"external_auth_id": "abc123456",
8+
"slug": "dan-spaggleforth",
9+
"last_activity_at": "2022-02-03T16:27:55.000000Z",
10+
"profile_url": "https://docs.example.com/user/dan-spaggleforth",
11+
"edit_url": "https://docs.example.com/settings/users/1",
12+
"avatar_url": "https://docs.example.com/uploads/images/user/2021-10/thumbs-50-50/profile-2021.jpg",
13+
"roles": [
14+
{
15+
"id": 2,
16+
"display_name": "Editors"
17+
}
18+
]
19+
}

0 commit comments

Comments
 (0)