solidus_json_api 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +2 -0
  4. data/CHANGELOG.md +224 -0
  5. data/Gemfile +6 -0
  6. data/LICENSE +26 -0
  7. data/README.md +94 -0
  8. data/Rakefile +38 -0
  9. data/app/controllers/concerns/spree/api/v2/renderable.rb +63 -0
  10. data/app/controllers/spree/api/v2/base_controller.rb +9 -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 +21 -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/line_item_decorator.rb +3 -0
  27. data/app/models/spree/order_decorator.rb +3 -0
  28. data/app/models/spree/price_decorator.rb +3 -0
  29. data/app/models/spree/state_decorator.rb +3 -0
  30. data/app/serializers/spree/address_serializer.rb +9 -0
  31. data/app/serializers/spree/base_serializer.rb +13 -0
  32. data/app/serializers/spree/country_serializer.rb +7 -0
  33. data/app/serializers/spree/error_serializer.rb +55 -0
  34. data/app/serializers/spree/image_serializer.rb +13 -0
  35. data/app/serializers/spree/line_item_serializer.rb +13 -0
  36. data/app/serializers/spree/option_type_serializer.rb +8 -0
  37. data/app/serializers/spree/option_value_serializer.rb +8 -0
  38. data/app/serializers/spree/order_serializer.rb +20 -0
  39. data/app/serializers/spree/price_serializer.rb +7 -0
  40. data/app/serializers/spree/product_serializer.rb +12 -0
  41. data/app/serializers/spree/role_serializer.rb +5 -0
  42. data/app/serializers/spree/state_serializer.rb +7 -0
  43. data/app/serializers/spree/store_serializer.rb +6 -0
  44. data/app/serializers/spree/taxon_serializer.rb +16 -0
  45. data/app/serializers/spree/taxonomy_serializer.rb +7 -0
  46. data/app/serializers/spree/user_serializer.rb +5 -0
  47. data/app/serializers/spree/variant_serializer.rb +12 -0
  48. data/circle.yml +12 -0
  49. data/config/locales/en.yml +25 -0
  50. data/config/routes.rb +53 -0
  51. data/docs/.nojekyll +0 -0
  52. data/docs/Dockerfile +12 -0
  53. data/docs/Gemfile +14 -0
  54. data/docs/README.md +12 -0
  55. data/docs/Rakefile +9 -0
  56. data/docs/config.rb +39 -0
  57. data/docs/font-selection.json +148 -0
  58. data/docs/source/CNAME +1 -0
  59. data/docs/source/fonts/slate.eot +0 -0
  60. data/docs/source/fonts/slate.svg +14 -0
  61. data/docs/source/fonts/slate.ttf +0 -0
  62. data/docs/source/fonts/slate.woff +0 -0
  63. data/docs/source/fonts/slate.woff2 +0 -0
  64. data/docs/source/images/favicon.ico +0 -0
  65. data/docs/source/images/navbar.png +0 -0
  66. data/docs/source/includes/_countries.md +133 -0
  67. data/docs/source/includes/_errors.md +17 -0
  68. data/docs/source/includes/_filtering.md +11 -0
  69. data/docs/source/includes/_images.md +201 -0
  70. data/docs/source/includes/_line_items.md +143 -0
  71. data/docs/source/includes/_option_types.md +267 -0
  72. data/docs/source/includes/_option_values.md +227 -0
  73. data/docs/source/includes/_orders.md +150 -0
  74. data/docs/source/includes/_pagination.md +10 -0
  75. data/docs/source/includes/_prices.md +188 -0
  76. data/docs/source/includes/_products.md +407 -0
  77. data/docs/source/includes/_states.md +96 -0
  78. data/docs/source/includes/_taxonomies.md +325 -0
  79. data/docs/source/includes/_taxons.md +414 -0
  80. data/docs/source/includes/_variants.md +430 -0
  81. data/docs/source/index.md +51 -0
  82. data/docs/source/javascripts/all.js +4 -0
  83. data/docs/source/javascripts/all_nosearch.js +3 -0
  84. data/docs/source/javascripts/app/_lang.js +162 -0
  85. data/docs/source/javascripts/app/_search.js +74 -0
  86. data/docs/source/javascripts/app/_toc.js +55 -0
  87. data/docs/source/javascripts/lib/_energize.js +169 -0
  88. data/docs/source/javascripts/lib/_imagesloaded.min.js +7 -0
  89. data/docs/source/javascripts/lib/_jquery.highlight.js +108 -0
  90. data/docs/source/javascripts/lib/_jquery.tocify.js +1042 -0
  91. data/docs/source/javascripts/lib/_jquery_ui.js +566 -0
  92. data/docs/source/javascripts/lib/_lunr.js +1910 -0
  93. data/docs/source/layouts/layout.erb +110 -0
  94. data/docs/source/stylesheets/_icon-font.scss +38 -0
  95. data/docs/source/stylesheets/_normalize.css +427 -0
  96. data/docs/source/stylesheets/_syntax.scss.erb +27 -0
  97. data/docs/source/stylesheets/_variables.scss +109 -0
  98. data/docs/source/stylesheets/print.css.scss +142 -0
  99. data/docs/source/stylesheets/screen.css.scss +622 -0
  100. data/lib/solidus_json_api/config.rb +8 -0
  101. data/lib/solidus_json_api/engine.rb +21 -0
  102. data/lib/solidus_json_api.rb +5 -0
  103. data/solidus_json_api.gemspec +36 -0
  104. data/spec/controllers/spree/api/v2/base_controller_spec.rb +46 -0
  105. data/spec/controllers/spree/api/v2/children_controller_spec.rb +28 -0
  106. data/spec/controllers/spree/api/v2/countries_controller_spec.rb +25 -0
  107. data/spec/controllers/spree/api/v2/images_controller_spec.rb +91 -0
  108. data/spec/controllers/spree/api/v2/line_items_controller_spec.rb +101 -0
  109. data/spec/controllers/spree/api/v2/option_types_controller_spec.rb +71 -0
  110. data/spec/controllers/spree/api/v2/option_values_controller_spec.rb +88 -0
  111. data/spec/controllers/spree/api/v2/orders_controller_spec.rb +61 -0
  112. data/spec/controllers/spree/api/v2/prices_controller_spec.rb +55 -0
  113. data/spec/controllers/spree/api/v2/products_controller_spec.rb +99 -0
  114. data/spec/controllers/spree/api/v2/states_controller_spec.rb +42 -0
  115. data/spec/controllers/spree/api/v2/taxonomies_controller_spec.rb +31 -0
  116. data/spec/controllers/spree/api/v2/taxons_controller_spec.rb +54 -0
  117. data/spec/controllers/spree/api/v2/variants_controller_spec.rb +106 -0
  118. data/spec/lib/solidus_json_api/config_spec.rb +10 -0
  119. data/spec/models/spree/base_decorator_spec.rb +9 -0
  120. data/spec/models/spree/price_decorator_spec.rb +3 -0
  121. data/spec/serializers/spree/address_serializer_spec.rb +35 -0
  122. data/spec/serializers/spree/country_serializer_spec.rb +27 -0
  123. data/spec/serializers/spree/error_serializer_spec.rb +141 -0
  124. data/spec/serializers/spree/image_serializer_spec.rb +30 -0
  125. data/spec/serializers/spree/line_item_serializer_spec.rb +40 -0
  126. data/spec/serializers/spree/option_type_serializer_spec.rb +27 -0
  127. data/spec/serializers/spree/option_value_serializer_spec.rb +29 -0
  128. data/spec/serializers/spree/order_serializer_spec.rb +68 -0
  129. data/spec/serializers/spree/price_serializer_spec.rb +28 -0
  130. data/spec/serializers/spree/product_serializer_spec.rb +47 -0
  131. data/spec/serializers/spree/role_serializer_spec.rb +17 -0
  132. data/spec/serializers/spree/state_serializer_spec.rb +25 -0
  133. data/spec/serializers/spree/store_serializer_spec.rb +25 -0
  134. data/spec/serializers/spree/taxon_serializer_spec.rb +44 -0
  135. data/spec/serializers/spree/taxonomy_serializer_spec.rb +27 -0
  136. data/spec/serializers/spree/user_serializer_spec.rb +17 -0
  137. data/spec/serializers/spree/variant_serializer_spec.rb +55 -0
  138. data/spec/spec_helper.rb +57 -0
  139. data/spec/support/shoulda_matchers.rb +6 -0
  140. metadata +442 -0
