spree_api 4.3.0 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/spree/api/v2/caching.rb +7 -3
- 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/storefront/metadata_controller_concern.rb +18 -0
- data/app/controllers/spree/api/v1/checkouts_controller.rb +1 -1
- data/app/controllers/spree/api/v2/base_controller.rb +7 -5
- data/app/controllers/spree/api/v2/platform/adjustments_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/classifications_controller.rb +1 -22
- data/app/controllers/spree/api/v2/platform/cms_pages_controller.rb +4 -0
- data/app/controllers/spree/api/v2/platform/cms_sections_controller.rb +13 -18
- data/app/controllers/spree/api/v2/platform/digital_links_controller.rb +25 -0
- data/app/controllers/spree/api/v2/platform/digitals_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/line_items_controller.rb +59 -0
- data/app/controllers/spree/api/v2/platform/menu_items_controller.rb +5 -19
- data/app/controllers/spree/api/v2/platform/menus_controller.rb +0 -4
- data/app/controllers/spree/api/v2/platform/orders_controller.rb +163 -0
- data/app/controllers/spree/api/v2/platform/payment_methods_controller.rb +27 -0
- data/app/controllers/spree/api/v2/platform/payments_controller.rb +17 -0
- data/app/controllers/spree/api/v2/platform/promotion_actions_controller.rb +30 -0
- data/app/controllers/spree/api/v2/platform/promotion_categories_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/promotion_rules_controller.rb +25 -0
- data/app/controllers/spree/api/v2/platform/promotions_controller.rb +31 -0
- data/app/controllers/spree/api/v2/platform/resource_controller.rb +47 -16
- data/app/controllers/spree/api/v2/platform/roles_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/shipments_controller.rb +143 -0
- data/app/controllers/spree/api/v2/platform/shipping_categories_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/shipping_methods_controller.rb +24 -0
- data/app/controllers/spree/api/v2/platform/states_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/stock_items_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/stock_locations_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/store_credit_categories_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/store_credit_types_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/store_credits_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/tax_categories_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/tax_rates_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/taxonomies_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/taxons_controller.rb +25 -0
- data/app/controllers/spree/api/v2/platform/users_controller.rb +4 -0
- data/app/controllers/spree/api/v2/platform/variants_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/webhooks/events_controller.rb +21 -0
- data/app/controllers/spree/api/v2/platform/webhooks/subscribers_controller.rb +21 -0
- data/app/controllers/spree/api/v2/platform/wished_items_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/wishlists_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/zones_controller.rb +19 -0
- data/app/controllers/spree/api/v2/resource_controller.rb +3 -3
- data/app/controllers/spree/api/v2/storefront/account/addresses_controller.rb +2 -2
- data/app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb +4 -1
- data/app/controllers/spree/api/v2/storefront/cart_controller.rb +18 -28
- data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +24 -0
- data/app/controllers/spree/api/v2/storefront/digitals_controller.rb +54 -0
- data/app/controllers/spree/api/v2/storefront/wishlists_controller.rb +171 -0
- data/app/helpers/spree/api/v2/collection_options_helpers.rb +1 -1
- data/app/jobs/spree/webhooks/subscribers/make_request_job.rb +17 -0
- data/app/models/concerns/spree/webhooks/has_webhooks.rb +60 -0
- data/app/models/spree/api/webhooks/order_decorator.rb +43 -0
- data/app/models/spree/api/webhooks/payment_decorator.rb +26 -0
- data/app/models/spree/api/webhooks/product_decorator.rb +27 -0
- data/app/models/spree/api/webhooks/shipment_decorator.rb +21 -0
- data/app/models/spree/api/webhooks/stock_item_decorator.rb +43 -0
- data/app/models/spree/api/webhooks/stock_movement_decorator.rb +52 -0
- data/app/models/spree/api/webhooks/variant_decorator.rb +26 -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 +15 -0
- data/app/models/spree/webhooks/base.rb +11 -0
- data/app/models/spree/webhooks/event.rb +12 -0
- data/app/models/spree/webhooks/subscriber.rb +57 -0
- data/app/serializers/concerns/spree/api/v2/resource_serializer_concern.rb +19 -1
- data/app/serializers/spree/api/v2/base_serializer.rb +11 -4
- data/app/serializers/spree/api/v2/platform/address_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/adjustment_serializer.rb +20 -0
- data/app/serializers/spree/api/v2/platform/asset_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/calculator_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/classification_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/cms_page_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/cms_section_serializer.rb +8 -1
- data/app/serializers/spree/api/v2/platform/country_serializer.rb +1 -1
- 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/digital_link_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/digital_serializer.rb +30 -0
- data/app/serializers/spree/api/v2/platform/feature_page_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/homepage_serializer.rb +11 -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/menu_item_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/menu_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/option_type_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/option_value_serializer.rb +1 -1
- 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 +21 -0
- data/app/serializers/spree/api/v2/platform/price_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/product_property_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/product_serializer.rb +7 -3
- 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 +16 -0
- data/app/serializers/spree/api/v2/platform/reimbursement_credit_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/reimbursement_serializer.rb +18 -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/standard_page_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/state_change_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/state_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/stock_item_serializer.rb +1 -3
- data/app/serializers/spree/api/v2/platform/stock_location_serializer.rb +2 -4
- 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 +1 -1
- data/app/serializers/spree/api/v2/platform/tax_category_serializer.rb +2 -2
- data/app/serializers/spree/api/v2/platform/tax_rate_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/taxon_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/taxonomy_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/user_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/variant_serializer.rb +3 -2
- data/app/serializers/spree/api/v2/platform/webhooks/event_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/webhooks/subscriber_serializer.rb +13 -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 +1 -1
- data/app/serializers/spree/v2/storefront/cart_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/cms_section_serializer.rb +5 -1
- data/app/serializers/spree/v2/storefront/credit_card_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/digital_link_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/estimated_shipping_rate_serializer.rb +2 -2
- data/app/serializers/spree/v2/storefront/line_item_serializer.rb +2 -1
- data/app/serializers/spree/v2/storefront/option_type_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/option_value_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/payment_method_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/payment_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/product_serializer.rb +2 -2
- data/app/serializers/spree/v2/storefront/promotion_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/shipment_serializer.rb +2 -1
- data/app/serializers/spree/v2/storefront/store_credit_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/store_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/taxon_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/taxonomy_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/user_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/variant_serializer.rb +1 -1
- 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/services/spree/webhooks/subscribers/handle_request.rb +73 -0
- data/app/services/spree/webhooks/subscribers/make_request.rb +82 -0
- data/app/services/spree/webhooks/subscribers/queue_requests.rb +17 -0
- data/app/services/spree/webhooks.rb +13 -0
- data/config/i18n-tasks.yml +40 -0
- data/config/initializers/doorkeeper.rb +12 -12
- data/config/initializers/rabl.rb +2 -2
- data/config/locales/en.yml +29 -27
- data/config/routes.rb +83 -59
- data/db/migrate/20210902162826_create_spree_webhooks_tables.rb +16 -0
- data/db/migrate/20210919183228_enable_polymorphic_resource_owner.rb +21 -0
- data/db/migrate/20211025162826_create_spree_webhooks_events.rb +14 -0
- data/docs/oauth/index.yml +126 -33
- data/docs/v2/platform/index.yaml +19099 -1736
- data/docs/v2/storefront/index.yaml +14801 -14628
- data/{app/models/spree → lib/spree/api}/api_dependencies.rb +56 -4
- data/lib/spree/api/engine.rb +19 -3
- data/lib/spree/api/testing_support/factories/oauth_application_factory.rb +6 -0
- data/lib/spree/api/testing_support/factories/webhook_event_factory.rb +27 -0
- data/lib/spree/api/testing_support/factories/webhook_subscriber_factory.rb +13 -0
- data/lib/spree/api/testing_support/factories.rb +3 -0
- data/lib/spree/api/testing_support/helpers.rb +1 -1
- data/lib/spree/api/testing_support/jobs.rb +18 -0
- data/lib/spree/api/testing_support/matchers/webhooks.rb +67 -0
- data/lib/spree/api/testing_support/serializers.rb +25 -0
- data/lib/spree/api/testing_support/spree_webhooks.rb +9 -0
- data/lib/spree/api/testing_support/v2/base.rb +1 -1
- data/lib/spree/api/testing_support/v2/current_order.rb +34 -1
- data/lib/spree/api/testing_support/v2/platform_contexts.rb +101 -52
- data/lib/spree/api/testing_support/v2/serializers_params.rb +3 -1
- data/lib/spree/api.rb +1 -0
- data/spec/fixtures/files/icon_256x256.jpg +0 -0
- data/spree_api.gemspec +16 -15
- metadata +175 -28
- data/app/controllers/spree/api/errors_controller.rb +0 -9
@@ -0,0 +1,18 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Platform
|
5
|
+
class StoreCreditSerializer < BaseSerializer
|
6
|
+
include ResourceSerializerConcern
|
7
|
+
|
8
|
+
belongs_to :user
|
9
|
+
belongs_to :created_by, serializer: :user, type: :user
|
10
|
+
belongs_to :store_credit_category, object_method_name: :category, id_method_name: :category_id
|
11
|
+
belongs_to :store_credit_type, object_method_name: :credit_type, id_method_name: :type_id
|
12
|
+
|
13
|
+
has_many :store_credit_events
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -3,7 +3,7 @@ module Spree
|
|
3
3
|
module V2
|
4
4
|
module Platform
|
5
5
|
class StoreSerializer < BaseSerializer
|
6
|
-
include
|
6
|
+
include ResourceSerializerConcern
|
7
7
|
|
8
8
|
has_many :menus
|
9
9
|
has_one :default_country, serializer: :country, record_type: :country, id_method_name: :default_country_id
|
@@ -5,7 +5,7 @@ module Spree
|
|
5
5
|
class UserSerializer < BaseSerializer
|
6
6
|
set_type :user
|
7
7
|
|
8
|
-
attributes :email, :created_at, :updated_at
|
8
|
+
attributes :email, :created_at, :updated_at, :public_metadata, :private_metadata
|
9
9
|
|
10
10
|
attribute :average_order_value do |user, params|
|
11
11
|
price_stats(user.report_values_for(:average_order_value, params[:store]))
|
@@ -3,8 +3,8 @@ module Spree
|
|
3
3
|
module V2
|
4
4
|
module Platform
|
5
5
|
class VariantSerializer < BaseSerializer
|
6
|
-
include
|
7
|
-
include
|
6
|
+
include ResourceSerializerConcern
|
7
|
+
include DisplayMoneyHelper
|
8
8
|
|
9
9
|
attributes :name, :options_text, :total_on_hand
|
10
10
|
|
@@ -46,6 +46,7 @@ module Spree
|
|
46
46
|
|
47
47
|
belongs_to :product
|
48
48
|
belongs_to :tax_category
|
49
|
+
has_many :digitals
|
49
50
|
has_many :images
|
50
51
|
has_many :option_values
|
51
52
|
has_many :stock_items
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Platform
|
5
|
+
class WishedItemSerializer < BaseSerializer
|
6
|
+
include ResourceSerializerConcern
|
7
|
+
|
8
|
+
attribute :price do |wished_item, params|
|
9
|
+
wished_item.price(currency: params[:currency])
|
10
|
+
end
|
11
|
+
|
12
|
+
attribute :total do |wished_item, params|
|
13
|
+
wished_item.total(currency: params[:currency])
|
14
|
+
end
|
15
|
+
|
16
|
+
attribute :display_price do |wished_item, params|
|
17
|
+
wished_item.display_price(currency: params[:currency]).to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
attribute :display_total do |wished_item, params|
|
21
|
+
wished_item.display_total(currency: params[:currency]).to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
belongs_to :variant
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Platform
|
5
|
+
class WishlistSerializer < BaseSerializer
|
6
|
+
include ResourceSerializerConcern
|
7
|
+
|
8
|
+
attributes :token
|
9
|
+
|
10
|
+
attribute :variant_included do |wishlist, params|
|
11
|
+
wishlist.include?(params[:is_variant_included])
|
12
|
+
end
|
13
|
+
|
14
|
+
has_many :wished_items
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -5,7 +5,7 @@ module Spree
|
|
5
5
|
set_type :address
|
6
6
|
|
7
7
|
attributes :firstname, :lastname, :address1, :address2, :city, :zipcode, :phone, :state_name,
|
8
|
-
:company, :country_name, :country_iso3, :country_iso, :label
|
8
|
+
:company, :country_name, :country_iso3, :country_iso, :label, :public_metadata
|
9
9
|
|
10
10
|
attribute :state_code do |address|
|
11
11
|
address.state_abbr
|
@@ -10,7 +10,7 @@ module Spree
|
|
10
10
|
:display_item_total, :display_ship_total, :display_adjustment_total, :display_tax_total,
|
11
11
|
:promo_total, :display_promo_total, :item_count, :special_instructions, :display_total,
|
12
12
|
:pre_tax_item_amount, :display_pre_tax_item_amount, :pre_tax_total, :display_pre_tax_total,
|
13
|
-
:shipment_state, :payment_state
|
13
|
+
:shipment_state, :payment_state, :public_metadata
|
14
14
|
|
15
15
|
has_many :line_items
|
16
16
|
has_many :variants
|
@@ -21,7 +21,11 @@ module Spree
|
|
21
21
|
section.fullscreen?
|
22
22
|
end
|
23
23
|
|
24
|
-
belongs_to :linked_resource, polymorphic:
|
24
|
+
belongs_to :linked_resource, polymorphic: {
|
25
|
+
Spree::Cms::Pages::StandardPage => :cms_page,
|
26
|
+
Spree::Cms::Pages::FeaturePage => :cms_page,
|
27
|
+
Spree::Cms::Pages::Homepage => :cms_page
|
28
|
+
}
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
@@ -4,7 +4,7 @@ module Spree
|
|
4
4
|
class CreditCardSerializer < BaseSerializer
|
5
5
|
set_type :credit_card
|
6
6
|
|
7
|
-
attributes :cc_type, :last_digits, :month, :year, :name, :default
|
7
|
+
attributes :cc_type, :last_digits, :month, :year, :name, :default, :public_metadata
|
8
8
|
|
9
9
|
belongs_to :payment_method
|
10
10
|
end
|
@@ -13,11 +13,11 @@ module Spree
|
|
13
13
|
end
|
14
14
|
|
15
15
|
attributes :display_cost, :display_final_price do |object, params|
|
16
|
-
Spree::Money.new(object.cost, currency: params[:currency])
|
16
|
+
Spree::Money.new(object.cost, currency: params[:currency]).to_s
|
17
17
|
end
|
18
18
|
|
19
19
|
attribute :display_tax_amount do |object, params|
|
20
|
-
Spree::Money.new(object.tax_amount, currency: params[:currency])
|
20
|
+
Spree::Money.new(object.tax_amount, currency: params[:currency]).to_s
|
21
21
|
end
|
22
22
|
|
23
23
|
attribute :free do |object|
|
@@ -10,9 +10,10 @@ module Spree
|
|
10
10
|
:discounted_amount, :display_discounted_amount,
|
11
11
|
:display_additional_tax_total, :promo_total, :display_promo_total,
|
12
12
|
:included_tax_total, :display_included_tax_total,
|
13
|
-
:pre_tax_amount, :display_pre_tax_amount
|
13
|
+
:pre_tax_amount, :display_pre_tax_amount, :public_metadata
|
14
14
|
|
15
15
|
belongs_to :variant
|
16
|
+
has_many :digital_links
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
@@ -8,7 +8,7 @@ module Spree
|
|
8
8
|
has_one :payment_method
|
9
9
|
|
10
10
|
attributes :amount, :response_code, :number, :cvv_response_code, :cvv_response_message,
|
11
|
-
:payment_method_id, :payment_method_name, :state
|
11
|
+
:payment_method_id, :payment_method_name, :state, :public_metadata
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -6,7 +6,7 @@ module Spree
|
|
6
6
|
|
7
7
|
set_type :product
|
8
8
|
|
9
|
-
attributes :name, :description, :available_on, :slug, :meta_description, :meta_keywords, :updated_at, :sku
|
9
|
+
attributes :name, :description, :available_on, :slug, :meta_description, :meta_keywords, :updated_at, :sku, :public_metadata
|
10
10
|
|
11
11
|
attribute :purchasable do |product|
|
12
12
|
product.purchasable?
|
@@ -49,7 +49,7 @@ module Spree
|
|
49
49
|
has_many :product_properties
|
50
50
|
|
51
51
|
has_many :taxons, serializer: :taxon, record_type: :taxon do |object, params|
|
52
|
-
object.taxons_for_store(params[:store])
|
52
|
+
object.taxons_for_store(params[:store]).order(:id)
|
53
53
|
end
|
54
54
|
|
55
55
|
# all images from all variants
|
@@ -5,13 +5,14 @@ module Spree
|
|
5
5
|
set_type :shipment
|
6
6
|
|
7
7
|
attributes :number, :final_price, :display_final_price,
|
8
|
-
:state, :shipped_at, :tracking_url
|
8
|
+
:state, :shipped_at, :tracking_url, :public_metadata
|
9
9
|
|
10
10
|
attribute :free do |shipment|
|
11
11
|
shipment.free?
|
12
12
|
end
|
13
13
|
|
14
14
|
has_many :shipping_rates
|
15
|
+
has_one :selected_shipping_rate, serializer: :shipping_rate
|
15
16
|
|
16
17
|
belongs_to :stock_location
|
17
18
|
end
|
@@ -6,7 +6,7 @@ module Spree
|
|
6
6
|
|
7
7
|
attributes :name, :url, :meta_description, :meta_keywords, :seo_title, :default_currency, :default, :supported_currencies, :facebook,
|
8
8
|
:twitter, :instagram, :default_locale, :customer_support_email, :default_country_id, :description,
|
9
|
-
:address, :contact_phone, :supported_locales
|
9
|
+
:address, :contact_phone, :supported_locales, :settings
|
10
10
|
|
11
11
|
has_many :menus
|
12
12
|
has_many :cms_pages
|
@@ -5,7 +5,7 @@ module Spree
|
|
5
5
|
set_type :taxon
|
6
6
|
|
7
7
|
attributes :name, :pretty_name, :permalink, :seo_title, :description, :meta_title, :meta_description,
|
8
|
-
:meta_keywords, :left, :right, :position, :depth, :updated_at
|
8
|
+
:meta_keywords, :left, :right, :position, :depth, :updated_at, :public_metadata
|
9
9
|
|
10
10
|
attribute :is_root do |taxon|
|
11
11
|
taxon.root?
|
@@ -6,7 +6,7 @@ module Spree
|
|
6
6
|
|
7
7
|
set_type :variant
|
8
8
|
|
9
|
-
attributes :sku, :weight, :height, :width, :depth, :is_master, :options_text
|
9
|
+
attributes :sku, :weight, :height, :width, :depth, :is_master, :options_text, :public_metadata
|
10
10
|
|
11
11
|
attribute :purchasable do |variant|
|
12
12
|
variant.purchasable?
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Spree
|
2
|
+
module V2
|
3
|
+
module Storefront
|
4
|
+
class WishedItemSerializer < BaseSerializer
|
5
|
+
set_type :wished_item
|
6
|
+
|
7
|
+
attributes :quantity
|
8
|
+
|
9
|
+
attribute :price do |wished_item, params|
|
10
|
+
wished_item.price(currency: params[:currency])
|
11
|
+
end
|
12
|
+
|
13
|
+
attribute :total do |wished_item, params|
|
14
|
+
wished_item.total(currency: params[:currency])
|
15
|
+
end
|
16
|
+
|
17
|
+
attribute :display_price do |wished_item, params|
|
18
|
+
wished_item.display_price(currency: params[:currency]).to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
attribute :display_total do |wished_item, params|
|
22
|
+
wished_item.display_total(currency: params[:currency]).to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
belongs_to :variant
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Spree
|
2
|
+
module V2
|
3
|
+
module Storefront
|
4
|
+
class WishlistSerializer < BaseSerializer
|
5
|
+
set_type :wishlist
|
6
|
+
|
7
|
+
attributes :token, :name, :is_private, :is_default
|
8
|
+
|
9
|
+
attribute :variant_included do |wishlist, params|
|
10
|
+
wishlist.include?(params[:is_variant_included])
|
11
|
+
end
|
12
|
+
|
13
|
+
has_many :wished_items
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module Webhooks
|
5
|
+
module Subscribers
|
6
|
+
class HandleRequest
|
7
|
+
def initialize(event_name:, subscriber:, webhook_payload_body:)
|
8
|
+
@event_name = event_name
|
9
|
+
@subscriber = subscriber
|
10
|
+
@webhook_payload_body = JSON.parse(webhook_payload_body)
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
Rails.logger.debug(msg("sending to '#{url}'"))
|
15
|
+
Rails.logger.debug(msg("webhook_payload_body: #{body_with_event_metadata}"))
|
16
|
+
|
17
|
+
if request.unprocessable_uri?
|
18
|
+
return process(:warn, msg("can not make a request to '#{url}'"))
|
19
|
+
end
|
20
|
+
return process(:warn, msg("failed for '#{url}'")) if request.failed_request?
|
21
|
+
|
22
|
+
process(:debug, msg("success for URL '#{url}'"))
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :webhook_payload_body, :event_name, :subscriber
|
28
|
+
|
29
|
+
delegate :execution_time, :failed_request?, :response_code, :success?, :unprocessable_uri?, to: :request
|
30
|
+
delegate :id, :url, to: :subscriber
|
31
|
+
delegate :created_at, :id, to: :event, prefix: true
|
32
|
+
|
33
|
+
def process(log_level, msg)
|
34
|
+
Rails.logger.public_send(log_level, msg)
|
35
|
+
make_request
|
36
|
+
update_event(msg)
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def request
|
41
|
+
@request ||=
|
42
|
+
Spree::Webhooks::Subscribers::MakeRequest.new(webhook_payload_body: body_with_event_metadata, url: url)
|
43
|
+
end
|
44
|
+
alias make_request request
|
45
|
+
|
46
|
+
def body_with_event_metadata
|
47
|
+
webhook_payload_body.
|
48
|
+
merge(event_created_at: event_created_at, event_id: event_id, event_type: event.name).
|
49
|
+
to_json
|
50
|
+
end
|
51
|
+
|
52
|
+
def event
|
53
|
+
@event ||= Spree::Webhooks::Event.create!(
|
54
|
+
name: event_name, subscriber_id: subscriber.id, url: url
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
def update_event(msg)
|
59
|
+
event.update(
|
60
|
+
execution_time: execution_time,
|
61
|
+
request_errors: msg,
|
62
|
+
response_code: response_code,
|
63
|
+
success: success?
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
def msg(msg)
|
68
|
+
"[SPREE WEBHOOKS] '#{event_name}' #{msg}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|