-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapiary.apib
252 lines (146 loc) · 4.54 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
FORMAT: 1A
HOST: https://private-345a7-lifemessager.apiary-mock.com/
# LifeMessager
## The way to get user token
After request the `login mail` api, user will receive an email contain a login link like this:
https://lifemessager.com/#!/login?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0MjY3MzA1MDYsInVzZXJfaWQiOjIxfQ.q2iPcnpvMYj4enek5xTrKNmqbIdI6N6Cd8pS4XNlOkg
The `token` in url hash is the user token.
# Group User
## User [/users/{id}]
+ Parameters
+ id (required, number, `123`) ... user id
+ Model (application/json)
{
"id": 123,
"email": "example@example.com",
"subscribed": true,
"unsubscribe_token": "...",
"timezone": "Asia/Beijing",
"alert_time": "08:00",
"created_at": "2015-03-18T02:38:20.067Z",
"deleted_at": null
}
### Get user info [GET]
+ Request (application/json)
+ Headers
Authentication: Bearer [session_token]
+ Response 200 (application/json)
[User][]
### Update user info [PATCH]
+ Request (application/json)
+ Headers
Authentication: Bearer [session_token]
+ Body
{
"timezone": "Asia/Beijing",
"alert_time": "08:00"
}
+ Response 200 (application/json)
[User][]
### Delete account [DELETE]
+ Request (application/json)
+ Headers
Authentication: Bearer [session_token]
+ Response 204
### Subscribe daily mail [PUT /subscription]
## User Collection [/users]
### Create new user [POST]
+ Request (application/json)
```js
{
"email": "example@example.com", // (required, string) user's email
"timezone": "Asia/Beijing", // (required, string) user's timezone
"alert_time": "08:00" // (optional, string) daily email send time in user's timezone, default: 08:00
}
```
+ Response 201 (application/json)
[User][]
## Manage Subscribe [/users/{id}/subscription]
+ Parameters
+ id (required, number, `123`) ... user id
### Subscribe daily mail [PUT]
+ Request (application/json)
+ Headers
Authentication: Bearer [session_token]
+ Response 201 (application/json)
### Unsubscribe daily mail [DELETE]
+ Request
+ Headers
Authentication: unsubscribe [unsubscribe_token from user data]
+ Response 204 (application/json)
## Cancel delete progress [/users/{id}/regain]
+ Parameters
+ id (required, number, `123`) ... user id
### Request [POST]
+ Request (application/json)
+ Headers
Authentication: Bearer [session_token]
+ Response 201 (application/json)
## Send change mail address validation email [/users/{id}/change_email_applies]
### Request [POST]
+ Request (application/json)
+ Headers
Authentication: Bearer [session_token]
+ Response 201 (application/json)
## Request change email [/users/{id}/email]
### Request [PUT]
+ Request (application/json)
+ Headers
Authentication: change_email [session_token]
+ Response 200 (application/json)
# Group Session
## Login [/sessions/emails]
### Request a login mail [POST]
+ Request (application/json)
```js
{
"email": "example@example.com"
}
```
+ Response 201 (application/json)
## Keep session [/sessions]
### Renew or request persistent token [POST]
+ Request (application/json)
+ Headers
Authentication: Bearer [token from login mail]
+ Response 201 (application/json)
```js
{
"token": "...",
"expired_at": "2015-03-18T02:38:20.067Z"
}
```
# Group Diary
## Diary [/diaries/{date}]
+ Parameters
+ date (required, string, `2015-03-18`) ... The date of expected diary
+ Model (application/json)
{
"created_at": "2015-03-18T02:38:20.067Z",
"timezone": "Asia/Beijing",
"locale_date": "2015-03-18",
"notes": [{
"id": 1,
"from_email": "example@example.com",
"created_at": "2015-03-18T02:38:20.067Z",
"content": "..."
}]
}
### Get Diary of Specified Day [GET]
+ Request (application/json)
+ Headers
Authentication: Bearer [session_token]
+ Response 200 (application/json)
[Diary][]
## Note Collection [/notes]
### Append new note for today's diary [POST]
+ Request
+ Headers
Content-Type: multipart/form-data
Authentication: Bearer [session_token]
+ Body
```js
content: "..." // (required, string or file) note's content
type: "image" // (optional, string, `text`) note's type, avaliable: text, image
```
+ Response 201 (application/json)