workarea-api-storefront 4.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/README.md +58 -0
- data/Rakefile +10 -0
- data/app/controllers/workarea/api/storefront/accounts_controller.rb +31 -0
- data/app/controllers/workarea/api/storefront/analytics_controller.rb +41 -0
- data/app/controllers/workarea/api/storefront/application_controller.rb +65 -0
- data/app/controllers/workarea/api/storefront/assets_controller.rb +11 -0
- data/app/controllers/workarea/api/storefront/authentication.rb +30 -0
- data/app/controllers/workarea/api/storefront/authentication_tokens_controller.rb +50 -0
- data/app/controllers/workarea/api/storefront/cart_items_controller.rb +100 -0
- data/app/controllers/workarea/api/storefront/carts_controller.rb +47 -0
- data/app/controllers/workarea/api/storefront/categories_controller.rb +25 -0
- data/app/controllers/workarea/api/storefront/checkouts_controller.rb +117 -0
- data/app/controllers/workarea/api/storefront/contacts_controller.rb +20 -0
- data/app/controllers/workarea/api/storefront/current_checkout.rb +60 -0
- data/app/controllers/workarea/api/storefront/email_signups_controller.rb +15 -0
- data/app/controllers/workarea/api/storefront/menus_controller.rb +19 -0
- data/app/controllers/workarea/api/storefront/orders_controller.rb +32 -0
- data/app/controllers/workarea/api/storefront/pages_controller.rb +14 -0
- data/app/controllers/workarea/api/storefront/password_resets_controller.rb +17 -0
- data/app/controllers/workarea/api/storefront/products_controller.rb +17 -0
- data/app/controllers/workarea/api/storefront/recent_views_controller.rb +46 -0
- data/app/controllers/workarea/api/storefront/recommendations_controller.rb +22 -0
- data/app/controllers/workarea/api/storefront/saved_addresses_controller.rb +38 -0
- data/app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb +54 -0
- data/app/controllers/workarea/api/storefront/searches_controller.rb +29 -0
- data/app/controllers/workarea/api/storefront/system_content_controller.rb +16 -0
- data/app/controllers/workarea/api/storefront/taxons_controller.rb +20 -0
- data/app/controllers/workarea/api/storefront/user_activity.rb +36 -0
- data/app/controllers/workarea/storefront/application_controller.decorator +12 -0
- data/app/helpers/workarea/api/storefront/application_helper.rb +15 -0
- data/app/helpers/workarea/api/storefront/checkouts_helper.rb +11 -0
- data/app/helpers/workarea/api/storefront/content_blocks_helper.rb +38 -0
- data/app/models/workarea/catalog/category.decorator +7 -0
- data/app/models/workarea/user/authentication_token.rb +33 -0
- data/app/models/workarea/user.decorator +8 -0
- data/app/view_models/workarea/api/storefront/search_suggestion_view_model.rb +21 -0
- data/app/views/workarea/api/storefront/accounts/_account.json.jbuilder +7 -0
- data/app/views/workarea/api/storefront/accounts/create.json.jbuilder +7 -0
- data/app/views/workarea/api/storefront/accounts/show.json.jbuilder +1 -0
- data/app/views/workarea/api/storefront/assets/show.json.jbuilder +4 -0
- data/app/views/workarea/api/storefront/authentication_tokens/_authentication_token.json.jbuilder +2 -0
- data/app/views/workarea/api/storefront/authentication_tokens/create.json.jbuilder +1 -0
- data/app/views/workarea/api/storefront/authentication_tokens/update.json.jbuilder +1 -0
- data/app/views/workarea/api/storefront/cart_items/item.json.jbuilder +9 -0
- data/app/views/workarea/api/storefront/carts/index.json.jbuilder +4 -0
- data/app/views/workarea/api/storefront/carts/show.json.jbuilder +1 -0
- data/app/views/workarea/api/storefront/categories/_category.json.jbuilder +4 -0
- data/app/views/workarea/api/storefront/categories/index.json.jbuilder +3 -0
- data/app/views/workarea/api/storefront/categories/show.json.jbuilder +30 -0
- data/app/views/workarea/api/storefront/checkouts/_shipping_options.json.jbuilder +4 -0
- data/app/views/workarea/api/storefront/checkouts/show.json.jbuilder +17 -0
- data/app/views/workarea/api/storefront/checkouts/steps/_addresses.json.jbuilder +19 -0
- data/app/views/workarea/api/storefront/checkouts/steps/_payment.json.jbuilder +9 -0
- data/app/views/workarea/api/storefront/checkouts/steps/_shipping.json.jbuilder +9 -0
- data/app/views/workarea/api/storefront/content_blocks/_block.json.jbuilder +7 -0
- data/app/views/workarea/api/storefront/email_signups/create.json.jbuilder +2 -0
- data/app/views/workarea/api/storefront/email_signups/show.json.jbuilder +4 -0
- data/app/views/workarea/api/storefront/facets/_range.json.jbuilder +8 -0
- data/app/views/workarea/api/storefront/facets/_terms.json.jbuilder +8 -0
- data/app/views/workarea/api/storefront/fulfillments/_fulfillment.json.jbuilder +18 -0
- data/app/views/workarea/api/storefront/menus/_menu.json.jbuilder +11 -0
- data/app/views/workarea/api/storefront/menus/index.json.jbuilder +3 -0
- data/app/views/workarea/api/storefront/menus/show.json.jbuilder +1 -0
- data/app/views/workarea/api/storefront/orders/_item.json.jbuilder +26 -0
- data/app/views/workarea/api/storefront/orders/_order.json.jbuilder +42 -0
- data/app/views/workarea/api/storefront/orders/index.json.jbuilder +4 -0
- data/app/views/workarea/api/storefront/orders/show.json.jbuilder +7 -0
- data/app/views/workarea/api/storefront/orders/tenders/_credit_card.json.jbuilder +6 -0
- data/app/views/workarea/api/storefront/orders/tenders/_store_credit.json.jbuilder +2 -0
- data/app/views/workarea/api/storefront/pages/show.json.jbuilder +16 -0
- data/app/views/workarea/api/storefront/products/_image_urls.json.jbuilder +5 -0
- data/app/views/workarea/api/storefront/products/_product.json.jbuilder +41 -0
- data/app/views/workarea/api/storefront/products/show.json.jbuilder +9 -0
- data/app/views/workarea/api/storefront/recent_views/show.json.jbuilder +8 -0
- data/app/views/workarea/api/storefront/recommendations/show.json.jbuilder +3 -0
- data/app/views/workarea/api/storefront/saved_addresses/_saved_address.json.jbuilder +2 -0
- data/app/views/workarea/api/storefront/saved_addresses/index.json.jbuilder +4 -0
- data/app/views/workarea/api/storefront/saved_addresses/show.json.jbuilder +2 -0
- data/app/views/workarea/api/storefront/saved_credit_cards/_card.json.jbuilder +9 -0
- data/app/views/workarea/api/storefront/saved_credit_cards/index.json.jbuilder +4 -0
- data/app/views/workarea/api/storefront/saved_credit_cards/show.json.jbuilder +2 -0
- data/app/views/workarea/api/storefront/searches/index.json.jbuilder +1 -0
- data/app/views/workarea/api/storefront/searches/show.json.jbuilder +19 -0
- data/app/views/workarea/api/storefront/shared/_address.json.jbuilder +12 -0
- data/app/views/workarea/api/storefront/shared/_pagination.json.jbuilder +11 -0
- data/app/views/workarea/api/storefront/system_content/show.json.jbuilder +12 -0
- data/app/views/workarea/api/storefront/taxons/_taxon.json.jbuilder +10 -0
- data/app/views/workarea/api/storefront/taxons/show.json.jbuilder +7 -0
- data/app/workers/workarea/remove_authentication_tokens_on_password_changes.rb +19 -0
- data/bin/rails +18 -0
- data/config/initializers/config.rb +2 -0
- data/config/locales/en.yml +13 -0
- data/config/routes.rb +41 -0
- data/lib/workarea/api/storefront/engine.rb +10 -0
- data/lib/workarea/api/storefront.rb +15 -0
- data/test/documentation/workarea/api/storefront/accounts_documentation_test.rb +70 -0
- data/test/documentation/workarea/api/storefront/analytics_documentation_test.rb +51 -0
- data/test/documentation/workarea/api/storefront/assets_documentation_test.rb +32 -0
- data/test/documentation/workarea/api/storefront/authentication_documentation_test.rb +84 -0
- data/test/documentation/workarea/api/storefront/cart_items_documentation_test.rb +104 -0
- data/test/documentation/workarea/api/storefront/carts_documentation_test.rb +121 -0
- data/test/documentation/workarea/api/storefront/categories_documentation_test.rb +90 -0
- data/test/documentation/workarea/api/storefront/checkouts_documentation_test.rb +142 -0
- data/test/documentation/workarea/api/storefront/contacts_documentation_test.rb +39 -0
- data/test/documentation/workarea/api/storefront/email_signups_documentation_test.rb +53 -0
- data/test/documentation/workarea/api/storefront/menus_documentation_test.rb +67 -0
- data/test/documentation/workarea/api/storefront/orders_documentation_test.rb +127 -0
- data/test/documentation/workarea/api/storefront/pages_documentation_test.rb +66 -0
- data/test/documentation/workarea/api/storefront/password_resets_documentation_test.rb +30 -0
- data/test/documentation/workarea/api/storefront/products_documentation_test.rb +64 -0
- data/test/documentation/workarea/api/storefront/recent_views_documentation_test.rb +116 -0
- data/test/documentation/workarea/api/storefront/recommendations_documentation_test.rb +68 -0
- data/test/documentation/workarea/api/storefront/saved_addresses_documentation_test.rb +129 -0
- data/test/documentation/workarea/api/storefront/saved_credit_cards_documentation_test.rb +129 -0
- data/test/documentation/workarea/api/storefront/searches_documentation_test.rb +88 -0
- data/test/documentation/workarea/api/storefront/system_content_documentation_test.rb +66 -0
- data/test/documentation/workarea/api/storefront/taxons_documentation_test.rb +37 -0
- data/test/documentation/workarea/api/storefront/validation_documentation_test.rb +81 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config/application.rb +25 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +55 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +43 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +21 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/workarea.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +6 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/seeds.rb +2 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +1 -0
- data/test/integration/workarea/api/storefront/accounts_integration_test.rb +49 -0
- data/test/integration/workarea/api/storefront/analytics_integration_test.rb +36 -0
- data/test/integration/workarea/api/storefront/assets_integration_test.rb +24 -0
- data/test/integration/workarea/api/storefront/authentication_integration_test.rb +50 -0
- data/test/integration/workarea/api/storefront/authentication_tokens_integration_test.rb +87 -0
- data/test/integration/workarea/api/storefront/cart_items_integration_test.rb +149 -0
- data/test/integration/workarea/api/storefront/carts_integration_test.rb +114 -0
- data/test/integration/workarea/api/storefront/categories_integration_test.rb +84 -0
- data/test/integration/workarea/api/storefront/checkouts_integration_test.rb +203 -0
- data/test/integration/workarea/api/storefront/contacts_integration_test.rb +28 -0
- data/test/integration/workarea/api/storefront/email_signups_integration_test.rb +35 -0
- data/test/integration/workarea/api/storefront/menus_integration_test.rb +53 -0
- data/test/integration/workarea/api/storefront/orders_integration_test.rb +115 -0
- data/test/integration/workarea/api/storefront/pages_integration_test.rb +57 -0
- data/test/integration/workarea/api/storefront/password_resets_integration_test.rb +20 -0
- data/test/integration/workarea/api/storefront/products_integration_test.rb +50 -0
- data/test/integration/workarea/api/storefront/recent_views_integration_test.rb +118 -0
- data/test/integration/workarea/api/storefront/recommendations_integration_test.rb +51 -0
- data/test/integration/workarea/api/storefront/saved_addresses_integration_test.rb +100 -0
- data/test/integration/workarea/api/storefront/saved_credit_cards_integration_test.rb +107 -0
- data/test/integration/workarea/api/storefront/searches_integration_test.rb +128 -0
- data/test/integration/workarea/api/storefront/system_content_integration_test.rb +35 -0
- data/test/integration/workarea/api/storefront/taxons_integration_test.rb +44 -0
- data/test/integration/workarea/api/storefront/user_carts_integration_test.rb +55 -0
- data/test/models/workarea/user/authentication_token_test.rb +30 -0
- data/test/support/authentication_test.rb +25 -0
- data/test/support/orders_test.rb +18 -0
- data/test/test_helper.rb +10 -0
- data/workarea-api-storefront.gemspec +18 -0
- metadata +277 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
json.addresses do
|
2
|
+
json.complete step.complete?
|
3
|
+
json.email summary.email
|
4
|
+
json.problems summary.order.errors.full_messages
|
5
|
+
|
6
|
+
json.shipping_address do
|
7
|
+
if summary.shipping_address.present?
|
8
|
+
json.partial! 'workarea/api/storefront/shared/address', address: summary.shipping_address
|
9
|
+
json.problems summary.shipping_address.errors.full_messages
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
json.billing_address do
|
14
|
+
if summary.billing_address.present?
|
15
|
+
json.partial! 'workarea/api/storefront/shared/address', address: summary.billing_address
|
16
|
+
json.problems summary.billing_address.errors.full_messages
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
json.payment do
|
2
|
+
json.complete step.complete?
|
3
|
+
json.problems step.payment.errors.full_messages
|
4
|
+
|
5
|
+
json.tenders summary.payment.tenders do |tender|
|
6
|
+
json.partial! "workarea/api/storefront/orders/tenders/#{tender.slug}", tender: tender
|
7
|
+
json.problems tender.errors.full_messages
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
json.shipping do
|
2
|
+
json.complete summary.shipping_service.present? && step.complete?
|
3
|
+
json.problems summary.shipping.errors.full_messages
|
4
|
+
|
5
|
+
json.shipping_service summary.shipping_service
|
6
|
+
json.shipping_total cart.shipping_total
|
7
|
+
|
8
|
+
json.partial! 'workarea/api/storefront/checkouts/shipping_options', cart: cart
|
9
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
json.status order.try(:fulfillment_status)
|
2
|
+
|
3
|
+
json.packages order.packages do |package|
|
4
|
+
json.tracking_number package.tracking_number
|
5
|
+
json.tracking_link package.tracking_link
|
6
|
+
|
7
|
+
json.items package.items do |item|
|
8
|
+
json.partial! 'workarea/api/storefront/orders/item', item: item
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
json.pending_items order.pending_items do |item|
|
13
|
+
json.partial! 'workarea/api/storefront/orders/item', item: item
|
14
|
+
end
|
15
|
+
|
16
|
+
json.canceled_items order.canceled_items do |item|
|
17
|
+
json.partial! 'workarea/api/storefront/orders/item', item: item
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
json.cache! menu.cache_key, expires_in: 1.hour do
|
2
|
+
json.id menu.id
|
3
|
+
json.name menu.name
|
4
|
+
json.position menu.position
|
5
|
+
json.url menu_path(menu)
|
6
|
+
json.taxon_url menu.taxon.url.presence || storefront_api_url_for(menu.taxon)
|
7
|
+
|
8
|
+
json.content_blocks menu.content.blocks do |block|
|
9
|
+
json.partial! 'workarea/api/storefront/content_blocks/block', block: block
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! 'workarea/api/storefront/menus/menu', menu: @menu
|
@@ -0,0 +1,26 @@
|
|
1
|
+
json.id item.id
|
2
|
+
json.product_id item.product_id
|
3
|
+
json.sku item.sku
|
4
|
+
json.quantity item.quantity
|
5
|
+
json.product_url product_url(item.product, sku: item.sku)
|
6
|
+
json.options item.details
|
7
|
+
json.customizations item.customizations
|
8
|
+
|
9
|
+
json.product_image do
|
10
|
+
json.partial! 'workarea/api/storefront/products/image_urls', image: item.image
|
11
|
+
end
|
12
|
+
|
13
|
+
json.pricing do
|
14
|
+
json.price_adjustments item.price_adjustments do |adjustment|
|
15
|
+
json.description adjustment.description
|
16
|
+
json.discount adjustment.discount?
|
17
|
+
json.amount adjustment.amount
|
18
|
+
end
|
19
|
+
|
20
|
+
json.total_price item.total_price
|
21
|
+
json.on_sale item.on_sale?
|
22
|
+
json.original_unit_price item.original_unit_price
|
23
|
+
json.original_price item.original_price
|
24
|
+
json.customized item.customized?
|
25
|
+
json.customizations_unit_price item.customizations_unit_price
|
26
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
json.id order.id
|
2
|
+
json.url order_url(order)
|
3
|
+
json.user_id order.user_id
|
4
|
+
json.email order.email
|
5
|
+
json.placed_at order.placed_at
|
6
|
+
json.canceled_at order.canceled_at
|
7
|
+
json.promo_codes order.promo_codes
|
8
|
+
json.requires_shipping order.requires_shipping?
|
9
|
+
|
10
|
+
json.items order.items do |item|
|
11
|
+
json.partial! 'workarea/api/storefront/orders/item', item: item
|
12
|
+
end
|
13
|
+
|
14
|
+
json.pricing do
|
15
|
+
json.price_adjustments order.total_adjustments do |adjustment|
|
16
|
+
json.description adjustment.description.titleize
|
17
|
+
json.amount adjustment.amount
|
18
|
+
end
|
19
|
+
|
20
|
+
json.shipping_total order.shipping_total
|
21
|
+
json.tax_total order.tax_total
|
22
|
+
json.subtotal_price order.subtotal_price
|
23
|
+
json.total_price order.total_price
|
24
|
+
json.paid_amount order.try(:paid_amount) || 0
|
25
|
+
end
|
26
|
+
|
27
|
+
json.shipping_service order.shipping_service
|
28
|
+
json.shipping_address do
|
29
|
+
if order.shipping_address.present?
|
30
|
+
json.partial! 'workarea/api/storefront/shared/address', address: order.shipping_address
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
json.billing_address do
|
35
|
+
if order.billing_address.present?
|
36
|
+
json.partial! 'workarea/api/storefront/shared/address', address: order.billing_address
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
json.tenders order.tenders do |tender|
|
41
|
+
json.partial! "workarea/api/storefront/orders/tenders/#{tender.slug}", tender: tender
|
42
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
json.cache! @page.cache_key, expires_in: 1.hour do
|
2
|
+
json.id @page.id
|
3
|
+
json.name @page.name
|
4
|
+
json.url page_url(@page)
|
5
|
+
|
6
|
+
json.browser_title @page.browser_title
|
7
|
+
json.meta_description @page.meta_description
|
8
|
+
|
9
|
+
json.breadcrumbs @page.breadcrumbs do |taxon|
|
10
|
+
json.partial! 'workarea/api/storefront/taxons/taxon', taxon: taxon
|
11
|
+
end
|
12
|
+
|
13
|
+
json.content_blocks @page.content.blocks do |block|
|
14
|
+
json.partial! 'workarea/api/storefront/content_blocks/block', block: block
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
json.cache! product.cache_key, expires_in: 1.hour do
|
2
|
+
json.id product.id
|
3
|
+
|
4
|
+
json.name product.name
|
5
|
+
json.description product.description
|
6
|
+
json.slug product.slug
|
7
|
+
|
8
|
+
json.browser_title product.browser_title
|
9
|
+
json.meta_description product.meta_description
|
10
|
+
|
11
|
+
json.template product.template
|
12
|
+
json.customizations product.customizations
|
13
|
+
json.details product.details
|
14
|
+
json.digital product.digital?
|
15
|
+
json.filters product.filters
|
16
|
+
json.purchasable product.purchasable?
|
17
|
+
json.inventory_status product.inventory_status
|
18
|
+
|
19
|
+
json.variants product.variants do |variant|
|
20
|
+
json.id variant.id
|
21
|
+
json.name variant.name
|
22
|
+
json.sku variant.sku
|
23
|
+
json.details variant.details
|
24
|
+
end
|
25
|
+
|
26
|
+
json.sell_min_price json.sell_min_price
|
27
|
+
json.sell_max_price product.sell_max_price
|
28
|
+
json.on_sale product.on_sale?
|
29
|
+
json.original_min_price product.original_min_price
|
30
|
+
json.original_max_price product.original_max_price
|
31
|
+
|
32
|
+
json.images product.images do |image|
|
33
|
+
json.id image.id
|
34
|
+
json.option image.option
|
35
|
+
json.position image.position
|
36
|
+
json.primary image == product.primary_image
|
37
|
+
json.partial! 'workarea/api/storefront/products/image_urls', image: image
|
38
|
+
end
|
39
|
+
|
40
|
+
json.append_partials('api.storefront.product_details', product: product)
|
41
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
json.cache! @product.cache_key, expires_in: 1.hour do
|
2
|
+
json.product do
|
3
|
+
json.partial! 'workarea/api/storefront/products/product', product: @product
|
4
|
+
end
|
5
|
+
|
6
|
+
json.recommendations @product.recommendations do |product|
|
7
|
+
json.partial! 'workarea/api/storefront/products/product', product: product
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
json.id @recent_views.id
|
2
|
+
json.categories @recent_views.categories do |category|
|
3
|
+
json.partial! 'workarea/api/storefront/categories/category', category: category
|
4
|
+
end
|
5
|
+
json.products @recent_views.products do |product|
|
6
|
+
json.partial! 'workarea/api/storefront/products/product', product: product
|
7
|
+
end
|
8
|
+
json.searches @recent_views.searches
|
@@ -0,0 +1 @@
|
|
1
|
+
json.results @results
|
@@ -0,0 +1,19 @@
|
|
1
|
+
json.query_string @search.query_string
|
2
|
+
json.message @search.message
|
3
|
+
json.redirect @search.redirect
|
4
|
+
json.sorts @search.sorts
|
5
|
+
json.sort @search.sort
|
6
|
+
|
7
|
+
json.content_blocks @search.content.blocks do |block|
|
8
|
+
json.partial! 'workarea/api/storefront/content_blocks/block', block: block
|
9
|
+
end
|
10
|
+
|
11
|
+
json.partial! 'workarea/api/storefront/shared/pagination', model: @search
|
12
|
+
|
13
|
+
json.facets @search.facets do |facet|
|
14
|
+
json.partial! "workarea/api/storefront/facets/#{facet.type}", facet: facet
|
15
|
+
end
|
16
|
+
|
17
|
+
json.products @search.products do |product|
|
18
|
+
json.partial! 'workarea/api/storefront/products/product', product: product
|
19
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
json.id address.id
|
2
|
+
json.first_name address.first_name
|
3
|
+
json.last_name address.last_name
|
4
|
+
json.company address.company
|
5
|
+
json.street address.street
|
6
|
+
json.street_2 address.street_2
|
7
|
+
json.city address.city
|
8
|
+
json.country address.country.try(:alpha2)
|
9
|
+
json.region address.region
|
10
|
+
json.postal_code address.postal_code
|
11
|
+
json.phone_number address.phone_number
|
12
|
+
json.phone_extension address.phone_extension
|
@@ -0,0 +1,11 @@
|
|
1
|
+
json.first_page model.first_page?
|
2
|
+
json.second_page model.second_page?
|
3
|
+
json.last_page model.last_page?
|
4
|
+
|
5
|
+
json.page model.page
|
6
|
+
json.next_page model.next_page
|
7
|
+
json.prev_page model.prev_page
|
8
|
+
json.per_page model.per_page
|
9
|
+
|
10
|
+
json.total_results model.total
|
11
|
+
json.total_pages model.total_pages
|
@@ -0,0 +1,12 @@
|
|
1
|
+
json.cache! @content.cache_key, expires_in: 1.hour do
|
2
|
+
json.id @content.id
|
3
|
+
json.name @content.name
|
4
|
+
json.url system_content_url(@content.name)
|
5
|
+
|
6
|
+
json.browser_title @content.browser_title
|
7
|
+
json.meta_description @content.meta_description
|
8
|
+
|
9
|
+
json.content_blocks @content.content.blocks do |block|
|
10
|
+
json.partial! 'workarea/api/storefront/content_blocks/block', block: block
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
json.cache! taxon.cache_key, expires_in: 1.day do
|
2
|
+
json.id taxon.id
|
3
|
+
json.url taxon_path(taxon)
|
4
|
+
json.name taxon.name
|
5
|
+
json.depth taxon.depth
|
6
|
+
json.navigable_url taxon.url.presence || storefront_api_url_for(taxon)
|
7
|
+
json.parent_id taxon.parent_id
|
8
|
+
json.parent_ids taxon.parent_ids
|
9
|
+
json.position taxon.position
|
10
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Workarea
|
2
|
+
class RemoveAuthenticationTokensOnPasswordChanges
|
3
|
+
include Sidekiq::Worker
|
4
|
+
include Sidekiq::CallbacksWorker
|
5
|
+
|
6
|
+
sidekiq_options(
|
7
|
+
enqueue_on: {
|
8
|
+
User => [:save],
|
9
|
+
ignore_if: -> { new_record? || changes['password_digest'].blank? },
|
10
|
+
with: -> { [id] }
|
11
|
+
},
|
12
|
+
unique: :until_executing
|
13
|
+
)
|
14
|
+
|
15
|
+
def perform(id)
|
16
|
+
User.find(id).authentication_tokens.destroy_all
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/bin/rails
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails gems
|
3
|
+
# installed from the root of your application.
|
4
|
+
|
5
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
6
|
+
ENGINE_PATH = File.expand_path('../../lib/workarea/api/storefront/engine', __FILE__)
|
7
|
+
|
8
|
+
# Set up gems listed in the Gemfile.
|
9
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __FILE__)
|
10
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
11
|
+
|
12
|
+
require 'action_controller/railtie'
|
13
|
+
require 'action_view/railtie'
|
14
|
+
require 'action_mailer/railtie'
|
15
|
+
require 'rails/test_unit/railtie'
|
16
|
+
require 'sprockets/railtie'
|
17
|
+
|
18
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
en:
|
2
|
+
workarea:
|
3
|
+
api:
|
4
|
+
storefront:
|
5
|
+
authentication_tokens:
|
6
|
+
error: Could not find a matching email and password
|
7
|
+
login_locked: This account has been locked for too many login attempts
|
8
|
+
recent_views:
|
9
|
+
missing_id: Recent views endpoints require either authentication or passing in a session_id in the parameters.
|
10
|
+
passwords:
|
11
|
+
error: Could not find a matching email and password
|
12
|
+
recommendations:
|
13
|
+
missing_id: Recommendation endpoints require either authentication or passing in a session_id in the parameters.
|
data/config/routes.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
Workarea::Api::Storefront::Engine.routes.draw do
|
2
|
+
resource :account, except: [:new, :edit, :destroy]
|
3
|
+
|
4
|
+
post 'analytics/category_view/:category_id', to: 'analytics#category_view', as: :analytics_category_view
|
5
|
+
post 'analytics/product_view/:product_id', to: 'analytics#product_view', as: :analytics_product_view
|
6
|
+
post 'analytics/search', to: 'analytics#search', as: :analytics_search
|
7
|
+
post 'analytics/search_abandonment', to: 'analytics#search_abandonment', as: :analytics_search_abandonment
|
8
|
+
post 'analytics/filters', to: 'analytics#filters', as: :analytics_filters
|
9
|
+
|
10
|
+
resource :authentication_tokens, only: [:create, :update]
|
11
|
+
resources :assets, only: :show
|
12
|
+
resources :categories, only: [:index, :show]
|
13
|
+
resources :contacts, only: :create
|
14
|
+
resources :orders, only: [:index, :show]
|
15
|
+
resources :pages, only: :show
|
16
|
+
resource :recent_views, only: [:show, :update]
|
17
|
+
resources :saved_addresses, except: [:new, :edit]
|
18
|
+
resources :saved_credit_cards, except: [:new, :edit]
|
19
|
+
resource :search, only: :show
|
20
|
+
resources :searches, only: :index
|
21
|
+
resources :system_content, only: :show
|
22
|
+
resources :menus, only: [:index, :show]
|
23
|
+
resource :email_signups, only: [:show, :create]
|
24
|
+
resources :password_resets, only: :create
|
25
|
+
resources :products, only: :show
|
26
|
+
resource :recommendations, only: :show
|
27
|
+
resources :taxons, only: :show
|
28
|
+
|
29
|
+
resources :carts, only: [:index, :show, :create] do
|
30
|
+
resources :items, only: [:create, :update, :destroy], controller: :cart_items
|
31
|
+
member { post 'add_promo_code', as: :add_promo_code_to }
|
32
|
+
end
|
33
|
+
|
34
|
+
resources :checkouts, only: [:show, :update] do
|
35
|
+
member do
|
36
|
+
get 'start'
|
37
|
+
get 'reset'
|
38
|
+
post 'complete'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'workarea/api/documentation_test'
|
3
|
+
|
4
|
+
module Workarea
|
5
|
+
module Api
|
6
|
+
module Storefront
|
7
|
+
class AccountsDocumentationTest < DocumentationTest
|
8
|
+
include AuthenticationTest
|
9
|
+
|
10
|
+
resource 'Accounts'
|
11
|
+
|
12
|
+
def test_showing_an_account
|
13
|
+
description 'Getting account details'
|
14
|
+
route storefront_api.account_path
|
15
|
+
|
16
|
+
user = create_user
|
17
|
+
auth = user.authentication_tokens.create!
|
18
|
+
|
19
|
+
record_request do
|
20
|
+
get storefront_api.account_path,
|
21
|
+
headers: { 'HTTP_AUTHORIZATION' => encode_credentials(auth.token) }
|
22
|
+
|
23
|
+
assert_equal(200, response.status)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_creating_an_account
|
28
|
+
description 'Creating an account'
|
29
|
+
route storefront_api.account_path
|
30
|
+
explanation <<-EOS
|
31
|
+
This endpoint does three things: it creates an account, it creates
|
32
|
+
an authentication token, and it sends an account creation email to
|
33
|
+
the customer.
|
34
|
+
EOS
|
35
|
+
|
36
|
+
record_request do
|
37
|
+
post storefront_api.account_path,
|
38
|
+
as: :json,
|
39
|
+
params: {
|
40
|
+
email: 'bob@workarea.com',
|
41
|
+
password: 'areallysecurepassword'
|
42
|
+
}
|
43
|
+
|
44
|
+
assert_equal(200, response.status)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_updating_an_account
|
49
|
+
description 'Updating an account'
|
50
|
+
route storefront_api.account_path
|
51
|
+
|
52
|
+
user = create_user
|
53
|
+
auth = user.authentication_tokens.create!
|
54
|
+
|
55
|
+
record_request do
|
56
|
+
get storefront_api.account_path,
|
57
|
+
headers: { 'HTTP_AUTHORIZATION' => encode_credentials(auth.token) },
|
58
|
+
as: :json,
|
59
|
+
params: {
|
60
|
+
email: 'billy@workarea.com',
|
61
|
+
password: 'adifferentbutstillreallysecurepassword'
|
62
|
+
}
|
63
|
+
|
64
|
+
assert_equal(200, response.status)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|