spree_api 4.3.0 → 4.5.1
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/product_list_includes.rb +10 -8
- data/app/controllers/concerns/spree/api/v2/storefront/metadata_controller_concern.rb +18 -0
- 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/products_controller.rb +5 -1
- 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 +25 -1
- data/app/controllers/spree/api/v2/storefront/digitals_controller.rb +58 -0
- data/app/controllers/spree/api/v2/storefront/stores_controller.rb +4 -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/helpers/spree/api/v2/store_media_serializer_images_concern.rb +35 -0
- data/app/jobs/spree/webhooks/subscribers/make_request_job.rb +17 -0
- data/app/models/concerns/spree/webhooks/has_webhooks.rb +84 -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 +46 -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 +61 -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_image_one_serializer.rb +9 -0
- data/app/serializers/spree/api/v2/platform/cms_section_image_three_serializer.rb +9 -0
- data/app/serializers/spree/api/v2/platform/cms_section_image_two_serializer.rb +9 -0
- 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/hero_image_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/homepage_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/image_gallery_serializer.rb +10 -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/side_by_side_image_serializer.rb +10 -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 +2 -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 +8 -4
- 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/order_serializer.rb +9 -0
- 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_property_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 +5 -1
- data/app/serializers/spree/v2/storefront/store_credit_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/store_serializer.rb +5 -10
- 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 +23 -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/locales/en.yml +29 -27
- data/config/routes.rb +84 -179
- 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 +19696 -1734
- data/docs/v2/storefront/index.yaml +15050 -14553
- data/lib/spree/api/configuration.rb +11 -0
- data/lib/spree/api/dependencies.rb +165 -0
- data/lib/spree/api/engine.rb +10 -5
- 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/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 +100 -52
- data/lib/spree/api/testing_support/v2/serializers_params.rb +3 -1
- data/lib/spree/api.rb +0 -3
- data/lib/spree_api.rb +0 -1
- data/spec/fixtures/files/icon_256x256.jpg +0 -0
- data/spree_api.gemspec +15 -16
- metadata +163 -177
- data/app/controllers/spree/api/base_controller.rb +0 -171
- data/app/controllers/spree/api/errors_controller.rb +0 -9
- data/app/controllers/spree/api/v1/addresses_controller.rb +0 -46
- data/app/controllers/spree/api/v1/checkouts_controller.rb +0 -106
- data/app/controllers/spree/api/v1/classifications_controller.rb +0 -21
- data/app/controllers/spree/api/v1/countries_controller.rb +0 -22
- data/app/controllers/spree/api/v1/credit_cards_controller.rb +0 -26
- data/app/controllers/spree/api/v1/customer_returns_controller.rb +0 -25
- data/app/controllers/spree/api/v1/images_controller.rb +0 -58
- data/app/controllers/spree/api/v1/inventory_units_controller.rb +0 -54
- data/app/controllers/spree/api/v1/line_items_controller.rb +0 -70
- data/app/controllers/spree/api/v1/option_types_controller.rb +0 -60
- data/app/controllers/spree/api/v1/option_values_controller.rb +0 -62
- data/app/controllers/spree/api/v1/orders_controller.rb +0 -160
- data/app/controllers/spree/api/v1/payments_controller.rb +0 -82
- data/app/controllers/spree/api/v1/product_properties_controller.rb +0 -73
- data/app/controllers/spree/api/v1/products_controller.rb +0 -131
- data/app/controllers/spree/api/v1/promotions_controller.rb +0 -30
- data/app/controllers/spree/api/v1/properties_controller.rb +0 -70
- data/app/controllers/spree/api/v1/reimbursements_controller.rb +0 -25
- data/app/controllers/spree/api/v1/return_authorizations_controller.rb +0 -70
- data/app/controllers/spree/api/v1/shipments_controller.rb +0 -196
- data/app/controllers/spree/api/v1/states_controller.rb +0 -36
- data/app/controllers/spree/api/v1/stock_items_controller.rb +0 -82
- data/app/controllers/spree/api/v1/stock_locations_controller.rb +0 -53
- data/app/controllers/spree/api/v1/stock_movements_controller.rb +0 -45
- data/app/controllers/spree/api/v1/stores_controller.rb +0 -56
- data/app/controllers/spree/api/v1/taxonomies_controller.rb +0 -67
- data/app/controllers/spree/api/v1/taxons_controller.rb +0 -100
- data/app/controllers/spree/api/v1/users_controller.rb +0 -97
- data/app/controllers/spree/api/v1/variants_controller.rb +0 -81
- data/app/controllers/spree/api/v1/zones_controller.rb +0 -55
- data/app/helpers/spree/api/api_helpers.rb +0 -190
- data/app/models/spree/api_configuration.rb +0 -10
- data/app/models/spree/api_dependencies.rb +0 -111
- data/app/views/spree/api/errors/gateway_error.rabl +0 -2
- data/app/views/spree/api/errors/invalid_api_key.rabl +0 -2
- data/app/views/spree/api/errors/invalid_resource.rabl +0 -3
- data/app/views/spree/api/errors/must_specify_api_key.rabl +0 -2
- data/app/views/spree/api/errors/not_found.rabl +0 -2
- data/app/views/spree/api/errors/unauthorized.rabl +0 -2
- data/app/views/spree/api/v1/addresses/show.rabl +0 -10
- data/app/views/spree/api/v1/adjustments/show.rabl +0 -4
- data/app/views/spree/api/v1/countries/index.rabl +0 -7
- data/app/views/spree/api/v1/countries/show.rabl +0 -5
- data/app/views/spree/api/v1/credit_cards/index.rabl +0 -7
- data/app/views/spree/api/v1/credit_cards/show.rabl +0 -3
- data/app/views/spree/api/v1/customer_returns/index.rabl +0 -7
- data/app/views/spree/api/v1/images/index.rabl +0 -4
- data/app/views/spree/api/v1/images/new.rabl +0 -3
- data/app/views/spree/api/v1/images/show.rabl +0 -6
- data/app/views/spree/api/v1/inventory_units/show.rabl +0 -2
- data/app/views/spree/api/v1/line_items/new.rabl +0 -3
- data/app/views/spree/api/v1/line_items/show.rabl +0 -14
- data/app/views/spree/api/v1/option_types/index.rabl +0 -3
- data/app/views/spree/api/v1/option_types/new.rabl +0 -3
- data/app/views/spree/api/v1/option_types/show.rabl +0 -5
- data/app/views/spree/api/v1/option_values/index.rabl +0 -3
- data/app/views/spree/api/v1/option_values/new.rabl +0 -3
- data/app/views/spree/api/v1/option_values/show.rabl +0 -2
- data/app/views/spree/api/v1/orders/address.rabl +0 -0
- data/app/views/spree/api/v1/orders/canceled.rabl +0 -0
- data/app/views/spree/api/v1/orders/cart.rabl +0 -0
- data/app/views/spree/api/v1/orders/complete.rabl +0 -0
- data/app/views/spree/api/v1/orders/could_not_apply_coupon.rabl +0 -2
- data/app/views/spree/api/v1/orders/could_not_transition.rabl +0 -3
- data/app/views/spree/api/v1/orders/index.rabl +0 -7
- data/app/views/spree/api/v1/orders/insufficient_quantity.rabl +0 -2
- data/app/views/spree/api/v1/orders/invalid_shipping_method.rabl +0 -2
- data/app/views/spree/api/v1/orders/mine.rabl +0 -9
- data/app/views/spree/api/v1/orders/order.rabl +0 -10
- data/app/views/spree/api/v1/orders/payment.rabl +0 -3
- data/app/views/spree/api/v1/orders/show.rabl +0 -51
- data/app/views/spree/api/v1/payments/credit_over_limit.rabl +0 -2
- data/app/views/spree/api/v1/payments/index.rabl +0 -7
- data/app/views/spree/api/v1/payments/new.rabl +0 -5
- data/app/views/spree/api/v1/payments/show.rabl +0 -2
- data/app/views/spree/api/v1/payments/update_forbidden.rabl +0 -2
- data/app/views/spree/api/v1/product_properties/index.rabl +0 -7
- data/app/views/spree/api/v1/product_properties/new.rabl +0 -2
- data/app/views/spree/api/v1/product_properties/show.rabl +0 -2
- data/app/views/spree/api/v1/products/index.rabl +0 -9
- data/app/views/spree/api/v1/products/new.rabl +0 -3
- data/app/views/spree/api/v1/products/product.rabl +0 -1
- data/app/views/spree/api/v1/products/show.rabl +0 -36
- data/app/views/spree/api/v1/promotions/handler.rabl +0 -5
- data/app/views/spree/api/v1/promotions/show.rabl +0 -2
- data/app/views/spree/api/v1/properties/index.rabl +0 -7
- data/app/views/spree/api/v1/properties/new.rabl +0 -2
- data/app/views/spree/api/v1/properties/show.rabl +0 -2
- data/app/views/spree/api/v1/reimbursements/index.rabl +0 -7
- data/app/views/spree/api/v1/return_authorizations/index.rabl +0 -7
- data/app/views/spree/api/v1/return_authorizations/new.rabl +0 -3
- data/app/views/spree/api/v1/return_authorizations/show.rabl +0 -2
- data/app/views/spree/api/v1/shared/stock_location_required.rabl +0 -2
- data/app/views/spree/api/v1/shipments/big.rabl +0 -48
- data/app/views/spree/api/v1/shipments/cannot_ready_shipment.rabl +0 -2
- data/app/views/spree/api/v1/shipments/mine.rabl +0 -9
- data/app/views/spree/api/v1/shipments/show.rabl +0 -32
- data/app/views/spree/api/v1/shipments/small.rabl +0 -37
- data/app/views/spree/api/v1/shipping_rates/show.rabl +0 -2
- data/app/views/spree/api/v1/states/index.rabl +0 -12
- data/app/views/spree/api/v1/states/show.rabl +0 -2
- data/app/views/spree/api/v1/stock_items/index.rabl +0 -7
- data/app/views/spree/api/v1/stock_items/show.rabl +0 -5
- data/app/views/spree/api/v1/stock_locations/index.rabl +0 -7
- data/app/views/spree/api/v1/stock_locations/show.rabl +0 -8
- data/app/views/spree/api/v1/stock_movements/index.rabl +0 -7
- data/app/views/spree/api/v1/stock_movements/show.rabl +0 -5
- data/app/views/spree/api/v1/stores/index.rabl +0 -4
- data/app/views/spree/api/v1/stores/show.rabl +0 -2
- data/app/views/spree/api/v1/tags/index.rabl +0 -9
- data/app/views/spree/api/v1/taxonomies/index.rabl +0 -7
- data/app/views/spree/api/v1/taxonomies/jstree.rabl +0 -7
- data/app/views/spree/api/v1/taxonomies/nested.rabl +0 -11
- data/app/views/spree/api/v1/taxonomies/new.rabl +0 -3
- data/app/views/spree/api/v1/taxonomies/show.rabl +0 -15
- data/app/views/spree/api/v1/taxons/index.rabl +0 -10
- data/app/views/spree/api/v1/taxons/jstree.rabl +0 -7
- data/app/views/spree/api/v1/taxons/new.rabl +0 -3
- data/app/views/spree/api/v1/taxons/show.rabl +0 -6
- data/app/views/spree/api/v1/taxons/taxons.rabl +0 -5
- data/app/views/spree/api/v1/users/index.rabl +0 -7
- data/app/views/spree/api/v1/users/new.rabl +0 -3
- data/app/views/spree/api/v1/users/show.rabl +0 -11
- data/app/views/spree/api/v1/variants/big.rabl +0 -14
- data/app/views/spree/api/v1/variants/index.rabl +0 -9
- data/app/views/spree/api/v1/variants/new.rabl +0 -2
- data/app/views/spree/api/v1/variants/show.rabl +0 -3
- data/app/views/spree/api/v1/variants/small.rabl +0 -18
- data/app/views/spree/api/v1/zones/index.rabl +0 -7
- data/app/views/spree/api/v1/zones/show.rabl +0 -6
- data/config/initializers/rabl.rb +0 -9
- data/lib/spree/api/controller_setup.rb +0 -19
- data/lib/spree/api/responders/rabl_template.rb +0 -28
- data/lib/spree/api/responders.rb +0 -11
- data/lib/spree/api/testing_support/helpers.rb +0 -44
- data/lib/spree/api/testing_support/setup.rb +0 -16
@@ -1,36 +1,47 @@
|
|
1
1
|
class String
|
2
2
|
def articleize
|
3
|
-
|
3
|
+
if split.first == 'User'
|
4
|
+
"a #{self}"
|
5
|
+
else
|
6
|
+
%w(a e i o u).include?(self[0].downcase) ? "an #{self}" : "a #{self}"
|
7
|
+
end
|
4
8
|
end
|
5
9
|
end
|
6
10
|
|
7
11
|
shared_context 'Platform API v2' do
|
8
12
|
let(:store) { Spree::Store.default }
|
9
|
-
let(:admin_app) {
|
10
|
-
let(:read_app) {
|
13
|
+
let(:admin_app) { Spree::OauthApplication.find_or_create_by!(name: 'Admin Panel', scopes: 'admin', redirect_uri: '') }
|
14
|
+
let(:read_app) { Spree::OauthApplication.find_or_create_by!(name: 'Read App', scopes: 'read', redirect_uri: '') }
|
11
15
|
let(:oauth_token) do
|
12
|
-
|
16
|
+
Spree::OauthAccessToken.create!(
|
13
17
|
application_id: admin_app.id,
|
14
18
|
scopes: admin_app.scopes
|
15
19
|
)
|
16
20
|
end
|
17
21
|
let(:read_oauth_token) do
|
18
|
-
|
22
|
+
Spree::OauthAccessToken.create!(
|
19
23
|
application_id: read_app.id,
|
20
24
|
scopes: read_app.scopes
|
21
25
|
)
|
22
26
|
end
|
23
27
|
let(:user_oauth_token) do
|
24
|
-
|
25
|
-
|
28
|
+
Spree::OauthAccessToken.create!(
|
29
|
+
resource_owner: user,
|
26
30
|
application_id: admin_app.id,
|
27
31
|
scopes: admin_app.scopes
|
28
32
|
)
|
29
33
|
end
|
34
|
+
let(:user_oauth_token_without_app) do
|
35
|
+
Spree::OauthAccessToken.create!(
|
36
|
+
resource_owner: user,
|
37
|
+
scopes: 'admin'
|
38
|
+
)
|
39
|
+
end
|
30
40
|
|
31
41
|
let(:valid_authorization) { "Bearer #{oauth_token.token}" }
|
32
42
|
let(:valid_read_authorization) { "Bearer #{read_oauth_token.token}" }
|
33
43
|
let(:valid_user_authorization) { "Bearer #{user_oauth_token.token}" }
|
44
|
+
let(:valid_user_authorization_without_app) { "Bearer #{user_oauth_token_without_app.token}" }
|
34
45
|
let(:bogus_authorization) { "Bearer #{::Base64.strict_encode64('bogus:bogus')}" }
|
35
46
|
|
36
47
|
let(:Authorization) { valid_authorization }
|
@@ -53,9 +64,14 @@ def json_api_include_parameter(example = '')
|
|
53
64
|
parameter name: :include, in: :query, type: :string, description: JSON_API_INCLUDES_DESCRIPTION, example: example
|
54
65
|
end
|
55
66
|
|
56
|
-
def json_api_filter_parameter(
|
57
|
-
|
58
|
-
|
67
|
+
def json_api_filter_parameter(examples = [])
|
68
|
+
examples.each do |api_filter|
|
69
|
+
name = api_filter[:name].to_sym
|
70
|
+
example = api_filter[:example]
|
71
|
+
let(name) { nil }
|
72
|
+
|
73
|
+
parameter name: name, in: :query, type: :string, description: JSON_API_FILTER_DESCRIPTION, example: example
|
74
|
+
end
|
59
75
|
end
|
60
76
|
|
61
77
|
shared_examples 'authentication failed' do
|
@@ -95,21 +111,21 @@ shared_examples 'records returned' do
|
|
95
111
|
end
|
96
112
|
|
97
113
|
shared_examples 'record created' do
|
98
|
-
response '201', '
|
114
|
+
response '201', 'Record created' do
|
99
115
|
schema '$ref' => '#/components/schemas/resource'
|
100
116
|
run_test!
|
101
117
|
end
|
102
118
|
end
|
103
119
|
|
104
120
|
shared_examples 'record updated' do
|
105
|
-
response '200', '
|
121
|
+
response '200', 'Record updated' do
|
106
122
|
schema '$ref' => '#/components/schemas/resource'
|
107
123
|
run_test!
|
108
124
|
end
|
109
125
|
end
|
110
126
|
|
111
127
|
shared_examples 'invalid request' do |param_name|
|
112
|
-
response '422', '
|
128
|
+
response '422', 'Invalid request' do
|
113
129
|
let(param_name) { invalid_param_value }
|
114
130
|
schema '$ref' => '#/components/schemas/validation_errors'
|
115
131
|
run_test!
|
@@ -117,15 +133,17 @@ shared_examples 'invalid request' do |param_name|
|
|
117
133
|
end
|
118
134
|
|
119
135
|
# index action
|
120
|
-
shared_examples 'GET records list' do |resource_name,
|
121
|
-
|
122
|
-
|
136
|
+
shared_examples 'GET records list' do |resource_name, **options|
|
137
|
+
endpoint_name = options[:custom_endpoint_name] || resource_name
|
138
|
+
|
139
|
+
get "Return a list of #{endpoint_name.pluralize}" do
|
140
|
+
tags endpoint_name.pluralize
|
123
141
|
security [ bearer_auth: [] ]
|
124
|
-
description "Returns a list of #{
|
142
|
+
description "Returns a list of #{endpoint_name.pluralize}"
|
125
143
|
operationId "#{resource_name.parameterize.pluralize.to_sym}-list"
|
126
144
|
include_context 'jsonapi pagination'
|
127
|
-
json_api_include_parameter(include_example)
|
128
|
-
json_api_filter_parameter(
|
145
|
+
json_api_include_parameter(options[:include_example]) unless options[:include_example].nil?
|
146
|
+
json_api_filter_parameter(options[:filter_examples]) unless options[:filter_examples].nil?
|
129
147
|
|
130
148
|
before { records_list }
|
131
149
|
|
@@ -135,14 +153,16 @@ shared_examples 'GET records list' do |resource_name, include_example, filter_ex
|
|
135
153
|
end
|
136
154
|
|
137
155
|
# show
|
138
|
-
shared_examples 'GET record' do |resource_name,
|
139
|
-
|
140
|
-
|
156
|
+
shared_examples 'GET record' do |resource_name, **options|
|
157
|
+
endpoint_name = options[:custom_endpoint_name] || resource_name
|
158
|
+
|
159
|
+
get "Return #{endpoint_name.articleize}" do
|
160
|
+
tags endpoint_name.pluralize
|
141
161
|
security [ bearer_auth: [] ]
|
142
|
-
description "Returns #{
|
162
|
+
description "Returns #{endpoint_name.articleize}"
|
143
163
|
operationId "show-#{resource_name.parameterize.to_sym}"
|
144
164
|
parameter name: :id, in: :path, type: :string
|
145
|
-
json_api_include_parameter(include_example)
|
165
|
+
json_api_include_parameter(options[:include_example]) unless options[:include_example].nil?
|
146
166
|
|
147
167
|
it_behaves_like 'record found'
|
148
168
|
it_behaves_like 'record not found'
|
@@ -151,54 +171,82 @@ shared_examples 'GET record' do |resource_name, include_example|
|
|
151
171
|
end
|
152
172
|
|
153
173
|
# create
|
154
|
-
shared_examples 'POST create record' do |resource_name,
|
174
|
+
shared_examples 'POST create record' do |resource_name, **options|
|
175
|
+
custom_create_params = options[:custom_create_params] || nil
|
176
|
+
endpoint_name = options[:custom_endpoint_name] || resource_name
|
155
177
|
param_name = resource_name.parameterize(separator: '_').to_sym
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
178
|
+
consumes_kind = options[:consumes_kind] || 'application/json'
|
179
|
+
request_data_type = case consumes_kind
|
180
|
+
when 'multipart/form-data'
|
181
|
+
:formData
|
182
|
+
else
|
183
|
+
:body
|
184
|
+
end
|
185
|
+
|
186
|
+
post "Create #{endpoint_name.articleize}" do
|
187
|
+
tags endpoint_name.pluralize
|
188
|
+
consumes consumes_kind
|
160
189
|
security [ bearer_auth: [] ]
|
161
|
-
description "Creates #{
|
190
|
+
description "Creates #{endpoint_name.articleize}"
|
162
191
|
operationId "create-#{resource_name.parameterize.to_sym}"
|
163
|
-
|
164
|
-
|
192
|
+
if custom_create_params
|
193
|
+
parameter name: param_name, in: request_data_type, schema: custom_create_params
|
194
|
+
else
|
195
|
+
parameter name: param_name, in: request_data_type, schema: { '$ref' => "#/components/schemas/create_#{param_name}_params" }
|
196
|
+
end
|
197
|
+
json_api_include_parameter(options[:include_example]) unless options[:include_example].nil?
|
165
198
|
|
166
199
|
let(param_name) { valid_create_param_value }
|
167
200
|
|
168
201
|
it_behaves_like 'record created'
|
169
|
-
it_behaves_like 'invalid request', param_name
|
202
|
+
it_behaves_like 'invalid request', param_name unless options[:skip_invalid_params] == true
|
170
203
|
end
|
171
204
|
end
|
172
205
|
|
173
206
|
# update
|
174
|
-
shared_examples '
|
207
|
+
shared_examples 'PATCH update record' do |resource_name, **options|
|
208
|
+
custom_update_params = options[:custom_update_params] || nil
|
209
|
+
endpoint_name = options[:custom_endpoint_name] || resource_name
|
175
210
|
param_name = resource_name.parameterize(separator: '_').to_sym
|
176
|
-
|
177
|
-
|
178
|
-
|
211
|
+
consumes_kind = options[:consumes_kind] || 'application/json'
|
212
|
+
request_data_type = case consumes_kind
|
213
|
+
when 'multipart/form-data'
|
214
|
+
:formData
|
215
|
+
else
|
216
|
+
:body
|
217
|
+
end
|
218
|
+
|
219
|
+
patch "Update #{endpoint_name.articleize}" do
|
220
|
+
tags endpoint_name.pluralize
|
179
221
|
security [ bearer_auth: [] ]
|
180
|
-
description "Updates #{
|
222
|
+
description "Updates #{endpoint_name.articleize}"
|
181
223
|
operationId "update-#{resource_name.parameterize.to_sym}"
|
182
|
-
consumes
|
224
|
+
consumes consumes_kind
|
183
225
|
parameter name: :id, in: :path, type: :string
|
184
|
-
|
185
|
-
|
226
|
+
if custom_update_params
|
227
|
+
parameter name: param_name, in: request_data_type, schema: custom_update_params
|
228
|
+
else
|
229
|
+
parameter name: param_name, in: request_data_type, schema: { '$ref' => "#/components/schemas/update_#{param_name}_params" }
|
230
|
+
end
|
231
|
+
json_api_include_parameter(options[:include_example]) unless options[:include_example].nil?
|
186
232
|
|
187
233
|
let(param_name) { valid_update_param_value }
|
188
234
|
|
189
235
|
it_behaves_like 'record updated'
|
190
|
-
it_behaves_like 'invalid request', param_name
|
236
|
+
it_behaves_like 'invalid request', param_name unless options[:skip_invalid_params] == true
|
191
237
|
it_behaves_like 'record not found'
|
192
238
|
it_behaves_like 'authentication failed'
|
193
239
|
end
|
194
240
|
end
|
195
241
|
|
196
242
|
# destroy
|
197
|
-
shared_examples 'DELETE record' do |resource_name|
|
198
|
-
|
199
|
-
|
243
|
+
shared_examples 'DELETE record' do |resource_name, **options|
|
244
|
+
endpoint_name = options[:custom_endpoint_name] || resource_name
|
245
|
+
|
246
|
+
delete "Delete #{endpoint_name.articleize}" do
|
247
|
+
tags endpoint_name.pluralize
|
200
248
|
security [ bearer_auth: [] ]
|
201
|
-
description "Deletes #{
|
249
|
+
description "Deletes #{endpoint_name.articleize}"
|
202
250
|
operationId "delete-#{resource_name.parameterize.to_sym}"
|
203
251
|
parameter name: :id, in: :path, type: :string
|
204
252
|
|
@@ -208,17 +256,17 @@ shared_examples 'DELETE record' do |resource_name|
|
|
208
256
|
end
|
209
257
|
end
|
210
258
|
|
211
|
-
shared_examples 'CRUD examples' do |resource_name,
|
259
|
+
shared_examples 'CRUD examples' do |resource_name, **options|
|
212
260
|
resource_path = resource_name.parameterize(separator: '_').pluralize
|
213
261
|
|
214
262
|
path "/api/v2/platform/#{resource_path}" do
|
215
|
-
include_examples 'GET records list', resource_name,
|
216
|
-
include_examples 'POST create record', resource_name,
|
263
|
+
include_examples 'GET records list', resource_name, options
|
264
|
+
include_examples 'POST create record', resource_name, options
|
217
265
|
end
|
218
266
|
|
219
267
|
path "/api/v2/platform/#{resource_path}/{id}" do
|
220
|
-
include_examples 'GET record', resource_name,
|
221
|
-
include_examples '
|
222
|
-
include_examples 'DELETE record', resource_name
|
268
|
+
include_examples 'GET record', resource_name, options
|
269
|
+
include_examples 'PATCH update record', resource_name, options
|
270
|
+
include_examples 'DELETE record', resource_name, options
|
223
271
|
end
|
224
272
|
end
|
@@ -2,13 +2,15 @@ shared_context 'API v2 serializers params' do
|
|
2
2
|
let(:store) { Spree::Store.default || create(:store, default: true) }
|
3
3
|
let(:currency) { store.default_currency }
|
4
4
|
let(:locale) { store.default_locale }
|
5
|
+
let(:zone) { Spree::Zone.default_tax || create(:zone, default_tax: true) }
|
5
6
|
|
6
7
|
let(:serializer_params) do
|
7
8
|
{
|
8
9
|
store: store,
|
9
10
|
currency: currency,
|
10
11
|
user: nil,
|
11
|
-
locale: locale
|
12
|
+
locale: locale,
|
13
|
+
price_options: { tax_zone: zone }
|
12
14
|
}
|
13
15
|
end
|
14
16
|
end
|
data/lib/spree/api.rb
CHANGED
data/lib/spree_api.rb
CHANGED
Binary file
|
data/spree_api.gemspec
CHANGED
@@ -1,36 +1,35 @@
|
|
1
|
-
|
2
|
-
require_relative '../core/lib/spree/core/version.rb'
|
1
|
+
require_relative '../core/lib/spree/core/version'
|
3
2
|
|
4
3
|
Gem::Specification.new do |s|
|
5
|
-
s.name =
|
4
|
+
s.name = 'spree_api'
|
6
5
|
s.version = Spree.version
|
7
|
-
s.authors = [
|
8
|
-
s.email = [
|
6
|
+
s.authors = ['Ryan Bigg']
|
7
|
+
s.email = ['ryan@spreecommerce.com']
|
9
8
|
s.summary = %q{Spree's API}
|
10
9
|
s.description = %q{Spree's API}
|
11
10
|
s.homepage = 'https://spreecommerce.org'
|
12
11
|
s.license = 'BSD-3-Clause'
|
13
12
|
|
14
13
|
s.metadata = {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
'bug_tracker_uri' => 'https://github.com/spree/spree/issues',
|
15
|
+
'changelog_uri' => "https://github.com/spree/spree/releases/tag/v#{s.version}",
|
16
|
+
'documentation_uri' => 'https://dev-docs.spreecommerce.org/',
|
17
|
+
'source_code_uri' => "https://github.com/spree/spree/tree/v#{s.version}",
|
19
18
|
}
|
20
19
|
|
21
20
|
s.required_ruby_version = '>= 2.5'
|
22
21
|
|
23
22
|
s.files = `git ls-files`.split($\).reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }
|
24
|
-
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
25
|
-
s.require_paths = [
|
23
|
+
s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
24
|
+
s.require_paths = ['lib']
|
26
25
|
|
26
|
+
s.add_development_dependency 'i18n-tasks'
|
27
27
|
s.add_development_dependency 'jsonapi-rspec'
|
28
|
-
s.add_development_dependency 'rswag-specs'
|
29
28
|
s.add_development_dependency 'multi_json'
|
29
|
+
s.add_development_dependency 'rswag-specs'
|
30
30
|
|
31
|
-
s.add_dependency '
|
32
|
-
s.add_dependency '
|
31
|
+
s.add_dependency 'bcrypt', '~> 3.1'
|
32
|
+
s.add_dependency 'doorkeeper', '~> 5.3'
|
33
33
|
s.add_dependency 'jsonapi-serializer', '~> 2.1'
|
34
|
-
s.add_dependency '
|
35
|
-
s.add_dependency 'responders'
|
34
|
+
s.add_dependency 'spree_core', s.version
|
36
35
|
end
|