solidus_api 2.5.2 → 2.6.0.rc1

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 (212) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -1
  3. data/app/controllers/spree/api/address_books_controller.rb +2 -0
  4. data/app/controllers/spree/api/addresses_controller.rb +2 -0
  5. data/app/controllers/spree/api/base_controller.rb +2 -0
  6. data/app/controllers/spree/api/checkouts_controller.rb +2 -0
  7. data/app/controllers/spree/api/classifications_controller.rb +2 -0
  8. data/app/controllers/spree/api/config_controller.rb +2 -0
  9. data/app/controllers/spree/api/countries_controller.rb +2 -0
  10. data/app/controllers/spree/api/credit_cards_controller.rb +2 -0
  11. data/app/controllers/spree/api/images_controller.rb +2 -0
  12. data/app/controllers/spree/api/inventory_units_controller.rb +2 -0
  13. data/app/controllers/spree/api/line_items_controller.rb +2 -0
  14. data/app/controllers/spree/api/option_types_controller.rb +2 -0
  15. data/app/controllers/spree/api/option_values_controller.rb +2 -0
  16. data/app/controllers/spree/api/orders_controller.rb +2 -0
  17. data/app/controllers/spree/api/payments_controller.rb +3 -1
  18. data/app/controllers/spree/api/product_properties_controller.rb +2 -0
  19. data/app/controllers/spree/api/products_controller.rb +2 -0
  20. data/app/controllers/spree/api/promotions_controller.rb +2 -0
  21. data/app/controllers/spree/api/properties_controller.rb +2 -0
  22. data/app/controllers/spree/api/resource_controller.rb +2 -0
  23. data/app/controllers/spree/api/return_authorizations_controller.rb +2 -0
  24. data/app/controllers/spree/api/shipments_controller.rb +2 -0
  25. data/app/controllers/spree/api/states_controller.rb +4 -2
  26. data/app/controllers/spree/api/stock_items_controller.rb +2 -0
  27. data/app/controllers/spree/api/stock_locations_controller.rb +2 -0
  28. data/app/controllers/spree/api/stock_movements_controller.rb +2 -0
  29. data/app/controllers/spree/api/store_credit_events_controller.rb +2 -0
  30. data/app/controllers/spree/api/stores_controller.rb +2 -0
  31. data/app/controllers/spree/api/taxonomies_controller.rb +2 -0
  32. data/app/controllers/spree/api/taxons_controller.rb +2 -0
  33. data/app/controllers/spree/api/users_controller.rb +2 -0
  34. data/app/controllers/spree/api/variants_controller.rb +2 -0
  35. data/app/controllers/spree/api/zones_controller.rb +2 -0
  36. data/app/helpers/spree/api/api_helpers.rb +6 -4
  37. data/app/models/spree/api_configuration.rb +2 -0
  38. data/app/views/spree/api/address_books/show.json.jbuilder +2 -0
  39. data/app/views/spree/api/addresses/_address.json.jbuilder +2 -0
  40. data/app/views/spree/api/addresses/show.json.jbuilder +2 -0
  41. data/app/views/spree/api/adjustments/_adjustment.json.jbuilder +2 -0
  42. data/app/views/spree/api/config/money.json.jbuilder +2 -0
  43. data/app/views/spree/api/config/show.json.jbuilder +2 -0
  44. data/app/views/spree/api/countries/index.json.jbuilder +2 -0
  45. data/app/views/spree/api/countries/show.json.jbuilder +2 -0
  46. data/app/views/spree/api/credit_cards/_credit_card.json.jbuilder +2 -0
  47. data/app/views/spree/api/credit_cards/index.json.jbuilder +2 -0
  48. data/app/views/spree/api/credit_cards/show.json.jbuilder +2 -0
  49. data/app/views/spree/api/errors/delete_restriction.json.jbuilder +2 -0
  50. data/app/views/spree/api/errors/gateway_error.json.jbuilder +2 -0
  51. data/app/views/spree/api/errors/invalid_api_key.json.jbuilder +2 -0
  52. data/app/views/spree/api/errors/invalid_resource.json.jbuilder +2 -0
  53. data/app/views/spree/api/errors/must_specify_api_key.json.jbuilder +2 -0
  54. data/app/views/spree/api/errors/not_found.json.jbuilder +2 -0
  55. data/app/views/spree/api/errors/unauthorized.json.jbuilder +2 -0
  56. data/app/views/spree/api/images/_image.json.jbuilder +2 -0
  57. data/app/views/spree/api/images/index.json.jbuilder +2 -0
  58. data/app/views/spree/api/images/show.json.jbuilder +2 -0
  59. data/app/views/spree/api/inventory_units/show.json.jbuilder +2 -0
  60. data/app/views/spree/api/line_items/_line_item.json.jbuilder +2 -0
  61. data/app/views/spree/api/line_items/new.json.jbuilder +2 -0
  62. data/app/views/spree/api/line_items/show.json.jbuilder +2 -0
  63. data/app/views/spree/api/option_types/_option_type.json.jbuilder +2 -0
  64. data/app/views/spree/api/option_types/index.json.jbuilder +2 -0
  65. data/app/views/spree/api/option_types/show.json.jbuilder +2 -0
  66. data/app/views/spree/api/option_values/_option_value.json.jbuilder +2 -0
  67. data/app/views/spree/api/option_values/index.json.jbuilder +2 -0
  68. data/app/views/spree/api/option_values/show.json.jbuilder +2 -0
  69. data/app/views/spree/api/orders/_big.json.jbuilder +13 -5
  70. data/app/views/spree/api/orders/_order.json.jbuilder +2 -0
  71. data/app/views/spree/api/orders/could_not_apply_coupon.json.jbuilder +2 -0
  72. data/app/views/spree/api/orders/could_not_transition.json.jbuilder +2 -0
  73. data/app/views/spree/api/orders/expected_total_mismatch.json.jbuilder +2 -0
  74. data/app/views/spree/api/orders/index.json.jbuilder +2 -0
  75. data/app/views/spree/api/orders/invalid_shipping_method.json.jbuilder +2 -0
  76. data/app/views/spree/api/orders/mine.json.jbuilder +2 -0
  77. data/app/views/spree/api/orders/show.json.jbuilder +2 -0
  78. data/app/views/spree/api/payments/credit_over_limit.json.jbuilder +2 -0
  79. data/app/views/spree/api/payments/index.json.jbuilder +2 -0
  80. data/app/views/spree/api/payments/new.json.jbuilder +2 -0
  81. data/app/views/spree/api/payments/show.json.jbuilder +2 -0
  82. data/app/views/spree/api/payments/source_views/_check.json.jbuilder +1 -0
  83. data/app/views/spree/api/payments/source_views/_gateway.json.jbuilder +6 -0
  84. data/app/views/spree/api/payments/source_views/_storecredit.json.jbuilder +3 -0
  85. data/app/views/spree/api/payments/update_forbidden.json.jbuilder +2 -0
  86. data/app/views/spree/api/product_properties/index.json.jbuilder +2 -0
  87. data/app/views/spree/api/product_properties/new.json.jbuilder +2 -0
  88. data/app/views/spree/api/product_properties/show.json.jbuilder +2 -0
  89. data/app/views/spree/api/products/_product.json.jbuilder +2 -0
  90. data/app/views/spree/api/products/index.json.jbuilder +2 -0
  91. data/app/views/spree/api/products/new.json.jbuilder +2 -0
  92. data/app/views/spree/api/products/show.json.jbuilder +2 -0
  93. data/app/views/spree/api/promotions/handler.json.jbuilder +2 -0
  94. data/app/views/spree/api/promotions/show.json.jbuilder +2 -0
  95. data/app/views/spree/api/properties/index.json.jbuilder +2 -0
  96. data/app/views/spree/api/properties/new.json.jbuilder +2 -0
  97. data/app/views/spree/api/properties/show.json.jbuilder +2 -0
  98. data/app/views/spree/api/return_authorizations/index.json.jbuilder +2 -0
  99. data/app/views/spree/api/return_authorizations/new.json.jbuilder +2 -0
  100. data/app/views/spree/api/return_authorizations/show.json.jbuilder +2 -0
  101. data/app/views/spree/api/shared/_pagination.json.jbuilder +2 -0
  102. data/app/views/spree/api/shipments/_big.json.jbuilder +8 -4
  103. data/app/views/spree/api/shipments/_small.json.jbuilder +2 -0
  104. data/app/views/spree/api/shipments/cannot_ready_shipment.json.jbuilder +2 -0
  105. data/app/views/spree/api/shipments/estimated_rates.json.jbuilder +2 -0
  106. data/app/views/spree/api/shipments/mine.json.jbuilder +2 -0
  107. data/app/views/spree/api/shipments/show.json.jbuilder +2 -0
  108. data/app/views/spree/api/shipping_rates/_shipping_rate.json.jbuilder +2 -0
  109. data/app/views/spree/api/states/index.json.jbuilder +2 -0
  110. data/app/views/spree/api/states/show.json.jbuilder +2 -0
  111. data/app/views/spree/api/stock_items/_stock_item.json.jbuilder +2 -0
  112. data/app/views/spree/api/stock_items/index.json.jbuilder +2 -0
  113. data/app/views/spree/api/stock_items/show.json.jbuilder +2 -0
  114. data/app/views/spree/api/stock_locations/_stock_location.json.jbuilder +2 -0
  115. data/app/views/spree/api/stock_locations/index.json.jbuilder +2 -0
  116. data/app/views/spree/api/stock_locations/show.json.jbuilder +2 -0
  117. data/app/views/spree/api/stock_movements/_stock_movement.json.jbuilder +2 -0
  118. data/app/views/spree/api/stock_movements/index.json.jbuilder +2 -0
  119. data/app/views/spree/api/stock_movements/show.json.jbuilder +2 -0
  120. data/app/views/spree/api/store_credit_events/mine.json.jbuilder +2 -0
  121. data/app/views/spree/api/stores/index.json.jbuilder +2 -0
  122. data/app/views/spree/api/stores/show.json.jbuilder +2 -0
  123. data/app/views/spree/api/taxonomies/_nested.json.jbuilder +2 -0
  124. data/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder +2 -0
  125. data/app/views/spree/api/taxonomies/index.json.jbuilder +2 -0
  126. data/app/views/spree/api/taxonomies/jstree.json.jbuilder +2 -0
  127. data/app/views/spree/api/taxonomies/new.json.jbuilder +2 -0
  128. data/app/views/spree/api/taxonomies/show.json.jbuilder +2 -0
  129. data/app/views/spree/api/taxons/_taxon.json.jbuilder +2 -0
  130. data/app/views/spree/api/taxons/_taxons.json.jbuilder +2 -0
  131. data/app/views/spree/api/taxons/index.json.jbuilder +2 -0
  132. data/app/views/spree/api/taxons/jstree.json.jbuilder +2 -0
  133. data/app/views/spree/api/taxons/new.json.jbuilder +2 -0
  134. data/app/views/spree/api/taxons/show.json.jbuilder +2 -0
  135. data/app/views/spree/api/users/_user.json.jbuilder +2 -0
  136. data/app/views/spree/api/users/index.json.jbuilder +2 -0
  137. data/app/views/spree/api/users/new.json.jbuilder +2 -0
  138. data/app/views/spree/api/users/show.json.jbuilder +2 -0
  139. data/app/views/spree/api/variants/_big.json.jbuilder +2 -0
  140. data/app/views/spree/api/variants/_small.json.jbuilder +2 -0
  141. data/app/views/spree/api/variants/index.json.jbuilder +2 -0
  142. data/app/views/spree/api/variants/new.json.jbuilder +2 -0
  143. data/app/views/spree/api/variants/show.json.jbuilder +2 -0
  144. data/app/views/spree/api/zones/_zone.json.jbuilder +2 -0
  145. data/app/views/spree/api/zones/index.json.jbuilder +2 -0
  146. data/app/views/spree/api/zones/show.json.jbuilder +2 -0
  147. data/config/routes.rb +9 -7
  148. data/db/migrate/20100107141738_add_api_key_to_spree_users.rb +2 -0
  149. data/db/migrate/20120411123334_resize_api_key_field.rb +2 -0
  150. data/db/migrate/20120530054546_rename_api_key_to_spree_api_key.rb +2 -0
  151. data/db/migrate/20131017162334_add_index_to_user_spree_api_key.rb +2 -0
  152. data/lib/solidus_api.rb +2 -0
  153. data/lib/spree/api/engine.rb +2 -0
  154. data/lib/spree/api/responders/rabl_template.rb +2 -0
  155. data/lib/spree/api/responders.rb +2 -0
  156. data/lib/spree/api/testing_support/caching.rb +2 -0
  157. data/lib/spree/api/testing_support/helpers.rb +2 -0
  158. data/lib/spree/api/testing_support/setup.rb +2 -0
  159. data/lib/spree/api.rb +2 -0
  160. data/lib/spree_api.rb +2 -0
  161. data/script/rails +4 -2
  162. data/solidus_api.gemspec +4 -3
  163. data/spec/controllers/spree/api/base_controller_spec.rb +2 -0
  164. data/spec/controllers/spree/api/resource_controller_spec.rb +8 -4
  165. data/spec/features/checkout_spec.rb +2 -0
  166. data/spec/models/spree/legacy_user_spec.rb +2 -0
  167. data/spec/requests/api/address_books_spec.rb +2 -0
  168. data/spec/requests/rabl_cache_spec.rb +2 -0
  169. data/spec/requests/ransackable_attributes_spec.rb +2 -0
  170. data/spec/requests/spree/api/addresses_controller_spec.rb +2 -1
  171. data/spec/requests/spree/api/checkouts_controller_spec.rb +2 -1
  172. data/spec/requests/spree/api/classifications_controller_spec.rb +2 -0
  173. data/spec/requests/spree/api/config_controller_spec.rb +3 -1
  174. data/spec/requests/spree/api/countries_controller_spec.rb +2 -1
  175. data/spec/requests/spree/api/credit_cards_controller_spec.rb +2 -1
  176. data/spec/requests/spree/api/images_controller_spec.rb +2 -1
  177. data/spec/requests/spree/api/inventory_units_controller_spec.rb +2 -0
  178. data/spec/requests/spree/api/line_items_controller_spec.rb +2 -1
  179. data/spec/requests/spree/api/option_types_controller_spec.rb +2 -1
  180. data/spec/requests/spree/api/option_values_controller_spec.rb +3 -2
  181. data/spec/requests/spree/api/orders_controller_spec.rb +17 -13
  182. data/spec/requests/spree/api/payments_controller_spec.rb +2 -0
  183. data/spec/requests/spree/api/product_properties_controller_spec.rb +2 -1
  184. data/spec/requests/spree/api/products_controller_spec.rb +4 -3
  185. data/spec/requests/spree/api/promotion_application_spec.rb +2 -1
  186. data/spec/requests/spree/api/promotions_controller_spec.rb +2 -1
  187. data/spec/requests/spree/api/properties_controller_spec.rb +2 -1
  188. data/spec/requests/spree/api/return_authorizations_controller_spec.rb +2 -1
  189. data/spec/requests/spree/api/shipments_controller_spec.rb +13 -0
  190. data/spec/requests/spree/api/states_controller_spec.rb +2 -1
  191. data/spec/requests/spree/api/stock_items_controller_spec.rb +2 -1
  192. data/spec/requests/spree/api/stock_locations_controller_spec.rb +2 -1
  193. data/spec/requests/spree/api/stock_movements_controller_spec.rb +2 -1
  194. data/spec/requests/spree/api/store_credit_events_controller_spec.rb +2 -0
  195. data/spec/requests/spree/api/stores_controller_spec.rb +9 -6
  196. data/spec/requests/spree/api/taxonomies_controller_spec.rb +2 -1
  197. data/spec/requests/spree/api/taxons_controller_spec.rb +2 -1
  198. data/spec/requests/spree/api/unauthenticated_products_controller_spec.rb +3 -2
  199. data/spec/requests/spree/api/users_controller_spec.rb +2 -1
  200. data/spec/requests/spree/api/variants_controller_spec.rb +2 -2
  201. data/spec/requests/spree/api/zones_controller_spec.rb +2 -1
  202. data/spec/shared_examples/protect_product_actions.rb +2 -0
  203. data/spec/spec_helper.rb +3 -1
  204. data/spec/support/be_paginated_matcher.rb +2 -0
  205. data/spec/support/controller_hacks.rb +2 -0
  206. data/spec/support/database_cleaner.rb +2 -0
  207. data/spec/support/have_attributes_matcher.rb +2 -0
  208. data/spec/test_views/spree/api/widgets/_widget.json.jbuilder +2 -0
  209. data/spec/test_views/spree/api/widgets/index.json.jbuilder +3 -1
  210. data/spec/test_views/spree/api/widgets/new.json.jbuilder +2 -0
  211. data/spec/test_views/spree/api/widgets/show.json.jbuilder +2 -0
  212. metadata +27 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ddcab56109f84fbbfb71d8d153d0089ac3f2828bf9777a706327ce2965f30efc
