-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiary.apib
236 lines (147 loc) · 5.14 KB
/
apiary.apib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
FORMAT: 1A
# Exercise
A simple API that will allow consumers to create,
read, update and delete on certain entities, namely: Company, Employee, Dependant.
NOTE: This document is a **work in progress**.
# Data Structures
## Company (object)
+ companyName: Gemalto (string, required)
+ address (object)
+ city: London (string, required)
+ country: UK (string, required)
+ employee (Employee, optional)
## CompanyWithId (Company)
+ companyId: 3 (number, required)
## Employee
+ employeeName: Kamal (string)
+ phoneNumber: +971555960145 (string)
+ gender: MALE (enum[string]) - the gender can be MALE, FEMALE or OTHER
+ dateOfBirth: `1985-05-05T12:30:00` (string)
+ salary: 1500 (number)
+ company (CompanyWithId, required) - the company of which the employee works.
+ dependant (Dependant, optional)
## EmployeeWithId (Employee)
+ employeeId: 3 (number, required)
## Dependant
+ dependantName: Dependant1 (string)
+ phoneNumber: +9715552142 (string)
+ gender: MALE (enum[string]) - the gender can be MALE, FEMALE or OTHER
+ dateOfBirth: `1999-05-05T12:30:00` (string)
+ relation: FATHER (enum[string])
+ employee (EmployeeWithId, required)
+ company (CompanyWithId, required)
## DependantWithId (Dependant)
+ dependantId: 3 (number, required)
# Group Companies
Resources in this group are related to **Company** CRUD
## Companies Resources [/api/v1/companies]
### List All Companies [GET]
+ Response 200 (application/json;charset=UTF-8)
+ Attributes (array)
+ CompanyWithId
### Create Company [POST]
+ Attributes (Company)
+ Request (application/json)
+ Response 201 (application/json;charset=UTF-8)
+ Headers
Location: http://localhost:8080/api/v1/companies/1
+ Attributes
+ CompanyWithId
## Retrieve Company [/api/v1/companies/{companyId}]
Retrieves the company with the given ID.
+ Parameters
+ companyId: 1 (required, number) - ID of the company in form of an integer
### Retrieve Company [GET]
+ Response 200 (application/json;charset=UTF-8)
+ Attributes
+ CompanyWithId
+ Response 404 (application/json;charset=UTF-8)
### Update Company [PUT]
+ Attributes (CompanyWithId)
+ Request (application/json)
+ Attributes (CompanyWithId)
+ Response 200
+ Attributes
+ CompanyWithId
+ Response 404 (application/json;charset=UTF-8)
### Delete Company [DELETE]
Delete a company.
**Warning:** This action **permanently** removes company, employees and it's dependant from the database.
+ Response 200
+ Response 404
# Group Employees
Resources in this group are related to **Employee** CRUD
## Employees Resources [/api/v1/employees]
### List All Employees[GET]
+ Response 200 (application/json;charset=UTF-8)
+ Attributes (array)
+ EmployeeWithId
+ Response 404 (application/json;charset=UTF-8)
### Create Employee [POST]
+ Attributes (Employee)
+ Request (application/json)
+ Response 201 (application/json;charset=UTF-8)
+ Headers
Location: http://localhost:8080/api/v1/employees/1
+ Attributes
+ EmployeeWithId
## Retrieve Employee [/api/v1/employees/{employeeId}]
This resource represents one particular employee identified by its *employee_id*.
+ Parameters
+ employeeId: 1 (required, number) - ID of the employee in form of an integer
### Retrieve Employee [GET]
+ Response 200 (application/json;charset=UTF-8)
+ Attributes
+ EmployeeWithId
+ Response 404 (application/json;charset=UTF-8)
### Update Employee [PUT]
+ Attributes (Employee)
+ Request (application/json)
+ Attributes (Employee)
+ Response 200 (application/json;charset=UTF-8)
+ Attributes
+ EmployeeWithId
+ Response 404 (application/json;charset=UTF-8)
### Delete Employee [DELETE]
**Warning:** This action **permanently** removes employees and it's
dependant from the database.
+ Response 200
+ Response 404
# Group Dependants
Resources in this group are related to **Dependant** CRUD
## Dependants Resources [/api/v1/dependants]
### List All Dependants [GET]
+ Response 200 (application/json;charset=UTF-8)
+ Attributes (array)
+ DependantWithId
+ Response 404 (application/json;charset=UTF-8)
### Create Dependant [POST]
+ Attributes (Dependant)
+ Request (application/json)
+ Response 201 (application/json;charset=UTF-8)
+ Headers
Location: http://localhost:8080/api/v1/dependants/3
+ Attributes
+ DependantWithId
## Retrieve Dependant [/api/v1/dependants/{dependantId}]
This resource represents one particular Dependant (object) identified by its *dependant_id*.
+ Parameters
+ dependantId: 1 (required, number) - ID of the Dependant in form of an integer
### Retrieve Dependant [GET]
+ Response 200 (application/json;charset=UTF-8)
+ Attributes
+ DependantWithId
+ Response 404 (application/json;charset=UTF-8)
### Update Dependant [PUT]
+ Attributes (Dependant)
+ Request (application/json)
+ Attributes (Dependant)
+ Response 200
+ Attributes
+ DependantWithId
+ Response 404 (application/json;charset=UTF-8)
### Delete Dependant [DELETE]
Delete a dependant.
**Warning:** This action **permanently** removes dependants from the database.
+ Response 200
+ Response 404