solidus_api 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_api might be problematic. Click here for more details.

Files changed (202) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/CHANGELOG.md +1 -0
  4. data/Gemfile +5 -0
  5. data/LICENSE +27 -0
  6. data/Rakefile +16 -0
  7. data/app/controllers/spree/api/addresses_controller.rb +43 -0
  8. data/app/controllers/spree/api/base_controller.rb +189 -0
  9. data/app/controllers/spree/api/checkouts_controller.rb +133 -0
  10. data/app/controllers/spree/api/classifications_controller.rb +18 -0
  11. data/app/controllers/spree/api/config_controller.rb +6 -0
  12. data/app/controllers/spree/api/countries_controller.rb +23 -0
  13. data/app/controllers/spree/api/credit_cards_controller.rb +25 -0
  14. data/app/controllers/spree/api/images_controller.rb +47 -0
  15. data/app/controllers/spree/api/inventory_units_controller.rb +52 -0
  16. data/app/controllers/spree/api/line_items_controller.rb +74 -0
  17. data/app/controllers/spree/api/option_types_controller.rb +49 -0
  18. data/app/controllers/spree/api/option_values_controller.rb +58 -0
  19. data/app/controllers/spree/api/orders_controller.rb +155 -0
  20. data/app/controllers/spree/api/payments_controller.rb +81 -0
  21. data/app/controllers/spree/api/product_properties_controller.rb +72 -0
  22. data/app/controllers/spree/api/products_controller.rb +129 -0
  23. data/app/controllers/spree/api/promotions_controller.rb +26 -0
  24. data/app/controllers/spree/api/properties_controller.rb +71 -0
  25. data/app/controllers/spree/api/return_authorizations_controller.rb +71 -0
  26. data/app/controllers/spree/api/shipments_controller.rb +172 -0
  27. data/app/controllers/spree/api/states_controller.rb +35 -0
  28. data/app/controllers/spree/api/stock_items_controller.rb +84 -0
  29. data/app/controllers/spree/api/stock_locations_controller.rb +50 -0
  30. data/app/controllers/spree/api/stock_movements_controller.rb +42 -0
  31. data/app/controllers/spree/api/stock_transfers_controller.rb +19 -0
  32. data/app/controllers/spree/api/store_credit_events_controller.rb +9 -0
  33. data/app/controllers/spree/api/stores_controller.rb +55 -0
  34. data/app/controllers/spree/api/taxonomies_controller.rb +64 -0
  35. data/app/controllers/spree/api/taxons_controller.rb +93 -0
  36. data/app/controllers/spree/api/transfer_items_controller.rb +42 -0
  37. data/app/controllers/spree/api/users_controller.rb +56 -0
  38. data/app/controllers/spree/api/variants_controller.rb +75 -0
  39. data/app/controllers/spree/api/zones_controller.rb +50 -0
  40. data/app/helpers/spree/api/api_helpers.rb +190 -0
  41. data/app/models/spree/api_configuration.rb +5 -0
  42. data/app/models/spree/option_value_decorator.rb +9 -0
  43. data/app/views/spree/api/addresses/show.v1.rabl +10 -0
  44. data/app/views/spree/api/adjustments/show.v1.rabl +4 -0
  45. data/app/views/spree/api/config/money.v1.rabl +2 -0
  46. data/app/views/spree/api/config/show.v1.rabl +2 -0
  47. data/app/views/spree/api/countries/index.v1.rabl +7 -0
  48. data/app/views/spree/api/countries/show.v1.rabl +5 -0
  49. data/app/views/spree/api/credit_cards/index.v1.rabl +7 -0
  50. data/app/views/spree/api/credit_cards/show.v1.rabl +3 -0
  51. data/app/views/spree/api/errors/gateway_error.v1.rabl +2 -0
  52. data/app/views/spree/api/errors/invalid_api_key.v1.rabl +2 -0
  53. data/app/views/spree/api/errors/invalid_resource.v1.rabl +3 -0
  54. data/app/views/spree/api/errors/must_specify_api_key.v1.rabl +2 -0
  55. data/app/views/spree/api/errors/not_found.v1.rabl +2 -0
  56. data/app/views/spree/api/errors/unauthorized.v1.rabl +2 -0
  57. data/app/views/spree/api/errors/variant_not_in_stock_transfer.v1.rabl +2 -0
  58. data/app/views/spree/api/images/index.v1.rabl +4 -0
  59. data/app/views/spree/api/images/show.v1.rabl +6 -0
  60. data/app/views/spree/api/inventory_units/show.rabl +2 -0
  61. data/app/views/spree/api/line_items/new.v1.rabl +3 -0
  62. data/app/views/spree/api/line_items/show.v1.rabl +15 -0
  63. data/app/views/spree/api/option_types/index.v1.rabl +3 -0
  64. data/app/views/spree/api/option_types/show.v1.rabl +5 -0
  65. data/app/views/spree/api/option_values/index.v1.rabl +3 -0
  66. data/app/views/spree/api/option_values/show.v1.rabl +2 -0
  67. data/app/views/spree/api/orders/address.v1.rabl +0 -0
  68. data/app/views/spree/api/orders/canceled.v1.rabl +0 -0
  69. data/app/views/spree/api/orders/cart.v1.rabl +0 -0
  70. data/app/views/spree/api/orders/complete.v1.rabl +0 -0
  71. data/app/views/spree/api/orders/could_not_apply_coupon.v1.rabl +2 -0
  72. data/app/views/spree/api/orders/could_not_transition.v1.rabl +3 -0
  73. data/app/views/spree/api/orders/expected_total_mismatch.v1.rabl +2 -0
  74. data/app/views/spree/api/orders/index.v1.rabl +7 -0
  75. data/app/views/spree/api/orders/invalid_shipping_method.v1.rabl +2 -0
  76. data/app/views/spree/api/orders/mine.v1.rabl +9 -0
  77. data/app/views/spree/api/orders/order.v1.rabl +9 -0
  78. data/app/views/spree/api/orders/payment.v1.rabl +3 -0
  79. data/app/views/spree/api/orders/show.v1.rabl +52 -0
  80. data/app/views/spree/api/payments/credit_over_limit.v1.rabl +2 -0
  81. data/app/views/spree/api/payments/index.v1.rabl +7 -0
  82. data/app/views/spree/api/payments/new.v1.rabl +5 -0
  83. data/app/views/spree/api/payments/show.v1.rabl +2 -0
  84. data/app/views/spree/api/payments/update_forbidden.v1.rabl +2 -0
  85. data/app/views/spree/api/product_properties/index.v1.rabl +7 -0
  86. data/app/views/spree/api/product_properties/new.v1.rabl +2 -0
  87. data/app/views/spree/api/product_properties/show.v1.rabl +2 -0
  88. data/app/views/spree/api/products/index.v1.rabl +9 -0
  89. data/app/views/spree/api/products/new.v1.rabl +3 -0
  90. data/app/views/spree/api/products/product.v1.rabl +1 -0
  91. data/app/views/spree/api/products/show.v1.rabl +31 -0
  92. data/app/views/spree/api/promotions/handler.v1.rabl +5 -0
  93. data/app/views/spree/api/promotions/show.v1.rabl +2 -0
  94. data/app/views/spree/api/properties/index.v1.rabl +7 -0
  95. data/app/views/spree/api/properties/new.v1.rabl +2 -0
  96. data/app/views/spree/api/properties/show.v1.rabl +2 -0
  97. data/app/views/spree/api/return_authorizations/index.v1.rabl +7 -0
  98. data/app/views/spree/api/return_authorizations/new.v1.rabl +3 -0
  99. data/app/views/spree/api/return_authorizations/show.v1.rabl +2 -0
  100. data/app/views/spree/api/shared/stock_location_required.v1.rabl +2 -0
  101. data/app/views/spree/api/shipments/big.v1.rabl +48 -0
  102. data/app/views/spree/api/shipments/cannot_ready_shipment.v1.rabl +2 -0
  103. data/app/views/spree/api/shipments/mine.v1.rabl +9 -0
  104. data/app/views/spree/api/shipments/show.v1.rabl +32 -0
  105. data/app/views/spree/api/shipments/small.v1.rabl +37 -0
  106. data/app/views/spree/api/shipping_rates/show.v1.rabl +2 -0
  107. data/app/views/spree/api/states/index.v1.rabl +14 -0
  108. data/app/views/spree/api/states/show.v1.rabl +2 -0
  109. data/app/views/spree/api/stock_items/index.v1.rabl +7 -0
  110. data/app/views/spree/api/stock_items/show.v1.rabl +5 -0
  111. data/app/views/spree/api/stock_locations/index.v1.rabl +7 -0
  112. data/app/views/spree/api/stock_locations/show.v1.rabl +8 -0
  113. data/app/views/spree/api/stock_movements/index.v1.rabl +7 -0
  114. data/app/views/spree/api/stock_movements/show.v1.rabl +5 -0
  115. data/app/views/spree/api/stock_transfers/receive.v1.rabl +5 -0
  116. data/app/views/spree/api/store_credit_events/mine.v1.rabl +10 -0
  117. data/app/views/spree/api/stores/index.v1.rabl +4 -0
  118. data/app/views/spree/api/stores/show.v1.rabl +2 -0
  119. data/app/views/spree/api/taxonomies/index.v1.rabl +7 -0
  120. data/app/views/spree/api/taxonomies/jstree.rabl +8 -0
  121. data/app/views/spree/api/taxonomies/nested.v1.rabl +11 -0
  122. data/app/views/spree/api/taxonomies/new.v1.rabl +3 -0
  123. data/app/views/spree/api/taxonomies/show.v1.rabl +15 -0
  124. data/app/views/spree/api/taxons/index.v1.rabl +12 -0
  125. data/app/views/spree/api/taxons/jstree.rabl +8 -0
  126. data/app/views/spree/api/taxons/new.v1.rabl +3 -0
  127. data/app/views/spree/api/taxons/show.v1.rabl +6 -0
  128. data/app/views/spree/api/taxons/taxons.v1.rabl +5 -0
  129. data/app/views/spree/api/transfer_items/show.v1.rabl +6 -0
  130. data/app/views/spree/api/users/index.v1.rabl +7 -0
  131. data/app/views/spree/api/users/new.v1.rabl +3 -0
  132. data/app/views/spree/api/users/show.v1.rabl +10 -0
  133. data/app/views/spree/api/variants/big.v1.rabl +17 -0
  134. data/app/views/spree/api/variants/index.v1.rabl +9 -0
  135. data/app/views/spree/api/variants/new.v1.rabl +2 -0
  136. data/app/views/spree/api/variants/show.v1.rabl +3 -0
  137. data/app/views/spree/api/variants/small.v1.rabl +17 -0
  138. data/app/views/spree/api/zones/index.v1.rabl +7 -0
  139. data/app/views/spree/api/zones/show.v1.rabl +6 -0
  140. data/config/initializers/metal_load_paths.rb +1 -0
  141. data/config/locales/en.yml +29 -0
  142. data/config/routes.rb +139 -0
  143. data/db/migrate/20100107141738_add_api_key_to_spree_users.rb +7 -0
  144. data/db/migrate/20120411123334_resize_api_key_field.rb +7 -0
  145. data/db/migrate/20120530054546_rename_api_key_to_spree_api_key.rb +7 -0
  146. data/db/migrate/20131017162334_add_index_to_user_spree_api_key.rb +7 -0
  147. data/lib/solidus_api.rb +1 -0
  148. data/lib/spree/api/engine.rb +38 -0
  149. data/lib/spree/api/responders/rabl_template.rb +31 -0
  150. data/lib/spree/api/responders.rb +11 -0
  151. data/lib/spree/api/testing_support/caching.rb +10 -0
  152. data/lib/spree/api/testing_support/helpers.rb +44 -0
  153. data/lib/spree/api/testing_support/setup.rb +16 -0
  154. data/lib/spree/api.rb +10 -0
  155. data/lib/spree_api.rb +3 -0
  156. data/script/rails +9 -0
  157. data/solidus_api.gemspec +21 -0
  158. data/spec/controllers/spree/api/addresses_controller_spec.rb +56 -0
  159. data/spec/controllers/spree/api/base_controller_spec.rb +164 -0
  160. data/spec/controllers/spree/api/checkouts_controller_spec.rb +386 -0
  161. data/spec/controllers/spree/api/classifications_controller_spec.rb +48 -0
  162. data/spec/controllers/spree/api/config_controller_spec.rb +23 -0
  163. data/spec/controllers/spree/api/countries_controller_spec.rb +48 -0
  164. data/spec/controllers/spree/api/credit_cards_controller_spec.rb +80 -0
  165. data/spec/controllers/spree/api/images_controller_spec.rb +93 -0
  166. data/spec/controllers/spree/api/inventory_units_controller_spec.rb +50 -0
  167. data/spec/controllers/spree/api/line_items_controller_spec.rb +186 -0
  168. data/spec/controllers/spree/api/option_types_controller_spec.rb +116 -0
  169. data/spec/controllers/spree/api/option_values_controller_spec.rb +135 -0
  170. data/spec/controllers/spree/api/orders_controller_spec.rb +759 -0
  171. data/spec/controllers/spree/api/payments_controller_spec.rb +254 -0
  172. data/spec/controllers/spree/api/product_properties_controller_spec.rb +116 -0
  173. data/spec/controllers/spree/api/products_controller_spec.rb +454 -0
  174. data/spec/controllers/spree/api/promotion_application_spec.rb +50 -0
  175. data/spec/controllers/spree/api/promotions_controller_spec.rb +64 -0
  176. data/spec/controllers/spree/api/properties_controller_spec.rb +102 -0
  177. data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +173 -0
  178. data/spec/controllers/spree/api/shipments_controller_spec.rb +252 -0
  179. data/spec/controllers/spree/api/states_controller_spec.rb +82 -0
  180. data/spec/controllers/spree/api/stock_items_controller_spec.rb +307 -0
  181. data/spec/controllers/spree/api/stock_locations_controller_spec.rb +172 -0
  182. data/spec/controllers/spree/api/stock_movements_controller_spec.rb +84 -0
  183. data/spec/controllers/spree/api/stock_transfers_controller_spec.rb +83 -0
  184. data/spec/controllers/spree/api/store_credit_events_controller_spec.rb +68 -0
  185. data/spec/controllers/spree/api/stores_controller_spec.rb +133 -0
  186. data/spec/controllers/spree/api/taxonomies_controller_spec.rb +114 -0
  187. data/spec/controllers/spree/api/taxons_controller_spec.rb +177 -0
  188. data/spec/controllers/spree/api/transfer_items_controller_spec.rb +152 -0
  189. data/spec/controllers/spree/api/unauthenticated_products_controller_spec.rb +26 -0
  190. data/spec/controllers/spree/api/users_controller_spec.rb +153 -0
  191. data/spec/controllers/spree/api/variants_controller_spec.rb +235 -0
  192. data/spec/controllers/spree/api/zones_controller_spec.rb +115 -0
  193. data/spec/features/checkout_spec.rb +187 -0
  194. data/spec/fixtures/thinking-cat.jpg +0 -0
  195. data/spec/models/spree/legacy_user_spec.rb +45 -0
  196. data/spec/requests/rabl_cache_spec.rb +32 -0
  197. data/spec/shared_examples/protect_product_actions.rb +17 -0
  198. data/spec/spec_helper.rb +60 -0
  199. data/spec/support/controller_hacks.rb +38 -0
  200. data/spec/support/database_cleaner.rb +14 -0
  201. data/spec/support/have_attributes_matcher.rb +13 -0
  202. metadata +334 -0