4
- data.tar.gz: 65406b044f2831228871056a36f8fa77553b027d1118c350dcce53aab5f55d61
3
+ metadata.gz: 7c5d3883943667e7a4f52315a0071be065726a672bdf8d9b18e1048fe4a4d5c3
4
+ data.tar.gz: c0efc2209c8ab214173df7181e4eb29b8c3ffcd9b88b5bf6ce1a23eb680efe7c
5
5
  SHA512:
6
- metadata.gz: ce13a46a961d8c7182ffd054609c209f21af399a19140511daaa51d1aff84510c0788f883bb8ca0f2cb47c41b12d19202b611f2b2fa189963154c84b82999932
7
- data.tar.gz: 5d19e5737c30c49dc9c8269d9244db721695bfd49a8e611826d00b07088cbc597f887f07a9df29220da0cf297e00e7b59bb7d813de6afa81875d631f2b69bdca
6
+ metadata.gz: 7a4bb5441f83cea2bf0707e1a60a6b652e941617b2f1bfc22277f56787adcb720e13100d6d1cb4ea1aea8a887c74fbb685b454c6cd086308042361a6aaa0d4a5
7
+ data.tar.gz: 5f7b1a01e2201a559398510e9868b59b40a9e40b05c168a93b07ecbdfa5257e9ed447b8a66209218ff46d72d25b61dd3475b2dd436cc00eda528f31f0905dc8b
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rubygems'
2
4
  require 'rake'
