Skip to content

Commit ee9c1b6

Browse files
committed
Added ReadMe File
1 parent f2a2b81 commit ee9c1b6

File tree

1 file changed

+194
-0
lines changed

1 file changed

+194
-0
lines changed

README.md

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
FORMAT: 1A
2+
HOST: https://subscriptions13.apiblueprint.org/
3+
4+
# Subscriptions
5+
6+
This a *__Subscriptions__* module of Trendyol Bootcamp API.
7+
8+
---
9+
# Notes
10+
11+
- Each users should have a free subscription plan by default.
12+
- Each subscription record keeps one subscription period details.
13+
- Simply we decided to use a static 'plan_id' property which represents the subscription type.
14+
15+
| plan_id | Representation |
16+
|---|---|
17+
| 0 | Free Plan |
18+
| 1 | Premium Plan |
19+
| 2 | Family Plan |
20+
21+
- **Q-1:** Should we need to create an endpoint for deleting subscription?
22+
- **Q-2:** Should we need to retrieve the subscripton by user id?
23+
24+
---
25+
# Subscription
26+
27+
Represents one period of subscription.
28+
---
29+
30+
- id `(Number)` : Unique identifier.
31+
- user_id `(Number)` : User's unique identifier.
32+
- plan_id `(Number)` : Plan's id identifier.
33+
- price `(Float)` : Billed price of the subscription.
34+
- is_paid `(Boolean)` : It represents whether the payment has been made or not.
35+
- start_date `(Date)` : The start date of subscription.
36+
- end_date `(Date)` : The end date of subscription.
37+
38+
---
39+
40+
## Subscriptions [/subscriptions?{id}]
41+
42+
### List All Subscriptions [GET]
43+
44+
+ Response 200 (application/json)
45+
46+
[
47+
{
48+
"id": 1,
49+
"user_id": 1,
50+
"plan_id": 1,
51+
"price": 17.99,
52+
"is_paid": true,
53+
"start_date": "2020-08-05T00:00:00.000Z",
54+
"end_date": "2020-09-05T00:00:00.000Z"
55+
},
56+
{
57+
"id": 1,
58+
"user_id": 1,
59+
"plan_id": 2,
60+
"price": 24.99,
61+
"is_paid": true,
62+
"start_date": "2020-09-05T00:00:00.000Z",
63+
"end_date": "2020-10-05T00:00:00.000Z"
64+
},
65+
{
66+
"id": 2,
67+
"user_id": 2,
68+
"plan_id": 2,
69+
"price": 24.99,
70+
"is_paid": true,
71+
"start_date": "2020-08-05T00:00:00.000Z",
72+
"end_date": "2020-09-05T00:00:00.000Z"
73+
}
74+
]
75+
76+
+ Response 500 (application/json)
77+
78+
{
79+
"error": "message.internal_server_error"
80+
}
81+
82+
### Create a New Subscription [POST]
83+
84+
+ Request (application/json)
85+
86+
{
87+
"user_id": 1,
88+
"plan_id": 1,
89+
}
90+
91+
+ Response 201 (application/json)
92+
93+
+ Headers
94+
95+
Location: /subscriptions/1
96+
97+
+ Body
98+
99+
{
100+
"id": 1,
101+
"user_id": 1,
102+
"plan_id": 1,
103+
"price": 17.99,
104+
"is_paid": true,
105+
"start_date": "2020-08-05T00:00:00.000Z",
106+
"end_date": "2020-09-05T00:00:00.000Z"
107+
}
108+
109+
+ Response 500 (application/json)
110+
111+
{
112+
"error": "message.internal_server_error"
113+
}
114+
115+
### Change Subscription Plan [PATCH]
116+
117+
+ Request (application/json)
118+
119+
{
120+
"id": 1,
121+
"new_plan_id": 2,
122+
}
123+
124+
+ Response 204 (application/json)
125+
126+
127+
+ Response 500 (application/json)
128+
129+
{
130+
"error": "message.internal_server_error"
131+
}
132+
133+
## Subscriptions/id [/subscriptions/{id}]
134+
135+
+ Parameters
136+
+ id (number) - ID of the Subscription in the form of an integer
137+
138+
### Get Subscription by ID [GET]
139+
140+
+ Response 200 (application/json)
141+
142+
{
143+
"id": 1,
144+
"user_id": 1,
145+
"plan_id": 1,
146+
"price": 17.99,
147+
"is_paid": true,
148+
"start_date": "2020-08-05T00:00:00.000Z",
149+
"end_date": "2020-09-05T00:00:00.000Z"
150+
}
151+
152+
+ Response 404 (application/json)
153+
154+
{
155+
156+
"error": "message.subscription.not_found"
157+
}
158+
159+
### Delete Subscription [DELETE]
160+
161+
+ Response 204
162+
163+
+ Response 500 (application/json)
164+
165+
{
166+
"error": "message.internal_server_error"
167+
}
168+
169+
170+
## Subscriptions/id/payment [/subscriptions/{id}/payment]
171+
172+
+ Parameters
173+
+ id (number) - ID of the Subscription in the form of an integer
174+
175+
### Pay Subscription Price [PATCH]
176+
177+
+ Request (application/json)
178+
179+
{
180+
"id": 1,
181+
"card_owner_name": "Steve Jobs",
182+
"card_number": "5500 0000 0000 0004",
183+
"valid_thru_month": 11,
184+
"valid_thru_year": 28,
185+
"cvc": 256
186+
}
187+
188+
+ Response 204
189+
190+
+ Response 500 (application/json)
191+
192+
{
193+
"error": "message.internal_server_error"
194+
}

0 commit comments

Comments
 (0)