@@ -0,0 +1,150 @@
1
+ # Orders
2
+
3
+ ## List Orders
4
+
5
+ ```shell
6
+ curl "https://example.com/api/v2/orders"
7
+ -d token=abc123
8
+ ```
9
+
10
+ ```json
11
+ {
12
+ "data" : [
13
+ {
14
+ "attributes" : {
15
+ "additional_tax_total" : "0.0",
16
+ "adjustment_total" : "0.0",
17
+ "approved_at" : null,
18
+ "canceled_at" : null,
19
+ "channel" : "spree",
20
+ "completed_at" : "2015-09-08T04:04:01.162Z",
21
+ "confirmation_delivered" : false,
22
+ "currency" : "CAD",
23
+ "display_additional_tax_total" : "$0.00 CAD",
24
+ "display_adjustment_total" : "$0.00 CAD",
25
+ "display_included_tax_total" : "$0.00 CAD",
26
+ "display_item_total" : "$10.00 CAD",
27
+ "display_promo_total" : "$0.00 CAD",
28
+ "display_shipment_total" : "$100.00 CAD",
29
+ "display_total" : "$110.00 CAD",
30
+ "email" : "spree@example.com",
31
+ "included_tax_total" : "0.0",
32
+ "item_count" : 0,
33
+ "item_total" : "10.0",
34
+ "number" : "#R123456789",
35
+ "payment_state" : null,
36
+ "payment_total" : "0.0",
37
+ "promo_total" : "0.0",
38
+ "shipment_state" : null,
39
+ "shipment_total" : "100.0",
40
+ "special_instructions" : null,
41
+ "state" : "complete",
42
+ "store_name" : "Example Store",
43
+ "total" : "110.0"
44
+ },
45
+ "relationships" : {
46
+ "bill_address" : {
47
+ "data" : {
48
+ "type" : "spree_addresses"
49
+ }
50
+ },
51
+ "line_items" : {
52
+ "data" : [
53
+ {
54
+ "type" : "spree_line_items"
55
+ }
56
+ ]
57
+ },
58
+ "ship_address" : {
59
+ "data" : {
60
+ "type" : "spree_addresses"
61
+ }
62
+ },
63
+ "user" : {
64
+ "data" : {
65
+ "type" : "spree_users"
66
+ }
67
+ }
68
+ },
69
+ "type" : "spree_orders"
70
+ }
71
+ ]
72
+ }
73
+ ```
74
+
75
+ List all of the orders in the DB if you're an admin.
76
+ If you're a standard user, then only the orders that you own are listed.
77
+
78
+ ## Show Order
79
+
80
+ ```shell
81
+ curl "https://example.com/api/v2/orders/:id"
82
+ -d token=abc123
83
+ ```
84
+
85
+ ```json
86
+ {
87
+ "data" : {
88
+ "attributes" : {
89
+ "additional_tax_total" : "0.0",
90
+ "adjustment_total" : "0.0",
91
+ "approved_at" : null,
92
+ "canceled_at" : null,
93
+ "channel" : "spree",
94
+ "completed_at" : "2015-09-08T04:04:01.162Z",
95
+ "confirmation_delivered" : false,
96
+ "currency" : "CAD",
97
+ "display_additional_tax_total" : "$0.00 CAD",
98
+ "display_adjustment_total" : "$0.00 CAD",
99
+ "display_included_tax_total" : "$0.00 CAD",
100
+ "display_item_total" : "$10.00 CAD",
101
+ "display_promo_total" : "$0.00 CAD",
102
+ "display_shipment_total" : "$100.00 CAD",
103
+ "display_total" : "$110.00 CAD",
104
+ "email" : "spree@example.com",
105
+ "included_tax_total" : "0.0",
106
+ "item_count" : 0,
107
+ "item_total" : "10.0",
108
+ "number" : "#R123456789",
109
+ "payment_state" : null,
110
+ "payment_total" : "0.0",
111
+ "promo_total" : "0.0",
112
+ "shipment_state" : null,
113
+ "shipment_total" : "100.0",
114
+ "special_instructions" : null,
115
+ "state" : "complete",
116
+ "store_name" : "Example Store",
117
+ "total" : "110.0"
118
+ },
119
+ "relationships" : {
120
+ "bill_address" : {
121
+ "data" : {
122
+ "type" : "spree_addresses"
123
+ }
124
+ },
125
+ "line_items" : {
126
+ "data" : [
127
+ {
128
+ "type" : "spree_line_items"
129
+ }
130
+ ]
131
+ },
132
+ "ship_address" : {
133
+ "data" : {
134
+ "type" : "spree_addresses"
135
+ }
136
+ },
137
+ "user" : {
138
+ "data" : {
139
+ "type" : "spree_users"
140
+ }
141
+ }
142
+ },
143
+ "type" : "spree_orders"
144
+ }
145
+ }
146
+ ```
147
+
148
+ This will get an order via the id supplied.
149
+ Please note that you can ony access the orders that you own.
150
+ If you are an admin, you can view any order.
@@ -0,0 +1,10 @@
1
+ # Pagination
2
+
3
+ ```shell
4
+ curl "https://example.com/api/v2/kitten?page[number]2&page[size]=20"
5
+ ```
6
+
7
+ This projects supports the [JSON API's `page` keyword](http://jsonapi.org/format/#fetching-pagination).
8
+ To specify the page number, set a `page[number]` value.
9
+ To specify the page size (the amount of records returned), set a `page[size]` value; the default is 24.
10
+ If you would like the links to the `self`, `next`, `prev`, `first`, and `last` it is not yet supported.
@@ -0,0 +1,188 @@
1
+ # Prices
2
+
3
+ ## List Prices
4
+
5
+ ```shell
6
+ curl "https://example.com/api/v2/prices"
7
+ ```
8
+
9
+ ```json
10
+ {
11
+ "data": [
12
+ {
13
+ "id": "1",
14
+ "type": "spree_prices",
15
+ "attributes": {
16
+ "amount": "15.99",
17
+ "price": "15.99",
18
+ "display_amount": "$15.99 CAD",
19
+ "display_price": "$15.99 CAD",
20
+ "currency": "CAD"
21
+ },
22
+ "relationships": {
23
+ "variant": {
24
+ "data": {
25
+ "type": "spree_variants",
26
+ "id": "1"
27
+ }
28
+ }
29
+ }
30
+ }
31
+ ]
32
+ }
33
+ ```
34
+
35
+ List all of the prices in the database.
36
+
37
+ ## Show Price
38
+
39
+ ```shell
40
+ curl "https://example.com/api/v2/prices/1"
41
+ ```
42
+
43
+ ```json
44
+ {
45
+ "data": {
46
+ "id": "1",
47
+ "type": "spree_prices",
48
+ "attributes": {
49
+ "amount": "15.99",
50
+ "price": "15.99",
51
+ "display_amount": "$15.99 CAD",
52
+ "display_price": "$15.99 CAD",
53
+ "currency": "CAD"
54
+ },
55
+ "relationships": {
56
+ "variant": {
57
+ "data": {
58
+ "type": "spree_variants",
59
+ "id": "1"
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ Fetch a price via its `id`.
68
+
69
+ ## Show Variant of a Price
70
+
71
+ ```shell
72
+ curl "https://example.com/api/v2/prices/1/variant"
73
+ ```
74
+
75
+ ```json
76
+ {
77
+ "data": {
78
+ "id": "1",
79
+ "type": "spree_variants",
80
+ "attributes": {
81
+ "sku": "ROR-00011",
82
+ "weight": "0.0",
83
+ "height": "1.0",
84
+ "width": "3.0",
85
+ "depth": "2.0",
86
+ "is_master": true,
87
+ "position": 1,
88
+ "name": "Ruby on Rails Tote",
89
+ "price": "15.99",
90
+ "display_price" : "$15.99 CAD"
91
+ },
92
+ "relationships": {
93
+ "prices": {
94
+ "data": [
95
+ {
96
+ "type": "spree_prices",
97
+ "id": "1"
98
+ }
99
+ ]
100
+ },
101
+ "option_values": {
102
+ "data": [
103
+ {
104
+ "type": "spree_option_values",
105
+ "id": "1"
106
+ }
107
+ ]
108
+ },
109
+ "images": {
110
+ "data": [
111
+ {
112
+ "type": "spree_images",
113
+ "id": "1"
114
+ }
115
+ ]
116
+ },
117
+ "product": {
118
+ "data": {
119
+ "type": "spree_products",
120
+ "id": "1"
121
+ }
122
+ }
123
+ }
124
+ }
125
+ }
126
+ ```
127
+
128
+ Fetch the variant a price belongs to via the price's `id`.
129
+
130
+ ## Show Product of a Price
131
+
132
+ ```shell
133
+ curl "https://example.com/api/v2/prices/1/product"
134
+ ```
135
+
136
+ ```json
137
+ {
138
+ "data": {
139
+ "id": "1",
140
+ "type": "spree_products",
141
+ "attributes": {
142
+ "name": "Ruby on Rails Tote",
143
+ "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.",
144
+ "slug": "ruby-on-rails-tote",
145
+ "meta_description": null,
146
+ "meta_keywords": null,
147
+ "store_name": "Whole New Home"
148
+ },
149
+ "relationships": {
150
+ "master": {
151
+ "data": {
152
+ "type": "spree_variants",
153
+ "id": "1"
154
+ }
155
+ },
156
+ "variants": {
157
+ "data": []
158
+ },
159
+ "taxons": {
160
+ "data": [
161
+ {
162
+ "type": "spree_taxons",
163
+ "id": "18"
164
+ }
165
+ ]
166
+ },
167
+ "option_types": {
168
+ "data": [
169
+ {
170
+ "type": "spree_option_types",
171
+ "id": "1"
172
+ }
173
+ ]
174
+ },
175
+ "images": {
176
+ "data": [
177
+ {
178
+ "type": "spree_images",
179
+ "id": "1"
180
+ }
181
+ ]
182
+ }
183
+ }
184
+ }
185
+ }
186
+ ```
187
+
188
+ Fetch the product a price belongs to via the price's `id`.