3
5
  require 'rake/testtask'
@@ -8,7 +10,7 @@ RSpec::Core::RakeTask.new
8
10
  task default: :spec
9
11
 
10
12
  DummyApp::RakeTasks.new(
11
- gem_root: File.expand_path('../', __FILE__),
13
+ gem_root: File.expand_path(__dir__),
12
14
  lib_name: 'solidus_api'
13
15
  )
14
16
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class AddressBooksController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class AddressesController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spree/api/responders'
2
4
 
3
5
  module Spree
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class CheckoutsController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class ClassificationsController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class ConfigController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class CountriesController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class CreditCardsController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class ImagesController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class InventoryUnitsController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class LineItemsController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class OptionTypesController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class OptionValuesController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class OrdersController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class PaymentsController < Spree::Api::BaseController
@@ -27,7 +29,7 @@ module Spree
27
29
 
28
30
  def update
29
31
  authorize! params[:action], @payment
30
- if ! @payment.pending?
32
+ if !@payment.pending?
31
33
  render 'update_forbidden', status: 403
32
34
  elsif @payment.update_attributes(payment_params)
33
35
  respond_with(@payment, default_template: :show)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class ProductPropertiesController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class ProductsController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class PromotionsController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class PropertiesController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Spree::Api::ResourceController < Spree::Api::BaseController
