atkhayar-spree-dev-api 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +5 -0
- data/LICENSE +26 -0
- data/Rakefile +29 -0
- data/app/controllers/concerns/spree/api/v2/caching.rb +37 -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 +25 -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 +52 -0
- data/app/controllers/spree/api/v2/base_controller.rb +171 -0
- data/app/controllers/spree/api/v2/platform/addresses_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/adjustments_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/classifications_controller.rb +22 -0
- data/app/controllers/spree/api/v2/platform/cms_pages_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/cms_sections_controller.rb +29 -0
- data/app/controllers/spree/api/v2/platform/countries_controller.rb +19 -0
- 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/firebase_controller.rb +76 -0
- data/app/controllers/spree/api/v2/platform/images_controller.rb +20 -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 +21 -0
- data/app/controllers/spree/api/v2/platform/menus_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/option_types_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/option_values_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/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 +37 -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 +146 -0
- 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/stores_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 +55 -0
- data/app/controllers/spree/api/v2/platform/users_controller.rb +32 -0
- data/app/controllers/spree/api/v2/platform/users_resource_controller.rb +144 -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 +76 -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 +245 -0
- data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +160 -0
- data/app/controllers/spree/api/v2/storefront/cms_pages_controller.rb +41 -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/menus_controller.rb +35 -0
- data/app/controllers/spree/api/v2/storefront/order_status_controller.rb +34 -0
- data/app/controllers/spree/api/v2/storefront/products_controller.rb +61 -0
- data/app/controllers/spree/api/v2/storefront/stores_controller.rb +27 -0
- data/app/controllers/spree/api/v2/storefront/taxons_controller.rb +50 -0
- data/app/controllers/spree/api/v2/storefront/wishlists_controller.rb +171 -0
- data/app/helpers/spree/api/v2/collection_options_helpers.rb +46 -0
- data/app/helpers/spree/api/v2/display_money_helper.rb +43 -0
- 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/user_api_authentication.rb +19 -0
- data/app/models/concerns/spree/user_api_methods.rb +7 -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/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/resource_serializer_concern.rb +34 -0
- data/app/serializers/concerns/spree/api/v2/taxon_image_transformation_concern.rb +15 -0
- data/app/serializers/spree/api/v2/base_serializer.rb +39 -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/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/cms_page_serializer.rb +13 -0
- 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 +18 -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/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/icon_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/image_gallery_serializer.rb +10 -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/menu_item_serializer.rb +45 -0
- data/app/serializers/spree/api/v2/platform/menu_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/option_type_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/option_value_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/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 +11 -0
- data/app/serializers/spree/api/v2/platform/product_serializer.rb +82 -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 +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 +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 +15 -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 +38 -0
- data/app/serializers/spree/api/v2/platform/taxonomy_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/user_serializer.rb +39 -0
- data/app/serializers/spree/api/v2/platform/variant_serializer.rb +58 -0
- 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 +20 -0
- data/app/serializers/spree/v2/storefront/base_serializer.rb +10 -0
- data/app/serializers/spree/v2/storefront/cart_serializer.rb +36 -0
- data/app/serializers/spree/v2/storefront/cms_page_serializer.rb +14 -0
- data/app/serializers/spree/v2/storefront/cms_section_serializer.rb +32 -0
- data/app/serializers/spree/v2/storefront/country_serializer.rb +24 -0
- data/app/serializers/spree/v2/storefront/credit_card_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/digital_link_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/estimated_shipping_rate_serializer.rb +29 -0
- data/app/serializers/spree/v2/storefront/icon_serializer.rb +14 -0
- data/app/serializers/spree/v2/storefront/image_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/line_item_serializer.rb +20 -0
- data/app/serializers/spree/v2/storefront/menu_item_serializer.rb +43 -0
- data/app/serializers/spree/v2/storefront/menu_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/option_type_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/option_value_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/order_serializer.rb +9 -0
- data/app/serializers/spree/v2/storefront/payment_method_serializer.rb +15 -0
- data/app/serializers/spree/v2/storefront/payment_serializer.rb +15 -0
- data/app/serializers/spree/v2/storefront/product_property_serializer.rb +19 -0
- data/app/serializers/spree/v2/storefront/product_serializer.rb +76 -0
- data/app/serializers/spree/v2/storefront/promotion_serializer.rb +12 -0
- data/app/serializers/spree/v2/storefront/shipment_serializer.rb +24 -0
- data/app/serializers/spree/v2/storefront/shipping_rate_serializer.rb +16 -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 +17 -0
- data/app/serializers/spree/v2/storefront/store_credit_type_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/store_serializer.rb +20 -0
- data/app/serializers/spree/v2/storefront/taxon_image_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/taxon_serializer.rb +37 -0
- data/app/serializers/spree/v2/storefront/taxonomy_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/user_serializer.rb +31 -0
- data/app/serializers/spree/v2/storefront/variant_serializer.rb +49 -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/services/spree/api/error_handler.rb +40 -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 +48 -0
- data/config/initializers/json_api_mime_types.rb +8 -0
- data/config/initializers/user_class_extensions.rb +7 -0
- data/config/locales/en.yml +38 -0
- data/config/routes.rb +214 -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/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 +233 -0
- data/docs/v2/platform/index.yaml +21111 -0
- data/docs/v2/storefront/index.yaml +16504 -0
- data/lib/spree/api/configuration.rb +11 -0
- data/lib/spree/api/dependencies.rb +165 -0
- data/lib/spree/api/engine.rb +34 -0
- data/lib/spree/api/testing_support/caching.rb +10 -0
- 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 +13 -0
- data/lib/spree/api/testing_support/v2/current_order.rb +112 -0
- data/lib/spree/api/testing_support/v2/platform_contexts.rb +273 -0
- data/lib/spree/api/testing_support/v2/serializers_params.rb +16 -0
- data/lib/spree/api.rb +8 -0
- data/lib/spree_api.rb +3 -0
- data/script/rails +9 -0
- data/spec/fixtures/files/icon_256x256.jpg +0 -0
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spree_api.gemspec +35 -0
- metadata +427 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
class CreateDoorkeeperTables < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
create_table :spree_oauth_applications do |t|
|
4
|
+
t.string :name, null: false
|
5
|
+
t.string :uid, null: false
|
6
|
+
t.string :secret, null: false
|
7
|
+
t.text :redirect_uri, null: false
|
8
|
+
t.string :scopes, null: false, default: ''
|
9
|
+
t.boolean :confidential, null: false, default: true
|
10
|
+
t.timestamps null: false
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index :spree_oauth_applications, :uid, unique: true
|
14
|
+
|
15
|
+
create_table :spree_oauth_access_grants do |t|
|
16
|
+
t.integer :resource_owner_id, null: false
|
17
|
+
t.references :application, null: false
|
18
|
+
t.string :token, null: false
|
19
|
+
t.integer :expires_in, null: false
|
20
|
+
t.text :redirect_uri, null: false
|
21
|
+
t.datetime :created_at, null: false
|
22
|
+
t.datetime :revoked_at
|
23
|
+
t.string :scopes
|
24
|
+
end
|
25
|
+
|
26
|
+
add_index :spree_oauth_access_grants, :token, unique: true
|
27
|
+
add_foreign_key(
|
28
|
+
:spree_oauth_access_grants,
|
29
|
+
:spree_oauth_applications,
|
30
|
+
column: :application_id
|
31
|
+
)
|
32
|
+
|
33
|
+
create_table :spree_oauth_access_tokens do |t|
|
34
|
+
t.integer :resource_owner_id
|
35
|
+
t.references :application
|
36
|
+
|
37
|
+
# If you use a custom token generator you may need to change this column
|
38
|
+
# from string to text, so that it accepts tokens larger than 255
|
39
|
+
# characters. More info on custom token generators in:
|
40
|
+
# https://github.com/doorkeeper-gem/doorkeeper/tree/v3.0.0.rc1#custom-access-token-generator
|
41
|
+
#
|
42
|
+
# t.text :token, null: false
|
43
|
+
t.string :token, null: false
|
44
|
+
|
45
|
+
t.string :refresh_token
|
46
|
+
t.integer :expires_in
|
47
|
+
t.datetime :revoked_at
|
48
|
+
t.datetime :created_at, null: false
|
49
|
+
t.string :scopes
|
50
|
+
|
51
|
+
# If there is a previous_refresh_token column,
|
52
|
+
# refresh tokens will be revoked after a related access token is used.
|
53
|
+
# If there is no previous_refresh_token column,
|
54
|
+
# previous tokens are revoked as soon as a new access token is created.
|
55
|
+
# Comment out this line if you'd rather have refresh tokens
|
56
|
+
# instantly revoked.
|
57
|
+
t.string :previous_refresh_token, null: false, default: ""
|
58
|
+
end
|
59
|
+
|
60
|
+
add_index :spree_oauth_access_tokens, :token, unique: true
|
61
|
+
add_index :spree_oauth_access_tokens, :resource_owner_id
|
62
|
+
add_index :spree_oauth_access_tokens, :refresh_token, unique: true
|
63
|
+
add_foreign_key(
|
64
|
+
:spree_oauth_access_tokens,
|
65
|
+
:spree_oauth_applications,
|
66
|
+
column: :application_id
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class ChangeIntegerIdColumnsType < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
change_column :spree_oauth_access_grants, :resource_owner_id, :bigint
|
4
|
+
change_column :spree_oauth_access_grants, :application_id, :bigint
|
5
|
+
|
6
|
+
change_column :spree_oauth_access_tokens, :resource_owner_id, :bigint
|
7
|
+
change_column :spree_oauth_access_tokens, :application_id, :bigint
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateSpreeWebhooksTables < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :spree_webhooks_subscribers do |t|
|
4
|
+
t.string :url, null: false
|
5
|
+
t.boolean :active, default: false, index: true
|
6
|
+
|
7
|
+
if t.respond_to? :jsonb
|
8
|
+
t.jsonb :subscriptions
|
9
|
+
else
|
10
|
+
t.json :subscriptions
|
11
|
+
end
|
12
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class EnablePolymorphicResourceOwner < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
add_column :spree_oauth_access_tokens, :resource_owner_type, :string
|
4
|
+
add_column :spree_oauth_access_grants, :resource_owner_type, :string
|
5
|
+
change_column_null :spree_oauth_access_grants, :resource_owner_type, false
|
6
|
+
|
7
|
+
add_index :spree_oauth_access_tokens,
|
8
|
+
[:resource_owner_id, :resource_owner_type],
|
9
|
+
name: 'polymorphic_owner_oauth_access_tokens'
|
10
|
+
|
11
|
+
add_index :spree_oauth_access_grants,
|
12
|
+
[:resource_owner_id, :resource_owner_type],
|
13
|
+
name: 'polymorphic_owner_oauth_access_grants'
|
14
|
+
|
15
|
+
Spree::OauthAccessToken.reset_column_information
|
16
|
+
Spree::OauthAccessToken.update_all(resource_owner_type: Spree.user_class)
|
17
|
+
|
18
|
+
Spree::OauthAccessGrant.reset_column_information
|
19
|
+
Spree::OauthAccessGrant.update_all(resource_owner_type: Spree.user_class)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateSpreeWebhooksEvents < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :spree_webhooks_events do |t|
|
4
|
+
t.integer "execution_time"
|
5
|
+
t.string "name", null: false
|
6
|
+
t.string "request_errors"
|
7
|
+
t.string "response_code", index: true
|
8
|
+
t.belongs_to "subscriber", null: false, index: true
|
9
|
+
t.boolean "success", index: true
|
10
|
+
t.string "url", null: false
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,233 @@
|
|
1
|
+
openapi: 3.0.3
|
2
|
+
servers:
|
3
|
+
- url: 'https://demo.spreecommerce.org'
|
4
|
+
description: demo
|
5
|
+
- url: 'http://localhost:3000'
|
6
|
+
description: localhost
|
7
|
+
info:
|
8
|
+
version: 1.0.0
|
9
|
+
title: Authentication
|
10
|
+
description: Spree uses oAuth based Authentication via short-lived Bearer tokens. You can either create a new one or refresh existing token.
|
11
|
+
contact:
|
12
|
+
name: Spark Solutions
|
13
|
+
url: 'https://sparksolutions.co'
|
14
|
+
email: we@sparksolutions.co
|
15
|
+
license:
|
16
|
+
url: 'https://github.com/spree/spree/blob/master/license.md'
|
17
|
+
name: BSD-3-Clause
|
18
|
+
paths:
|
19
|
+
/spree_oauth/token:
|
20
|
+
post:
|
21
|
+
description: |-
|
22
|
+
This endpoint creates a new Bearer Token or refreshes an existing Bearer Token.
|
23
|
+
|
24
|
+
The `token` found in the response body is required to authorize API calls.
|
25
|
+
operationId: create-or-refresh-token
|
26
|
+
responses:
|
27
|
+
'200':
|
28
|
+
description: Token was successfully created or refreshed.
|
29
|
+
content:
|
30
|
+
application/json:
|
31
|
+
schema:
|
32
|
+
$ref: '#/components/schemas/Token'
|
33
|
+
examples:
|
34
|
+
Storefront User Token:
|
35
|
+
value:
|
36
|
+
access_token: SfM3k8kq5Wkc6xz6rgMlsl-mbygJ1ptq4DR0Ah51vjA
|
37
|
+
token_type: Bearer
|
38
|
+
expires_in: 7200
|
39
|
+
refresh_token: SqJDIwX00fehqHxS6xmb-kzqAlrYe_0EHgekMexVT8k
|
40
|
+
created_at: 1581873931
|
41
|
+
Platform User Token:
|
42
|
+
value:
|
43
|
+
access_token: 2480c16561d1391ea81ca5336b651e9a29f4524f6dee8c7f3f02a600159189c3
|
44
|
+
token_type: Bearer
|
45
|
+
expires_in: 7200
|
46
|
+
refresh_token: f5d78642252eeb3f3001f67b196ac21a27afc030462a54060b0ebbdae2b8dc9c
|
47
|
+
scope: admin
|
48
|
+
created_at: 1539863418
|
49
|
+
Refreshed Token:
|
50
|
+
value:
|
51
|
+
access_token: Es9lLPW2mVaDB80I-I_OdQCw3JfOT1s19YN1naFWx98
|
52
|
+
token_type: Bearer
|
53
|
+
expires_in: 7200
|
54
|
+
refresh_token: j92BxulqIIYtiiaBsuAM1TzGsGSVxaykT4kk8OYHGNY
|
55
|
+
created_at: 1581876572
|
56
|
+
requestBody:
|
57
|
+
required: true
|
58
|
+
content:
|
59
|
+
application/json:
|
60
|
+
schema:
|
61
|
+
oneOf:
|
62
|
+
- $ref: '#/components/schemas/CreateTokenBody'
|
63
|
+
- $ref: '#/components/schemas/ClientTokenBody'
|
64
|
+
- $ref: '#/components/schemas/RefreshTokenBody'
|
65
|
+
examples:
|
66
|
+
Create Storefront API User Token:
|
67
|
+
value:
|
68
|
+
grant_type: password
|
69
|
+
username: spree@example.com
|
70
|
+
password: spree123
|
71
|
+
Create Platform API User Token:
|
72
|
+
value:
|
73
|
+
client_id: 7ZY15L7crVZul8i3PZPrnpOkEURK7xnXEWRZdE6K39M
|
74
|
+
client_secret: cxMZ0tbe604qj_13hibNmc3GDsXUQfpzHt9PvweihFc
|
75
|
+
grant_type: password
|
76
|
+
username: spree@example.com
|
77
|
+
password: spree123
|
78
|
+
scope: admin
|
79
|
+
Create Platform API Application Token:
|
80
|
+
value:
|
81
|
+
grant_type: client_credentials
|
82
|
+
client_id: 7ZY15L7crVZul8i3PZPrnpOkEURK7xnXEWRZdE6K39M
|
83
|
+
client_secret: cxMZ0tbe604qj_13hibNmc3GDsXUQfpzHt9PvweihFc
|
84
|
+
scope: admin
|
85
|
+
Refresh a Token:
|
86
|
+
value:
|
87
|
+
grant_type: refresh_token
|
88
|
+
refresh_token: SqJDIwX00fehqHxS6xmb-kzqAlrYe_0EHgekMexVT8k
|
89
|
+
application/xml:
|
90
|
+
schema:
|
91
|
+
type: object
|
92
|
+
properties: {}
|
93
|
+
description: ''
|
94
|
+
summary: Create or Refresh a Token
|
95
|
+
tags:
|
96
|
+
- Token
|
97
|
+
components:
|
98
|
+
schemas:
|
99
|
+
Token:
|
100
|
+
x-examples:
|
101
|
+
create token:
|
102
|
+
access_token: SfM3k8kq5Wkc6xz6rgMlsl-mbygJ1ptq4DR0Ah51vjA
|
103
|
+
token_type: Bearer
|
104
|
+
expires_in: 7200
|
105
|
+
refresh_token: SqJDIwX00fehqHxS6xmb-kzqAlrYe_0EHgekMexVT8k
|
106
|
+
created_at: 1581873931
|
107
|
+
refresh token:
|
108
|
+
access_token: Es9lLPW2mVaDB80I-I_OdQCw3JfOT1s19YN1naFWx98
|
109
|
+
token_type: Bearer
|
110
|
+
expires_in: 7200
|
111
|
+
refresh_token: j92BxulqIIYtiiaBsuAM1TzGsGSVxaykT4kk8OYHGNY
|
112
|
+
created_at: 1581876572
|
113
|
+
type: object
|
114
|
+
properties:
|
115
|
+
access_token:
|
116
|
+
type: string
|
117
|
+
example: 2480c16561d1391ea81ca5336b651e9a29f4524f6dee8c7f3f02a600159189c3
|
118
|
+
token_type:
|
119
|
+
type: string
|
120
|
+
example: Bearer
|
121
|
+
default: Bearer
|
122
|
+
expires_in:
|
123
|
+
type: integer
|
124
|
+
example: 7200
|
125
|
+
description: Time (in seconds) after which the access token will expire
|
126
|
+
refresh_token:
|
127
|
+
type: string
|
128
|
+
example: f5d78642252eeb3f3001f67b196ac21a27afc030462a54060b0ebbdae2b8dc9c
|
129
|
+
scope:
|
130
|
+
type: string
|
131
|
+
example: admin
|
132
|
+
default: admin
|
133
|
+
created_at:
|
134
|
+
type: integer
|
135
|
+
example: 1539863418
|
136
|
+
required:
|
137
|
+
- access_token
|
138
|
+
- token_type
|
139
|
+
- expires_in
|
140
|
+
- refresh_token
|
141
|
+
- created_at
|
142
|
+
x-internal: true
|
143
|
+
CreateTokenBody:
|
144
|
+
type: object
|
145
|
+
x-examples:
|
146
|
+
User Token:
|
147
|
+
grant_type: password
|
148
|
+
username: spree@example.com
|
149
|
+
password: spree123
|
150
|
+
Application Token:
|
151
|
+
grant_type: password
|
152
|
+
username: spree@example.com
|
153
|
+
password: spree123
|
154
|
+
scope: admin
|
155
|
+
x-internal: true
|
156
|
+
title: 'Create a new token (grant_type: password)'
|
157
|
+
description: ''
|
158
|
+
properties:
|
159
|
+
grant_type:
|
160
|
+
type: string
|
161
|
+
description: ''
|
162
|
+
example: password
|
163
|
+
enum:
|
164
|
+
- password
|
165
|
+
username:
|
166
|
+
type: string
|
167
|
+
description: User email address
|
168
|
+
example: spree@example.com
|
169
|
+
password:
|
170
|
+
type: string
|
171
|
+
description: User password
|
172
|
+
example: spree123
|
173
|
+
scope:
|
174
|
+
type: string
|
175
|
+
enum:
|
176
|
+
- admin
|
177
|
+
description: 'Pass the value `admin` to create a Platform User Token, allowing access to the Platform API.'
|
178
|
+
nullable: true
|
179
|
+
required:
|
180
|
+
- grant_type
|
181
|
+
- username
|
182
|
+
- password
|
183
|
+
ClientTokenBody:
|
184
|
+
type: object
|
185
|
+
x-examples:
|
186
|
+
example-1:
|
187
|
+
grant_type: refresh_token
|
188
|
+
refresh_token: SqJDIwX00fehqHxS6xmb-kzqAlrYe_0EHgekMexVT8k
|
189
|
+
x-internal: true
|
190
|
+
title: 'Create a new token (grant_type: client_credentials)'
|
191
|
+
description: ''
|
192
|
+
properties:
|
193
|
+
grant_type:
|
194
|
+
type: string
|
195
|
+
example: client_credentials
|
196
|
+
enum:
|
197
|
+
- client_credentials
|
198
|
+
client_id:
|
199
|
+
type: string
|
200
|
+
description: Use the client id
|
201
|
+
example: 27af95fd57a424e5d01aaf5eab
|
202
|
+
client_secret:
|
203
|
+
type: string
|
204
|
+
example: 1324a8d5c0ca57daf384fae39f811a5144330143301'
|
205
|
+
description: Client secret key.
|
206
|
+
required:
|
207
|
+
- grant_type
|
208
|
+
- client_id
|
209
|
+
- client_secret
|
210
|
+
RefreshTokenBody:
|
211
|
+
type: object
|
212
|
+
x-examples:
|
213
|
+
example-1:
|
214
|
+
grant_type: refresh_token
|
215
|
+
refresh_token: SqJDIwX00fehqHxS6xmb-kzqAlrYe_0EHgekMexVT8k
|
216
|
+
x-internal: true
|
217
|
+
title: 'Refresh an existing token (grant_type: refresh_token)'
|
218
|
+
description: ''
|
219
|
+
properties:
|
220
|
+
grant_type:
|
221
|
+
type: string
|
222
|
+
example: refresh_token
|
223
|
+
enum:
|
224
|
+
- refresh_token
|
225
|
+
refresh_token:
|
226
|
+
type: string
|
227
|
+
description: Refresh token obtained from the create token response
|
228
|
+
example: 27af95fd57a424e5d01aaf5eab1324a8d5c0ca57daf384fae39f811a5144330143301'
|
229
|
+
required:
|
230
|
+
- grant_type
|
231
|
+
- refresh_token
|
232
|
+
tags:
|
233
|
+
- name: Token
|