goca-spree-api 3.1.14.rails.5.0 → 3.1.14.rails.5.2.8.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 +5 -5
- data/Gemfile +3 -1
- data/app/controllers/spree/api/base_controller.rb +5 -5
- data/app/controllers/spree/api/v1/addresses_controller.rb +1 -1
- data/app/controllers/spree/api/v1/classifications_controller.rb +1 -1
- data/app/controllers/spree/api/v1/images_controller.rb +3 -0
- data/app/controllers/spree/api/v1/inventory_units_controller.rb +3 -3
- data/app/controllers/spree/api/v1/line_items_controller.rb +3 -0
- data/app/controllers/spree/api/v1/option_types_controller.rb +16 -7
- data/app/controllers/spree/api/v1/option_values_controller.rb +6 -3
- data/app/controllers/spree/api/v1/orders_controller.rb +1 -1
- data/app/controllers/spree/api/v1/products_controller.rb +8 -5
- data/app/controllers/spree/api/v1/states_controller.rb +3 -3
- data/app/controllers/spree/api/v1/stock_items_controller.rb +1 -1
- data/app/controllers/spree/api/v1/stock_locations_controller.rb +1 -1
- data/app/controllers/spree/api/v1/taxonomies_controller.rb +11 -7
- data/app/controllers/spree/api/v1/taxons_controller.rb +10 -7
- data/app/controllers/spree/api/v1/users_controller.rb +5 -3
- data/app/controllers/spree/api/v1/zones_controller.rb +3 -3
- data/app/helpers/spree/api/api_helpers.rb +5 -2
- data/app/models/spree/api_configuration.rb +1 -1
- data/app/views/spree/api/errors/invalid_api_key.v1.rabl +1 -1
- data/app/views/spree/api/errors/invalid_resource.v1.rabl +1 -1
- data/app/views/spree/api/errors/must_specify_api_key.v1.rabl +1 -1
- data/app/views/spree/api/errors/not_found.v1.rabl +1 -1
- data/app/views/spree/api/errors/unauthorized.v1.rabl +1 -1
- data/app/views/spree/api/v1/countries/show.v1.rabl +1 -1
- data/app/views/spree/api/v1/line_items/show.v1.rabl +2 -2
- data/app/views/spree/api/v1/option_types/show.v1.rabl +1 -1
- data/app/views/spree/api/v1/orders/invalid_shipping_method.v1.rabl +1 -1
- data/app/views/spree/api/v1/orders/payment.v1.rabl +1 -1
- data/app/views/spree/api/v1/orders/show.v1.rabl +9 -9
- data/app/views/spree/api/v1/payments/credit_over_limit.v1.rabl +1 -1
- data/app/views/spree/api/v1/payments/update_forbidden.v1.rabl +1 -1
- data/app/views/spree/api/v1/products/show.v1.rabl +5 -5
- data/app/views/spree/api/v1/shipments/cannot_ready_shipment.v1.rabl +1 -1
- data/app/views/spree/api/v1/shipments/show.v1.rabl +7 -7
- data/app/views/spree/api/v1/shipments/small.v1.rabl +8 -8
- data/app/views/spree/api/v1/taxonomies/jstree.rabl +2 -2
- data/app/views/spree/api/v1/taxonomies/nested.v1.rabl +2 -2
- data/app/views/spree/api/v1/taxons/jstree.rabl +3 -3
- data/app/views/spree/api/v1/taxons/show.v1.rabl +1 -1
- data/app/views/spree/api/v1/taxons/taxons.v1.rabl +1 -1
- data/app/views/spree/api/v1/users/show.v1.rabl +3 -2
- data/app/views/spree/api/v1/variants/big.v1.rabl +3 -3
- data/app/views/spree/api/v1/variants/small.v1.rabl +3 -2
- data/app/views/spree/api/v1/zones/show.v1.rabl +1 -1
- data/lib/spree/api/engine.rb +13 -1
- data/lib/spree/api/responders/rabl_template.rb +1 -1
- data/lib/spree/api/testing_support/caching.rb +2 -2
- data/spree_api.gemspec +2 -1
- metadata +24 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c5380421d3a8bd6b3439c2f1d67c775833542372f62fab29a0be899e979af933
|
4
|
+
data.tar.gz: c8da5d0ac52a90566eb1134df43c8d2bc2e2a99a741f4c8d435f03342b855584
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ecb91a007f31c596dee6b1c5e3d6d4d51e7bf51bff8e9fe315e6f93007770467fe8d214de7b6236d549f4eff2943e8d598cc4ed068706802acc014ab58753dd
|
7
|
+
data.tar.gz: a7d3d4a8131bc7f811639f291df3565a5631fcf27d54a7114a6c558405a9ecb42dbfdf781e486d7be52dca5496849b84815123dd0ca3cca8df6982c73679da12
|
data/Gemfile
CHANGED
@@ -25,7 +25,7 @@ module Spree
|
|
25
25
|
|
26
26
|
def map_nested_attributes_keys(klass, attributes)
|
27
27
|
nested_keys = klass.nested_attributes_options.keys
|
28
|
-
attributes.inject({}) do |h, (k,v)|
|
28
|
+
attributes.to_h.inject({}) do |h, (k,v)|
|
29
29
|
key = nested_keys.include?(k.to_sym) ? "#{k}_attributes" : k
|
30
30
|
h[key] = v
|
31
31
|
h
|
@@ -64,9 +64,9 @@ module Spree
|
|
64
64
|
return if @current_api_user
|
65
65
|
|
66
66
|
if requires_authentication? && api_key.blank? && order_token.blank?
|
67
|
-
render "spree/api/errors/must_specify_api_key", status: 401 and return
|
67
|
+
render "spree/api/errors/must_specify_api_key", status: 401, layout: false and return
|
68
68
|
elsif order_token.blank? && (requires_authentication? || api_key.present?)
|
69
|
-
render "spree/api/errors/invalid_api_key", status: 401 and return
|
69
|
+
render "spree/api/errors/invalid_api_key", status: 401, layout: false and return
|
70
70
|
else
|
71
71
|
# An anonymous user
|
72
72
|
@current_api_user = Spree.user_class.new
|
@@ -89,7 +89,7 @@ module Spree
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def unprocessable_entity(message)
|
92
|
-
render
|
92
|
+
render plain: { exception: message }.to_json, status: 422
|
93
93
|
end
|
94
94
|
|
95
95
|
def gateway_error(exception)
|
@@ -102,7 +102,7 @@ module Spree
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def not_found
|
105
|
-
render "spree/api/errors/not_found", status: 404 and return
|
105
|
+
render "spree/api/errors/not_found", status: 404, layout: false and return
|
106
106
|
end
|
107
107
|
|
108
108
|
def current_ability
|
@@ -15,7 +15,7 @@ module Spree
|
|
15
15
|
inventory_unit.transaction do
|
16
16
|
if inventory_unit.update_attributes(inventory_unit_params)
|
17
17
|
fire
|
18
|
-
render :show, :
|
18
|
+
render :show, status: 200
|
19
19
|
else
|
20
20
|
invalid_resource!(inventory_unit)
|
21
21
|
end
|
@@ -35,8 +35,8 @@ module Spree
|
|
35
35
|
|
36
36
|
unless inventory_unit.respond_to?(can_event) &&
|
37
37
|
inventory_unit.send(can_event)
|
38
|
-
render :
|
39
|
-
:
|
38
|
+
render plain: { exception: "cannot transition to #{@event}" }.to_json,
|
39
|
+
status: 200
|
40
40
|
false
|
41
41
|
end
|
42
42
|
end
|
@@ -3,11 +3,17 @@ module Spree
|
|
3
3
|
module V1
|
4
4
|
class OptionTypesController < Spree::Api::BaseController
|
5
5
|
def index
|
6
|
-
if params[:ids]
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
@option_types = if params[:ids]
|
7
|
+
Spree::OptionType.
|
8
|
+
includes(:option_values).
|
9
|
+
accessible_by(current_ability, :read).
|
10
|
+
where(id: params[:ids].split(','))
|
11
|
+
else
|
12
|
+
Spree::OptionType.
|
13
|
+
includes(:option_values).
|
14
|
+
accessible_by(current_ability, :read).
|
15
|
+
load.ransack(params[:q]).result
|
16
|
+
end
|
11
17
|
respond_with(@option_types)
|
12
18
|
end
|
13
19
|
|
@@ -16,11 +22,14 @@ module Spree
|
|
16
22
|
respond_with(@option_type)
|
17
23
|
end
|
18
24
|
|
25
|
+
def new
|
26
|
+
end
|
27
|
+
|
19
28
|
def create
|
20
29
|
authorize! :create, Spree::OptionType
|
21
30
|
@option_type = Spree::OptionType.new(option_type_params)
|
22
31
|
if @option_type.save
|
23
|
-
render :show, :
|
32
|
+
render :show, status: 201
|
24
33
|
else
|
25
34
|
invalid_resource!(@option_type)
|
26
35
|
end
|
@@ -38,7 +47,7 @@ module Spree
|
|
38
47
|
def destroy
|
39
48
|
@option_type = Spree::OptionType.accessible_by(current_ability, :destroy).find(params[:id])
|
40
49
|
@option_type.destroy
|
41
|
-
render :
|
50
|
+
render plain: nil, status: 204
|
42
51
|
end
|
43
52
|
|
44
53
|
private
|
@@ -4,7 +4,7 @@ module Spree
|
|
4
4
|
class OptionValuesController < Spree::Api::BaseController
|
5
5
|
def index
|
6
6
|
if params[:ids]
|
7
|
-
@option_values = scope.where(:
|
7
|
+
@option_values = scope.where(id: params[:ids])
|
8
8
|
else
|
9
9
|
@option_values = scope.ransack(params[:q]).result.distinct
|
10
10
|
end
|
@@ -16,11 +16,14 @@ module Spree
|
|
16
16
|
respond_with(@option_value)
|
17
17
|
end
|
18
18
|
|
19
|
+
def new
|
20
|
+
end
|
21
|
+
|
19
22
|
def create
|
20
23
|
authorize! :create, Spree::OptionValue
|
21
24
|
@option_value = scope.new(option_value_params)
|
22
25
|
if @option_value.save
|
23
|
-
render :show, :
|
26
|
+
render :show, status: 201
|
24
27
|
else
|
25
28
|
invalid_resource!(@option_value)
|
26
29
|
end
|
@@ -38,7 +41,7 @@ module Spree
|
|
38
41
|
def destroy
|
39
42
|
@option_value = scope.accessible_by(current_ability, :destroy).find(params[:id])
|
40
43
|
@option_value.destroy
|
41
|
-
render :
|
44
|
+
render plain: nil, status: 204
|
42
45
|
end
|
43
46
|
|
44
47
|
private
|
@@ -11,14 +11,14 @@ module Spree
|
|
11
11
|
end
|
12
12
|
|
13
13
|
@products = @products.distinct.page(params[:page]).per(params[:per_page])
|
14
|
-
expires_in 15.minutes, :
|
14
|
+
expires_in 15.minutes, public: true
|
15
15
|
headers['Surrogate-Control'] = "max-age=#{15.minutes}"
|
16
16
|
respond_with(@products)
|
17
17
|
end
|
18
18
|
|
19
19
|
def show
|
20
20
|
@product = find_product(params[:id])
|
21
|
-
expires_in 15.minutes, :
|
21
|
+
expires_in 15.minutes, public: true
|
22
22
|
headers['Surrogate-Control'] = "max-age=#{15.minutes}"
|
23
23
|
headers['Surrogate-Key'] = "product_id=1"
|
24
24
|
respond_with(@product)
|
@@ -57,6 +57,9 @@ module Spree
|
|
57
57
|
# shipping_category: "Free Shipping Items"
|
58
58
|
# }
|
59
59
|
#
|
60
|
+
def new
|
61
|
+
end
|
62
|
+
|
60
63
|
def create
|
61
64
|
authorize! :create, Product
|
62
65
|
params[:product][:available_on] ||= Time.current
|
@@ -66,7 +69,7 @@ module Spree
|
|
66
69
|
@product = Core::Importer::Product.new(nil, product_params, options).create
|
67
70
|
|
68
71
|
if @product.persisted?
|
69
|
-
respond_with(@product, :
|
72
|
+
respond_with(@product, status: 201, default_template: :show)
|
70
73
|
else
|
71
74
|
invalid_resource!(@product)
|
72
75
|
end
|
@@ -80,7 +83,7 @@ module Spree
|
|
80
83
|
@product = Core::Importer::Product.new(@product, product_params, options).update
|
81
84
|
|
82
85
|
if @product.errors.empty?
|
83
|
-
respond_with(@product.reload, :
|
86
|
+
respond_with(@product.reload, status: 200, default_template: :show)
|
84
87
|
else
|
85
88
|
invalid_resource!(@product)
|
86
89
|
end
|
@@ -90,7 +93,7 @@ module Spree
|
|
90
93
|
@product = find_product(params[:id])
|
91
94
|
authorize! :destroy, @product
|
92
95
|
@product.destroy
|
93
|
-
respond_with(@product, :
|
96
|
+
respond_with(@product, status: 204)
|
94
97
|
end
|
95
98
|
|
96
99
|
private
|
@@ -6,14 +6,14 @@ module Spree
|
|
6
6
|
|
7
7
|
def index
|
8
8
|
@states = scope.ransack(params[:q]).result.includes(:country)
|
9
|
-
|
9
|
+
|
10
10
|
if params[:page] || params[:per_page]
|
11
11
|
@states = @states.page(params[:page]).per(params[:per_page])
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
state = @states.last
|
15
15
|
if stale?(state)
|
16
|
-
|
16
|
+
render :index, layout: false
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -64,7 +64,7 @@ module Spree
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def scope
|
67
|
-
includes = {:
|
67
|
+
includes = { variant: [{ option_values: :option_type }, :product] }
|
68
68
|
@stock_location.stock_items.accessible_by(current_ability, :read).includes(includes)
|
69
69
|
end
|
70
70
|
|
@@ -8,19 +8,23 @@ module Spree
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def show
|
11
|
-
|
11
|
+
@taxonomy ||= taxonomy
|
12
|
+
render :show, layout: false
|
12
13
|
end
|
13
14
|
|
14
|
-
# Because JSTree wants parameters in a *slightly* different format
|
15
15
|
def jstree
|
16
|
-
|
16
|
+
@taxonomy ||= taxonomy
|
17
|
+
render :jstree, layout: false
|
18
|
+
end
|
19
|
+
|
20
|
+
def new
|
17
21
|
end
|
18
22
|
|
19
23
|
def create
|
20
24
|
authorize! :create, Taxonomy
|
21
25
|
@taxonomy = Taxonomy.new(taxonomy_params)
|
22
26
|
if @taxonomy.save
|
23
|
-
respond_with(@taxonomy, :
|
27
|
+
respond_with(@taxonomy, status: 201, default_template: :show)
|
24
28
|
else
|
25
29
|
invalid_resource!(@taxonomy)
|
26
30
|
end
|
@@ -29,7 +33,7 @@ module Spree
|
|
29
33
|
def update
|
30
34
|
authorize! :update, taxonomy
|
31
35
|
if taxonomy.update_attributes(taxonomy_params)
|
32
|
-
respond_with(taxonomy, :
|
36
|
+
respond_with(taxonomy, status: 200, default_template: :show)
|
33
37
|
else
|
34
38
|
invalid_resource!(taxonomy)
|
35
39
|
end
|
@@ -38,13 +42,13 @@ module Spree
|
|
38
42
|
def destroy
|
39
43
|
authorize! :destroy, taxonomy
|
40
44
|
taxonomy.destroy
|
41
|
-
respond_with(taxonomy, :
|
45
|
+
respond_with(taxonomy, status: 204)
|
42
46
|
end
|
43
47
|
|
44
48
|
private
|
45
49
|
|
46
50
|
def taxonomies
|
47
|
-
@taxonomies = Taxonomy.accessible_by(current_ability, :read).order('name').includes(:
|
51
|
+
@taxonomies = Taxonomy.accessible_by(current_ability, :read).order('name').includes(root: :children).
|
48
52
|
ransack(params[:q]).result.
|
49
53
|
page(params[:page]).per(params[:per_page])
|
50
54
|
end
|
@@ -18,12 +18,16 @@ module Spree
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def show
|
21
|
-
@taxon
|
22
|
-
|
21
|
+
@taxon ||= taxonomy.taxons.accessible_by(current_ability, :read).find(params[:id])
|
22
|
+
render :show, layout: false
|
23
23
|
end
|
24
24
|
|
25
25
|
def jstree
|
26
|
-
|
26
|
+
@taxon ||= taxonomy.taxons.accessible_by(current_ability, :read).find(params[:id])
|
27
|
+
render :jstree, layout: false
|
28
|
+
end
|
29
|
+
|
30
|
+
def new
|
27
31
|
end
|
28
32
|
|
29
33
|
def create
|
@@ -33,7 +37,7 @@ module Spree
|
|
33
37
|
taxonomy = Spree::Taxonomy.find_by(id: params[:taxonomy_id])
|
34
38
|
|
35
39
|
if taxonomy.nil?
|
36
|
-
@taxon.errors
|
40
|
+
@taxon.errors.add(:taxonomy_id, I18n.t('spree.api.invalid_taxonomy_id'))
|
37
41
|
invalid_resource!(@taxon) and return
|
38
42
|
end
|
39
43
|
|
@@ -62,12 +66,11 @@ module Spree
|
|
62
66
|
end
|
63
67
|
|
64
68
|
def products
|
65
|
-
# Returns the products sorted by their position with the classification
|
66
|
-
# Products#index does not do the sorting.
|
67
69
|
taxon = Spree::Taxon.find(params[:id])
|
68
70
|
@products = taxon.products.ransack(params[:q]).result
|
69
71
|
@products = @products.page(params[:page]).per(params[:per_page] || 500)
|
70
|
-
|
72
|
+
|
73
|
+
render 'spree/api/v1/products/index', layout: false
|
71
74
|
end
|
72
75
|
|
73
76
|
private
|
@@ -7,6 +7,8 @@ module Spree
|
|
7
7
|
|
8
8
|
def index
|
9
9
|
@users = Spree.user_class.accessible_by(current_ability,:read).ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
|
10
|
+
expires_in 15.minutes, public: true
|
11
|
+
headers['Surrogate-Control'] = "max-age=#{15.minutes}"
|
10
12
|
respond_with(@users)
|
11
13
|
end
|
12
14
|
|
@@ -21,7 +23,7 @@ module Spree
|
|
21
23
|
authorize! :create, Spree.user_class
|
22
24
|
@user = Spree.user_class.new(user_params)
|
23
25
|
if @user.save
|
24
|
-
respond_with(@user, :
|
26
|
+
respond_with(@user, status: 201, default_template: :show)
|
25
27
|
else
|
26
28
|
invalid_resource!(@user)
|
27
29
|
end
|
@@ -30,7 +32,7 @@ module Spree
|
|
30
32
|
def update
|
31
33
|
authorize! :update, user
|
32
34
|
if user.update_attributes(user_params)
|
33
|
-
respond_with(user, :
|
35
|
+
respond_with(user, status: 200, default_template: :show)
|
34
36
|
else
|
35
37
|
invalid_resource!(user)
|
36
38
|
end
|
@@ -39,7 +41,7 @@ module Spree
|
|
39
41
|
def destroy
|
40
42
|
authorize! :destroy, user
|
41
43
|
user.destroy
|
42
|
-
respond_with(user, :
|
44
|
+
respond_with(user, status: 204)
|
43
45
|
end
|
44
46
|
|
45
47
|
private
|
@@ -7,7 +7,7 @@ module Spree
|
|
7
7
|
authorize! :create, Zone
|
8
8
|
@zone = Zone.new(map_nested_attributes_keys(Spree::Zone, zone_params))
|
9
9
|
if @zone.save
|
10
|
-
respond_with(@zone, :
|
10
|
+
respond_with(@zone, status: 201, default_template: :show)
|
11
11
|
else
|
12
12
|
invalid_resource!(@zone)
|
13
13
|
end
|
@@ -16,7 +16,7 @@ module Spree
|
|
16
16
|
def destroy
|
17
17
|
authorize! :destroy, zone
|
18
18
|
zone.destroy
|
19
|
-
respond_with(zone, :
|
19
|
+
respond_with(zone, status: 204)
|
20
20
|
end
|
21
21
|
|
22
22
|
def index
|
@@ -31,7 +31,7 @@ module Spree
|
|
31
31
|
def update
|
32
32
|
authorize! :update, zone
|
33
33
|
if zone.update_attributes(map_nested_attributes_keys(Spree::Zone, zone_params))
|
34
|
-
respond_with(zone, :
|
34
|
+
respond_with(zone, status: 200, default_template: :show)
|
35
35
|
else
|
36
36
|
invalid_resource!(zone)
|
37
37
|
end
|
@@ -29,7 +29,8 @@ module Spree
|
|
29
29
|
:stock_movement_attributes,
|
30
30
|
:stock_item_attributes,
|
31
31
|
:promotion_attributes,
|
32
|
-
:store_attributes
|
32
|
+
:store_attributes,
|
33
|
+
:tag_attributes
|
33
34
|
]
|
34
35
|
|
35
36
|
mattr_reader *ATTRIBUTES
|
@@ -98,7 +99,7 @@ module Spree
|
|
98
99
|
|
99
100
|
@@taxon_attributes = [
|
100
101
|
:id, :name, :pretty_name, :permalink, :parent_id,
|
101
|
-
:taxonomy_id
|
102
|
+
:taxonomy_id, :meta_title, :meta_description
|
102
103
|
]
|
103
104
|
|
104
105
|
@@inventory_unit_attributes = [
|
@@ -161,6 +162,8 @@ module Spree
|
|
161
162
|
:mail_from_address, :default_currency, :code, :default
|
162
163
|
]
|
163
164
|
|
165
|
+
@@tag_attributes = [:id, :name]
|
166
|
+
|
164
167
|
def variant_attributes
|
165
168
|
if @current_user_roles && @current_user_roles.include?("admin")
|
166
169
|
@@variant_attributes + [:cost_price]
|
@@ -1,2 +1,2 @@
|
|
1
1
|
object false
|
2
|
-
node(:error) { I18n.t(:invalid_api_key, :
|
2
|
+
node(:error) { I18n.t(:invalid_api_key, key: api_key, scope: "spree.api") }
|
@@ -1,2 +1,2 @@
|
|
1
1
|
object false
|
2
|
-
node(:error) { I18n.t(:must_specify_api_key, :
|
2
|
+
node(:error) { I18n.t(:must_specify_api_key, scope: "spree.api") }
|
@@ -1,2 +1,2 @@
|
|
1
1
|
object false
|
2
|
-
node(:error) { I18n.t(:resource_not_found, :
|
2
|
+
node(:error) { I18n.t(:resource_not_found, scope: "spree.api") }
|
@@ -1,2 +1,2 @@
|
|
1
1
|
object false
|
2
|
-
node(:error) { I18n.t(:unauthorized, :
|
2
|
+
node(:error) { I18n.t(:unauthorized, scope: "spree.api") }
|
@@ -7,9 +7,9 @@ node(:total) { |li| li.total }
|
|
7
7
|
child :variant do
|
8
8
|
extends "spree/api/v1/variants/small"
|
9
9
|
attributes :product_id
|
10
|
-
child(:
|
10
|
+
child(images: :images) { extends "spree/api/v1/images/show" }
|
11
11
|
end
|
12
12
|
|
13
|
-
child :
|
13
|
+
child adjustments: :adjustments do
|
14
14
|
extends "spree/api/v1/adjustments/show"
|
15
15
|
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
object false
|
2
|
-
node(:errors) { [I18n.t(:invalid_shipping_method, :
|
2
|
+
node(:errors) { [I18n.t(:invalid_shipping_method, scope: "spree.api.order")] }
|
@@ -5,26 +5,26 @@ if lookup_context.find_all("spree/api/v1/orders/#{root_object.state}").present?
|
|
5
5
|
extends "spree/api/v1/orders/#{root_object.state}"
|
6
6
|
end
|
7
7
|
|
8
|
-
child :
|
8
|
+
child billing_address: :bill_address do
|
9
9
|
extends "spree/api/v1/addresses/show"
|
10
10
|
end
|
11
11
|
|
12
|
-
child :
|
12
|
+
child shipping_address: :ship_address do
|
13
13
|
extends "spree/api/v1/addresses/show"
|
14
14
|
end
|
15
15
|
|
16
|
-
child :
|
16
|
+
child line_items: :line_items do
|
17
17
|
extends "spree/api/v1/line_items/show"
|
18
18
|
end
|
19
19
|
|
20
|
-
child :
|
20
|
+
child payments: :payments do
|
21
21
|
attributes *payment_attributes
|
22
22
|
|
23
|
-
child :
|
23
|
+
child payment_method: :payment_method do
|
24
24
|
attributes :id, :name
|
25
25
|
end
|
26
26
|
|
27
|
-
child :
|
27
|
+
child source: :source do
|
28
28
|
if @current_user_roles.include?('admin')
|
29
29
|
attributes *payment_source_attributes + [:gateway_customer_profile_id, :gateway_payment_profile_id]
|
30
30
|
else
|
@@ -33,11 +33,11 @@ child :payments => :payments do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
child :
|
36
|
+
child shipments: :shipments do
|
37
37
|
extends "spree/api/v1/shipments/small"
|
38
38
|
end
|
39
39
|
|
40
|
-
child :
|
40
|
+
child adjustments: :adjustments do
|
41
41
|
extends "spree/api/v1/adjustments/show"
|
42
42
|
end
|
43
43
|
|
@@ -46,6 +46,6 @@ node :permissions do
|
|
46
46
|
{ can_update: current_ability.can?(:update, root_object) }
|
47
47
|
end
|
48
48
|
|
49
|
-
child :
|
49
|
+
child valid_credit_cards: :credit_cards do
|
50
50
|
extends "spree/api/v1/credit_cards/show"
|
51
51
|
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
object false
|
2
|
-
node(:error) { I18n.t(:credit_over_limit, :
|
2
|
+
node(:error) { I18n.t(:credit_over_limit, limit: @payment.credit_allowed, scope: 'spree.api.payment') }
|
@@ -1,2 +1,2 @@
|
|
1
1
|
object false
|
2
|
-
node(:error) { I18n.t(:update_forbidden, :
|
2
|
+
node(:error) { I18n.t(:update_forbidden, state: @payment.state, scope: 'spree.api.payment') }
|
@@ -7,23 +7,23 @@ node(:display_price) { |p| p.display_price.to_s }
|
|
7
7
|
node(:has_variants) { |p| p.has_variants? }
|
8
8
|
node(:taxon_ids) { |p| p.taxon_ids }
|
9
9
|
|
10
|
-
child :
|
10
|
+
child master: :master do
|
11
11
|
extends "spree/api/v1/variants/small"
|
12
12
|
end
|
13
13
|
|
14
|
-
child :
|
14
|
+
child variants: :variants do
|
15
15
|
extends "spree/api/v1/variants/small"
|
16
16
|
end
|
17
17
|
|
18
|
-
child :
|
18
|
+
child option_types: :option_types do
|
19
19
|
attributes *option_type_attributes
|
20
20
|
end
|
21
21
|
|
22
|
-
child :
|
22
|
+
child product_properties: :product_properties do
|
23
23
|
attributes *product_property_attributes
|
24
24
|
end
|
25
25
|
|
26
|
-
child :
|
26
|
+
child classifications: :classifications do
|
27
27
|
attributes :taxon_id, :position
|
28
28
|
|
29
29
|
child(:taxon) do
|
@@ -1,2 +1,2 @@
|
|
1
1
|
object false
|
2
|
-
node(:error) { I18n.t(:cannot_ready, :
|
2
|
+
node(:error) { I18n.t(:cannot_ready, scope: "spree.api.shipment") }
|
@@ -4,27 +4,27 @@ attributes *shipment_attributes
|
|
4
4
|
node(:order_id) { |shipment| shipment.order.number }
|
5
5
|
node(:stock_location_name) { |shipment| shipment.stock_location.name }
|
6
6
|
|
7
|
-
child :
|
7
|
+
child shipping_rates: :shipping_rates do
|
8
8
|
extends "spree/api/v1/shipping_rates/show"
|
9
9
|
end
|
10
10
|
|
11
|
-
child :
|
11
|
+
child selected_shipping_rate: :selected_shipping_rate do
|
12
12
|
extends "spree/api/v1/shipping_rates/show"
|
13
13
|
end
|
14
14
|
|
15
|
-
child :
|
15
|
+
child shipping_methods: :shipping_methods do
|
16
16
|
attributes :id, :name
|
17
|
-
child :
|
17
|
+
child zones: :zones do
|
18
18
|
attributes :id, :name, :description
|
19
19
|
end
|
20
20
|
|
21
|
-
child :
|
21
|
+
child shipping_categories: :shipping_categories do
|
22
22
|
attributes :id, :name
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
child :
|
27
|
-
child :
|
26
|
+
child manifest: :manifest do
|
27
|
+
child variant: :variant do
|
28
28
|
extends "spree/api/v1/variants/small"
|
29
29
|
end
|
30
30
|
node(:quantity) { |m| m.quantity }
|
@@ -5,33 +5,33 @@ attributes *shipment_attributes
|
|
5
5
|
node(:order_id) { |shipment| shipment.order.number }
|
6
6
|
node(:stock_location_name) { |shipment| shipment.stock_location.name }
|
7
7
|
|
8
|
-
child :
|
8
|
+
child shipping_rates: :shipping_rates do
|
9
9
|
extends "spree/api/v1/shipping_rates/show"
|
10
10
|
end
|
11
11
|
|
12
|
-
child :
|
12
|
+
child selected_shipping_rate: :selected_shipping_rate do
|
13
13
|
extends "spree/api/v1/shipping_rates/show"
|
14
14
|
end
|
15
15
|
|
16
|
-
child :
|
16
|
+
child shipping_methods: :shipping_methods do
|
17
17
|
attributes :id, :code, :name
|
18
|
-
child :
|
18
|
+
child zones: :zones do
|
19
19
|
attributes :id, :name, :description
|
20
20
|
end
|
21
21
|
|
22
|
-
child :
|
22
|
+
child shipping_categories: :shipping_categories do
|
23
23
|
attributes :id, :name
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
child :
|
27
|
+
child manifest: :manifest do
|
28
28
|
glue(:variant) do
|
29
|
-
attribute :
|
29
|
+
attribute id: :variant_id
|
30
30
|
end
|
31
31
|
node(:quantity) { |m| m.quantity }
|
32
32
|
node(:states) { |m| m.states }
|
33
33
|
end
|
34
34
|
|
35
|
-
child :
|
35
|
+
child adjustments: :adjustments do
|
36
36
|
extends "spree/api/v1/adjustments/show"
|
37
37
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
collection @taxon.children, :
|
1
|
+
collection @taxon.children, object_root: false
|
2
2
|
node(:data) { |taxon| taxon.name }
|
3
3
|
node(:attr) do |taxon|
|
4
|
-
{ :
|
5
|
-
:
|
4
|
+
{ id: taxon.id,
|
5
|
+
name: taxon.name
|
6
6
|
}
|
7
7
|
end
|
8
8
|
node(:state) { "closed" }
|
@@ -1,10 +1,11 @@
|
|
1
1
|
object @user
|
2
|
+
cache [I18n.locale, root_object]
|
2
3
|
|
3
4
|
attributes *user_attributes
|
4
|
-
child(:
|
5
|
+
child(bill_address: :bill_address) do
|
5
6
|
extends "spree/api/v1/addresses/show"
|
6
7
|
end
|
7
8
|
|
8
|
-
child(:
|
9
|
+
child(ship_address: :ship_address) do
|
9
10
|
extends "spree/api/v1/addresses/show"
|
10
11
|
end
|
@@ -4,11 +4,11 @@ cache [I18n.locale, @current_user_roles.include?('admin'), 'big_variant', root_o
|
|
4
4
|
|
5
5
|
extends "spree/api/v1/variants/small"
|
6
6
|
|
7
|
-
child(:
|
7
|
+
child(stock_items: :stock_items) do
|
8
8
|
attributes :id, :count_on_hand, :stock_location_id, :backorderable
|
9
|
-
attribute
|
9
|
+
attribute available?: :available
|
10
10
|
|
11
11
|
glue(:stock_location) do
|
12
|
-
attribute :
|
12
|
+
attribute name: :stock_location_name
|
13
13
|
end
|
14
14
|
end
|
@@ -7,11 +7,12 @@ node(:options_text) { |v| v.options_text }
|
|
7
7
|
node(:track_inventory) { |v| v.should_track_inventory? }
|
8
8
|
node(:in_stock) { |v| v.in_stock? }
|
9
9
|
node(:is_backorderable) { |v| v.is_backorderable? }
|
10
|
+
node(:is_orderable) { |v| v.is_backorderable? || v.in_stock? }
|
10
11
|
node(:total_on_hand) { |v| v.total_on_hand }
|
11
12
|
node(:is_destroyed) { |v| v.destroyed? }
|
12
13
|
|
13
|
-
child :
|
14
|
+
child option_values: :option_values do
|
14
15
|
attributes *option_value_attributes
|
15
16
|
end
|
16
17
|
|
17
|
-
child(:
|
18
|
+
child(images: :images) { extends "spree/api/v1/images/show" }
|
data/lib/spree/api/engine.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rails/engine'
|
2
|
+
require 'versioncake'
|
2
3
|
|
3
4
|
module Spree
|
4
5
|
module Api
|
@@ -16,7 +17,18 @@ module Spree
|
|
16
17
|
config.json_engine = ActiveSupport::JSON
|
17
18
|
end
|
18
19
|
|
19
|
-
initializer "spree.api.
|
20
|
+
initializer "spree.api.versioncake" do |_app|
|
21
|
+
VersionCake.setup do |config|
|
22
|
+
config.resources do |r|
|
23
|
+
r.resource %r{.*}, [], [], [1]
|
24
|
+
end
|
25
|
+
|
26
|
+
config.missing_version = 1
|
27
|
+
config.extraction_strategy = :http_header
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
initializer "spree.api.environment", before: :load_config_initializers do |app|
|
20
32
|
Spree::Api::Config = Spree::ApiConfiguration.new
|
21
33
|
end
|
22
34
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
RSpec.configure do |config|
|
2
|
-
config.before(:each, :
|
2
|
+
config.before(:each, caching: true) do
|
3
3
|
ActionController::Base.perform_caching = true
|
4
4
|
end
|
5
5
|
|
6
|
-
config.after(:each, :
|
6
|
+
config.after(:each, caching: true) do
|
7
7
|
ActionController::Base.perform_caching = false
|
8
8
|
Rails.cache.clear
|
9
9
|
end
|
data/spree_api.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goca-spree-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.14.rails.5.0
|
4
|
+
version: 3.1.14.rails.5.2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bigg
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: goca-spree-core
|
@@ -16,28 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.1.14.rails.5.0
|
19
|
+
version: 3.1.14.rails.5.2.8.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.1.14.rails.5.0
|
26
|
+
version: 3.1.14.rails.5.2.8.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rabl
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.13.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.13.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: versioncake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.2.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.2.0
|
41
55
|
description: Spree's API
|
42
56
|
email:
|
43
57
|
- ryan@spreecommerce.com
|
@@ -198,7 +212,7 @@ homepage: https://spreecommerce.com
|
|
198
212
|
licenses:
|
199
213
|
- BSD-3
|
200
214
|
metadata: {}
|
201
|
-
post_install_message:
|
215
|
+
post_install_message:
|
202
216
|
rdoc_options: []
|
203
217
|
require_paths:
|
204
218
|
- lib
|
@@ -213,9 +227,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
227
|
- !ruby/object:Gem::Version
|
214
228
|
version: 1.3.1
|
215
229
|
requirements: []
|
216
|
-
|
217
|
-
|
218
|
-
signing_key:
|
230
|
+
rubygems_version: 3.2.3
|
231
|
+
signing_key:
|
219
232
|
specification_version: 4
|
220
233
|
summary: Spree's API
|
221
234
|
test_files: []
|