2
4
  before_action :load_resource, only: [:show, :update, :destroy]
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class ReturnAuthorizationsController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class ShipmentsController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class StatesController < Spree::Api::BaseController
@@ -24,9 +26,9 @@ module Spree
24
26
  def scope
25
27
  if params[:country_id]
26
28
  @country = Spree::Country.accessible_by(current_ability, :read).find(params[:country_id])
27
- return @country.states.accessible_by(current_ability, :read)
29
+ @country.states.accessible_by(current_ability, :read)
28
30
  else
29
- return Spree::State.accessible_by(current_ability, :read)
31
+ Spree::State.accessible_by(current_ability, :read)
30
32
  end
31
33
  end
32
34
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class StockItemsController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class StockLocationsController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class StockMovementsController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Spree::Api::StoreCreditEventsController < Spree::Api::BaseController
2
4
  def mine
3
5
  if current_api_user
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class StoresController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class TaxonomiesController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class TaxonsController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Spree::Api::UsersController < Spree::Api::ResourceController
2
4
  private
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class VariantsController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class ZonesController < Spree::Api::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  module ApiHelpers
@@ -51,7 +53,7 @@ module Spree
51
53
  @@product_attributes = [
52
54
  :id, :name, :description, :price, :display_price, :available_on,
53
55
  :slug, :meta_description, :meta_keywords, :shipping_category_id,
54
- :taxon_ids, :total_on_hand
56
+ :taxon_ids, :total_on_hand, :meta_title
55
57
  ]
