reqcord 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +8 -0
- data/CHANGELOG.md +77 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +171 -0
- data/LICENSE.txt +21 -0
- data/README.md +239 -95
- data/Rakefile +13 -0
- data/docs/configuration.md +319 -0
- data/examples/complex-spec-app/.rspec +1 -0
- data/examples/complex-spec-app/README.md +21 -0
- data/examples/complex-spec-app/app.rb +363 -0
- data/examples/complex-spec-app/docs/api/README.md +104 -0
- data/examples/complex-spec-app/docs/api/api/v1/admin/products/create.md +117 -0
- data/examples/complex-spec-app/docs/api/api/v1/admin/products/destroy.md +51 -0
- data/examples/complex-spec-app/docs/api/api/v1/admin/products/index.md +11 -0
- data/examples/complex-spec-app/docs/api/api/v1/admin/products/list.md +106 -0
- data/examples/complex-spec-app/docs/api/api/v1/auth/index.md +9 -0
- data/examples/complex-spec-app/docs/api/api/v1/auth/login.md +76 -0
- data/examples/complex-spec-app/docs/api/api/v1/cart-items/create.md +91 -0
- data/examples/complex-spec-app/docs/api/api/v1/cart-items/destroy.md +51 -0
- data/examples/complex-spec-app/docs/api/api/v1/cart-items/index.md +10 -0
- data/examples/complex-spec-app/docs/api/api/v1/carts/checkout.md +102 -0
- data/examples/complex-spec-app/docs/api/api/v1/carts/index.md +10 -0
- data/examples/complex-spec-app/docs/api/api/v1/carts/show.md +73 -0
- data/examples/complex-spec-app/docs/api/api/v1/home/index.md +9 -0
- data/examples/complex-spec-app/docs/api/api/v1/home/list.md +47 -0
- data/examples/complex-spec-app/docs/api/api/v1/notes/create.md +94 -0
- data/examples/complex-spec-app/docs/api/api/v1/notes/index.md +10 -0
- data/examples/complex-spec-app/docs/api/api/v1/notes/list.md +61 -0
- data/examples/complex-spec-app/docs/api/api/v1/orders/cancel.md +69 -0
- data/examples/complex-spec-app/docs/api/api/v1/orders/create.md +150 -0
- data/examples/complex-spec-app/docs/api/api/v1/orders/destroy.md +37 -0
- data/examples/complex-spec-app/docs/api/api/v1/orders/index.md +13 -0
- data/examples/complex-spec-app/docs/api/api/v1/orders/list.md +78 -0
- data/examples/complex-spec-app/docs/api/api/v1/orders/show.md +83 -0
- data/examples/complex-spec-app/docs/api/api/v1/products/index.md +11 -0
- data/examples/complex-spec-app/docs/api/api/v1/products/list.md +83 -0
- data/examples/complex-spec-app/docs/api/api/v1/products/search.md +88 -0
- data/examples/complex-spec-app/docs/api/api/v1/products/show.md +71 -0
- data/examples/complex-spec-app/docs/api/api/v1/profiles/index.md +10 -0
- data/examples/complex-spec-app/docs/api/api/v1/profiles/show.md +61 -0
- data/examples/complex-spec-app/docs/api/api/v1/profiles/update.md +91 -0
- data/examples/complex-spec-app/docs/api/api/v2/products/index.md +9 -0
- data/examples/complex-spec-app/docs/api/api/v2/products/list.md +77 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/admin/products/create.sh +18 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/admin/products/destroy.sh +9 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/admin/products/list.sh +9 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/auth/login.sh +9 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/cart-items/create.sh +16 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/cart-items/destroy.sh +9 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/carts/checkout.sh +13 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/carts/show.sh +9 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/home/list.sh +8 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/notes/create.sh +15 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/notes/list.sh +9 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/orders/cancel.sh +9 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/orders/create.sh +29 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/orders/destroy.sh +9 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/orders/list.sh +9 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/orders/show.sh +9 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/products/list.sh +8 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/products/search.sh +8 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/products/show.sh +8 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/profiles/show.sh +9 -0
- data/examples/complex-spec-app/docs/api/curl/api/v1/profiles/update.sh +16 -0
- data/examples/complex-spec-app/docs/api/curl/api/v2/products/list.sh +8 -0
- data/examples/complex-spec-app/docs/api/dataset.json +5116 -0
- data/examples/complex-spec-app/docs/api/postman/collection.json +2519 -0
- data/examples/complex-spec-app/generate.rb +14 -0
- data/examples/complex-spec-app/reqcord.yml +28 -0
- data/examples/complex-spec-app/spec/requests/admin_spec.rb +67 -0
- data/examples/complex-spec-app/spec/requests/cart_spec.rb +61 -0
- data/examples/complex-spec-app/spec/requests/home_and_auth_spec.rb +49 -0
- data/examples/complex-spec-app/spec/requests/orders_spec.rb +124 -0
- data/examples/complex-spec-app/spec/requests/products_spec.rb +65 -0
- data/examples/complex-spec-app/spec/spec_helper.rb +17 -0
- data/examples/complex-test-app/README.md +40 -0
- data/examples/complex-test-app/app.rb +384 -0
- data/examples/complex-test-app/docs/api/README.md +104 -0
- data/examples/complex-test-app/docs/api/api/v1/admin/products/create.md +117 -0
- data/examples/complex-test-app/docs/api/api/v1/admin/products/destroy.md +51 -0
- data/examples/complex-test-app/docs/api/api/v1/admin/products/index.md +11 -0
- data/examples/complex-test-app/docs/api/api/v1/admin/products/list.md +106 -0
- data/examples/complex-test-app/docs/api/api/v1/auth/index.md +9 -0
- data/examples/complex-test-app/docs/api/api/v1/auth/login.md +76 -0
- data/examples/complex-test-app/docs/api/api/v1/cart-items/create.md +91 -0
- data/examples/complex-test-app/docs/api/api/v1/cart-items/destroy.md +51 -0
- data/examples/complex-test-app/docs/api/api/v1/cart-items/index.md +10 -0
- data/examples/complex-test-app/docs/api/api/v1/carts/checkout.md +102 -0
- data/examples/complex-test-app/docs/api/api/v1/carts/index.md +10 -0
- data/examples/complex-test-app/docs/api/api/v1/carts/show.md +73 -0
- data/examples/complex-test-app/docs/api/api/v1/home/index.md +9 -0
- data/examples/complex-test-app/docs/api/api/v1/home/list.md +47 -0
- data/examples/complex-test-app/docs/api/api/v1/notes/create.md +94 -0
- data/examples/complex-test-app/docs/api/api/v1/notes/index.md +10 -0
- data/examples/complex-test-app/docs/api/api/v1/notes/list.md +61 -0
- data/examples/complex-test-app/docs/api/api/v1/orders/cancel.md +69 -0
- data/examples/complex-test-app/docs/api/api/v1/orders/create.md +150 -0
- data/examples/complex-test-app/docs/api/api/v1/orders/destroy.md +37 -0
- data/examples/complex-test-app/docs/api/api/v1/orders/index.md +13 -0
- data/examples/complex-test-app/docs/api/api/v1/orders/list.md +71 -0
- data/examples/complex-test-app/docs/api/api/v1/orders/show.md +83 -0
- data/examples/complex-test-app/docs/api/api/v1/products/index.md +11 -0
- data/examples/complex-test-app/docs/api/api/v1/products/list.md +83 -0
- data/examples/complex-test-app/docs/api/api/v1/products/search.md +88 -0
- data/examples/complex-test-app/docs/api/api/v1/products/show.md +71 -0
- data/examples/complex-test-app/docs/api/api/v1/profiles/index.md +10 -0
- data/examples/complex-test-app/docs/api/api/v1/profiles/show.md +61 -0
- data/examples/complex-test-app/docs/api/api/v1/profiles/update.md +91 -0
- data/examples/complex-test-app/docs/api/api/v2/products/index.md +9 -0
- data/examples/complex-test-app/docs/api/api/v2/products/list.md +77 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/admin/products/create.sh +18 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/admin/products/destroy.sh +9 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/admin/products/list.sh +9 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/auth/login.sh +9 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/cart-items/create.sh +16 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/cart-items/destroy.sh +9 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/carts/checkout.sh +13 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/carts/show.sh +9 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/home/list.sh +8 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/notes/create.sh +15 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/notes/list.sh +9 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/orders/cancel.sh +9 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/orders/create.sh +29 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/orders/destroy.sh +9 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/orders/list.sh +9 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/orders/show.sh +9 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/products/list.sh +8 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/products/search.sh +8 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/products/show.sh +8 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/profiles/show.sh +9 -0
- data/examples/complex-test-app/docs/api/curl/api/v1/profiles/update.sh +16 -0
- data/examples/complex-test-app/docs/api/curl/api/v2/products/list.sh +8 -0
- data/examples/complex-test-app/docs/api/dataset.json +5109 -0
- data/examples/complex-test-app/docs/api/postman/collection.json +2568 -0
- data/examples/complex-test-app/generate.rb +14 -0
- data/examples/complex-test-app/reqcord.yml +28 -0
- data/examples/complex-test-app/test/integration/admin_test.rb +70 -0
- data/examples/complex-test-app/test/integration/cart_test.rb +64 -0
- data/examples/complex-test-app/test/integration/home_and_auth_test.rb +53 -0
- data/examples/complex-test-app/test/integration/orders_test.rb +127 -0
- data/examples/complex-test-app/test/integration/products_test.rb +66 -0
- data/examples/reqcord.yml +58 -0
- data/examples/spec-app/.rspec +1 -0
- data/examples/spec-app/README.md +36 -0
- data/examples/spec-app/app.rb +209 -0
- data/examples/spec-app/docs/api/README.md +45 -0
- data/examples/spec-app/docs/api/api/v1/customers/create.md +95 -0
- data/examples/spec-app/docs/api/api/v1/customers/index.md +11 -0
- data/examples/spec-app/docs/api/api/v1/customers/list.md +67 -0
- data/examples/spec-app/docs/api/api/v1/customers/show.md +65 -0
- data/examples/spec-app/docs/api/api/v1/tasks/complete.md +51 -0
- data/examples/spec-app/docs/api/api/v1/tasks/create.md +90 -0
- data/examples/spec-app/docs/api/api/v1/tasks/destroy.md +35 -0
- data/examples/spec-app/docs/api/api/v1/tasks/index.md +14 -0
- data/examples/spec-app/docs/api/api/v1/tasks/list.md +65 -0
- data/examples/spec-app/docs/api/api/v1/tasks/show.md +65 -0
- data/examples/spec-app/docs/api/api/v1/tasks/update.md +74 -0
- data/examples/spec-app/docs/api/api/v1/users/create.md +95 -0
- data/examples/spec-app/docs/api/api/v1/users/index.md +11 -0
- data/examples/spec-app/docs/api/api/v1/users/list.md +67 -0
- data/examples/spec-app/docs/api/api/v1/users/show.md +65 -0
- data/examples/spec-app/docs/api/curl/api/v1/customers/create.sh +17 -0
- data/examples/spec-app/docs/api/curl/api/v1/customers/list.sh +9 -0
- data/examples/spec-app/docs/api/curl/api/v1/customers/show.sh +9 -0
- data/examples/spec-app/docs/api/curl/api/v1/tasks/complete.sh +8 -0
- data/examples/spec-app/docs/api/curl/api/v1/tasks/create.sh +15 -0
- data/examples/spec-app/docs/api/curl/api/v1/tasks/destroy.sh +8 -0
- data/examples/spec-app/docs/api/curl/api/v1/tasks/list.sh +8 -0
- data/examples/spec-app/docs/api/curl/api/v1/tasks/show.sh +8 -0
- data/examples/spec-app/docs/api/curl/api/v1/tasks/update.sh +14 -0
- data/examples/spec-app/docs/api/curl/api/v1/users/create.sh +17 -0
- data/examples/spec-app/docs/api/curl/api/v1/users/list.sh +9 -0
- data/examples/spec-app/docs/api/curl/api/v1/users/show.sh +9 -0
- data/examples/spec-app/docs/api/dataset.json +2402 -0
- data/examples/spec-app/docs/api/postman/collection.json +1290 -0
- data/examples/spec-app/generate.rb +14 -0
- data/examples/spec-app/reqcord.yml +27 -0
- data/examples/spec-app/spec/requests/customers_spec.rb +71 -0
- data/examples/spec-app/spec/requests/tasks_spec.rb +78 -0
- data/examples/spec-app/spec/requests/users_spec.rb +68 -0
- data/examples/spec-app/spec/spec_helper.rb +17 -0
- data/examples/test-app/README.md +57 -0
- data/examples/test-app/app.rb +212 -0
- data/examples/test-app/docs/api/README.md +45 -0
- data/examples/test-app/docs/api/api/v1/customers/create.md +95 -0
- data/examples/test-app/docs/api/api/v1/customers/index.md +11 -0
- data/examples/test-app/docs/api/api/v1/customers/list.md +67 -0
- data/examples/test-app/docs/api/api/v1/customers/show.md +65 -0
- data/examples/test-app/docs/api/api/v1/tasks/complete.md +51 -0
- data/examples/test-app/docs/api/api/v1/tasks/create.md +90 -0
- data/examples/test-app/docs/api/api/v1/tasks/destroy.md +35 -0
- data/examples/test-app/docs/api/api/v1/tasks/index.md +14 -0
- data/examples/test-app/docs/api/api/v1/tasks/list.md +65 -0
- data/examples/test-app/docs/api/api/v1/tasks/show.md +65 -0
- data/examples/test-app/docs/api/api/v1/tasks/update.md +74 -0
- data/examples/test-app/docs/api/api/v1/users/create.md +95 -0
- data/examples/test-app/docs/api/api/v1/users/index.md +11 -0
- data/examples/test-app/docs/api/api/v1/users/list.md +67 -0
- data/examples/test-app/docs/api/api/v1/users/show.md +65 -0
- data/examples/test-app/docs/api/curl/api/v1/customers/create.sh +17 -0
- data/examples/test-app/docs/api/curl/api/v1/customers/list.sh +9 -0
- data/examples/test-app/docs/api/curl/api/v1/customers/show.sh +9 -0
- data/examples/test-app/docs/api/curl/api/v1/tasks/complete.sh +8 -0
- data/examples/test-app/docs/api/curl/api/v1/tasks/create.sh +15 -0
- data/examples/test-app/docs/api/curl/api/v1/tasks/destroy.sh +8 -0
- data/examples/test-app/docs/api/curl/api/v1/tasks/list.sh +8 -0
- data/examples/test-app/docs/api/curl/api/v1/tasks/show.sh +8 -0
- data/examples/test-app/docs/api/curl/api/v1/tasks/update.sh +14 -0
- data/examples/test-app/docs/api/curl/api/v1/users/create.sh +17 -0
- data/examples/test-app/docs/api/curl/api/v1/users/list.sh +9 -0
- data/examples/test-app/docs/api/curl/api/v1/users/show.sh +9 -0
- data/examples/test-app/docs/api/dataset.json +2402 -0
- data/examples/test-app/docs/api/postman/collection.json +1290 -0
- data/examples/test-app/generate.rb +14 -0
- data/examples/test-app/reqcord.yml +28 -0
- data/examples/test-app/test/integration/customers_test.rb +72 -0
- data/examples/test-app/test/integration/tasks_test.rb +80 -0
- data/examples/test-app/test/integration/users_test.rb +72 -0
- data/lib/reqcord/capture/collector.rb +31 -0
- data/lib/reqcord/capture/integration_patch.rb +209 -0
- data/lib/reqcord/capture/minitest_context.rb +34 -0
- data/lib/reqcord/capture/rspec_context.rb +42 -0
- data/lib/reqcord/capture/test_context.rb +25 -0
- data/lib/reqcord/capture.rb +19 -0
- data/lib/reqcord/configuration.rb +198 -0
- data/lib/reqcord/dataset.rb +176 -0
- data/lib/reqcord/endpoint.rb +263 -0
- data/lib/reqcord/errors.rb +9 -0
- data/lib/reqcord/exporters/curl.rb +68 -0
- data/lib/reqcord/exporters/markdown.rb +295 -0
- data/lib/reqcord/exporters/postman.rb +206 -0
- data/lib/reqcord/exporters.rb +32 -0
- data/lib/reqcord/generator.rb +364 -0
- data/lib/reqcord/railtie.rb +51 -0
- data/lib/reqcord/renderers/curl.rb +56 -0
- data/lib/reqcord/renderers/payload.rb +69 -0
- data/lib/reqcord/request_example.rb +104 -0
- data/lib/reqcord/response_example.rb +72 -0
- data/lib/reqcord/route_collector.rb +242 -0
- data/lib/reqcord/sanitizers/sanitizer.rb +140 -0
- data/lib/reqcord/schema.rb +187 -0
- data/lib/reqcord/support.rb +58 -0
- data/lib/reqcord/version.rb +5 -0
- data/lib/reqcord.rb +78 -0
- data/lib/tasks/reqcord.rake +99 -0
- data/reqcord.gemspec +46 -0
- metadata +317 -3
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Checkout Cart
|
|
2
|
+
|
|
3
|
+
`POST /api/v1/cart/checkout`
|
|
4
|
+
|
|
5
|
+
Namespace: `api/v1`
|
|
6
|
+
|
|
7
|
+
## Headers
|
|
8
|
+
|
|
9
|
+
| Header | Value |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| Authorization | `Bearer {{token}}` |
|
|
12
|
+
| Content-Type | `application/json` |
|
|
13
|
+
| Accept | `application/json` |
|
|
14
|
+
|
|
15
|
+
## Body Parameters
|
|
16
|
+
|
|
17
|
+
| Field | Type | Required | Values |
|
|
18
|
+
| --- | --- | --- | --- |
|
|
19
|
+
| `payment_method` | string | yes | `"bank_transfer"` \| `"card"` |
|
|
20
|
+
|
|
21
|
+
## Example Request
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"payment_method": "card"
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## cURL
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
curl --request POST \
|
|
33
|
+
--url "http://localhost:3000/api/v1/cart/checkout" \
|
|
34
|
+
--header "Authorization: Bearer {{token}}" \
|
|
35
|
+
--header "Content-Type: application/json" \
|
|
36
|
+
--header "Accept: application/json" \
|
|
37
|
+
--data '{
|
|
38
|
+
"payment_method": "card"
|
|
39
|
+
}'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Responses
|
|
43
|
+
|
|
44
|
+
### 201 Created
|
|
45
|
+
|
|
46
|
+
#### Fields
|
|
47
|
+
|
|
48
|
+
| Field | Type | Required | Values |
|
|
49
|
+
| --- | --- | --- | --- |
|
|
50
|
+
| `id` | integer | yes | `5` |
|
|
51
|
+
| `status` | string | yes | `"pending"` |
|
|
52
|
+
| `payment_method` | string | yes | `"bank_transfer"` \| `"card"` |
|
|
53
|
+
| `total_cents` | integer | yes | `4800` |
|
|
54
|
+
| `line_items[].sku` | string | yes | `"MUG-001"` |
|
|
55
|
+
| `line_items[].name` | string | yes | `"Stoneware Mug"` |
|
|
56
|
+
| `line_items[].quantity` | integer | yes | `1` |
|
|
57
|
+
| `line_items[].unit_price_cents` | integer | yes | `2400` |
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"id": 5,
|
|
62
|
+
"status": "pending",
|
|
63
|
+
"payment_method": "card",
|
|
64
|
+
"total_cents": 4800,
|
|
65
|
+
"line_items": [
|
|
66
|
+
{
|
|
67
|
+
"sku": "TEA-001",
|
|
68
|
+
"name": "Earl Grey",
|
|
69
|
+
"quantity": 2,
|
|
70
|
+
"unit_price_cents": 1200
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"sku": "MUG-001",
|
|
74
|
+
"name": "Stoneware Mug",
|
|
75
|
+
"quantity": 1,
|
|
76
|
+
"unit_price_cents": 2400
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 422 Unprocessable Content
|
|
83
|
+
|
|
84
|
+
#### Fields
|
|
85
|
+
|
|
86
|
+
| Field | Type | Required | Values |
|
|
87
|
+
| --- | --- | --- | --- |
|
|
88
|
+
| `errors.payment_method[]` | string | yes | `"is not included in the list"` |
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"errors": {
|
|
93
|
+
"payment_method": [
|
|
94
|
+
"is not included in the list"
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
Resource: [Carts](index.md)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Get Cart
|
|
2
|
+
|
|
3
|
+
`GET /api/v1/cart`
|
|
4
|
+
|
|
5
|
+
Namespace: `api/v1`
|
|
6
|
+
|
|
7
|
+
## Headers
|
|
8
|
+
|
|
9
|
+
| Header | Value |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| Authorization | `Bearer {{token}}` |
|
|
12
|
+
| Accept | `application/json` |
|
|
13
|
+
|
|
14
|
+
## cURL
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
curl --request GET \
|
|
18
|
+
--url "http://localhost:3000/api/v1/cart" \
|
|
19
|
+
--header "Authorization: Bearer {{token}}" \
|
|
20
|
+
--header "Accept: application/json"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Responses
|
|
24
|
+
|
|
25
|
+
### 200 OK
|
|
26
|
+
|
|
27
|
+
#### Fields
|
|
28
|
+
|
|
29
|
+
| Field | Type | Required | Values |
|
|
30
|
+
| --- | --- | --- | --- |
|
|
31
|
+
| `items[].sku` | string | yes | `"MUG-001"` |
|
|
32
|
+
| `items[].name` | string | yes | `"Stoneware Mug"` |
|
|
33
|
+
| `items[].quantity` | integer | yes | `1` |
|
|
34
|
+
| `items[].unit_price_cents` | integer | yes | `2400` |
|
|
35
|
+
| `total_cents` | integer | yes | `4800` |
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"items": [
|
|
40
|
+
{
|
|
41
|
+
"sku": "TEA-001",
|
|
42
|
+
"name": "Earl Grey",
|
|
43
|
+
"quantity": 2,
|
|
44
|
+
"unit_price_cents": 1200
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"sku": "MUG-001",
|
|
48
|
+
"name": "Stoneware Mug",
|
|
49
|
+
"quantity": 1,
|
|
50
|
+
"unit_price_cents": 2400
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"total_cents": 4800
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 401 Unauthorized
|
|
58
|
+
|
|
59
|
+
#### Fields
|
|
60
|
+
|
|
61
|
+
| Field | Type | Required | Values |
|
|
62
|
+
| --- | --- | --- | --- |
|
|
63
|
+
| `error` | string | yes | `"Unauthorized"` |
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"error": "Unauthorized"
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
Resource: [Carts](index.md)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Home
|
|
2
|
+
|
|
3
|
+
`GET /api/v1`
|
|
4
|
+
|
|
5
|
+
Namespace: `api/v1`
|
|
6
|
+
|
|
7
|
+
## Headers
|
|
8
|
+
|
|
9
|
+
| Header | Value |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| Accept | `application/json` |
|
|
12
|
+
|
|
13
|
+
## cURL
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
curl --request GET \
|
|
17
|
+
--url "http://localhost:3000/api/v1" \
|
|
18
|
+
--header "Accept: application/json"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Responses
|
|
22
|
+
|
|
23
|
+
### 200 OK
|
|
24
|
+
|
|
25
|
+
#### Fields
|
|
26
|
+
|
|
27
|
+
| Field | Type | Required | Values |
|
|
28
|
+
| --- | --- | --- | --- |
|
|
29
|
+
| `name` | string | yes | `"Store API"` |
|
|
30
|
+
| `version` | string | yes | `"v1"` |
|
|
31
|
+
| `links.products` | string | yes | `"/api/v1/products"` |
|
|
32
|
+
| `links.orders` | string | yes | `"/api/v1/orders"` |
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"name": "Store API",
|
|
37
|
+
"version": "v1",
|
|
38
|
+
"links": {
|
|
39
|
+
"products": "/api/v1/products",
|
|
40
|
+
"orders": "/api/v1/orders"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
Resource: [Home](index.md)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Create Note
|
|
2
|
+
|
|
3
|
+
`POST /api/v1/orders/:order_id/notes`
|
|
4
|
+
|
|
5
|
+
Namespace: `api/v1`
|
|
6
|
+
|
|
7
|
+
## Headers
|
|
8
|
+
|
|
9
|
+
| Header | Value |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| Authorization | `Bearer {{token}}` |
|
|
12
|
+
| Content-Type | `application/json` |
|
|
13
|
+
| Accept | `application/json` |
|
|
14
|
+
|
|
15
|
+
## Path Parameters
|
|
16
|
+
|
|
17
|
+
| Field | Type | Required | Values |
|
|
18
|
+
| --- | --- | --- | --- |
|
|
19
|
+
| `order_id` | string | yes | `"1"` |
|
|
20
|
+
|
|
21
|
+
## Body Parameters
|
|
22
|
+
|
|
23
|
+
| Field | Type | Required | Values |
|
|
24
|
+
| --- | --- | --- | --- |
|
|
25
|
+
| `note.body` | string | yes | `"Ring the bell twice"` |
|
|
26
|
+
|
|
27
|
+
## Example Request
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"note": {
|
|
32
|
+
"body": "Ring the bell twice"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## cURL
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
curl --request POST \
|
|
41
|
+
--url "http://localhost:3000/api/v1/orders/1/notes" \
|
|
42
|
+
--header "Authorization: Bearer {{token}}" \
|
|
43
|
+
--header "Content-Type: application/json" \
|
|
44
|
+
--header "Accept: application/json" \
|
|
45
|
+
--data '{
|
|
46
|
+
"note": {
|
|
47
|
+
"body": "Ring the bell twice"
|
|
48
|
+
}
|
|
49
|
+
}'
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Responses
|
|
53
|
+
|
|
54
|
+
### 201 Created
|
|
55
|
+
|
|
56
|
+
#### Fields
|
|
57
|
+
|
|
58
|
+
| Field | Type | Required | Values |
|
|
59
|
+
| --- | --- | --- | --- |
|
|
60
|
+
| `id` | integer | yes | `3` |
|
|
61
|
+
| `order_id` | integer | yes | `1` |
|
|
62
|
+
| `body` | string | yes | `"Ring the bell twice"` |
|
|
63
|
+
| `author` | string | yes | `"ada"` |
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"id": 3,
|
|
68
|
+
"order_id": 1,
|
|
69
|
+
"body": "Ring the bell twice",
|
|
70
|
+
"author": "ada"
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 422 Unprocessable Content
|
|
75
|
+
|
|
76
|
+
#### Fields
|
|
77
|
+
|
|
78
|
+
| Field | Type | Required | Values |
|
|
79
|
+
| --- | --- | --- | --- |
|
|
80
|
+
| `errors.body[]` | string | yes | `"can't be blank"` |
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"errors": {
|
|
85
|
+
"body": [
|
|
86
|
+
"can't be blank"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
Resource: [Notes](index.md)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# List Notes
|
|
2
|
+
|
|
3
|
+
`GET /api/v1/orders/:order_id/notes`
|
|
4
|
+
|
|
5
|
+
Namespace: `api/v1`
|
|
6
|
+
|
|
7
|
+
## Headers
|
|
8
|
+
|
|
9
|
+
| Header | Value |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| Authorization | `Bearer {{token}}` |
|
|
12
|
+
| Accept | `application/json` |
|
|
13
|
+
|
|
14
|
+
## Path Parameters
|
|
15
|
+
|
|
16
|
+
| Field | Type | Required | Values |
|
|
17
|
+
| --- | --- | --- | --- |
|
|
18
|
+
| `order_id` | string | yes | `"1"` |
|
|
19
|
+
|
|
20
|
+
## cURL
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
curl --request GET \
|
|
24
|
+
--url "http://localhost:3000/api/v1/orders/1/notes" \
|
|
25
|
+
--header "Authorization: Bearer {{token}}" \
|
|
26
|
+
--header "Accept: application/json"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Responses
|
|
30
|
+
|
|
31
|
+
### 200 OK
|
|
32
|
+
|
|
33
|
+
#### Fields
|
|
34
|
+
|
|
35
|
+
| Field | Type | Required | Values |
|
|
36
|
+
| --- | --- | --- | --- |
|
|
37
|
+
| `[].id` | integer | yes | `2` |
|
|
38
|
+
| `[].order_id` | integer | yes | `1` |
|
|
39
|
+
| `[].body` | string | yes | `"Gift wrap please"` |
|
|
40
|
+
| `[].author` | string | yes | `"ada"` |
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
[
|
|
44
|
+
{
|
|
45
|
+
"id": 1,
|
|
46
|
+
"order_id": 1,
|
|
47
|
+
"body": "Leave at the door",
|
|
48
|
+
"author": "ada"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"id": 2,
|
|
52
|
+
"order_id": 1,
|
|
53
|
+
"body": "Gift wrap please",
|
|
54
|
+
"author": "ada"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
Resource: [Notes](index.md)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Cancel Order
|
|
2
|
+
|
|
3
|
+
`POST /api/v1/orders/:id/cancel`
|
|
4
|
+
|
|
5
|
+
Namespace: `api/v1`
|
|
6
|
+
|
|
7
|
+
## Headers
|
|
8
|
+
|
|
9
|
+
| Header | Value |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| Authorization | `Bearer {{token}}` |
|
|
12
|
+
| Accept | `application/json` |
|
|
13
|
+
|
|
14
|
+
## Path Parameters
|
|
15
|
+
|
|
16
|
+
| Field | Type | Required | Values |
|
|
17
|
+
| --- | --- | --- | --- |
|
|
18
|
+
| `id` | string | yes | `"1"` |
|
|
19
|
+
|
|
20
|
+
## cURL
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
curl --request POST \
|
|
24
|
+
--url "http://localhost:3000/api/v1/orders/1/cancel" \
|
|
25
|
+
--header "Authorization: Bearer {{token}}" \
|
|
26
|
+
--header "Accept: application/json"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Responses
|
|
30
|
+
|
|
31
|
+
### 200 OK
|
|
32
|
+
|
|
33
|
+
#### Fields
|
|
34
|
+
|
|
35
|
+
| Field | Type | Required | Values |
|
|
36
|
+
| --- | --- | --- | --- |
|
|
37
|
+
| `id` | integer | yes | `1` |
|
|
38
|
+
| `user_id` | integer | yes | `1` |
|
|
39
|
+
| `status` | string | yes | `"cancelled"` |
|
|
40
|
+
| `currency` | string | yes | `"USD"` |
|
|
41
|
+
| `total_cents` | integer | yes | `2700` |
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"id": 1,
|
|
46
|
+
"user_id": 1,
|
|
47
|
+
"status": "cancelled",
|
|
48
|
+
"currency": "USD",
|
|
49
|
+
"total_cents": 2700
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 409 Conflict
|
|
54
|
+
|
|
55
|
+
#### Fields
|
|
56
|
+
|
|
57
|
+
| Field | Type | Required | Values |
|
|
58
|
+
| --- | --- | --- | --- |
|
|
59
|
+
| `error` | string | yes | `"Shipped orders cannot be cancelled"` |
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"error": "Shipped orders cannot be cancelled"
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
Resource: [Orders](index.md)
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Create Order
|
|
2
|
+
|
|
3
|
+
`POST /api/v1/orders`
|
|
4
|
+
|
|
5
|
+
Namespace: `api/v1`
|
|
6
|
+
|
|
7
|
+
## Headers
|
|
8
|
+
|
|
9
|
+
| Header | Value |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| Authorization | `Bearer {{token}}` |
|
|
12
|
+
| Content-Type | `application/json` |
|
|
13
|
+
| Accept | `application/json` |
|
|
14
|
+
|
|
15
|
+
## Body Parameters
|
|
16
|
+
|
|
17
|
+
| Field | Type | Required | Values |
|
|
18
|
+
| --- | --- | --- | --- |
|
|
19
|
+
| `order.line_items[].sku` | string | yes | `"MUG-001"` |
|
|
20
|
+
| `order.line_items[].quantity` | integer | yes | `1` |
|
|
21
|
+
| `order.shipping_address.line1` | string | yes | `"1 Analytical Engine Way"` |
|
|
22
|
+
| `order.shipping_address.city` | string | yes | `"London"` |
|
|
23
|
+
| `order.shipping_address.country` | string | yes | `"GB"` \| `"IT"` |
|
|
24
|
+
|
|
25
|
+
## Example Request
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"order": {
|
|
30
|
+
"line_items": [
|
|
31
|
+
{
|
|
32
|
+
"sku": "TEA-001",
|
|
33
|
+
"quantity": 2
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"sku": "MUG-001",
|
|
37
|
+
"quantity": 1
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"shipping_address": {
|
|
41
|
+
"line1": "1 Analytical Engine Way",
|
|
42
|
+
"city": "London",
|
|
43
|
+
"country": "GB"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## cURL
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
curl --request POST \
|
|
53
|
+
--url "http://localhost:3000/api/v1/orders" \
|
|
54
|
+
--header "Authorization: Bearer {{token}}" \
|
|
55
|
+
--header "Content-Type: application/json" \
|
|
56
|
+
--header "Accept: application/json" \
|
|
57
|
+
--data '{
|
|
58
|
+
"order": {
|
|
59
|
+
"line_items": [
|
|
60
|
+
{
|
|
61
|
+
"sku": "TEA-001",
|
|
62
|
+
"quantity": 2
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"sku": "MUG-001",
|
|
66
|
+
"quantity": 1
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"shipping_address": {
|
|
70
|
+
"line1": "1 Analytical Engine Way",
|
|
71
|
+
"city": "London",
|
|
72
|
+
"country": "GB"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}'
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Responses
|
|
79
|
+
|
|
80
|
+
### 201 Created
|
|
81
|
+
|
|
82
|
+
#### Fields
|
|
83
|
+
|
|
84
|
+
| Field | Type | Required | Values |
|
|
85
|
+
| --- | --- | --- | --- |
|
|
86
|
+
| `id` | integer | yes | `4` |
|
|
87
|
+
| `status` | string | yes | `"pending"` |
|
|
88
|
+
| `currency` | string | yes | `"USD"` |
|
|
89
|
+
| `total_cents` | integer | yes | `4800` |
|
|
90
|
+
| `line_items[].sku` | string | yes | `"MUG-001"` |
|
|
91
|
+
| `line_items[].name` | string | yes | `"Stoneware Mug"` |
|
|
92
|
+
| `line_items[].quantity` | integer | yes | `1` |
|
|
93
|
+
| `line_items[].unit_price_cents` | integer | yes | `2400` |
|
|
94
|
+
| `line_items[].subtotal_cents` | integer | yes | `2400` |
|
|
95
|
+
| `shipping_address.line1` | string | yes | `"1 Analytical Engine Way"` |
|
|
96
|
+
| `shipping_address.city` | string | yes | `"London"` |
|
|
97
|
+
| `shipping_address.country` | string | yes | `"GB"` \| `"IT"` |
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"id": 4,
|
|
102
|
+
"status": "pending",
|
|
103
|
+
"currency": "USD",
|
|
104
|
+
"total_cents": 4800,
|
|
105
|
+
"line_items": [
|
|
106
|
+
{
|
|
107
|
+
"sku": "TEA-001",
|
|
108
|
+
"name": "Earl Grey",
|
|
109
|
+
"quantity": 2,
|
|
110
|
+
"unit_price_cents": 1200,
|
|
111
|
+
"subtotal_cents": 2400
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"sku": "MUG-001",
|
|
115
|
+
"name": "Stoneware Mug",
|
|
116
|
+
"quantity": 1,
|
|
117
|
+
"unit_price_cents": 2400,
|
|
118
|
+
"subtotal_cents": 2400
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"shipping_address": {
|
|
122
|
+
"line1": "1 Analytical Engine Way",
|
|
123
|
+
"city": "London",
|
|
124
|
+
"country": "GB"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 422 Unprocessable Content
|
|
130
|
+
|
|
131
|
+
#### Fields
|
|
132
|
+
|
|
133
|
+
| Field | Type | Required | Values |
|
|
134
|
+
| --- | --- | --- | --- |
|
|
135
|
+
| `errors.line_items[]` | string | no | `"can't be blank"` |
|
|
136
|
+
| `errors.sku[]` | string | no | `"TEA-999 is not a known product"` |
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"errors": {
|
|
141
|
+
"line_items": [
|
|
142
|
+
"can't be blank"
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
Resource: [Orders](index.md)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Delete Order
|
|
2
|
+
|
|
3
|
+
`DELETE /api/v1/orders/:id`
|
|
4
|
+
|
|
5
|
+
Namespace: `api/v1`
|
|
6
|
+
|
|
7
|
+
## Headers
|
|
8
|
+
|
|
9
|
+
| Header | Value |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| Authorization | `Bearer {{token}}` |
|
|
12
|
+
| Accept | `application/json` |
|
|
13
|
+
|
|
14
|
+
## Path Parameters
|
|
15
|
+
|
|
16
|
+
| Field | Type | Required | Values |
|
|
17
|
+
| --- | --- | --- | --- |
|
|
18
|
+
| `id` | string | yes | `"1"` |
|
|
19
|
+
|
|
20
|
+
## cURL
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
curl --request DELETE \
|
|
24
|
+
--url "http://localhost:3000/api/v1/orders/1" \
|
|
25
|
+
--header "Authorization: Bearer {{token}}" \
|
|
26
|
+
--header "Accept: application/json"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Responses
|
|
30
|
+
|
|
31
|
+
### 204 No Content
|
|
32
|
+
|
|
33
|
+
_No response body._
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
Resource: [Orders](index.md)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Orders
|
|
2
|
+
|
|
3
|
+
Namespace: `api/v1`
|
|
4
|
+
|
|
5
|
+
API version: `v1`
|
|
6
|
+
|
|
7
|
+
| Method | Path | Description |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `GET` | [`/api/v1/orders`](list.md) | List Orders |
|
|
10
|
+
| `POST` | [`/api/v1/orders`](create.md) | Create Order |
|
|
11
|
+
| `DELETE` | [`/api/v1/orders/:id`](destroy.md) | Delete Order |
|
|
12
|
+
| `GET` | [`/api/v1/orders/:id`](show.md) | Get Order |
|
|
13
|
+
| `POST` | [`/api/v1/orders/:id/cancel`](cancel.md) | Cancel Order |
|