solidus_api_v2 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +2 -0
  4. data/CHANGELOG.md +38 -0
  5. data/Gemfile +13 -0
  6. data/LICENSE +26 -0
  7. data/README.md +98 -0
  8. data/Rakefile +37 -0
  9. data/app/controllers/concerns/spree/api/v2/renderable.rb +51 -0
  10. data/app/controllers/spree/api/v2/base_controller.rb +31 -0
  11. data/app/controllers/spree/api/v2/children_controller.rb +29 -0
  12. data/app/controllers/spree/api/v2/countries_controller.rb +21 -0
  13. data/app/controllers/spree/api/v2/images_controller.rb +29 -0
  14. data/app/controllers/spree/api/v2/line_items_controller.rb +36 -0
  15. data/app/controllers/spree/api/v2/option_types_controller.rb +31 -0
  16. data/app/controllers/spree/api/v2/option_values_controller.rb +29 -0
  17. data/app/controllers/spree/api/v2/orders_controller.rb +11 -0
  18. data/app/controllers/spree/api/v2/prices_controller.rb +27 -0
  19. data/app/controllers/spree/api/v2/products_controller.rb +37 -0
  20. data/app/controllers/spree/api/v2/states_controller.rb +29 -0
  21. data/app/controllers/spree/api/v2/taxonomies_controller.rb +21 -0
  22. data/app/controllers/spree/api/v2/taxons_controller.rb +40 -0
  23. data/app/controllers/spree/api/v2/variants_controller.rb +35 -0
  24. data/app/models/spree/base_decorator.rb +5 -0
  25. data/app/models/spree/image_decorator.rb +3 -0
  26. data/app/models/spree/price_decorator.rb +3 -0
  27. data/app/models/spree/state_decorator.rb +3 -0
  28. data/app/serializers/spree/address_serializer.rb +9 -0
  29. data/app/serializers/spree/base_serializer.rb +13 -0
  30. data/app/serializers/spree/country_serializer.rb +7 -0
  31. data/app/serializers/spree/error_serializer.rb +52 -0
  32. data/app/serializers/spree/image_serializer.rb +13 -0
  33. data/app/serializers/spree/line_item_serializer.rb +13 -0
  34. data/app/serializers/spree/option_type_serializer.rb +8 -0
  35. data/app/serializers/spree/option_value_serializer.rb +8 -0
  36. data/app/serializers/spree/order_serializer.rb +21 -0
  37. data/app/serializers/spree/price_serializer.rb +7 -0
  38. data/app/serializers/spree/product_serializer.rb +12 -0
  39. data/app/serializers/spree/role_serializer.rb +5 -0
  40. data/app/serializers/spree/state_serializer.rb +7 -0
  41. data/app/serializers/spree/store_serializer.rb +6 -0
  42. data/app/serializers/spree/taxon_serializer.rb +16 -0
  43. data/app/serializers/spree/taxonomy_serializer.rb +7 -0
  44. data/app/serializers/spree/user_serializer.rb +5 -0
  45. data/app/serializers/spree/variant_serializer.rb +12 -0
  46. data/bin/rails +7 -0
  47. data/circle.yml +13 -0
  48. data/config/locales/en.yml +25 -0
  49. data/config/routes.rb +53 -0
  50. data/docs/.nojekyll +0 -0
  51. data/docs/Dockerfile +12 -0
  52. data/docs/Gemfile +13 -0
  53. data/docs/README.md +12 -0
  54. data/docs/Rakefile +9 -0
  55. data/docs/config.rb +39 -0
  56. data/docs/font-selection.json +148 -0
  57. data/docs/source/fonts/slate.eot +0 -0
  58. data/docs/source/fonts/slate.svg +14 -0
  59. data/docs/source/fonts/slate.ttf +0 -0
  60. data/docs/source/fonts/slate.woff +0 -0
  61. data/docs/source/fonts/slate.woff2 +0 -0
  62. data/docs/source/images/logo.png +0 -0
  63. data/docs/source/images/navbar.png +0 -0
  64. data/docs/source/includes/_authentication.md +61 -0
  65. data/docs/source/includes/_countries.md +133 -0
  66. data/docs/source/includes/_errors.md +17 -0
  67. data/docs/source/includes/_filtering.md +11 -0
  68. data/docs/source/includes/_images.md +201 -0
  69. data/docs/source/includes/_line_items.md +137 -0
  70. data/docs/source/includes/_option_types.md +267 -0
  71. data/docs/source/includes/_option_values.md +227 -0
  72. data/docs/source/includes/_orders.md +75 -0
  73. data/docs/source/includes/_pagination.md +10 -0
  74. data/docs/source/includes/_prices.md +188 -0
  75. data/docs/source/includes/_products.md +403 -0
  76. data/docs/source/includes/_states.md +96 -0
  77. data/docs/source/includes/_taxonomies.md +325 -0
  78. data/docs/source/includes/_taxons.md +414 -0
  79. data/docs/source/includes/_variants.md +430 -0
  80. data/docs/source/index.md +53 -0
  81. data/docs/source/javascripts/all.js +4 -0
  82. data/docs/source/javascripts/all_nosearch.js +3 -0
  83. data/docs/source/javascripts/app/_lang.js +162 -0
  84. data/docs/source/javascripts/app/_search.js +74 -0
  85. data/docs/source/javascripts/app/_toc.js +55 -0
  86. data/docs/source/javascripts/lib/_energize.js +169 -0
  87. data/docs/source/javascripts/lib/_imagesloaded.min.js +7 -0
  88. data/docs/source/javascripts/lib/_jquery.highlight.js +108 -0
  89. data/docs/source/javascripts/lib/_jquery.tocify.js +1042 -0
  90. data/docs/source/javascripts/lib/_jquery_ui.js +566 -0
  91. data/docs/source/javascripts/lib/_lunr.js +1910 -0
  92. data/docs/source/layouts/layout.erb +102 -0
  93. data/docs/source/stylesheets/_icon-font.scss +38 -0
  94. data/docs/source/stylesheets/_normalize.css +427 -0
  95. data/docs/source/stylesheets/_syntax.scss.erb +27 -0
  96. data/docs/source/stylesheets/_variables.scss +109 -0
  97. data/docs/source/stylesheets/print.css.scss +142 -0
  98. data/docs/source/stylesheets/screen.css.scss +622 -0
  99. data/lib/solidus_api_v2.rb +5 -0
  100. data/lib/spree_api_v2/engine.rb +21 -0
  101. data/lib/spree_api_v2.rb +4 -0
  102. data/solidus_api_v2.gemspec +36 -0
  103. data/spec/controllers/spree/api/v2/children_controller_spec.rb +28 -0
  104. data/spec/controllers/spree/api/v2/countries_controller_spec.rb +25 -0
  105. data/spec/controllers/spree/api/v2/images_controller_spec.rb +93 -0
  106. data/spec/controllers/spree/api/v2/line_items_controller_spec.rb +86 -0
  107. data/spec/controllers/spree/api/v2/option_types_controller_spec.rb +73 -0
  108. data/spec/controllers/spree/api/v2/option_values_controller_spec.rb +88 -0
  109. data/spec/controllers/spree/api/v2/orders_controller_spec.rb +15 -0
  110. data/spec/controllers/spree/api/v2/prices_controller_spec.rb +55 -0
  111. data/spec/controllers/spree/api/v2/products_controller_spec.rb +95 -0
  112. data/spec/controllers/spree/api/v2/states_controller_spec.rb +42 -0
  113. data/spec/controllers/spree/api/v2/taxonomies_controller_spec.rb +31 -0
  114. data/spec/controllers/spree/api/v2/taxons_controller_spec.rb +54 -0
  115. data/spec/controllers/spree/api/v2/variants_controller_spec.rb +108 -0
  116. data/spec/models/spree/base_decorator_spec.rb +9 -0
  117. data/spec/models/spree/price_decorator_spec.rb +3 -0
  118. data/spec/serializers/spree/address_serializer_spec.rb +35 -0
  119. data/spec/serializers/spree/country_serializer_spec.rb +27 -0
  120. data/spec/serializers/spree/error_serializer_spec.rb +116 -0
  121. data/spec/serializers/spree/image_serializer_spec.rb +30 -0
  122. data/spec/serializers/spree/line_item_serializer_spec.rb +40 -0
  123. data/spec/serializers/spree/option_type_serializer_spec.rb +27 -0
  124. data/spec/serializers/spree/option_value_serializer_spec.rb +29 -0
  125. data/spec/serializers/spree/order_serializer_spec.rb +69 -0
  126. data/spec/serializers/spree/price_serializer_spec.rb +28 -0
  127. data/spec/serializers/spree/product_serializer_spec.rb +47 -0
  128. data/spec/serializers/spree/role_serializer_spec.rb +17 -0
  129. data/spec/serializers/spree/state_serializer_spec.rb +25 -0
  130. data/spec/serializers/spree/store_serializer_spec.rb +25 -0
  131. data/spec/serializers/spree/taxon_serializer_spec.rb +44 -0
  132. data/spec/serializers/spree/taxonomy_serializer_spec.rb +27 -0
  133. data/spec/serializers/spree/user_serializer_spec.rb +17 -0
  134. data/spec/serializers/spree/variant_serializer_spec.rb +55 -0
  135. data/spec/spec_helper.rb +51 -0
  136. data/spec/support/shoulda_matchers.rb +6 -0
  137. data/spree_api_v2.gemspec +36 -0
  138. metadata +437 -0
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
+ <svg xmlns="http://www.w3.org/2000/svg">
4
+ <metadata>Generated by IcoMoon</metadata>
5
+ <defs>
6
+ <font id="slate" horiz-adv-x="1024">
7
+ <font-face units-per-em="1024" ascent="960" descent="-64" />
8
+ <missing-glyph horiz-adv-x="1024" />
9
+ <glyph unicode="&#x20;" d="" horiz-adv-x="512" />
10
+ <glyph unicode="&#xe600;" d="M438.857 877.714q119.429 0 220.286-58.857t159.714-159.714 58.857-220.286-58.857-220.286-159.714-159.714-220.286-58.857-220.286 58.857-159.714 159.714-58.857 220.286 58.857 220.286 159.714 159.714 220.286 58.857zM512 165.143v108.571q0 8-5.143 13.429t-12.571 5.429h-109.714q-7.429 0-13.143-5.714t-5.714-13.143v-108.571q0-7.429 5.714-13.143t13.143-5.714h109.714q7.429 0 12.571 5.429t5.143 13.429zM510.857 361.714l10.286 354.857q0 6.857-5.714 10.286-5.714 4.571-13.714 4.571h-125.714q-8 0-13.714-4.571-5.714-3.429-5.714-10.286l9.714-354.857q0-5.714 5.714-10t13.714-4.286h105.714q8 0 13.429 4.286t6 10z" />
11
+ <glyph unicode="&#xe602;" d="M585.143 164.571v91.429q0 8-5.143 13.143t-13.143 5.143h-54.857v292.571q0 8-5.143 13.143t-13.143 5.143h-182.857q-8 0-13.143-5.143t-5.143-13.143v-91.429q0-8 5.143-13.143t13.143-5.143h54.857v-182.857h-54.857q-8 0-13.143-5.143t-5.143-13.143v-91.429q0-8 5.143-13.143t13.143-5.143h256q8 0 13.143 5.143t5.143 13.143zM512 676.571v91.429q0 8-5.143 13.143t-13.143 5.143h-109.714q-8 0-13.143-5.143t-5.143-13.143v-91.429q0-8 5.143-13.143t13.143-5.143h109.714q8 0 13.143 5.143t5.143 13.143zM877.714 438.857q0-119.429-58.857-220.286t-159.714-159.714-220.286-58.857-220.286 58.857-159.714 159.714-58.857 220.286 58.857 220.286 159.714 159.714 220.286 58.857 220.286-58.857 159.714-159.714 58.857-220.286z" />
12
+ <glyph unicode="&#xe606;" d="M733.714 531.428q0 16-10.286 26.286l-52 51.429q-10.857 10.857-25.714 10.857t-25.714-10.857l-233.143-232.571-129.143 129.143q-10.857 10.857-25.714 10.857t-25.714-10.857l-52-51.429q-10.286-10.286-10.286-26.286 0-15.429 10.286-25.714l206.857-206.857q10.857-10.857 25.714-10.857 15.429 0 26.286 10.857l310.286 310.286q10.286 10.286 10.286 25.714zM877.714 438.857q0-119.429-58.857-220.286t-159.714-159.714-220.286-58.857-220.286 58.857-159.714 159.714-58.857 220.286 58.857 220.286 159.714 159.714 220.286 58.857 220.286-58.857 159.714-159.714 58.857-220.286z" />
13
+ <glyph unicode="&#xe607;" d="M658.286 475.428q0 105.714-75.143 180.857t-180.857 75.143-180.857-75.143-75.143-180.857 75.143-180.857 180.857-75.143 180.857 75.143 75.143 180.857zM950.857 0q0-29.714-21.714-51.429t-51.429-21.714q-30.857 0-51.429 21.714l-196 195.429q-102.286-70.857-228-70.857-81.714 0-156.286 31.714t-128.571 85.714-85.714 128.571-31.714 156.286 31.714 156.286 85.714 128.571 128.571 85.714 156.286 31.714 156.286-31.714 128.571-85.714 85.714-128.571 31.714-156.286q0-125.714-70.857-228l196-196q21.143-21.143 21.143-51.429z" horiz-adv-x="951" />
14
+ </font></defs></svg>
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,61 @@
1
+ # Authentication
2
+
3
+ ```shell
4
+ # Specifying the token as a header.
5
+ curl "https://kabuni.com/api/v1/endpoint"
6
+ -H "X-Spree-Token: abc123"
7
+
8
+ # Specifying the token as a param.
9
+ curl "/api/v1/endpoint"
10
+ -d token=abc123
11
+ ```
12
+
13
+ > Make sure to replace `abc123` with your API key.
14
+
15
+ Spree uses API keys to allow access to the API.
16
+ To obtain a token, you must either create a new user, or, via token authentication, "log" the user in.
17
+
18
+ Spree does not expect every request to require an API key (such as reading public product data).
19
+
20
+ ## Authenticate a User (Login)
21
+
22
+ ```shell
23
+ curl "https://kabuni.com/api/v1/account/signin"
24
+ -X POST
25
+ -d user[email]=spree@example.com
26
+ -d user[password]=spree123
27
+ ```
28
+
29
+ ```json
30
+ {
31
+ "data": {
32
+ "id": "1",
33
+ "type": "spree_users",
34
+ "attributes": {
35
+ "email": "spree@example.com",
36
+ "first_name": "John",
37
+ "last_name": "Doe",
38
+ "job_title": null,
39
+ "based_city": null,
40
+ "experience": null,
41
+ "avatar": "default/avatar-placeholder.jpg",
42
+ "role": "user",
43
+ "biography": null,
44
+ "client_budget": null,
45
+ "license_number": null,
46
+ "certification_authority": null,
47
+ "is_newsletter_subscribed": null,
48
+ "is_designer_available": true
49
+ },
50
+ "relationships": {
51
+ "store": {
52
+ "data": null
53
+ }
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ To login users, you will need to supply the `email` and `password`.
60
+ The response will be a user data object with the token in the body.
61
+ The response's headers will include a `X-Spree-Token` which is what you will use as the token.
@@ -0,0 +1,133 @@
1
+ # Countries
2
+
3
+ ## List Countries
4
+
5
+ ```shell
6
+ curl "https://kabuni.com/api/v2/countries"
7
+ ```
8
+
9
+ ```json
10
+ {
11
+ "data": [
12
+ {
13
+ "id": "1",
14
+ "type": "spree_countries",
15
+ "attributes": {
16
+ "iso_name": "ANDORRA",
17
+ "iso": "AD",
18
+ "iso3": "AND",
19
+ "name": "Andorra",
20
+ "numcode": 20,
21
+ "states_required": true
22
+ },
23
+ "relationships": {
24
+ "states": {
25
+ "data": [
26
+ {
27
+ "type": "spree_states",
28
+ "id": "1"
29
+ }
30
+ ]
31
+ }
32
+ }
33
+ }
34
+ ]
35
+ }
36
+ ```
37
+
38
+ List all of the ~200 countries in the DB.
39
+
40
+ ## Show Country
41
+
42
+ ```shell
43
+ curl "https://kabuni.com/api/v2/countries/1"
44
+ ```
45
+
46
+ ```json
47
+ {
48
+ "data": {
49
+ "id": "1",
50
+ "type": "spree_countries",
51
+ "attributes": {
52
+ "iso_name": "ANDORRA",
53
+ "iso": "AD",
54
+ "iso3": "AND",
55
+ "name": "Andorra",
56
+ "numcode": 20,
57
+ "states_required": true
58
+ },
59
+ "relationships": {
60
+ "states": {
61
+ "data": [
62
+ {
63
+ "type": "spree_states",
64
+ "id": "1"
65
+ }
66
+ ]
67
+ }
68
+ }
69
+ }
70
+ }
71
+ ```
72
+
73
+ Select a country via its `id`.
74
+
75
+ ## List States of a Country
76
+
77
+ ```shell
78
+ curl "https://kabuni.com/api/v2/countries/1/states"
79
+ ```
80
+
81
+ ```json
82
+ {
83
+ "data": [
84
+ {
85
+ "id": "1",
86
+ "type": "spree_states",
87
+ "attributes": {
88
+ "name": "Canillo",
89
+ "abbr": "02"
90
+ },
91
+ "relationships": {
92
+ "country": {
93
+ "data": {
94
+ "type": "spree_countries",
95
+ "id": "1"
96
+ }
97
+ }
98
+ }
99
+ }
100
+ ]
101
+ }
102
+ ```
103
+
104
+ See all of the states that a country owns via the country's `id`.
105
+
106
+ ## Show State of a Country
107
+
108
+ ```shell
109
+ curl "https://kabuni.com/api/v2/countries/1/states/1"
110
+ ```
111
+
112
+ ```json
113
+ {
114
+ "data": {
115
+ "id": "1",
116
+ "type": "spree_states",
117
+ "attributes": {
118
+ "name": "Canillo",
119
+ "abbr": "02"
120
+ },
121
+ "relationships": {
122
+ "country": {
123
+ "data": {
124
+ "type": "spree_countries",
125
+ "id": "1"
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ View one of the states that a country owns via the country's `id` and the state's `id`.
@@ -0,0 +1,17 @@
1
+ # Errors
2
+
3
+ The Spree API uses the following error codes:
4
+
5
+ Error Code | Meaning
6
+ ---------- | -------
7
+ 400 | Bad Request -- Your request sucks
8
+ 401 | Unauthorized -- Your API key is wrong
9
+ 403 | Forbidden -- The kitten requested is hidden for administrators only
10
+ 404 | Not Found -- The specified kitten could not be found
11
+ 405 | Method Not Allowed -- You tried to access a kitten with an invalid method
12
+ 406 | Not Acceptable -- You requested a format that isn't json
13
+ 410 | Gone -- The kitten requested has been removed from our servers
14
+ 418 | I'm a teapot
15
+ 429 | Too Many Requests -- You're requesting too many kittens! Slow down!
16
+ 500 | Internal Server Error -- We had a problem with our server. Try again later.
17
+ 503 | Service Unavailable -- We're temporarially offline for maintanance. Please try again later.
@@ -0,0 +1,11 @@
1
+ # Filtering
2
+
3
+ ```shell
4
+ curl "https://kabuni.com/api/v2/kittens?filter[id]=1"
5
+ curl "https://kabuni.com/api/v2/kittens?filter[id]=2,3,4"
6
+ curl "https://kabuni.com/api/v2/kittens?filter[breed]=Persian,British%20Shorthair,Bengal"
7
+ ```
8
+
9
+ This project supports the [JSON API's `filter` keyword](http://jsonapi.org/format/#fetching-filtering) with only the root object, not any of its relationships yet.
10
+ You can filter any of the attributes that is inside of the data object.
11
+ Please see the example requests to the side on how you my filter a kitten object.
@@ -0,0 +1,201 @@
1
+ # Images
2
+
3
+ ## List Images
4
+
5
+ ```shell
6
+ curl "https://kabuni.com/api/v2/images"
7
+ ```
8
+
9
+ ```json
10
+ {
11
+ "data": [
12
+ {
13
+ "id": "1",
14
+ "type": "spree_images",
15
+ "attributes": {
16
+ "position": 1,
17
+ "alt": null,
18
+ "links": {
19
+ "original": "/spree/products/1/original/ror_baseball_jersey_red.png?1442035822",
20
+ "mini": "/spree/products/1/mini/ror_baseball_jersey_red.png?1442035822",
21
+ "small": "/spree/products/1/small/ror_baseball_jersey_red.png?1442035822",
22
+ "product": "/spree/products/1/product/ror_baseball_jersey_red.png?1442035822",
23
+ "large": "/spree/products/1/large/ror_baseball_jersey_red.png?1442035822"
24
+ }
25
+ },
26
+ "relationships": {
27
+ "viewable": {
28
+ "data": {
29
+ "type": "spree_variants",
30
+ "id": "1"
31
+ }
32
+ }
33
+ }
34
+ }
35
+ ]
36
+ }
37
+ ```
38
+
39
+ List all of the images stored in the database.
40
+
41
+ ## Show Image
42
+
43
+ ```shell
44
+ curl "https://kabuni.com/api/v2/images/1"
45
+ ```
46
+
47
+ ```json
48
+ {
49
+ "data": {
50
+ "id": "1",
51
+ "type": "spree_images",
52
+ "attributes": {
53
+ "position": 1,
54
+ "alt": null,
55
+ "links": {
56
+ "original": "/spree/products/1/original/ror_baseball_jersey_red.png?1442035822",
57
+ "mini": "/spree/products/1/mini/ror_baseball_jersey_red.png?1442035822",
58
+ "small": "/spree/products/1/small/ror_baseball_jersey_red.png?1442035822",
59
+ "product": "/spree/products/1/product/ror_baseball_jersey_red.png?1442035822",
60
+ "large": "/spree/products/1/large/ror_baseball_jersey_red.png?1442035822"
61
+ }
62
+ },
63
+ "relationships": {
64
+ "viewable": {
65
+ "data": {
66
+ "type": "spree_variants",
67
+ "id": "1"
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
73
+ ```
74
+
75
+ Fetch an image and its links via the image's `id`.
76
+
77
+ ## Show Variant of an Image
78
+
79
+ ```shell
80
+ curl "https://kabuni.com/api/v2/images/1/variant"
81
+ ```
82
+
83
+ ```json
84
+ {
85
+ "data": {
86
+ "id": "17",
87
+ "type": "spree_variants",
88
+ "attributes": {
89
+ "sku": "ROR-00001",
90
+ "weight": "0.0",
91
+ "height": null,
92
+ "width": null,
93
+ "depth": null,
94
+ "is_master": false,
95
+ "position": 2,
96
+ "name": "Ruby on Rails Baseball Jersey",
97
+ "price": null,
98
+ "display_price": "$0.00 CAD"
99
+ },
100
+ "relationships": {
101
+ "prices": {
102
+ "data": [
103
+ {
104
+ "type": "spree_prices",
105
+ "id": "33"
106
+ }
107
+ ]
108
+ },
109
+ "option_values": {
110
+ "data": [
111
+ {
112
+ "type": "spree_option_values",
113
+ "id": "1"
114
+ }
115
+ ]
116
+ },
117
+ "images": {
118
+ "data": [
119
+ {
120
+ "type": "spree_images",
121
+ "id": "1"
122
+ }
123
+ ]
124
+ },
125
+ "product": {
126
+ "data": {
127
+ "type": "spree_products",
128
+ "id": "3"
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
136
+ Fetch the variant that an image belongs to via the variant's `id`.
137
+
138
+ ## Show Product of an Image
139
+
140
+ ```shell
141
+ curl "https://kabuni.com/api/v2/images/1/product"
142
+ ```
143
+
144
+ ```json
145
+ {
146
+ "data": {
147
+ "id": "3",
148
+ "type": "spree_products",
149
+ "attributes": {
150
+ "name": "Ruby on Rails Baseball Jersey",
151
+ "description": "Dolorem molestias sint maxime id at rem qui exercitationem. Neque voluptas corrupti magni suscipit iusto voluptatum. Ea quibusdam dolorem inventore praesentium sed dicta eveniet et. Rerum inventore laudantium quisquam earum consequatur dignissimos.",
152
+ "slug": "ruby-on-rails-baseball-jersey",
153
+ "meta_description": null,
154
+ "meta_keywords": null,
155
+ "store_name": "Whole New Home"
156
+ },
157
+ "relationships": {
158
+ "master": {
159
+ "data": {
160
+ "type": "spree_variants",
161
+ "id": "3"
162
+ }
163
+ },
164
+ "variants": {
165
+ "data": [
166
+ {
167
+ "type": "spree_variants",
168
+ "id": "1"
169
+ }
170
+ ]
171
+ },
172
+ "taxons": {
173
+ "data": [
174
+ {
175
+ "type": "spree_taxons",
176
+ "id": "53"
177
+ }
178
+ ]
179
+ },
180
+ "option_types": {
181
+ "data": [
182
+ {
183
+ "type": "spree_option_types",
184
+ "id": "1"
185
+ }
186
+ ]
187
+ },
188
+ "images": {
189
+ "data": [
190
+ {
191
+ "type": "spree_images",
192
+ "id": "24"
193
+ }
194
+ ]
195
+ }
196
+ }
197
+ }
198
+ }
199
+ ```
200
+
201
+ Find the product that image belongs to via the image's `id`.
@@ -0,0 +1,137 @@
1
+ # Line Items
2
+
3
+ ## Create Line Item
4
+
5
+ ```shell
6
+ curl "https://kabuni.com/api/v2/line_items"
7
+ -X POST
8
+ -d token=abc123
9
+ -d line_item[order_id]=1
10
+ -d line_item[variant_id]=1
11
+ -d line_item[quantity]=1
12
+ ```
13
+
14
+ ```json
15
+ {
16
+ "data" : {
17
+ "attributes" : {
18
+ "additional_tax_total" : 0,
19
+ "adjustment_total" : 0.0,
20
+ "amount" : "10.0",
21
+ "cost_price" : "17.0",
22
+ "currency" : "CAD",
23
+ "display_amount" : "$10.00 CAD",
24
+ "display_price" : "$10.00 CAD",
25
+ "display_total" : "$10.00 CAD",
26
+ "order_id" : 1,
27
+ "price" : "10.0",
28
+ "quantity" : 1,
29
+ "total" : "10.0",
30
+ "variant_id" : 1
31
+ },
32
+ "relationships" : {
33
+ "order" : {
34
+ "data" : {
35
+ "type" : "spree_orders"
36
+ }
37
+ },
38
+ "variant" : {
39
+ "data" : {
40
+ "type" : "spree_variants"
41
+ }
42
+ }
43
+ },
44
+ "type" : "spree_line_items"
45
+ }
46
+ }
47
+ ```
48
+
49
+ This endpoint allows you add a variant to a users order by creating a line item.
50
+
51
+ ### When Out of Range
52
+
53
+ > Quantity is out of range.
54
+
55
+ ```shell
56
+ curl "https://kabuni.com/api/v2/line_items"
57
+ -X POST
58
+ -d token=abc123
59
+ -d line_item[order_id]=1
60
+ -d line_item[variant_id]=1
61
+ -d line_item[quantity]=100000000000
62
+ ```
63
+
64
+ ```json
65
+ {
66
+ "errors" : [
67
+ {
68
+ "detail" : "Quantity is too High",
69
+ "meta" : {},
70
+ "title" : "The quantity that you have submitted is astronomically high, please tone it down a bit."
71
+ }
72
+ ]
73
+ }
74
+ ```
75
+
76
+ When requesting an insanely large amount of variants to be added to your order, this will result in an error.
77
+
78
+ ### When a Variant or an Order Could Not be Found
79
+
80
+ > Order could not be found.
81
+
82
+ ```shell
83
+ curl "https://kabuni.com/api/v2/line_items"
84
+ -X POST
85
+ -d token=abc123
86
+ -d line_item[order_id]=0
87
+ -d line_item[variant_id]=1
88
+ -d line_item[quantity]=1
89
+ ```
90
+
91
+ ```json
92
+ {
93
+ "errors" : [
94
+ {
95
+ "detail" : "Record Not Found",
96
+ "meta" : {},
97
+ "title" : "One of the records that you were looking for could not be found. Please check to see if the record exists or if you're permitted to read it"
98
+ }
99
+ ]
100
+ }
101
+ ```
102
+
103
+ Sometimes, you'll submit a bad variant id or order id.
104
+ When this happens, you'll receive an error because of it.
105
+
106
+ ### When the Product is Out of Stock
107
+
108
+ > Product is out of stock.
109
+
110
+ ```shell
111
+ curl "https://kabuni.com/api/v2/line_items"
112
+ -X POST
113
+ -d token=abc123
114
+ -d line_item[order_id]=1
115
+ -d line_item[variant_id]=1
116
+ -d line_item[quantity]=1
117
+ ```
118
+
119
+ ```json
120
+ {
121
+ "errors" : [
122
+ {
123
+ "detail" : "Product is out of Stock",
124
+ "meta" : {},
125
+ "title" : "This product is out of stock for the selected quantity."
126
+ }
127
+ ]
128
+ }
129
+ ```
130
+
131
+ Sometimes, there's just not going to be any left in stock.
132
+ This can happen for both two reasons:
133
+
134
+ 1. The variant is tracking inventory and its stock items `count_on_hand`s have all reached 0.
135
+ 2. The variant is not backorderable.
136
+
137
+ If both of these conditions are met, then you will reveice an out of stock error.