spree_api_v1 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.circleci/config.yml +189 -0
- data/.gitignore +23 -0
- data/.rspec +3 -0
- data/.rubocop.yml +24 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +22 -0
- data/Gemfile +59 -0
- data/LICENSE +26 -0
- data/README.md +62 -0
- data/Rakefile +15 -0
- data/app/controllers/spree/api/v1/addresses_controller.rb +46 -0
- data/app/controllers/spree/api/v1/base_controller.rb +174 -0
- data/app/controllers/spree/api/v1/checkouts_controller.rb +106 -0
- data/app/controllers/spree/api/v1/classifications_controller.rb +21 -0
- data/app/controllers/spree/api/v1/countries_controller.rb +22 -0
- data/app/controllers/spree/api/v1/credit_cards_controller.rb +26 -0
- data/app/controllers/spree/api/v1/customer_returns_controller.rb +25 -0
- data/app/controllers/spree/api/v1/images_controller.rb +58 -0
- data/app/controllers/spree/api/v1/inventory_units_controller.rb +54 -0
- data/app/controllers/spree/api/v1/line_items_controller.rb +70 -0
- data/app/controllers/spree/api/v1/option_types_controller.rb +60 -0
- data/app/controllers/spree/api/v1/option_values_controller.rb +62 -0
- data/app/controllers/spree/api/v1/orders_controller.rb +160 -0
- data/app/controllers/spree/api/v1/payments_controller.rb +82 -0
- data/app/controllers/spree/api/v1/product_properties_controller.rb +73 -0
- data/app/controllers/spree/api/v1/products_controller.rb +131 -0
- data/app/controllers/spree/api/v1/promotions_controller.rb +30 -0
- data/app/controllers/spree/api/v1/properties_controller.rb +70 -0
- data/app/controllers/spree/api/v1/reimbursements_controller.rb +25 -0
- data/app/controllers/spree/api/v1/return_authorizations_controller.rb +70 -0
- data/app/controllers/spree/api/v1/shipments_controller.rb +196 -0
- data/app/controllers/spree/api/v1/states_controller.rb +36 -0
- data/app/controllers/spree/api/v1/stock_items_controller.rb +82 -0
- data/app/controllers/spree/api/v1/stock_locations_controller.rb +53 -0
- data/app/controllers/spree/api/v1/stock_movements_controller.rb +45 -0
- data/app/controllers/spree/api/v1/stores_controller.rb +56 -0
- data/app/controllers/spree/api/v1/taxonomies_controller.rb +67 -0
- data/app/controllers/spree/api/v1/taxons_controller.rb +100 -0
- data/app/controllers/spree/api/v1/users_controller.rb +97 -0
- data/app/controllers/spree/api/v1/variants_controller.rb +81 -0
- data/app/controllers/spree/api/v1/zones_controller.rb +55 -0
- data/app/helpers/spree/api/api_helpers.rb +190 -0
- data/app/models/spree/api_v1_configuration.rb +5 -0
- data/app/views/spree/api/errors/gateway_error.rabl +2 -0
- data/app/views/spree/api/errors/invalid_api_key.rabl +2 -0
- data/app/views/spree/api/errors/invalid_resource.rabl +3 -0
- data/app/views/spree/api/errors/must_specify_api_key.rabl +2 -0
- data/app/views/spree/api/errors/not_found.rabl +2 -0
- data/app/views/spree/api/errors/unauthorized.rabl +2 -0
- data/app/views/spree/api/v1/addresses/show.rabl +10 -0
- data/app/views/spree/api/v1/adjustments/show.rabl +4 -0
- data/app/views/spree/api/v1/countries/index.rabl +7 -0
- data/app/views/spree/api/v1/countries/show.rabl +5 -0
- data/app/views/spree/api/v1/credit_cards/index.rabl +7 -0
- data/app/views/spree/api/v1/credit_cards/show.rabl +3 -0
- data/app/views/spree/api/v1/customer_returns/index.rabl +7 -0
- data/app/views/spree/api/v1/images/index.rabl +4 -0
- data/app/views/spree/api/v1/images/new.rabl +3 -0
- data/app/views/spree/api/v1/images/show.rabl +6 -0
- data/app/views/spree/api/v1/inventory_units/show.rabl +2 -0
- data/app/views/spree/api/v1/line_items/new.rabl +3 -0
- data/app/views/spree/api/v1/line_items/show.rabl +14 -0
- data/app/views/spree/api/v1/option_types/index.rabl +3 -0
- data/app/views/spree/api/v1/option_types/new.rabl +3 -0
- data/app/views/spree/api/v1/option_types/show.rabl +5 -0
- data/app/views/spree/api/v1/option_values/index.rabl +3 -0
- data/app/views/spree/api/v1/option_values/new.rabl +3 -0
- data/app/views/spree/api/v1/option_values/show.rabl +2 -0
- data/app/views/spree/api/v1/orders/address.rabl +0 -0
- data/app/views/spree/api/v1/orders/canceled.rabl +0 -0
- data/app/views/spree/api/v1/orders/cart.rabl +0 -0
- data/app/views/spree/api/v1/orders/complete.rabl +0 -0
- data/app/views/spree/api/v1/orders/could_not_apply_coupon.rabl +2 -0
- data/app/views/spree/api/v1/orders/could_not_transition.rabl +3 -0
- data/app/views/spree/api/v1/orders/index.rabl +7 -0
- data/app/views/spree/api/v1/orders/insufficient_quantity.rabl +2 -0
- data/app/views/spree/api/v1/orders/invalid_shipping_method.rabl +2 -0
- data/app/views/spree/api/v1/orders/mine.rabl +9 -0
- data/app/views/spree/api/v1/orders/order.rabl +10 -0
- data/app/views/spree/api/v1/orders/payment.rabl +3 -0
- data/app/views/spree/api/v1/orders/show.rabl +51 -0
- data/app/views/spree/api/v1/payments/credit_over_limit.rabl +2 -0
- data/app/views/spree/api/v1/payments/index.rabl +7 -0
- data/app/views/spree/api/v1/payments/new.rabl +5 -0
- data/app/views/spree/api/v1/payments/show.rabl +2 -0
- data/app/views/spree/api/v1/payments/update_forbidden.rabl +2 -0
- data/app/views/spree/api/v1/product_properties/index.rabl +7 -0
- data/app/views/spree/api/v1/product_properties/new.rabl +2 -0
- data/app/views/spree/api/v1/product_properties/show.rabl +2 -0
- data/app/views/spree/api/v1/products/index.rabl +9 -0
- data/app/views/spree/api/v1/products/new.rabl +3 -0
- data/app/views/spree/api/v1/products/product.rabl +1 -0
- data/app/views/spree/api/v1/products/show.rabl +36 -0
- data/app/views/spree/api/v1/promotions/handler.rabl +5 -0
- data/app/views/spree/api/v1/promotions/show.rabl +2 -0
- data/app/views/spree/api/v1/properties/index.rabl +7 -0
- data/app/views/spree/api/v1/properties/new.rabl +2 -0
- data/app/views/spree/api/v1/properties/show.rabl +2 -0
- data/app/views/spree/api/v1/reimbursements/index.rabl +7 -0
- data/app/views/spree/api/v1/return_authorizations/index.rabl +7 -0
- data/app/views/spree/api/v1/return_authorizations/new.rabl +3 -0
- data/app/views/spree/api/v1/return_authorizations/show.rabl +2 -0
- data/app/views/spree/api/v1/shared/stock_location_required.rabl +2 -0
- data/app/views/spree/api/v1/shipments/big.rabl +48 -0
- data/app/views/spree/api/v1/shipments/cannot_ready_shipment.rabl +2 -0
- data/app/views/spree/api/v1/shipments/mine.rabl +9 -0
- data/app/views/spree/api/v1/shipments/show.rabl +32 -0
- data/app/views/spree/api/v1/shipments/small.rabl +37 -0
- data/app/views/spree/api/v1/shipping_rates/show.rabl +2 -0
- data/app/views/spree/api/v1/states/index.rabl +12 -0
- data/app/views/spree/api/v1/states/show.rabl +2 -0
- data/app/views/spree/api/v1/stock_items/index.rabl +7 -0
- data/app/views/spree/api/v1/stock_items/show.rabl +5 -0
- data/app/views/spree/api/v1/stock_locations/index.rabl +7 -0
- data/app/views/spree/api/v1/stock_locations/show.rabl +8 -0
- data/app/views/spree/api/v1/stock_movements/index.rabl +7 -0
- data/app/views/spree/api/v1/stock_movements/show.rabl +5 -0
- data/app/views/spree/api/v1/stores/index.rabl +4 -0
- data/app/views/spree/api/v1/stores/show.rabl +2 -0
- data/app/views/spree/api/v1/tags/index.rabl +9 -0
- data/app/views/spree/api/v1/taxonomies/index.rabl +7 -0
- data/app/views/spree/api/v1/taxonomies/jstree.rabl +7 -0
- data/app/views/spree/api/v1/taxonomies/nested.rabl +11 -0
- data/app/views/spree/api/v1/taxonomies/new.rabl +3 -0
- data/app/views/spree/api/v1/taxonomies/show.rabl +15 -0
- data/app/views/spree/api/v1/taxons/index.rabl +10 -0
- data/app/views/spree/api/v1/taxons/jstree.rabl +7 -0
- data/app/views/spree/api/v1/taxons/new.rabl +3 -0
- data/app/views/spree/api/v1/taxons/show.rabl +6 -0
- data/app/views/spree/api/v1/taxons/taxons.rabl +5 -0
- data/app/views/spree/api/v1/users/index.rabl +7 -0
- data/app/views/spree/api/v1/users/new.rabl +3 -0
- data/app/views/spree/api/v1/users/show.rabl +11 -0
- data/app/views/spree/api/v1/variants/big.rabl +14 -0
- data/app/views/spree/api/v1/variants/index.rabl +9 -0
- data/app/views/spree/api/v1/variants/new.rabl +2 -0
- data/app/views/spree/api/v1/variants/show.rabl +3 -0
- data/app/views/spree/api/v1/variants/small.rabl +18 -0
- data/app/views/spree/api/v1/zones/index.rabl +7 -0
- data/app/views/spree/api/v1/zones/show.rabl +6 -0
- data/config/initializers/rabl.rb +9 -0
- data/config/routes.rb +123 -0
- data/lib/spree/api_v1/controller_setup.rb +19 -0
- data/lib/spree/api_v1/engine.rb +27 -0
- data/lib/spree/api_v1/factories.rb +6 -0
- data/lib/spree/api_v1/responders/rabl_template.rb +28 -0
- data/lib/spree/api_v1/responders.rb +11 -0
- data/lib/spree/api_v1/testing_support/helpers.rb +44 -0
- data/lib/spree/api_v1/testing_support/setup.rb +16 -0
- data/lib/spree/api_v1/version.rb +9 -0
- data/lib/spree/api_v1.rb +9 -0
- data/lib/spree_api_v1.rb +3 -0
- data/script/rails +9 -0
- data/spec/fixtures/files/icon_256x256.jpg +0 -0
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spree_api_v1.gemspec +26 -0
- metadata +261 -0
@@ -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/v1/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/v1/variants/small'
|
15
|
+
attributes :product_id
|
16
|
+
child(images: :images) { extends 'spree/api/v1/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, &:total)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
child order: :order do
|
28
|
+
extends 'spree/api/v1/orders/order'
|
29
|
+
|
30
|
+
child billing_address: :bill_address do
|
31
|
+
extends 'spree/api/v1/addresses/show'
|
32
|
+
end
|
33
|
+
|
34
|
+
child shipping_address: :ship_address do
|
35
|
+
extends 'spree/api/v1/addresses/show'
|
36
|
+
end
|
37
|
+
|
38
|
+
child adjustments: :adjustments do
|
39
|
+
extends 'spree/api/v1/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,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/v1/shipping_rates/show'
|
9
|
+
end
|
10
|
+
|
11
|
+
child selected_shipping_rate: :selected_shipping_rate do
|
12
|
+
extends 'spree/api/v1/shipping_rates/show'
|
13
|
+
end
|
14
|
+
|
15
|
+
child shipping_methods: :shipping_methods do
|
16
|
+
attributes :id, :name, :tracking_url
|
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/v1/variants/small'
|
29
|
+
end
|
30
|
+
node(:quantity, &:quantity)
|
31
|
+
node(:states, &: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/v1/shipping_rates/show'
|
10
|
+
end
|
11
|
+
|
12
|
+
child selected_shipping_rate: :selected_shipping_rate do
|
13
|
+
extends 'spree/api/v1/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, &:quantity)
|
32
|
+
node(:states, &:states)
|
33
|
+
end
|
34
|
+
|
35
|
+
child adjustments: :adjustments do
|
36
|
+
extends 'spree/api/v1/adjustments/show'
|
37
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
object false
|
2
|
+
node(:states_required) { @country.states_required } if @country
|
3
|
+
|
4
|
+
child(@states => :states) do
|
5
|
+
attributes *state_attributes
|
6
|
+
end
|
7
|
+
|
8
|
+
if @states.respond_to?(:total_pages)
|
9
|
+
node(:count) { @states.count }
|
10
|
+
node(:current_page) { params[:page].try(:to_i) || 1 }
|
11
|
+
node(:pages) { @states.total_pages }
|
12
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
object false
|
2
|
+
node(:count) { @tags.count }
|
3
|
+
node(:total_count) { @tags.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) { @tags.total_pages }
|
7
|
+
child(@tags => :tags) do
|
8
|
+
attributes :name, :id
|
9
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
object @taxonomy
|
2
|
+
|
3
|
+
if params[:set] == 'nested'
|
4
|
+
extends 'spree/api/v1/taxonomies/nested'
|
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,10 @@
|
|
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].try(:to_i) || Kaminari.config.default_per_page }
|
6
|
+
node(:pages) { @taxons.total_pages }
|
7
|
+
child @taxons => :taxons do
|
8
|
+
attributes *taxon_attributes
|
9
|
+
extends 'spree/api/v1/taxons/taxons' unless params[:without_children]
|
10
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
object @variant
|
2
|
+
|
3
|
+
cache [I18n.locale, @current_user_roles.include?('admin'), 'big_variant', root_object]
|
4
|
+
|
5
|
+
extends 'spree/api/v1/variants/small'
|
6
|
+
|
7
|
+
child(stock_items: :stock_items) do
|
8
|
+
attributes :id, :count_on_hand, :stock_location_id, :backorderable
|
9
|
+
attribute available?: :available
|
10
|
+
|
11
|
+
glue(:stock_location) do
|
12
|
+
attribute name: :stock_location_name
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
object false
|
2
|
+
node(:count) { @variants.count }
|
3
|
+
node(:total_count) { @variants.total_count }
|
4
|
+
node(:current_page) { params[:page] ? params[:page].to_i : 1 }
|
5
|
+
node(:pages) { @variants.total_pages }
|
6
|
+
|
7
|
+
child(@variants => :variants) do
|
8
|
+
extends 'spree/api/v1/variants/big'
|
9
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
cache [I18n.locale, @current_user_roles.include?('admin'), 'small_variant', root_object]
|
2
|
+
|
3
|
+
attributes *variant_attributes
|
4
|
+
|
5
|
+
node(:display_price) { |p| p.display_price.to_s }
|
6
|
+
node(:options_text, &:options_text)
|
7
|
+
node(:track_inventory, &:should_track_inventory?)
|
8
|
+
node(:in_stock, &:in_stock?)
|
9
|
+
node(:is_backorderable, &:is_backorderable?)
|
10
|
+
node(:is_orderable) { |v| v.is_backorderable? || v.in_stock? }
|
11
|
+
node(:total_on_hand, &:total_on_hand)
|
12
|
+
node(:is_destroyed, &:destroyed?)
|
13
|
+
|
14
|
+
child option_values: :option_values do
|
15
|
+
attributes *option_value_attributes
|
16
|
+
end
|
17
|
+
|
18
|
+
child(images: :images) { extends 'spree/api/v1/images/show' }
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Rabl.configure do |config|
|
2
|
+
config.include_json_root = false
|
3
|
+
config.include_child_root = false
|
4
|
+
|
5
|
+
# Motivation here it make it call as_json when rendering timestamps
|
6
|
+
# and therefore display milliseconds. Otherwise it would fall to
|
7
|
+
# JSON.dump which doesn't display the milliseconds
|
8
|
+
config.json_engine = ActiveSupport::JSON
|
9
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
Spree::Core::Engine.add_routes do
|
2
|
+
namespace :api, defaults: { format: 'json' } do
|
3
|
+
namespace :v1 do
|
4
|
+
resources :promotions, only: [:show]
|
5
|
+
|
6
|
+
resources :customer_returns, only: [:index]
|
7
|
+
resources :reimbursements, only: [:index]
|
8
|
+
|
9
|
+
resources :products do
|
10
|
+
resources :images
|
11
|
+
resources :variants
|
12
|
+
resources :product_properties
|
13
|
+
end
|
14
|
+
|
15
|
+
concern :order_routes do
|
16
|
+
member do
|
17
|
+
put :approve
|
18
|
+
put :cancel
|
19
|
+
put :empty
|
20
|
+
put :apply_coupon_code
|
21
|
+
end
|
22
|
+
|
23
|
+
resources :line_items
|
24
|
+
resources :payments do
|
25
|
+
member do
|
26
|
+
put :authorize
|
27
|
+
put :capture
|
28
|
+
put :purchase
|
29
|
+
put :void
|
30
|
+
put :credit
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
resources :addresses, only: [:show, :update]
|
35
|
+
|
36
|
+
resources :return_authorizations do
|
37
|
+
member do
|
38
|
+
put :add
|
39
|
+
put :cancel
|
40
|
+
put :receive
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
resources :checkouts, only: [:update], concerns: :order_routes do
|
46
|
+
member do
|
47
|
+
put :next
|
48
|
+
put :advance
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
resources :variants do
|
53
|
+
resources :images
|
54
|
+
end
|
55
|
+
|
56
|
+
resources :option_types do
|
57
|
+
resources :option_values
|
58
|
+
end
|
59
|
+
resources :option_values
|
60
|
+
|
61
|
+
resources :option_values, only: :index
|
62
|
+
|
63
|
+
get '/orders/mine', to: 'orders#mine', as: 'my_orders'
|
64
|
+
get '/orders/current', to: 'orders#current', as: 'current_order'
|
65
|
+
|
66
|
+
resources :orders, concerns: :order_routes do
|
67
|
+
put :remove_coupon_code, on: :member
|
68
|
+
end
|
69
|
+
|
70
|
+
resources :zones
|
71
|
+
resources :countries, only: [:index, :show] do
|
72
|
+
resources :states, only: [:index, :show]
|
73
|
+
end
|
74
|
+
|
75
|
+
resources :shipments, only: [:create, :update] do
|
76
|
+
collection do
|
77
|
+
post 'transfer_to_location'
|
78
|
+
post 'transfer_to_shipment'
|
79
|
+
get :mine
|
80
|
+
end
|
81
|
+
|
82
|
+
member do
|
83
|
+
put :ready
|
84
|
+
put :ship
|
85
|
+
put :add
|
86
|
+
put :remove
|
87
|
+
end
|
88
|
+
end
|
89
|
+
resources :states, only: [:index, :show]
|
90
|
+
|
91
|
+
resources :taxonomies do
|
92
|
+
member do
|
93
|
+
get :jstree
|
94
|
+
end
|
95
|
+
resources :taxons do
|
96
|
+
member do
|
97
|
+
get :jstree
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
resources :taxons, only: [:index]
|
103
|
+
|
104
|
+
resources :inventory_units, only: [:show, :update]
|
105
|
+
|
106
|
+
resources :users do
|
107
|
+
resources :credit_cards, only: [:index]
|
108
|
+
end
|
109
|
+
|
110
|
+
resources :properties
|
111
|
+
resources :stock_locations do
|
112
|
+
resources :stock_movements
|
113
|
+
resources :stock_items
|
114
|
+
end
|
115
|
+
|
116
|
+
resources :stock_items, only: [:index, :update, :destroy]
|
117
|
+
resources :stores
|
118
|
+
|
119
|
+
put '/classifications', to: 'classifications#update', as: :classifications
|
120
|
+
get '/taxons/products', to: 'taxons#products', as: :taxon_products
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spree/api_v1/responders'
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module ApiV1
|
5
|
+
module ControllerSetup
|
6
|
+
def self.included(klass)
|
7
|
+
klass.class_eval do
|
8
|
+
include CanCan::ControllerAdditions
|
9
|
+
|
10
|
+
prepend_view_path Rails.root + 'app/views'
|
11
|
+
append_view_path File.expand_path('../../../app/views', File.dirname(__FILE__))
|
12
|
+
|
13
|
+
self.responder = Spree::ApiV1::Responders::AppResponder
|
14
|
+
respond_to :json
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rails/engine'
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module ApiV1
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
isolate_namespace Spree
|
7
|
+
engine_name 'spree_api_v1'
|
8
|
+
|
9
|
+
# use rspec for tests
|
10
|
+
config.generators do |g|
|
11
|
+
g.test_framework :rspec
|
12
|
+
end
|
13
|
+
|
14
|
+
config.after_initialize do |_app|
|
15
|
+
Spree::ApiV1::Config = Spree::ApiV1Configuration.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.activate
|
19
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
|
20
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
config.to_prepare(&method(:activate).to_proc)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
# Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
|
3
|
+
#
|
4
|
+
# Example adding this to your spec_helper will load these Factories for use:
|
5
|
+
# require 'spree_api_v1/factories'
|
6
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Spree
|
2
|
+
module ApiV1
|
3
|
+
module Responders
|
4
|
+
module RablTemplate
|
5
|
+
def to_format
|
6
|
+
if template
|
7
|
+
render template, status: options[:status] || 200
|
8
|
+
else
|
9
|
+
super
|
10
|
+
end
|
11
|
+
rescue ActionView::MissingTemplate => e
|
12
|
+
api_behavior
|
13
|
+
end
|
14
|
+
|
15
|
+
def template
|
16
|
+
options[:default_template]
|
17
|
+
end
|
18
|
+
|
19
|
+
def api_behavior
|
20
|
+
if controller.params[:action] == 'destroy'
|
21
|
+
# Render a blank template
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|