spree_api 4.2.4 → 4.3.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +14 -1
- data/app/controllers/concerns/spree/api/v2/caching.rb +33 -0
- data/app/controllers/concerns/spree/api/v2/product_list_includes.rb +23 -0
- data/app/controllers/spree/api/v1/classifications_controller.rb +4 -3
- data/app/controllers/spree/api/v1/orders_controller.rb +5 -1
- data/app/controllers/spree/api/v1/products_controller.rb +2 -2
- data/app/controllers/spree/api/v1/taxonomies_controller.rb +1 -1
- data/app/controllers/spree/api/v2/base_controller.rb +31 -6
- data/app/controllers/spree/api/v2/platform/addresses_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/classifications_controller.rb +43 -0
- data/app/controllers/spree/api/v2/platform/cms_pages_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/cms_sections_controller.rb +34 -0
- data/app/controllers/spree/api/v2/platform/countries_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/menu_items_controller.rb +35 -0
- data/app/controllers/spree/api/v2/platform/menus_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/option_types_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/option_values_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/products_controller.rb +33 -0
- data/app/controllers/spree/api/v2/platform/resource_controller.rb +115 -0
- data/app/controllers/spree/api/v2/platform/taxons_controller.rb +30 -0
- data/app/controllers/spree/api/v2/platform/users_controller.rb +28 -0
- data/app/controllers/spree/api/v2/resource_controller.rb +24 -7
- data/app/controllers/spree/api/v2/storefront/account/addresses_controller.rb +2 -14
- data/app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb +13 -11
- data/app/controllers/spree/api/v2/storefront/account/orders_controller.rb +6 -2
- data/app/controllers/spree/api/v2/storefront/account_controller.rb +32 -1
- data/app/controllers/spree/api/v2/storefront/cart_controller.rb +28 -6
- data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +2 -1
- data/app/controllers/spree/api/v2/storefront/cms_pages_controller.rb +41 -0
- data/app/controllers/spree/api/v2/storefront/countries_controller.rb +16 -14
- data/app/controllers/spree/api/v2/storefront/menus_controller.rb +35 -0
- data/app/controllers/spree/api/v2/storefront/order_status_controller.rb +1 -1
- data/app/controllers/spree/api/v2/storefront/products_controller.rb +10 -12
- data/app/controllers/spree/api/v2/storefront/stores_controller.rb +1 -1
- data/app/controllers/spree/api/v2/storefront/taxons_controller.rb +7 -8
- data/app/helpers/spree/api/v2/display_money_helper.rb +2 -2
- data/app/models/spree/api_configuration.rb +4 -1
- data/app/models/spree/api_dependencies.rb +20 -5
- data/app/serializers/concerns/spree/api/v2/image_transformation_concern.rb +15 -0
- data/app/serializers/concerns/spree/api/v2/resource_serializer_concern.rb +16 -0
- data/app/serializers/concerns/spree/api/v2/taxon_image_transformation_concern.rb +15 -0
- data/app/serializers/spree/api/v2/base_serializer.rb +32 -0
- data/app/serializers/spree/api/v2/platform/address_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/base_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/classification_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/cms_page_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/cms_section_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/country_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/icon_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/image_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/menu_item_serializer.rb +45 -0
- data/app/serializers/spree/api/v2/platform/menu_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/option_type_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/option_value_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/product_property_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/product_serializer.rb +78 -0
- data/app/serializers/spree/api/v2/platform/state_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/stock_item_serializer.rb +20 -0
- data/app/serializers/spree/api/v2/platform/stock_location_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/store_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/tax_category_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/taxon_image_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/taxon_serializer.rb +38 -0
- data/app/serializers/spree/api/v2/platform/taxonomy_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/user_serializer.rb +37 -0
- data/app/serializers/spree/api/v2/platform/variant_serializer.rb +57 -0
- data/app/serializers/spree/v2/storefront/base_serializer.rb +3 -2
- data/app/serializers/spree/v2/storefront/cms_page_serializer.rb +14 -0
- data/app/serializers/spree/v2/storefront/cms_section_serializer.rb +28 -0
- data/app/serializers/spree/v2/storefront/country_serializer.rb +4 -4
- data/app/serializers/spree/v2/storefront/estimated_shipping_rate_serializer.rb +2 -0
- data/app/serializers/spree/v2/storefront/icon_serializer.rb +14 -0
- data/app/serializers/spree/v2/storefront/image_serializer.rb +3 -1
- data/app/serializers/spree/v2/storefront/menu_item_serializer.rb +43 -0
- data/app/serializers/spree/v2/storefront/menu_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/payment_method_serializer.rb +4 -0
- data/app/serializers/spree/v2/storefront/product_property_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/product_serializer.rb +21 -12
- data/app/serializers/spree/v2/storefront/store_serializer.rb +10 -0
- data/app/serializers/spree/v2/storefront/taxon_image_serializer.rb +3 -1
- data/app/serializers/spree/v2/storefront/taxon_serializer.rb +6 -5
- data/config/initializers/doorkeeper.rb +8 -1
- data/config/initializers/rabl.rb +9 -0
- data/config/locales/en.yml +1 -1
- data/config/routes.rb +115 -3
- data/db/migrate/20210727102516_change_integer_id_columns_type.rb +9 -0
- data/docs/oauth/index.yml +4 -4
- data/docs/v2/platform/index.yaml +3597 -0
- data/docs/v2/storefront/index.yaml +12117 -1610
- data/lib/spree/api/engine.rb +6 -17
- data/lib/spree/api/testing_support/v2/base.rb +1 -1
- data/lib/spree/api/testing_support/v2/platform_contexts.rb +214 -0
- data/lib/spree/api/testing_support/v2/serializers_params.rb +14 -0
- data/lib/spree/api.rb +1 -0
- data/spree_api.gemspec +6 -3
- metadata +114 -13
- data/app/assets/javascripts/spree/api/main.js +0 -36
- data/app/assets/javascripts/spree/api/storefront/cart.js +0 -49
@@ -1,36 +0,0 @@
|
|
1
|
-
//= require spree
|
2
|
-
|
3
|
-
var SpreeAPI = {
|
4
|
-
oauthToken: null, // user Bearer token to authorize operations for the given user
|
5
|
-
orderToken: null // order token to authorize operations on current order (cart)
|
6
|
-
}
|
7
|
-
|
8
|
-
SpreeAPI.Storefront = {}
|
9
|
-
SpreeAPI.Platform = {}
|
10
|
-
|
11
|
-
// API routes
|
12
|
-
Spree.routes.api_v2_storefront_cart_create = Spree.pathFor('api/v2/storefront/cart')
|
13
|
-
Spree.routes.api_v2_storefront_cart_add_item = Spree.pathFor('api/v2/storefront/cart/add_item')
|
14
|
-
Spree.routes.api_v2_storefront_cart_apply_coupon_code = Spree.pathFor('api/v2/storefront/cart/apply_coupon_code')
|
15
|
-
|
16
|
-
// helpers
|
17
|
-
SpreeAPI.handle500error = function () {
|
18
|
-
alert('Internal Server Error')
|
19
|
-
}
|
20
|
-
|
21
|
-
SpreeAPI.prepareHeaders = function (headers) {
|
22
|
-
if (typeof headers === 'undefined') {
|
23
|
-
headers = {}
|
24
|
-
}
|
25
|
-
|
26
|
-
// if signed in we need to pass the Bearer authorization token
|
27
|
-
// so backend will recognize that actions are authorized in scope of this user
|
28
|
-
if (SpreeAPI.oauthToken) {
|
29
|
-
headers['Authorization'] = 'Bearer ' + SpreeAPI.oauthToken
|
30
|
-
}
|
31
|
-
|
32
|
-
// default headers, required for POST/PATCH/DELETE requests
|
33
|
-
headers['Accept'] = 'application/json'
|
34
|
-
headers['Content-Type'] = 'application/json'
|
35
|
-
return headers
|
36
|
-
}
|
@@ -1,49 +0,0 @@
|
|
1
|
-
//= require spree/api/main
|
2
|
-
|
3
|
-
SpreeAPI.Storefront.createCart = function (successCallback, failureCallback) {
|
4
|
-
fetch(Spree.routes.api_v2_storefront_cart_create, {
|
5
|
-
method: 'POST',
|
6
|
-
headers: SpreeAPI.prepareHeaders()
|
7
|
-
}).then(function (response) {
|
8
|
-
switch (response.status) {
|
9
|
-
case 422:
|
10
|
-
response.json().then(function (json) { failureCallback(json.error) })
|
11
|
-
break
|
12
|
-
case 500:
|
13
|
-
SpreeAPI.handle500error()
|
14
|
-
break
|
15
|
-
case 201:
|
16
|
-
response.json().then(function (json) {
|
17
|
-
SpreeAPI.orderToken = json.data.attributes.token
|
18
|
-
successCallback()
|
19
|
-
})
|
20
|
-
break
|
21
|
-
}
|
22
|
-
})
|
23
|
-
}
|
24
|
-
|
25
|
-
SpreeAPI.Storefront.addToCart = function (variantId, quantity, options, successCallback, failureCallback) {
|
26
|
-
fetch(Spree.routes.api_v2_storefront_cart_add_item, {
|
27
|
-
method: 'POST',
|
28
|
-
headers: SpreeAPI.prepareHeaders({ 'X-Spree-Order-Token': SpreeAPI.orderToken }),
|
29
|
-
body: JSON.stringify({
|
30
|
-
variant_id: variantId,
|
31
|
-
quantity: quantity,
|
32
|
-
options: options
|
33
|
-
})
|
34
|
-
}).then(function (response) {
|
35
|
-
switch (response.status) {
|
36
|
-
case 422:
|
37
|
-
response.json().then(function (json) { failureCallback(json.error) })
|
38
|
-
break
|
39
|
-
case 500:
|
40
|
-
SpreeAPI.handle500error()
|
41
|
-
break
|
42
|
-
case 200:
|
43
|
-
response.json().then(function (json) {
|
44
|
-
successCallback(json.data)
|
45
|
-
})
|
46
|
-
break
|
47
|
-
}
|
48
|
-
})
|
49
|
-
}
|