File without changes
@@ -0,0 +1,2 @@
1
+ object false
2
+ node(:error) { @coupon_message }
@@ -0,0 +1,3 @@
1
+ object false
2
+ node(:error) { I18n.t(:could_not_transition, scope: "spree.api.order") }
3
+ node(:errors) { @order.errors.to_hash }
@@ -0,0 +1,2 @@
1
+ object false
2
+ node(:errors) { {expected_total: [I18n.t(:expected_total_mismatch, scope: "spree.api.order")]} }
@@ -0,0 +1,7 @@
1
+ object false
2
+ child(@orders => :orders) do
3
+ extends "spree/api/orders/order"
4
+ end
5
+ node(:count) { @orders.count }
6
+ node(:current_page) { params[:page] || 1 }
7
+ node(:pages) { @orders.num_pages }
@@ -0,0 +1,2 @@
1
+ object false
2
+ node(:errors) { [I18n.t(:invalid_shipping_method, :scope => "spree.api.order")] }
@@ -0,0 +1,9 @@
1
+ object false
2
+
3
+ child(@orders => :orders) do
4
+ extends "spree/api/orders/show"
5
+ end
6
+
7
+ node(:count) { @orders.count }
8
+ node(:current_page) { params[:page] || 1 }
9
+ node(:pages) { @orders.num_pages }
@@ -0,0 +1,9 @@
1
+ cache [I18n.locale, root_object]
2
+ attributes *order_attributes
3
+ node(:display_item_total) { |o| o.display_item_total.to_s }
4
+ node(:total_quantity) { |o| o.line_items.sum(:quantity) }
5
+ node(:display_total) { |o| o.display_total.to_s }
6
+ node(:display_ship_total) { |o| o.display_ship_total }
7
+ node(:display_tax_total) { |o| o.display_tax_total }
8
+ node(:token) { |o| o.guest_token }
9
+ node(:checkout_steps) { |o| o.checkout_steps }
@@ -0,0 +1,3 @@
1
+ child :available_payment_methods => :payment_methods do
2
+ attributes :id, :name, :environment, :method_type
3
+ end
@@ -0,0 +1,52 @@
1
+ object @order
2
+ extends "spree/api/orders/order"
3
+
4
+ if lookup_context.find_all("spree/api/orders/#{root_object.state}").present?
5
+ extends "spree/api/orders/#{root_object.state}"
6
+ end
7
+
8
+ child :billing_address => :bill_address do
9
+ extends "spree/api/addresses/show"
10
+ end
11
+
12
+ child :shipping_address => :ship_address do
13
+ extends "spree/api/addresses/show"
14
+ end
15
+
16
+ child :line_items => :line_items do
17
+ extends "spree/api/line_items/show"
18
+ end
19
+
20
+ child :payments => :payments do
21
+ attributes *payment_attributes
22
+
23
+ child :payment_method => :payment_method do
24
+ attributes :id, :name, :environment
25
+ end
26
+
27
+ child :source => :source do
28
+ attributes *payment_source_attributes
29
+ if @current_user_roles.include?('admin')
30
+ attributes *(payment_source_attributes + [:gateway_customer_profile_id, :gateway_payment_profile_id])
31
+ else
32
+ attributes *payment_source_attributes
33
+ end
34
+ end
35
+ end
36
+
37
+ child :shipments => :shipments do
38
+ extends "spree/api/shipments/small"
39
+ end
40
+
41
+ child :adjustments => :adjustments do
42
+ extends "spree/api/adjustments/show"
43
+ end
44
+
45
+ # Necessary for backend's order interface
46
+ node :permissions do
47
+ { can_update: current_ability.can?(:update, root_object) }
48
+ end
49
+
50
+ child :valid_credit_cards => :credit_cards do
51
+ extends "spree/api/credit_cards/show"
52
+ end
@@ -0,0 +1,2 @@
1
+ object false
2
+ node(:error) { I18n.t(:credit_over_limit, :limit => @payment.credit_allowed, :scope => 'spree.api.payment') }
@@ -0,0 +1,7 @@
1
+ object false
2
+ child(@payments => :payments) do
3
+ attributes *payment_attributes
4
+ end
5
+ node(:count) { @payments.count }
6
+ node(:current_page) { params[:page] || 1 }
7
+ node(:pages) { @payments.num_pages }
@@ -0,0 +1,5 @@
1
+ object false
2
+ node(:attributes) { [*payment_attributes] }
3
+ child @payment_methods => :payment_methods do
4
+ attributes *payment_method_attributes
5
+ end
@@ -0,0 +1,2 @@
1
+ object @payment
2
+ attributes *payment_attributes
@@ -0,0 +1,2 @@
1
+ object false
2
+ node(:error) { I18n.t(:update_forbidden, :state => @payment.state, :scope => 'spree.api.payment') }
@@ -0,0 +1,7 @@
1
+ object false
2
+ child(@product_properties => :product_properties) do
3
+ attributes *product_property_attributes
4
+ end
5
+ node(:count) { @product_properties.count }
6
+ node(:current_page) { params[:page] || 1 }
7
+ node(:pages) { @product_properties.num_pages }
@@ -0,0 +1,2 @@
1
+ node(:attributes) { [*product_property_attributes] }
2
+ node(:required_attributes) { [] }
@@ -0,0 +1,2 @@
1
+ object @product_property
2
+ attributes *product_property_attributes
@@ -0,0 +1,9 @@
1
+ object false
2
+ node(:count) { @products.count }
3
+ node(:total_count) { @products.total_count }
4
+ node(:current_page) { params[:page] ? params[:page].to_i : 1 }
5
+ node(:per_page) { params[:per_page] || Kaminari.config.default_per_page }
6
+ node(:pages) { @products.num_pages }
7
+ child(@products => :products) do
8
+ extends "spree/api/products/show"
9
+ end
@@ -0,0 +1,3 @@
1
+ object false
2
+ node(:attributes) { [*product_attributes] }
3
+ node(:required_attributes) { required_fields_for(Spree::Product) }
@@ -0,0 +1 @@
1
+ attributes *product_attributes
@@ -0,0 +1,31 @@
1
+ object @product
2
+ cache [I18n.locale, @current_user_roles.include?('admin'), current_currency, root_object]
3
+
4
+ attributes *product_attributes
5
+
6
+ node(:display_price) { |p| p.display_price.to_s }
7
+ node(:has_variants) { |p| p.has_variants? }
8
+
9
+ child :master => :master do
10
+ extends "spree/api/variants/small"
11
+ end
12
+
13
+ child :variants => :variants do
14
+ extends "spree/api/variants/small"
15
+ end
16
+
17
+ child :option_types => :option_types do
18
+ attributes *option_type_attributes
19
+ end
20
+
21
+ child :product_properties => :product_properties do
22
+ attributes *product_property_attributes
23
+ end
24
+
25
+ child :classifications => :classifications do
26
+ attributes :taxon_id, :position
27
+
28
+ child(:taxon) do
29
+ extends "spree/api/taxons/show"
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ object false
2
+ node(:success) { @handler.success }
3
+ node(:error) { @handler.error }
4
+ node(:successful) { @handler.successful? }
5
+ node(:status_code) { @handler.status_code }
@@ -0,0 +1,2 @@
1
+ object @promotion
2
+ attributes *promotion_attributes
@@ -0,0 +1,7 @@
1
+ object false
2
+ child(@properties => :properties) do
3
+ attributes *property_attributes
4
+ end
5
+ node(:count) { @properties.count }
6
+ node(:current_page) { params[:page] || 1 }
7
+ node(:pages) { @properties.num_pages }
@@ -0,0 +1,2 @@
1
+ node(:attributes) { [*property_attributes] }
2
+ node(:required_attributes) { [] }
@@ -0,0 +1,2 @@
1
+ object @property
2
+ attributes *property_attributes
@@ -0,0 +1,7 @@
1
+ object false
2
+ child(@return_authorizations => :return_authorizations) do
3
+ attributes *return_authorization_attributes
4
+ end
5
+ node(:count) { @return_authorizations.count }
6
+ node(:current_page) { params[:page] || 1 }
7
+ node(:pages) { @return_authorizations.num_pages }
@@ -0,0 +1,3 @@
1
+ object false
2
+ node(:attributes) { [*return_authorization_attributes] }
3
+ node(:required_attributes) { required_fields_for(Spree::ReturnAuthorization) }
@@ -0,0 +1,2 @@
1
+ object @return_authorization
2
+ attributes *return_authorization_attributes
@@ -0,0 +1,2 @@
1
+ object false
2
+ node(:error) { I18n.t(:stock_location_required, scope: "spree.api") }
@@ -0,0 +1,48 @@
1
+ object @shipment
2
+ cache @shipment
3
+ attributes *shipment_attributes
4
+
5
+ child selected_shipping_rate: :selected_shipping_rate do
6
+ extends "spree/api/shipping_rates/show"
7
+ end
8
+
9
+ child inventory_units: :inventory_units do
10
+ object @inventory_unit
11
+ attributes *inventory_unit_attributes
12
+
13
+ child :variant do
14
+ extends "spree/api/variants/small"
15
+ attributes :product_id
16
+ child(images: :images) { extends "spree/api/images/show" }
17
+ end
18
+
19
+ child :line_item do
20
+ attributes *line_item_attributes
21
+ node(:single_display_amount) { |li| li.single_display_amount.to_s }
22
+ node(:display_amount) { |li| li.display_amount.to_s }
23
+ node(:total) { |li| li.total }
24
+ end
25
+ end
26
+
27
+ child order: :order do
28
+ extends "spree/api/orders/order"
29
+
30
+ child billing_address: :bill_address do
31
+ extends "spree/api/addresses/show"
32
+ end
33
+
34
+ child shipping_address: :ship_address do
35
+ extends "spree/api/addresses/show"
36
+ end
37
+
38
+ child adjustments: :adjustments do
39
+ extends "spree/api/adjustments/show"
40
+ end
41
+
42
+ child payments: :payments do
43
+ attributes :id, :amount, :display_amount, :state
44
+ child payment_method: :payment_method do
45
+ attributes :id, :name
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,2 @@
1
+ object false
2
+ node(:error) { I18n.t(:cannot_ready, :scope => "spree.api.shipment") }
@@ -0,0 +1,9 @@
1
+ object false
2
+
3
+ node(:count) { @shipments.count }
4
+ node(:current_page) { params[:page] || 1 }
5
+ node(:pages) { @shipments.num_pages }
6
+
7
+ child(@shipments => :shipments) do
8
+ extends "spree/api/shipments/big"
9
+ end
@@ -0,0 +1,32 @@
1
+ object @shipment
2
+ cache [I18n.locale, root_object]
3
+ attributes *shipment_attributes
4
+ node(:order_id) { |shipment| shipment.order.number }
5
+ node(:stock_location_name) { |shipment| shipment.stock_location.name }
6
+
7
+ child :shipping_rates => :shipping_rates do
8
+ extends "spree/api/shipping_rates/show"
9
+ end
10
+
11
+ child :selected_shipping_rate => :selected_shipping_rate do
12
+ extends "spree/api/shipping_rates/show"
13
+ end
14
+
15
+ child :shipping_methods => :shipping_methods do
16
+ attributes :id, :name
17
+ child :zones => :zones do
18
+ attributes :id, :name, :description
19
+ end
20
+
21
+ child :shipping_categories => :shipping_categories do
22
+ attributes :id, :name
23
+ end
24
+ end
25
+
26
+ child :manifest => :manifest do
27
+ child :variant => :variant do
28
+ extends "spree/api/variants/small"
29
+ end
30
+ node(:quantity) { |m| m.quantity }
31
+ node(:states) { |m| m.states }
32
+ end
@@ -0,0 +1,37 @@
1
+ object @shipment
2
+ cache [I18n.locale, 'small_shipment', root_object]
3
+
4
+ attributes *shipment_attributes
5
+ node(:order_id) { |shipment| shipment.order.number }
6
+ node(:stock_location_name) { |shipment| shipment.stock_location.name }
7
+
8
+ child :shipping_rates => :shipping_rates do
9
+ extends "spree/api/shipping_rates/show"
10
+ end
11
+
12
+ child :selected_shipping_rate => :selected_shipping_rate do
13
+ extends "spree/api/shipping_rates/show"
14
+ end
15
+
16
+ child :shipping_methods => :shipping_methods do
17
+ attributes :id, :code, :name
18
+ child :zones => :zones do
19
+ attributes :id, :name, :description
20
+ end
21
+
22
+ child :shipping_categories => :shipping_categories do
23
+ attributes :id, :name
24
+ end
25
+ end
26
+
27
+ child :manifest => :manifest do
28
+ glue(:variant) do
29
+ attribute :id => :variant_id
30
+ end
31
+ node(:quantity) { |m| m.quantity }
32
+ node(:states) { |m| m.states }
33
+ end
34
+
35
+ child :adjustments => :adjustments do
36
+ extends "spree/api/adjustments/show"
37
+ end
@@ -0,0 +1,2 @@
1
+ attributes :id, :name, :cost, :selected, :shipping_method_id, :shipping_method_code
2
+ node(:display_cost) { |sr| sr.display_cost.to_s }
@@ -0,0 +1,14 @@
1
+ object false
2
+ if @country
3
+ node(:states_required) { @country.states_required }
4
+ end
5
+
6
+ child(@states => :states) do
7
+ attributes *state_attributes
8
+ end
9
+
10
+ if @states.respond_to?(:num_pages)
11
+ node(:count) { @states.count }
12
+ node(:current_page) { params[:page] || 1 }
13
+ node(:pages) { @states.num_pages }
14
+ end
@@ -0,0 +1,2 @@
1
+ object @state
2
+ attributes *state_attributes
@@ -0,0 +1,7 @@
1
+ object false
2
+ child(@stock_items => :stock_items) do
3
+ extends 'spree/api/stock_items/show'
4
+ end
5
+ node(:count) { @stock_items.count }
6
+ node(:current_page) { params[:page] || 1 }
7
+ node(:pages) { @stock_items.num_pages }
@@ -0,0 +1,5 @@
1
+ object @stock_item
2
+ attributes *stock_item_attributes
3
+ child(:variant) do
4
+ extends "spree/api/variants/small"
5
+ end
@@ -0,0 +1,7 @@
1
+ object false
2
+ child(@stock_locations => :stock_locations) do
3
+ extends 'spree/api/stock_locations/show'
4
+ end
5
+ node(:count) { @stock_locations.count }
6
+ node(:current_page) { params[:page] || 1 }
7
+ node(:pages) { @stock_locations.num_pages }
@@ -0,0 +1,8 @@
1
+ object @stock_location
2
+ attributes *stock_location_attributes
3
+ child(:country) do |address|
4
+ attributes *country_attributes
5
+ end
6
+ child(:state) do |address|
7
+ attributes *state_attributes
8
+ end
@@ -0,0 +1,7 @@
1
+ object false
2
+ child(@stock_movements => :stock_movements) do
3
+ extends 'spree/api/stock_movements/show'
4
+ end
5
+ node(:count) { @stock_movements.count }
6
+ node(:current_page) { params[:page] || 1 }
7
+ node(:pages) { @stock_movements.num_pages }
@@ -0,0 +1,5 @@
1
+ object @stock_movement
2
+ attributes *stock_movement_attributes
3
+ child :stock_item do
4
+ extends "spree/api/stock_items/show"
5
+ end
@@ -0,0 +1,5 @@
1
+ object @stock_transfer
2
+ attributes *stock_transfer_attributes
3
+ node(:received_item) do
4
+ partial('spree/api/transfer_items/show', object: @transfer_item)
5
+ end
@@ -0,0 +1,10 @@
1
+ object false
2
+
3
+ child(@store_credit_events => :store_credit_events) do
4
+ attributes *store_credit_history_attributes
5
+ node(:order_number) { |event| event.order.try(:number) }
6
+ end
7
+
8
+ node(:count) { @store_credit_events.count }
9
+ node(:current_page) { params[:page] || 1 }
10
+ node(:pages) { @store_credit_events.num_pages }
@@ -0,0 +1,4 @@
1
+ object false
2
+ child(@stores => :stores) do
3
+ attributes *store_attributes
4
+ end
@@ -0,0 +1,2 @@
1
+ object @store
2
+ attributes *store_attributes
@@ -0,0 +1,7 @@
1
+ object false
2
+ child(@taxonomies => :taxonomies) do
3
+ extends "spree/api/taxonomies/show"
4
+ end
5
+ node(:count) { @taxonomies.count }
6
+ node(:current_page) { params[:page] || 1 }
7
+ node(:pages) { @taxonomies.num_pages }
@@ -0,0 +1,8 @@
1
+ object false
2
+ node(:data) { @taxonomy.root.name }
3
+ node(:attr) do
4
+ { :id => @taxonomy.root.id,
5
+ :name => @taxonomy.root.name
6
+ }
7
+ end
8
+ node(:state) { "closed" }
@@ -0,0 +1,11 @@
1
+ attributes *taxonomy_attributes
2
+
3
+ child :root => :root do
4
+ attributes *taxon_attributes
5
+
6
+ child :children => :taxons do
7
+ attributes *taxon_attributes
8
+
9
+ extends "spree/api/taxons/taxons"
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ object false
2
+ node(:attributes) { [*taxonomy_attributes] }
3
+ node(:required_attributes) { required_fields_for(Spree::Taxonomy) }
@@ -0,0 +1,15 @@
1
+ object @taxonomy
2
+
3
+ if set = params[:set]
4
+ extends "spree/api/taxonomies/#{set}"
5
+ else
6
+ attributes *taxonomy_attributes
7
+
8
+ child :root => :root do
9
+ attributes *taxon_attributes
10
+
11
+ child :children => :taxons do
12
+ attributes *taxon_attributes
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ object false
2
+ node(:count) { @taxons.count }
3
+ node(:total_count) { @taxons.total_count }
4
+ node(:current_page) { params[:page] ? params[:page].to_i : 1 }
5
+ node(:per_page) { params[:per_page] || Kaminari.config.default_per_page }
6
+ node(:pages) { @taxons.num_pages }
7
+ child @taxons => :taxons do
8
+ attributes *taxon_attributes
9
+ unless params[:without_children]
10
+ extends "spree/api/taxons/taxons"
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ collection @taxon.children, :object_root => false
2
+ node(:data) { |taxon| taxon.name }
3
+ node(:attr) do |taxon|
4
+ { :id => taxon.id,
5
+ :name => taxon.name
6
+ }
7
+ end
8
+ node(:state) { "closed" }
@@ -0,0 +1,3 @@
1
+ object false
2
+ node(:attributes) { [*taxon_attributes] }
3
+ node(:required_attributes) { required_fields_for(Spree::Taxon) }
@@ -0,0 +1,6 @@
1
+ object @taxon
2
+ attributes *taxon_attributes
3
+
4
+ child :children => :taxons do
5
+ attributes *taxon_attributes
6
+ end
@@ -0,0 +1,5 @@
1
+ child :children => :taxons do
2
+ attributes *taxon_attributes
3
+
4
+ extends "spree/api/taxons/taxons"
5
+ end
@@ -0,0 +1,6 @@
1
+ object @transfer_item
2
+ attributes *transfer_item_attributes
3
+ child(:variant) do
4
+ extends "spree/api/variants/small"
5
+ attributes *transfer_item_variant_attributes
6
+ end
@@ -0,0 +1,7 @@
1
+ object false
2
+ child(@users => :users) do
3
+ extends "spree/api/users/show"
4
+ end
5
+ node(:count) { @users.count }
6
+ node(:current_page) { params[:page] || 1 }
7
+ node(:pages) { @users.num_pages }
@@ -0,0 +1,3 @@
1
+ object false
2
+ node(:attributes) { [*user_attributes] }
3
+ node(:required_attributes) { required_fields_for(Spree.user_class) }
@@ -0,0 +1,10 @@
1
+ object @user
2
+
3
+ attributes *user_attributes
4
+ child(:bill_address => :bill_address) do
5
+ extends "spree/api/addresses/show"
6
+ end
7
+
8
+ child(:ship_address => :ship_address) do
9
+ extends "spree/api/addresses/show"
10
+ end
@@ -0,0 +1,17 @@
1
+ object @variant
2
+ attributes *variant_attributes
3
+
4
+ cache [I18n.locale, @current_user_roles.include?('admin'), 'big_variant', root_object]
5
+
6
+ extends "spree/api/variants/small"
7
+
8
+ node :total_on_hand do
9
+ root_object.total_on_hand
10
+ end
11
+
12
+
13
+ child(root_object.stock_items.accessible_by(current_ability) => :stock_items) do
14
+ attributes :id, :count_on_hand, :stock_location_id, :backorderable
15
+ attribute :available? => :available
16
+ node(:stock_location_name) { |si| si.stock_location.name }
17
+ end