56
58
 
57
59
  @@product_property_attributes = [
@@ -131,7 +133,7 @@ module Spree
131
133
 
132
134
  @@adjustment_attributes = [
133
135
  :id, :source_type, :source_id, :adjustable_type, :adjustable_id,
134
- :amount, :label, :promotion_code,
136
+ :amount, :label, :promotion_code_id,
135
137
  :finalized, :eligible, :created_at, :updated_at
136
138
  ]
137
139
 
@@ -166,12 +168,12 @@ module Spree
166
168
 
167
169
  @@store_attributes = [
168
170
  :id, :name, :url, :meta_description, :meta_keywords, :seo_title,
169
- :mail_from_address, :default_currency, :code, :default
171
+ :mail_from_address, :default_currency, :code, :default, :available_locales
170
172
  ]
171
173
 
172
174
  @@store_credit_history_attributes = [
173
175
  :display_amount, :display_user_total_amount, :display_action,
174
- :display_event_date
176
+ :display_event_date, :display_remaining_amount
175
177
  ]
176
178
 
177
179
  def variant_attributes
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  class ApiConfiguration < Preferences::Configuration
3
5
  preference :requires_authentication, :boolean, default: true
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.array! @user_addresses do |user_address|
2
4
  json.partial!("spree/api/addresses/address", address: user_address.address)
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.cache! address do
2
4
  json.(address, *address_attributes)
3
5
  json.country do
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/addresses/address", address: @address)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.cache! [I18n.locale, adjustment] do
2
4
  json.(adjustment, *adjustment_attributes)
3
5
  json.display_amount(adjustment.display_amount.to_s)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.symbol(::Money.new(1, Spree::Config[:currency]).symbol)
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.default_country_id(Spree::Country.default.id)
2
4
  json.default_country_iso(Spree::Config[:default_country_iso])
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.countries(@countries) { |country| json.(country, *country_attributes) }
2
4
  json.partial! 'spree/api/shared/pagination', pagination: @countries
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(@country, *country_attributes)
2
4
  json.states(@country.states) do |state|
3
5
  json.(state, :id, :name, :abbr, :country_id)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.cache! [I18n.locale, credit_card] do
2
4
  json.(credit_card, *creditcard_attributes)
3
5
  json.address do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.credit_cards(@credit_cards) do |credit_card|
2
4
  json.partial!("spree/api/credit_cards/credit_card", credit_card: credit_card)
3
5
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/credit_cards/credit_card", credit_card: @credit_card)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.error I18n.t(:delete_restriction_error, scope: "spree.api")
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.error(I18n.t(:gateway_error, scope: "spree.api", text: @error))
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.error(I18n.t(:invalid_api_key, key: api_key, scope: "spree.api"))
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.error(I18n.t(:invalid_resource, scope: "spree.api"))
2
4
  json.errors(@resource.errors.to_hash)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.error(I18n.t(:must_specify_api_key, scope: "spree.api"))
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.error(I18n.t(:resource_not_found, scope: "spree.api"))
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.error(I18n.t(:unauthorized, scope: "spree.api"))
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(image, *image_attributes)
2
4
  json.(image, :viewable_type, :viewable_id)
3
5
  Spree::Image.attachment_definitions[:attachment][:styles].each do |k, _v|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.images(@images) do |image|
2
4
  json.partial!("spree/api/images/image", image: image)
3
5
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/images/image", image: @image)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(@inventory_unit, *inventory_unit_attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.cache! [I18n.locale, line_item] do
2
4
  json.(line_item, *line_item_attributes)
3
5
  json.single_display_amount(line_item.single_display_amount.to_s)
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.attributes(([*line_item_attributes] - [:id]))
2
4
  json.required_attributes([:variant_id, :quantity])
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/line_items/line_item", line_item: @line_item)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(option_type, *option_type_attributes)
2
4
  json.option_values(option_type.option_values) do |option_value|
3
5
  json.(option_value, *option_value_attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.array! @option_types do |option_type|
2
4
  json.partial!("spree/api/option_types/option_type", option_type: option_type)
3
5
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/option_types/option_type", option_type: @option_type)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(option_value, *option_value_attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.array! @option_values do |option_value|
2
4
  json.partial!("spree/api/option_values/option_value", option_value: option_value)
3
5
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/option_values/option_value", option_value: @option_value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/orders/order", order: order)
2
4
  json.payment_methods(order.available_payment_methods) do |payment_method|
3
5
  json.(payment_method, :id, :name, :partial_name)
@@ -24,12 +26,18 @@ json.payments(order.payments) do |payment|
24
26
  json.(payment, *payment_attributes)
25
27
  json.payment_method { json.(payment.payment_method, :id, :name) }
26
28
  json.source do
27
- if payment.source
28
- json.(payment.source, *payment_source_attributes)
29
+ ##
30
+ # payment.source could be a Spree::Payment. If it is then we need to call
31
+ # source twice.
32
+ # @see https://github.com/solidusio/solidus/blob/v2.4/backend/app/views/spree/admin/payments/show.html.erb#L16
33
+ #
34
+ payment_source = payment.source.is_a?(Spree::Payment) ? payment.source.source : payment.source
29
35
 
30
- if @current_user_roles.include?("admin")
31
- json.(payment.source, :gateway_customer_profile_id, :gateway_payment_profile_id)
32
- end
36
+ if payment_source
37
+ json.partial!(
38
+ "spree/api/payments/source_views/#{payment.payment_method.partial_name}",
39
+ payment_source: payment_source
40
+ )
33
41
  else
34
42
  json.nil!
35
43
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.cache! [I18n.locale, order] do
2
4
  json.(order, *order_attributes)
3
5
  json.display_item_total(order.display_item_total.to_s)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.error(@coupon_message)
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.error(I18n.t(:could_not_transition, scope: "spree.api.order"))
2
4
  json.errors(@order.errors.to_hash)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.errors(expected_total: [I18n.t(:expected_total_mismatch, scope: "spree.api.order")])
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.orders(@orders) do |order|
2
4
  json.partial!("spree/api/orders/order", order: order)
3
5
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.errors([I18n.t(:invalid_shipping_method, scope: "spree.api.order")])
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.orders(@orders) do |order|
2
4
  json.partial!("spree/api/orders/big", order: order)
3
5
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.partial!("spree/api/orders/big", order: @order)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.error(I18n.t(:credit_over_limit, limit: @payment.credit_allowed, scope: "spree.api.payment"))
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.payments(@payments) { |payment| json.(payment, *payment_attributes) }
2
4
  json.partial! 'spree/api/shared/pagination', pagination: @payments
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.attributes([*payment_attributes])
2
4
  json.payment_methods(@payment_methods) do |payment_method|
3
5
  json.(payment_method, *payment_method_attributes)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.(@payment, *payment_attributes)