-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathendpoints.json
More file actions
237 lines (237 loc) · 8.53 KB
/
endpoints.json
File metadata and controls
237 lines (237 loc) · 8.53 KB
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
{
"GET /api": {
"example url": "/api",
"description": "serves a JSON file showing all available API endpoints"
},
"GET /api/loyalty_cards": {
"description": "serves an array of all loyalty cards",
"queries": [
"user_id",
"sort_by",
"order",
"merchant_id",
"id (loyalty_cards.id)"
],
"example url": "/api/loyalty_cards",
"example url query": "/api/loyalty_cards?user_id=U2&merchant_id=B&&id=2&sort_by=points&order=desc",
"example response (with no query)": {
"loyalty_cards": [
{
"id": 1,
"loyalty_program_id": 1,
"user_id": "U1",
"points": 0,
"created_at": "2024-01-04T15:43:47.508Z",
"merchant_id": "A",
"name": "programShopA",
"required_points": 6
}
]
}
},
"GET /api/loyalty_cards/:loyalty_card_id": {
"description": "serves an object containing the loyalty card with that specific id",
"example url": "/api/loyalty_cards/1",
"example response": {
"loyalty_card": {
"id": 1,
"loyalty_program_id": 1,
"user_id": "U1",
"points": 0,
"created_at": "2024-01-04T15:43:47.508Z",
"merchant_id": "A",
"name": "programShopA",
"required_points": 6
}
}
},
"PATCH /api/loyalty_cards/:loyalty_card_id": {
"description": "allows loyalty_cards points to be updated",
"example patch": {
"inc_points": 4
}
},
"GET /api/merchants": {
"description": "serves an array of all merchants",
"example url": "/api/merchants",
"example response": {
"merchants": [
{
"id": "A",
"user_id": "M1",
"company_name": "shopA",
"description": "This is the shop A",
"address": "A Street",
"phone_no": "0711111111",
"logo_url": "https://images.pexels.com/photos/158651/news-newsletter-newspaper-information-158651.jpeg?w=700&h=700",
"category": "coffee"
}
]
}
},
"GET /api/merchants/:id": {
"description": "serves an object showing one specific merchant",
"example url": "/api/merchants/M1",
"example response": {
"merchant": {
"id": "B",
"user_id": "M2",
"company_name": "shopB",
"description": "This is the shop B",
"address": "B Street",
"phone_no": "0722222222",
"logo_url": "https://images.pexels.com/photos/158651/news-newsletter-newspaper-information-158651.jpeg?w=700&h=700",
"category": "bakery"
}
}
},
"PATCH /api/merchants/:id": {
"description": "allows information for a specific merchant to be changed",
"example patch": {
"phone_no": 2343323,
"address": "A Street"
}
},
"GET /api/merchants/:id/cards": {
"description": "serves an array showing loyalty_cards for this specific merchant",
"example url": "/api/merchants/M1/cards",
"example response": {
"loyalty_cards": [
{
"id": 1,
"loyalty_program_id": 1,
"user_id": "U1",
"points": 0,
"created_at": "2024-01-04T15:43:47.508Z",
"merchant_id": "A",
"name": "programShopA",
"required_points": 6
}
]
}
},
"GET /api/merchants/:id/programs": {
"description": "serves an object showing loyalty_cards for this specific merchant",
"example url": "/api/merchants/M1/programs",
"example response": {
"loyalty_programs": {
"id": 1,
"merchant_id": "A",
"name": "programShopA",
"required_points": 6,
"created_at": "2024-01-04T15:43:47.508Z"
}
}
},
"POST /api/merchants/:id/programs": {
"description": "returns an object showing a newly created loyalty program for this specific merchant",
"example url": "/api/merchants/M1/programs",
"example post": {
"name": "this is a new program",
"required_points": 400
},
"example response": {
"loyalty_programs": {
"id": 5,
"merchant_id": "A",
"name": "this is a new program",
"required_points": 400,
"created_at": "2024-01-08T14:56:00.318Z"
}
}
},
"GET /api/merchants/:id/programs/:program_id": {
"description": "returns an object showing a newly created loyalty program for this specific merchant",
"example url": "/api/merchants/M1/programs/1",
"example response": {
"loyalty_programs": {
"id": 1,
"merchant_id": "A",
"name": "this is a new program",
"required_points": 400,
"created_at": "2024-01-08T14:56:00.318Z"
}
}
},
"DELETE /api/merchants/:id/programs/:program_id": {
"description": "returns an object showing a newly created loyalty program for this specific merchant",
"example url": "/api/merchants/M1/programs/1",
"example response": {}
},
"DELETE /api/redeem/:user_id/:loyalty_card_id": {
"description": "allows a loyalty card to be deleted for a specific user"
},
"PATCH /api/redeem/:user_id/:loyalty_card_id": {
"description": "PATCH requests should be made with no body. When a patch request is made to this endpoint, if points & required_points are the same value: points will be reset to 0.",
"example response": "Points Reset"
},
"GET /api/users/:user_id": {
"description": "shows an object showing a specific user",
"example url": "/api/users/U2",
"example response": {
"user": {
"id": "U2",
"name": "sam"
}
}
},
"DELETE /api/users/:user_id": {
"description": "allows a specific user to be deleted"
},
"GET /api/users/:user_id/loyalty_cards/": {
"description": "serves an array of loyalty cards for the given user",
"example url": "/api/users/U2/loyalty_cards",
"example response": [
{
"id": 4,
"loyalty_program_id": 3,
"user_id": "U2",
"points": 6,
"created_at": "2024-01-09T16:45:16.883Z",
"required_points": 10,
"name": "Coffee Card",
"company_name": "Idle Hands Coffee"
}
]
},
"POST /api/users/:user_id/loyalty_cards/:loyalty_program_id": {
"description": "allows a new card to be created for a user",
"example url": "/api/users/U2/loyalty_cards/1",
"example response": {
"id": 2,
"loyalty_program_id": 1,
"user_id": "U2",
"points": 1,
"created_at": "2024-01-04T15:43:47.508Z",
"merchant_id": "B",
"name": "programShopB",
"required_points": 5
}
},
"GET /api/loyalty_programs/": {
"description": "serves an object containing the loyalty programs with that specific id",
"example url": "/api/loyalty_programs",
"example response": {
"loyalty_programs": {
"id": 1,
"merchant_id": "A",
"name": "programShopA",
"required_points": 6,
"created_at": "2024-01-02T16:01:13.985Z"
}
}
},
"GET /api/loyalty_programs/:merchant_id": {
"description": "serves an object containing the loyalty programs with that specific id",
"example url": "/api/loyalty_programs/M1",
"example response": {
"loyalty_programs": {
"id": 1,
"merchant_id": "M1",
"name": "programShopA",
"required_points": 6,
"created_at": "2024-01-02T16:01:13.985Z"
}
}
}
}