spree_legacy_api_v2 1.0.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/README.md +47 -0
- data/Rakefile +23 -0
- data/app/controllers/concerns/spree/api/v2/caching.rb +40 -0
- data/app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb +29 -0
- data/app/controllers/concerns/spree/api/v2/number_resource.rb +11 -0
- data/app/controllers/concerns/spree/api/v2/platform/nested_set_reposition_concern.rb +37 -0
- data/app/controllers/concerns/spree/api/v2/platform/promotion_calculator_params.rb +17 -0
- data/app/controllers/concerns/spree/api/v2/platform/promotion_rule_params.rb +16 -0
- data/app/controllers/concerns/spree/api/v2/product_list_includes.rb +21 -0
- data/app/controllers/concerns/spree/api/v2/storefront/metadata_controller_concern.rb +18 -0
- data/app/controllers/concerns/spree/api/v2/storefront/order_concern.rb +49 -0
- data/app/controllers/spree/admin/oauth_applications_controller.rb +23 -0
- data/app/controllers/spree/api/v2/base_controller.rb +233 -0
- data/app/controllers/spree/api/v2/data_feeds/google_controller.rb +24 -0
- data/app/controllers/spree/api/v2/platform/addresses_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/adjustments_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/classifications_controller.rb +26 -0
- data/app/controllers/spree/api/v2/platform/countries_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/data_feeds_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/digital_links_controller.rb +29 -0
- data/app/controllers/spree/api/v2/platform/digitals_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/gift_cards_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/line_items_controller.rb +63 -0
- data/app/controllers/spree/api/v2/platform/option_types_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/option_values_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/orders_controller.rb +167 -0
- data/app/controllers/spree/api/v2/platform/payment_methods_controller.rb +31 -0
- data/app/controllers/spree/api/v2/platform/payments_controller.rb +21 -0
- data/app/controllers/spree/api/v2/platform/products_controller.rb +41 -0
- data/app/controllers/spree/api/v2/platform/promotion_actions_controller.rb +34 -0
- data/app/controllers/spree/api/v2/platform/promotion_categories_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/promotion_rules_controller.rb +29 -0
- data/app/controllers/spree/api/v2/platform/promotions_controller.rb +35 -0
- data/app/controllers/spree/api/v2/platform/resource_controller.rb +154 -0
- data/app/controllers/spree/api/v2/platform/roles_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/shipments_controller.rb +147 -0
- data/app/controllers/spree/api/v2/platform/shipping_categories_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/shipping_methods_controller.rb +28 -0
- data/app/controllers/spree/api/v2/platform/states_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/stock_items_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/stock_locations_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/store_credit_categories_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/store_credit_types_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/store_credits_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/tax_categories_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/tax_rates_controller.rb +27 -0
- data/app/controllers/spree/api/v2/platform/taxonomies_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/taxons_controller.rb +59 -0
- data/app/controllers/spree/api/v2/platform/users_controller.rb +37 -0
- data/app/controllers/spree/api/v2/platform/variants_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/wished_items_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/wishlists_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/zones_controller.rb +23 -0
- data/app/controllers/spree/api/v2/resource_controller.rb +79 -0
- data/app/controllers/spree/api/v2/storefront/account/addresses_controller.rb +77 -0
- data/app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb +52 -0
- data/app/controllers/spree/api/v2/storefront/account/orders_controller.rb +50 -0
- data/app/controllers/spree/api/v2/storefront/account_controller.rb +52 -0
- data/app/controllers/spree/api/v2/storefront/cart_controller.rb +246 -0
- data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +183 -0
- data/app/controllers/spree/api/v2/storefront/countries_controller.rb +57 -0
- data/app/controllers/spree/api/v2/storefront/digitals_controller.rb +58 -0
- data/app/controllers/spree/api/v2/storefront/order_status_controller.rb +34 -0
- data/app/controllers/spree/api/v2/storefront/policies_controller.rb +31 -0
- data/app/controllers/spree/api/v2/storefront/post_categories_controller.rb +35 -0
- data/app/controllers/spree/api/v2/storefront/posts_controller.rb +51 -0
- data/app/controllers/spree/api/v2/storefront/products_controller.rb +66 -0
- data/app/controllers/spree/api/v2/storefront/stores_controller.rb +27 -0
- data/app/controllers/spree/api/v2/storefront/taxons_controller.rb +51 -0
- data/app/controllers/spree/api/v2/storefront/variants_controller.rb +41 -0
- data/app/controllers/spree/api/v2/storefront/wishlists_controller.rb +214 -0
- data/app/helpers/spree/api/v2/collection_options_helpers.rb +46 -0
- data/app/helpers/spree/api/v2/display_money_helper.rb +63 -0
- data/app/helpers/spree/api/v2/store_media_serializer_images_concern.rb +30 -0
- data/app/models/concerns/spree/user_api_authentication.rb +19 -0
- data/app/models/concerns/spree/user_api_methods.rb +7 -0
- data/app/models/spree/oauth_access_grant.rb +7 -0
- data/app/models/spree/oauth_access_token.rb +7 -0
- data/app/models/spree/oauth_application.rb +22 -0
- data/app/paginators/spree/api/paginate.rb +68 -0
- data/app/presenters/spree/api/products/filters_presenter.rb +39 -0
- data/app/serializers/concerns/spree/api/v2/image_transformation_concern.rb +15 -0
- data/app/serializers/concerns/spree/api/v2/public_metafields_concern.rb +15 -0
- data/app/serializers/concerns/spree/api/v2/resource_serializer_concern.rb +42 -0
- data/app/serializers/concerns/spree/api/v2/taxon_image_transformation_concern.rb +15 -0
- data/app/serializers/spree/api/v2/base_serializer.rb +43 -0
- data/app/serializers/spree/api/v2/platform/address_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/adjustment_serializer.rb +20 -0
- data/app/serializers/spree/api/v2/platform/admin_user_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/asset_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/base_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/calculator_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/classification_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/country_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/credit_card_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/customer_return_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/data_feed_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/digital_link_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/digital_serializer.rb +29 -0
- data/app/serializers/spree/api/v2/platform/gift_card_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/image_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/inventory_unit_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/line_item_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/log_entry_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/metafield_serializer.rb +21 -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/order_promotion_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/order_serializer.rb +31 -0
- data/app/serializers/spree/api/v2/platform/payment_capture_event_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/payment_method_serializer.rb +18 -0
- data/app/serializers/spree/api/v2/platform/payment_serializer.rb +22 -0
- data/app/serializers/spree/api/v2/platform/payment_source_serializer.rb +12 -0
- data/app/serializers/spree/api/v2/platform/price_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/product_property_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/product_serializer.rb +90 -0
- data/app/serializers/spree/api/v2/platform/promotion_action_line_item_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/promotion_action_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/promotion_category_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/promotion_rule_serializer.rb +21 -0
- data/app/serializers/spree/api/v2/platform/promotion_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/property_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/prototype_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/refund_reason_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/refund_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/reimbursement_credit_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/reimbursement_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/reimbursement_type_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/return_authorization_reason_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/return_authorization_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/return_item_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/role_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/shipment_serializer.rb +22 -0
- data/app/serializers/spree/api/v2/platform/shipping_category_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/shipping_method_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/shipping_rate_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/state_change_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/state_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/stock_item_serializer.rb +18 -0
- data/app/serializers/spree/api/v2/platform/stock_location_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/stock_movement_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/stock_transfer_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/store_credit_category_serializer.rb +12 -0
- data/app/serializers/spree/api/v2/platform/store_credit_event_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/store_credit_serializer.rb +18 -0
- data/app/serializers/spree/api/v2/platform/store_credit_type_serializer.rb +12 -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/tax_rate_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/taxon_image_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/taxon_serializer.rb +47 -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 +66 -0
- data/app/serializers/spree/api/v2/platform/wished_item_serializer.rb +29 -0
- data/app/serializers/spree/api/v2/platform/wishlist_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/zone_member_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/zone_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/address_serializer.rb +22 -0
- data/app/serializers/spree/v2/storefront/base_serializer.rb +10 -0
- data/app/serializers/spree/v2/storefront/cart_serializer.rb +67 -0
- data/app/serializers/spree/v2/storefront/country_serializer.rb +24 -0
- data/app/serializers/spree/v2/storefront/credit_card_serializer.rb +15 -0
- data/app/serializers/spree/v2/storefront/digital_link_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/estimated_shipping_rate_serializer.rb +35 -0
- data/app/serializers/spree/v2/storefront/gift_card_serializer.rb +16 -0
- data/app/serializers/spree/v2/storefront/image_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/line_item_serializer.rb +23 -0
- data/app/serializers/spree/v2/storefront/metafield_serializer.rb +19 -0
- data/app/serializers/spree/v2/storefront/option_type_serializer.rb +15 -0
- data/app/serializers/spree/v2/storefront/option_value_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/order_promotion_serializer.rb +14 -0
- data/app/serializers/spree/v2/storefront/order_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/payment_method_serializer.rb +17 -0
- data/app/serializers/spree/v2/storefront/payment_serializer.rb +20 -0
- data/app/serializers/spree/v2/storefront/payment_source_serializer.rb +12 -0
- data/app/serializers/spree/v2/storefront/policy_serializer.rb +19 -0
- data/app/serializers/spree/v2/storefront/post_category_serializer.rb +23 -0
- data/app/serializers/spree/v2/storefront/post_serializer.rb +51 -0
- data/app/serializers/spree/v2/storefront/product_property_serializer.rb +19 -0
- data/app/serializers/spree/v2/storefront/product_serializer.rb +92 -0
- data/app/serializers/spree/v2/storefront/shipment_serializer.rb +26 -0
- data/app/serializers/spree/v2/storefront/shipping_category_serializer.rb +10 -0
- data/app/serializers/spree/v2/storefront/shipping_method_serializer.rb +12 -0
- data/app/serializers/spree/v2/storefront/shipping_rate_serializer.rb +26 -0
- data/app/serializers/spree/v2/storefront/state_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/stock_location_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/store_credit_category_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/store_credit_event_serializer.rb +15 -0
- data/app/serializers/spree/v2/storefront/store_credit_serializer.rb +19 -0
- data/app/serializers/spree/v2/storefront/store_credit_type_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/store_serializer.rb +18 -0
- data/app/serializers/spree/v2/storefront/taxon_image_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/taxon_serializer.rb +55 -0
- data/app/serializers/spree/v2/storefront/taxonomy_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/user_serializer.rb +33 -0
- data/app/serializers/spree/v2/storefront/variant_serializer.rb +58 -0
- data/app/serializers/spree/v2/storefront/wished_item_serializer.rb +29 -0
- data/app/serializers/spree/v2/storefront/wishlist_serializer.rb +17 -0
- data/app/views/spree/admin/oauth_applications/_form.html.erb +6 -0
- data/app/views/spree/admin/oauth_applications/_table_header.html.erb +7 -0
- data/app/views/spree/admin/oauth_applications/_table_row.html.erb +34 -0
- data/app/views/spree/admin/oauth_applications/create.turbo_stream.erb +31 -0
- data/app/views/spree/admin/oauth_applications/edit.html.erb +1 -0
- data/app/views/spree/admin/oauth_applications/index.html.erb +21 -0
- data/app/views/spree/admin/oauth_applications/new.html.erb +1 -0
- data/config/initializers/doorkeeper.rb +50 -0
- data/config/initializers/json_api_mime_types.rb +8 -0
- data/config/initializers/user_class_extensions.rb +7 -0
- data/config/routes.rb +219 -0
- data/db/migrate/20100107141738_add_api_key_to_spree_users.rb +7 -0
- data/db/migrate/20120411123334_resize_api_key_field.rb +7 -0
- data/db/migrate/20120530054546_rename_api_key_to_spree_api_key.rb +7 -0
- data/db/migrate/20131017162334_add_index_to_user_spree_api_key.rb +7 -0
- data/db/migrate/20180320110726_create_doorkeeper_tables.rb +69 -0
- data/db/migrate/20210727102516_change_integer_id_columns_type.rb +9 -0
- data/db/migrate/20210919183228_enable_polymorphic_resource_owner.rb +21 -0
- data/lib/generators/spree_legacy_api_v2/install/install_generator.rb +23 -0
- data/lib/spree_legacy_api_v2/engine.rb +77 -0
- data/lib/spree_legacy_api_v2/testing_support/factories/oauth_application_factory.rb +7 -0
- data/lib/spree_legacy_api_v2/testing_support/factories.rb +1 -0
- data/lib/spree_legacy_api_v2/testing_support/serializers.rb +15 -0
- data/lib/spree_legacy_api_v2/testing_support/v2/base.rb +13 -0
- data/lib/spree_legacy_api_v2/testing_support/v2/current_order.rb +116 -0
- data/lib/spree_legacy_api_v2/testing_support/v2/platform_contexts.rb +272 -0
- data/lib/spree_legacy_api_v2/testing_support/v2/serializers_params.rb +16 -0
- data/lib/spree_legacy_api_v2/version.rb +9 -0
- data/lib/spree_legacy_api_v2.rb +7 -0
- metadata +359 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class CountriesController < ResourceController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def model_class
|
|
9
|
+
Spree::Country
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def scope_includes
|
|
13
|
+
[:states, :zones]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def resource_serializer
|
|
17
|
+
Spree.api.platform_country_serializer
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class DataFeedsController < ResourceController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def model_class
|
|
9
|
+
Spree::DataFeed
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def resource_serializer
|
|
13
|
+
Spree.api.platform_data_feed_serializer
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class DigitalLinksController < ResourceController
|
|
6
|
+
def reset
|
|
7
|
+
spree_authorize! :update, resource if spree_current_user.present?
|
|
8
|
+
|
|
9
|
+
if resource.reset!
|
|
10
|
+
render_serialized_payload { serialize_resource(resource) }
|
|
11
|
+
else
|
|
12
|
+
render_error_payload(resource.errors)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def model_class
|
|
19
|
+
Spree::DigitalLink
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def resource_serializer
|
|
23
|
+
Spree.api.platform_digital_link_serializer
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class DigitalsController < ResourceController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def model_class
|
|
9
|
+
Spree::Digital
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def spree_permitted_attributes
|
|
13
|
+
super + [:attachment]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def resource_serializer
|
|
17
|
+
Spree.api.platform_digital_serializer
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class GiftCardsController < ResourceController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def model_class
|
|
9
|
+
Spree::GiftCard
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def permitted_resource_params
|
|
13
|
+
params.require(:gift_card).permit(permitted_gift_card_attributes)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def resource_serializer
|
|
17
|
+
Spree.api.platform_gift_card_serializer
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class LineItemsController < ResourceController
|
|
6
|
+
def create
|
|
7
|
+
order = current_store.orders.find(permitted_resource_params[:order_id])
|
|
8
|
+
|
|
9
|
+
result = create_service.call(order: order, line_item_attributes: permitted_resource_params)
|
|
10
|
+
|
|
11
|
+
if result.success?
|
|
12
|
+
render_serialized_payload(201) { serialize_resource(result.value) }
|
|
13
|
+
else
|
|
14
|
+
render_error_payload(result.error)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def update
|
|
19
|
+
result = update_service.call(line_item: resource, line_item_attributes: permitted_resource_params)
|
|
20
|
+
|
|
21
|
+
if result.success?
|
|
22
|
+
render_serialized_payload { serialize_resource(result.value) }
|
|
23
|
+
else
|
|
24
|
+
render_error_payload(resource.errors)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def destroy
|
|
29
|
+
result = destroy_service.call(line_item: resource)
|
|
30
|
+
|
|
31
|
+
if result.success?
|
|
32
|
+
head 204
|
|
33
|
+
else
|
|
34
|
+
render_error_payload(result.error)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def model_class
|
|
41
|
+
Spree::LineItem
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def create_service
|
|
45
|
+
Spree.api.platform_line_item_create_service
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def update_service
|
|
49
|
+
Spree.api.platform_line_item_update_service
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def destroy_service
|
|
53
|
+
Spree.api.platform_line_item_destroy_service
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def resource_serializer
|
|
57
|
+
Spree.api.platform_line_item_serializer
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class OptionTypesController < ResourceController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def model_class
|
|
9
|
+
Spree::OptionType
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def resource_serializer
|
|
13
|
+
Spree.api.platform_option_type_serializer
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class OptionValuesController < ResourceController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def model_class
|
|
9
|
+
Spree::OptionValue
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def scope_includes
|
|
13
|
+
[:option_type]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def resource_serializer
|
|
17
|
+
Spree.api.platform_option_value_serializer
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class OrdersController < ResourceController
|
|
6
|
+
include CouponCodesHelper
|
|
7
|
+
include NumberResource
|
|
8
|
+
|
|
9
|
+
def create
|
|
10
|
+
resource = current_store.orders.new(permitted_resource_params)
|
|
11
|
+
|
|
12
|
+
if resource.save
|
|
13
|
+
render_serialized_payload(201) { serialize_resource(resource) }
|
|
14
|
+
else
|
|
15
|
+
render_error_payload(resource.errors)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def update
|
|
20
|
+
result = update_service.call(
|
|
21
|
+
order: resource,
|
|
22
|
+
params: params,
|
|
23
|
+
permitted_attributes: spree_permitted_attributes,
|
|
24
|
+
request_env: request.headers.env
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
render_result(result)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def next
|
|
31
|
+
result = next_service.call(order: resource)
|
|
32
|
+
|
|
33
|
+
render_result(result)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def advance
|
|
37
|
+
result = advance_service.call(order: resource)
|
|
38
|
+
|
|
39
|
+
render_result(result)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def complete
|
|
43
|
+
result = complete_service.call(order: resource)
|
|
44
|
+
|
|
45
|
+
render_result(result)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def empty
|
|
49
|
+
result = empty_service.call(order: resource)
|
|
50
|
+
|
|
51
|
+
render_result(result)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def cancel
|
|
55
|
+
result = cancel_service.call(order: resource, canceler: spree_current_user)
|
|
56
|
+
|
|
57
|
+
render_result(result)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def approve
|
|
61
|
+
result = approve_service.call(order: resource, approver: spree_current_user)
|
|
62
|
+
|
|
63
|
+
render_result(result)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def destroy
|
|
67
|
+
result = destroy_service.call(order: resource)
|
|
68
|
+
|
|
69
|
+
if result.success?
|
|
70
|
+
head 204
|
|
71
|
+
else
|
|
72
|
+
render_error_payload(result.error)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def apply_coupon_code
|
|
77
|
+
resource.coupon_code = params[:coupon_code]
|
|
78
|
+
result = coupon_handler.new(resource).apply
|
|
79
|
+
|
|
80
|
+
if result.error.blank?
|
|
81
|
+
render_serialized_payload { serialize_resource(resource.reload) }
|
|
82
|
+
else
|
|
83
|
+
render_error_payload(result.error)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def use_store_credit
|
|
88
|
+
result = use_store_credit_service.call(
|
|
89
|
+
order: resource,
|
|
90
|
+
amount: params[:amount].try(:to_f)
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
render_result(result)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
private
|
|
97
|
+
|
|
98
|
+
def model_class
|
|
99
|
+
Spree::Order
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def allowed_sort_attributes
|
|
103
|
+
super.push(:available_on, :make_active_at, :total, :payment_total, :item_total, :shipment_total,
|
|
104
|
+
:adjustment_total, :promo_total, :included_tax_total, :additional_tax_total,
|
|
105
|
+
:item_count, :tax_total, :completed_at)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def update_service
|
|
109
|
+
Spree.api.platform_order_update_service
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def next_service
|
|
113
|
+
Spree.api.platform_order_next_service
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def advance_service
|
|
117
|
+
Spree.api.platform_order_advance_service
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def use_store_credit_service
|
|
121
|
+
Spree.api.platform_order_use_store_credit_service
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def complete_service
|
|
125
|
+
Spree.api.platform_order_complete_service
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def empty_service
|
|
129
|
+
Spree.api.platform_order_empty_service
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def destroy_service
|
|
133
|
+
Spree.api.platform_order_destroy_service
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def approve_service
|
|
137
|
+
Spree.api.platform_order_approve_service
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def cancel_service
|
|
141
|
+
Spree.api.platform_order_cancel_service
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def coupon_handler
|
|
145
|
+
Spree.api.platform_coupon_handler
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def spree_permitted_attributes
|
|
149
|
+
super + [
|
|
150
|
+
bill_address_attributes: Spree::Address.json_api_permitted_attributes,
|
|
151
|
+
ship_address_attributes: Spree::Address.json_api_permitted_attributes,
|
|
152
|
+
line_items_attributes: Spree::LineItem.json_api_permitted_attributes,
|
|
153
|
+
payments_attributes: Spree::Payment.json_api_permitted_attributes + [
|
|
154
|
+
source_attributes: Spree::CreditCard.json_api_permitted_attributes
|
|
155
|
+
],
|
|
156
|
+
shipments_attributes: Spree::Shipment.json_api_permitted_attributes
|
|
157
|
+
]
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def resource_serializer
|
|
161
|
+
Spree.api.platform_order_serializer
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class PaymentMethodsController < ResourceController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def model_class
|
|
9
|
+
Spree::PaymentMethod
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def spree_permitted_attributes
|
|
13
|
+
preferred_attributes = []
|
|
14
|
+
|
|
15
|
+
if action_name == 'update'
|
|
16
|
+
resource.defined_preferences.each do |preference|
|
|
17
|
+
preferred_attributes << "preferred_#{preference}".to_sym
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
super + preferred_attributes
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def resource_serializer
|
|
25
|
+
Spree.api.platform_payment_method_serializer
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class PaymentsController < ResourceController
|
|
6
|
+
include NumberResource
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def model_class
|
|
11
|
+
Spree::Payment
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def resource_serializer
|
|
15
|
+
Spree.api.platform_payment_serializer
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class ProductsController < ResourceController
|
|
6
|
+
include ::Spree::Api::V2::ProductListIncludes
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def model_class
|
|
11
|
+
Spree::Product
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def scope_includes
|
|
15
|
+
product_list_includes
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def spree_permitted_attributes
|
|
19
|
+
super.push(:price)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def allowed_sort_attributes
|
|
23
|
+
super.push(:available_on, :make_active_at)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def sorted_collection
|
|
27
|
+
collection_sorter.new(collection, current_currency, params, allowed_sort_attributes).call
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def collection_sorter
|
|
31
|
+
Spree.api.platform_products_sorter
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def resource_serializer
|
|
35
|
+
Spree.api.platform_product_serializer
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class PromotionActionsController < ResourceController
|
|
6
|
+
include ::Spree::Api::V2::Platform::PromotionCalculatorParams
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def model_class
|
|
11
|
+
Spree::PromotionAction
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def scope_includes
|
|
15
|
+
[:promotion]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def spree_permitted_attributes
|
|
19
|
+
conditional_params = action_name == 'update' ? [:id] : []
|
|
20
|
+
|
|
21
|
+
super + [{
|
|
22
|
+
promotion_action_line_items_attributes: Spree::PromotionActionLineItem.json_api_permitted_attributes.concat(conditional_params),
|
|
23
|
+
calculator_attributes: Spree::Calculator.json_api_permitted_attributes.concat(conditional_params, calculator_params)
|
|
24
|
+
}]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def resource_serializer
|
|
28
|
+
Spree.api.platform_promotion_action_serializer
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class PromotionCategoriesController < ResourceController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def model_class
|
|
9
|
+
Spree::PromotionCategory
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def scope_includes
|
|
13
|
+
[:promotions]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def resource_serializer
|
|
17
|
+
Spree.api.platform_promotion_category_serializer
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class PromotionRulesController < ResourceController
|
|
6
|
+
include ::Spree::Api::V2::Platform::PromotionRuleParams
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def model_class
|
|
11
|
+
Spree::PromotionRule
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def scope_includes
|
|
15
|
+
[:promotion]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def spree_permitted_attributes
|
|
19
|
+
super + rule_params
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def resource_serializer
|
|
23
|
+
Spree.api.platform_promotion_rule_serializer
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class PromotionsController < ResourceController
|
|
6
|
+
include ::Spree::Api::V2::Platform::PromotionRuleParams
|
|
7
|
+
include ::Spree::Api::V2::Platform::PromotionCalculatorParams
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def model_class
|
|
12
|
+
Spree::Promotion
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def scope_includes
|
|
16
|
+
[:promotion_category, :promotion_rules, :promotion_actions]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def spree_permitted_attributes
|
|
20
|
+
conditional_params = action_name == 'update' ? [:id] : []
|
|
21
|
+
|
|
22
|
+
super + [{ promotion_actions_attributes: Spree::PromotionAction.json_api_permitted_attributes.concat(conditional_params) + [{
|
|
23
|
+
promotion_action_line_items_attributes: Spree::PromotionActionLineItem.json_api_permitted_attributes.concat(conditional_params),
|
|
24
|
+
calculator_attributes: Spree::Calculator.json_api_permitted_attributes.concat(conditional_params, calculator_params)
|
|
25
|
+
}], promotion_rules_attributes: Spree::PromotionRule.json_api_permitted_attributes.concat(conditional_params, rule_params) }]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def resource_serializer
|
|
29
|
+
Spree.api.platform_promotion_serializer
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|