workarea-core 3.4.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +52 -0
- data/README.md +19 -0
- data/Rakefile +23 -0
- data/app/assets/images/workarea/core/favicon_placeholder.png +0 -0
- data/app/assets/images/workarea/core/icon.svg +4 -0
- data/app/assets/images/workarea/core/open_graph_placeholder.png +0 -0
- data/app/assets/images/workarea/core/placeholder.png +0 -0
- data/app/assets/images/workarea/core/product_placeholder.jpg +0 -0
- data/app/assets/javascripts/workarea/core/config.js +59 -0
- data/app/assets/javascripts/workarea/core/modules/cookie.js +64 -0
- data/app/assets/javascripts/workarea/core/modules/date.js +111 -0
- data/app/assets/javascripts/workarea/core/modules/deletion_forms.js +45 -0
- data/app/assets/javascripts/workarea/core/modules/duplicate_id.js +78 -0
- data/app/assets/javascripts/workarea/core/modules/environment.js +23 -0
- data/app/assets/javascripts/workarea/core/modules/form_submitting_controls.js +52 -0
- data/app/assets/javascripts/workarea/core/modules/forms.js +14 -0
- data/app/assets/javascripts/workarea/core/modules/image.js +43 -0
- data/app/assets/javascripts/workarea/core/modules/jquery.js +34 -0
- data/app/assets/javascripts/workarea/core/modules/local_time.js +16 -0
- data/app/assets/javascripts/workarea/core/modules/reveal_password.js +47 -0
- data/app/assets/javascripts/workarea/core/modules/string.js +62 -0
- data/app/assets/javascripts/workarea/core/modules/style_guide_accordions.js +21 -0
- data/app/assets/javascripts/workarea/core/modules/style_guide_autocomplete_fields.js +42 -0
- data/app/assets/javascripts/workarea/core/modules/style_guide_empty_links.js +23 -0
- data/app/assets/javascripts/workarea/core/modules/transition_events.js +71 -0
- data/app/assets/javascripts/workarea/core/modules/url.js +123 -0
- data/app/assets/javascripts/workarea/core/routes.js +9 -0
- data/app/assets/javascripts/workarea/core/templates/hidden_input.jst.ejs +1 -0
- data/app/assets/javascripts/workarea/core/templates/lorem_ipsum_view.jst.ejs +6 -0
- data/app/assets/javascripts/workarea/core/templates/reveal_password_button.jst.ejs +4 -0
- data/app/assets/javascripts/workarea/core/templates/ui_menu_item.jst.ejs +10 -0
- data/app/assets/javascripts/workarea/core/workarea.js +63 -0
- data/app/controllers/workarea/admin_guest_browsing.rb +54 -0
- data/app/controllers/workarea/application_controller.rb +42 -0
- data/app/controllers/workarea/authentication.rb +117 -0
- data/app/controllers/workarea/authorization.rb +46 -0
- data/app/controllers/workarea/current_referrer.rb +14 -0
- data/app/controllers/workarea/current_release.rb +56 -0
- data/app/controllers/workarea/impersonation.rb +92 -0
- data/app/controllers/workarea/style_guides.rb +17 -0
- data/app/helpers/workarea/addresses_helper.rb +48 -0
- data/app/helpers/workarea/application_helper.rb +70 -0
- data/app/helpers/workarea/content_assets_helper.rb +22 -0
- data/app/helpers/workarea/details_helper.rb +12 -0
- data/app/helpers/workarea/facets_helper.rb +53 -0
- data/app/helpers/workarea/i18n_helper.rb +19 -0
- data/app/helpers/workarea/plugins_helper.rb +23 -0
- data/app/helpers/workarea/style_guides_helper.rb +88 -0
- data/app/mailers/workarea/application_mailer.rb +13 -0
- data/app/middleware/workarea/audit_log_client_middleware.rb +8 -0
- data/app/middleware/workarea/audit_log_server_middleware.rb +14 -0
- data/app/middleware/workarea/enforce_host_middleware.rb +39 -0
- data/app/middleware/workarea/i18n_client_middleware.rb +8 -0
- data/app/middleware/workarea/i18n_server_middleware.rb +11 -0
- data/app/middleware/workarea/rack_cache_config_middleware.rb +19 -0
- data/app/middleware/workarea/release_server_middleware.rb +11 -0
- data/app/middleware/workarea/skip_rack_cache_middleware.rb +19 -0
- data/app/middleware/workarea/strip_http_caching_middleware.rb +23 -0
- data/app/models/workarea/address.rb +149 -0
- data/app/models/workarea/application_document.rb +75 -0
- data/app/models/workarea/bulk_action.rb +82 -0
- data/app/models/workarea/bulk_action/deletion.rb +11 -0
- data/app/models/workarea/bulk_action/product_edit.rb +83 -0
- data/app/models/workarea/bulk_action/sequential_product_edit.rb +21 -0
- data/app/models/workarea/calculate_percent_change.rb +8 -0
- data/app/models/workarea/catalog/category.rb +31 -0
- data/app/models/workarea/catalog/clean_details.rb +18 -0
- data/app/models/workarea/catalog/customizations.rb +81 -0
- data/app/models/workarea/catalog/details_queries.rb +57 -0
- data/app/models/workarea/catalog/product.rb +154 -0
- data/app/models/workarea/catalog/product_image.rb +59 -0
- data/app/models/workarea/catalog/product_placeholder_image.rb +57 -0
- data/app/models/workarea/catalog/product_positions.rb +40 -0
- data/app/models/workarea/catalog/variant.rb +26 -0
- data/app/models/workarea/checkout.rb +234 -0
- data/app/models/workarea/checkout/auto_complete.rb +74 -0
- data/app/models/workarea/checkout/collect_payment.rb +40 -0
- data/app/models/workarea/checkout/credit_card_params.rb +54 -0
- data/app/models/workarea/checkout/shipping_options.rb +99 -0
- data/app/models/workarea/checkout/steps/addresses.rb +102 -0
- data/app/models/workarea/checkout/steps/base.rb +35 -0
- data/app/models/workarea/checkout/steps/payment.rb +71 -0
- data/app/models/workarea/checkout/steps/shipping.rb +82 -0
- data/app/models/workarea/comment.rb +15 -0
- data/app/models/workarea/commentable.rb +35 -0
- data/app/models/workarea/content.rb +231 -0
- data/app/models/workarea/content/asset.rb +162 -0
- data/app/models/workarea/content/asset_lookup.rb +14 -0
- data/app/models/workarea/content/block.rb +157 -0
- data/app/models/workarea/content/block_draft.rb +36 -0
- data/app/models/workarea/content/block_name.rb +45 -0
- data/app/models/workarea/content/block_type.rb +195 -0
- data/app/models/workarea/content/block_type_definition.rb +16 -0
- data/app/models/workarea/content/email.rb +31 -0
- data/app/models/workarea/content/field.rb +49 -0
- data/app/models/workarea/content/fields/asset.rb +15 -0
- data/app/models/workarea/content/fields/boolean.rb +11 -0
- data/app/models/workarea/content/fields/breakpoints.rb +11 -0
- data/app/models/workarea/content/fields/category.rb +8 -0
- data/app/models/workarea/content/fields/color.rb +11 -0
- data/app/models/workarea/content/fields/integer.rb +11 -0
- data/app/models/workarea/content/fields/options.rb +11 -0
- data/app/models/workarea/content/fields/products.rb +11 -0
- data/app/models/workarea/content/fields/range.rb +23 -0
- data/app/models/workarea/content/fields/string.rb +11 -0
- data/app/models/workarea/content/fields/taxonomy.rb +8 -0
- data/app/models/workarea/content/fields/text.rb +8 -0
- data/app/models/workarea/content/fields/url.rb +8 -0
- data/app/models/workarea/content/fieldset.rb +31 -0
- data/app/models/workarea/content/page.rb +18 -0
- data/app/models/workarea/content/preset.rb +66 -0
- data/app/models/workarea/contentable.rb +9 -0
- data/app/models/workarea/data_file/csv.rb +161 -0
- data/app/models/workarea/data_file/csv_fields.rb +82 -0
- data/app/models/workarea/data_file/export.rb +38 -0
- data/app/models/workarea/data_file/format.rb +85 -0
- data/app/models/workarea/data_file/import.rb +82 -0
- data/app/models/workarea/data_file/json.rb +56 -0
- data/app/models/workarea/data_file/operation.rb +71 -0
- data/app/models/workarea/data_file/tax_import.rb +33 -0
- data/app/models/workarea/data_file/tax_rates.rb +58 -0
- data/app/models/workarea/data_file/unknown_format_error.rb +5 -0
- data/app/models/workarea/details.rb +111 -0
- data/app/models/workarea/discount_ids.rb +34 -0
- data/app/models/workarea/email.rb +21 -0
- data/app/models/workarea/email/signup.rb +18 -0
- data/app/models/workarea/featured_products.rb +39 -0
- data/app/models/workarea/fulfillment.rb +166 -0
- data/app/models/workarea/fulfillment/event.rb +14 -0
- data/app/models/workarea/fulfillment/item.rb +27 -0
- data/app/models/workarea/fulfillment/package.rb +46 -0
- data/app/models/workarea/fulfillment/status.rb +55 -0
- data/app/models/workarea/guard_negative_price.rb +6 -0
- data/app/models/workarea/help/article.rb +71 -0
- data/app/models/workarea/help/asset.rb +26 -0
- data/app/models/workarea/inquiry.rb +30 -0
- data/app/models/workarea/insights/base.rb +66 -0
- data/app/models/workarea/insights/best_customers.rb +30 -0
- data/app/models/workarea/insights/best_full_price_customers.rb +31 -0
- data/app/models/workarea/insights/cold_products.rb +49 -0
- data/app/models/workarea/insights/cold_searches.rb +49 -0
- data/app/models/workarea/insights/customer_acquisition.rb +62 -0
- data/app/models/workarea/insights/customers_at_risk.rb +26 -0
- data/app/models/workarea/insights/hot_products.rb +49 -0
- data/app/models/workarea/insights/hot_searches.rb +49 -0
- data/app/models/workarea/insights/low_aov_customers.rb +27 -0
- data/app/models/workarea/insights/most_discount_given.rb +52 -0
- data/app/models/workarea/insights/most_discounted_products.rb +25 -0
- data/app/models/workarea/insights/new_products.rb +33 -0
- data/app/models/workarea/insights/non_sellers.rb +25 -0
- data/app/models/workarea/insights/popular_searches.rb +29 -0
- data/app/models/workarea/insights/popular_searches_without_results.rb +30 -0
- data/app/models/workarea/insights/products_purchased_together.rb +30 -0
- data/app/models/workarea/insights/products_to_improve.rb +44 -0
- data/app/models/workarea/insights/promising_products.rb +47 -0
- data/app/models/workarea/insights/release_reminder.rb +20 -0
- data/app/models/workarea/insights/repeat_purchase_rate.rb +38 -0
- data/app/models/workarea/insights/sales_by_navigation.rb +50 -0
- data/app/models/workarea/insights/searches_to_improve.rb +44 -0
- data/app/models/workarea/insights/star_products.rb +30 -0
- data/app/models/workarea/insights/star_searches.rb +30 -0
- data/app/models/workarea/insights/top_categories.rb +51 -0
- data/app/models/workarea/insights/top_discounts.rb +51 -0
- data/app/models/workarea/insights/top_products.rb +51 -0
- data/app/models/workarea/insights/trending_products.rb +69 -0
- data/app/models/workarea/insights/trending_searches.rb +69 -0
- data/app/models/workarea/insights/upcoming_releases.rb +20 -0
- data/app/models/workarea/invalid_display.rb +3 -0
- data/app/models/workarea/inventory.rb +72 -0
- data/app/models/workarea/inventory/capture.rb +100 -0
- data/app/models/workarea/inventory/collection.rb +50 -0
- data/app/models/workarea/inventory/policies/allow_backorder.rb +38 -0
- data/app/models/workarea/inventory/policies/base.rb +44 -0
- data/app/models/workarea/inventory/policies/displayable_when_out_of_stock.rb +11 -0
- data/app/models/workarea/inventory/policies/ignore.rb +20 -0
- data/app/models/workarea/inventory/policies/standard.rb +23 -0
- data/app/models/workarea/inventory/sku.rb +158 -0
- data/app/models/workarea/inventory/transaction.rb +102 -0
- data/app/models/workarea/inventory/transaction_item.rb +19 -0
- data/app/models/workarea/inventory/unit_of_work.rb +81 -0
- data/app/models/workarea/lock.rb +75 -0
- data/app/models/workarea/lockable.rb +58 -0
- data/app/models/workarea/metrics/by_day.rb +59 -0
- data/app/models/workarea/metrics/by_week.rb +36 -0
- data/app/models/workarea/metrics/calculate_percentiles.rb +42 -0
- data/app/models/workarea/metrics/category_by_day.rb +21 -0
- data/app/models/workarea/metrics/country_by_day.rb +20 -0
- data/app/models/workarea/metrics/discount_by_day.rb +17 -0
- data/app/models/workarea/metrics/menu_by_day.rb +21 -0
- data/app/models/workarea/metrics/product_by_day.rb +22 -0
- data/app/models/workarea/metrics/product_by_week.rb +32 -0
- data/app/models/workarea/metrics/product_for_last_week.rb +185 -0
- data/app/models/workarea/metrics/revenue_change.rb +39 -0
- data/app/models/workarea/metrics/sales_by_day.rb +20 -0
- data/app/models/workarea/metrics/scoring.rb +30 -0
- data/app/models/workarea/metrics/search_by_day.rb +35 -0
- data/app/models/workarea/metrics/search_by_week.rb +36 -0
- data/app/models/workarea/metrics/search_for_last_week.rb +192 -0
- data/app/models/workarea/metrics/sku_by_day.rb +19 -0
- data/app/models/workarea/metrics/traffic_referrer_by_day.rb +20 -0
- data/app/models/workarea/metrics/user.rb +128 -0
- data/app/models/workarea/navigable.rb +46 -0
- data/app/models/workarea/navigation/breadcrumbs.rb +58 -0
- data/app/models/workarea/navigation/menu.rb +30 -0
- data/app/models/workarea/navigation/redirect.rb +61 -0
- data/app/models/workarea/navigation/search_results.rb +49 -0
- data/app/models/workarea/navigation/taxon.rb +150 -0
- data/app/models/workarea/navigation/taxon_cache.rb +43 -0
- data/app/models/workarea/normalize_email.rb +13 -0
- data/app/models/workarea/order.rb +335 -0
- data/app/models/workarea/order/item.rb +139 -0
- data/app/models/workarea/order/items_extension.rb +14 -0
- data/app/models/workarea/order/queries.rb +200 -0
- data/app/models/workarea/order/status.rb +48 -0
- data/app/models/workarea/ordering.rb +47 -0
- data/app/models/workarea/payment.rb +179 -0
- data/app/models/workarea/payment/address.rb +9 -0
- data/app/models/workarea/payment/authorize/credit_card.rb +42 -0
- data/app/models/workarea/payment/authorize/store_credit.rb +43 -0
- data/app/models/workarea/payment/capture.rb +43 -0
- data/app/models/workarea/payment/capture/credit_card.rb +25 -0
- data/app/models/workarea/payment/capture/store_credit.rb +25 -0
- data/app/models/workarea/payment/credit_card.rb +120 -0
- data/app/models/workarea/payment/credit_card_operation.rb +20 -0
- data/app/models/workarea/payment/insufficient_funds.rb +5 -0
- data/app/models/workarea/payment/operation.rb +50 -0
- data/app/models/workarea/payment/operation_implementation.rb +24 -0
- data/app/models/workarea/payment/processing.rb +102 -0
- data/app/models/workarea/payment/profile.rb +59 -0
- data/app/models/workarea/payment/purchase/credit_card.rb +42 -0
- data/app/models/workarea/payment/purchase/store_credit.rb +7 -0
- data/app/models/workarea/payment/refund.rb +44 -0
- data/app/models/workarea/payment/refund/credit_card.rb +25 -0
- data/app/models/workarea/payment/refund/store_credit.rb +35 -0
- data/app/models/workarea/payment/saved_credit_card.rb +43 -0
- data/app/models/workarea/payment/status.rb +74 -0
- data/app/models/workarea/payment/store_credit_card.rb +34 -0
- data/app/models/workarea/payment/tender.rb +80 -0
- data/app/models/workarea/payment/tender/credit_card.rb +49 -0
- data/app/models/workarea/payment/tender/store_credit.rb +27 -0
- data/app/models/workarea/payment/transaction.rb +148 -0
- data/app/models/workarea/payment_reference.rb +18 -0
- data/app/models/workarea/price_adjustment.rb +46 -0
- data/app/models/workarea/price_adjustment_extension.rb +19 -0
- data/app/models/workarea/price_adjustment_set.rb +69 -0
- data/app/models/workarea/pricing.rb +56 -0
- data/app/models/workarea/pricing/cache_key.rb +51 -0
- data/app/models/workarea/pricing/calculator.rb +37 -0
- data/app/models/workarea/pricing/calculators/customizations_calculator.rb +33 -0
- data/app/models/workarea/pricing/calculators/discount_calculator.rb +38 -0
- data/app/models/workarea/pricing/calculators/item_calculator.rb +28 -0
- data/app/models/workarea/pricing/calculators/overrides_calculator.rb +105 -0
- data/app/models/workarea/pricing/calculators/tax_calculator.rb +29 -0
- data/app/models/workarea/pricing/collection.rb +84 -0
- data/app/models/workarea/pricing/discount.rb +370 -0
- data/app/models/workarea/pricing/discount/amount_calculator.rb +57 -0
- data/app/models/workarea/pricing/discount/application_group.rb +126 -0
- data/app/models/workarea/pricing/discount/buy_some_get_some.rb +120 -0
- data/app/models/workarea/pricing/discount/buy_some_get_some/item_application.rb +65 -0
- data/app/models/workarea/pricing/discount/buy_some_get_some/order_items_by_product.rb +38 -0
- data/app/models/workarea/pricing/discount/buy_some_get_some/product_application.rb +83 -0
- data/app/models/workarea/pricing/discount/category.rb +59 -0
- data/app/models/workarea/pricing/discount/code_list.rb +100 -0
- data/app/models/workarea/pricing/discount/collection.rb +61 -0
- data/app/models/workarea/pricing/discount/conditions/item_quantity.rb +42 -0
- data/app/models/workarea/pricing/discount/conditions/order_total.rb +53 -0
- data/app/models/workarea/pricing/discount/conditions/promo_codes.rb +78 -0
- data/app/models/workarea/pricing/discount/conditions/user_tags.rb +36 -0
- data/app/models/workarea/pricing/discount/flat_or_percent_off.rb +47 -0
- data/app/models/workarea/pricing/discount/free_gift.rb +136 -0
- data/app/models/workarea/pricing/discount/generated_promo_code.rb +96 -0
- data/app/models/workarea/pricing/discount/order.rb +104 -0
- data/app/models/workarea/pricing/discount/order_total.rb +52 -0
- data/app/models/workarea/pricing/discount/product.rb +60 -0
- data/app/models/workarea/pricing/discount/product_attribute.rb +65 -0
- data/app/models/workarea/pricing/discount/product_attribute/item_qualifier.rb +52 -0
- data/app/models/workarea/pricing/discount/quantity_fixed_price.rb +102 -0
- data/app/models/workarea/pricing/discount/quantity_fixed_price/application_calculator.rb +57 -0
- data/app/models/workarea/pricing/discount/quantity_fixed_price/item_shares.rb +64 -0
- data/app/models/workarea/pricing/discount/reconcile_total.rb +39 -0
- data/app/models/workarea/pricing/discount/redemption.rb +33 -0
- data/app/models/workarea/pricing/discount/shipping.rb +80 -0
- data/app/models/workarea/pricing/order_totals.rb +56 -0
- data/app/models/workarea/pricing/override.rb +36 -0
- data/app/models/workarea/pricing/price.rb +52 -0
- data/app/models/workarea/pricing/price_distributor.rb +88 -0
- data/app/models/workarea/pricing/request.rb +146 -0
- data/app/models/workarea/pricing/shipping_totals.rb +27 -0
- data/app/models/workarea/pricing/sku.rb +88 -0
- data/app/models/workarea/pricing/tax_applier.rb +90 -0
- data/app/models/workarea/product_list.rb +11 -0
- data/app/models/workarea/product_rule.rb +139 -0
- data/app/models/workarea/query_string.rb +58 -0
- data/app/models/workarea/recommendation/product_predictor.rb +10 -0
- data/app/models/workarea/recommendation/search_predictor.rb +10 -0
- data/app/models/workarea/recommendation/settings.rb +24 -0
- data/app/models/workarea/recommendation/user_activity.rb +53 -0
- data/app/models/workarea/releasable.rb +171 -0
- data/app/models/workarea/release.rb +232 -0
- data/app/models/workarea/release/changeset.rb +137 -0
- data/app/models/workarea/release/status.rb +52 -0
- data/app/models/workarea/release_session.rb +45 -0
- data/app/models/workarea/reports/export.rb +62 -0
- data/app/models/workarea/search/admin.rb +133 -0
- data/app/models/workarea/search/admin/catalog_category.rb +67 -0
- data/app/models/workarea/search/admin/catalog_product.rb +98 -0
- data/app/models/workarea/search/admin/content.rb +37 -0
- data/app/models/workarea/search/admin/content_asset.rb +46 -0
- data/app/models/workarea/search/admin/content_page.rb +25 -0
- data/app/models/workarea/search/admin/inventory_sku.rb +27 -0
- data/app/models/workarea/search/admin/navigation.rb +50 -0
- data/app/models/workarea/search/admin/navigation_menu.rb +13 -0
- data/app/models/workarea/search/admin/order.rb +74 -0
- data/app/models/workarea/search/admin/payment_transaction.rb +68 -0
- data/app/models/workarea/search/admin/pricing_discount.rb +37 -0
- data/app/models/workarea/search/admin/pricing_sku.rb +25 -0
- data/app/models/workarea/search/admin/releasable.rb +41 -0
- data/app/models/workarea/search/admin/release.rb +38 -0
- data/app/models/workarea/search/admin/user.rb +59 -0
- data/app/models/workarea/search/customization.rb +81 -0
- data/app/models/workarea/search/facet_values.rb +16 -0
- data/app/models/workarea/search/hash_text.rb +32 -0
- data/app/models/workarea/search/help.rb +17 -0
- data/app/models/workarea/search/order_text.rb +75 -0
- data/app/models/workarea/search/settings.rb +79 -0
- data/app/models/workarea/search/storefront.rb +101 -0
- data/app/models/workarea/search/storefront/category.rb +19 -0
- data/app/models/workarea/search/storefront/page.rb +19 -0
- data/app/models/workarea/search/storefront/product.rb +133 -0
- data/app/models/workarea/search/storefront/product/analytics.rb +26 -0
- data/app/models/workarea/search/storefront/product/categories.rb +86 -0
- data/app/models/workarea/search/storefront/product/facets.rb +62 -0
- data/app/models/workarea/search/storefront/product/inventory.rb +34 -0
- data/app/models/workarea/search/storefront/product/pricing.rb +56 -0
- data/app/models/workarea/search/storefront/product/sorting.rb +25 -0
- data/app/models/workarea/search/storefront/product/text.rb +71 -0
- data/app/models/workarea/search/storefront/search.rb +27 -0
- data/app/models/workarea/search/user_text.rb +45 -0
- data/app/models/workarea/shipping.rb +176 -0
- data/app/models/workarea/shipping/address.rb +22 -0
- data/app/models/workarea/shipping/location_query.rb +49 -0
- data/app/models/workarea/shipping/rate.rb +19 -0
- data/app/models/workarea/shipping/rate_lookup.rb +55 -0
- data/app/models/workarea/shipping/service.rb +89 -0
- data/app/models/workarea/shipping/service_selection.rb +15 -0
- data/app/models/workarea/shipping/sku.rb +35 -0
- data/app/models/workarea/shipping_option.rb +53 -0
- data/app/models/workarea/sort.rb +153 -0
- data/app/models/workarea/status_calculator.rb +40 -0
- data/app/models/workarea/tax.rb +29 -0
- data/app/models/workarea/tax/category.rb +48 -0
- data/app/models/workarea/tax/rate.rb +30 -0
- data/app/models/workarea/tax/rate_lookup.rb +107 -0
- data/app/models/workarea/traffic_referrer.rb +9 -0
- data/app/models/workarea/user.rb +90 -0
- data/app/models/workarea/user/addresses.rb +51 -0
- data/app/models/workarea/user/admin_bookmark.rb +40 -0
- data/app/models/workarea/user/admin_visit.rb +39 -0
- data/app/models/workarea/user/authorization.rb +72 -0
- data/app/models/workarea/user/avatar.rb +32 -0
- data/app/models/workarea/user/login.rb +76 -0
- data/app/models/workarea/user/password_reset.rb +37 -0
- data/app/models/workarea/user/passwords.rb +67 -0
- data/app/models/workarea/user/recent_password.rb +27 -0
- data/app/models/workarea/user/saved_address.rb +13 -0
- data/app/models/workarea/user/system_users.rb +30 -0
- data/app/queries/workarea/admin_query_operation.rb +58 -0
- data/app/queries/workarea/admin_search_query_wrapper.rb +68 -0
- data/app/queries/workarea/alerts.rb +82 -0
- data/app/queries/workarea/bulk_action_selections.rb +39 -0
- data/app/queries/workarea/categorization.rb +63 -0
- data/app/queries/workarea/extract_content_block_text.rb +33 -0
- data/app/queries/workarea/find_pipeline_asset.rb +30 -0
- data/app/queries/workarea/find_taxonomy_slug.rb +24 -0
- data/app/queries/workarea/find_unique_slug.rb +35 -0
- data/app/queries/workarea/metadata.rb +56 -0
- data/app/queries/workarea/metadata/catalog_category.rb +45 -0
- data/app/queries/workarea/metadata/content_page.rb +37 -0
- data/app/queries/workarea/metadata/home_page.rb +48 -0
- data/app/queries/workarea/order_item_details.rb +55 -0
- data/app/queries/workarea/order_metrics.rb +203 -0
- data/app/queries/workarea/pricing_override_params.rb +31 -0
- data/app/queries/workarea/product_primary_image_url.rb +34 -0
- data/app/queries/workarea/product_primary_navigation.rb +41 -0
- data/app/queries/workarea/recommendation/order_based.rb +48 -0
- data/app/queries/workarea/recommendation/product_based.rb +47 -0
- data/app/queries/workarea/recommendation/searches.rb +21 -0
- data/app/queries/workarea/recommendation/user_activity_based.rb +40 -0
- data/app/queries/workarea/reports/average_order_value.rb +44 -0
- data/app/queries/workarea/reports/customers.rb +46 -0
- data/app/queries/workarea/reports/first_time_vs_returning_sales.rb +59 -0
- data/app/queries/workarea/reports/group_by_time.rb +84 -0
- data/app/queries/workarea/reports/low_inventory.rb +36 -0
- data/app/queries/workarea/reports/report.rb +83 -0
- data/app/queries/workarea/reports/sales_by_category.rb +51 -0
- data/app/queries/workarea/reports/sales_by_country.rb +56 -0
- data/app/queries/workarea/reports/sales_by_discount.rb +47 -0
- data/app/queries/workarea/reports/sales_by_menu.rb +51 -0
- data/app/queries/workarea/reports/sales_by_product.rb +54 -0
- data/app/queries/workarea/reports/sales_by_sku.rb +61 -0
- data/app/queries/workarea/reports/sales_by_traffic_referrer.rb +64 -0
- data/app/queries/workarea/reports/sales_over_time.rb +73 -0
- data/app/queries/workarea/reports/searches.rb +65 -0
- data/app/queries/workarea/reports/searches_over_time.rb +37 -0
- data/app/queries/workarea/reports/searches_without_results_over_time.rb +38 -0
- data/app/queries/workarea/search/admin_assets.rb +23 -0
- data/app/queries/workarea/search/admin_categories.rb +20 -0
- data/app/queries/workarea/search/admin_discounts.rb +30 -0
- data/app/queries/workarea/search/admin_index_search.rb +127 -0
- data/app/queries/workarea/search/admin_inventory_skus.rb +20 -0
- data/app/queries/workarea/search/admin_orders.rb +49 -0
- data/app/queries/workarea/search/admin_pages.rb +16 -0
- data/app/queries/workarea/search/admin_payment_transactions.rb +24 -0
- data/app/queries/workarea/search/admin_pricing_skus.rb +16 -0
- data/app/queries/workarea/search/admin_product_rules_preview.rb +10 -0
- data/app/queries/workarea/search/admin_products.rb +39 -0
- data/app/queries/workarea/search/admin_releasables.rb +18 -0
- data/app/queries/workarea/search/admin_releases.rb +38 -0
- data/app/queries/workarea/search/admin_search.rb +16 -0
- data/app/queries/workarea/search/admin_sorting.rb +38 -0
- data/app/queries/workarea/search/admin_users.rb +39 -0
- data/app/queries/workarea/search/categorization.rb +14 -0
- data/app/queries/workarea/search/categorization_filtering.rb +38 -0
- data/app/queries/workarea/search/category_browse.rb +119 -0
- data/app/queries/workarea/search/date_filter.rb +49 -0
- data/app/queries/workarea/search/facet.rb +71 -0
- data/app/queries/workarea/search/facet_matches.rb +39 -0
- data/app/queries/workarea/search/facet_sorting.rb +67 -0
- data/app/queries/workarea/search/facet_sorting/size.rb +15 -0
- data/app/queries/workarea/search/facets.rb +29 -0
- data/app/queries/workarea/search/filter.rb +70 -0
- data/app/queries/workarea/search/help_search.rb +58 -0
- data/app/queries/workarea/search/load_product_results.rb +36 -0
- data/app/queries/workarea/search/pagination.rb +46 -0
- data/app/queries/workarea/search/product_display_rules.rb +68 -0
- data/app/queries/workarea/search/product_entries.rb +24 -0
- data/app/queries/workarea/search/product_rules.rb +122 -0
- data/app/queries/workarea/search/product_rules_filtering.rb +14 -0
- data/app/queries/workarea/search/product_search.rb +218 -0
- data/app/queries/workarea/search/query.rb +131 -0
- data/app/queries/workarea/search/query_suggestions.rb +71 -0
- data/app/queries/workarea/search/range_facet.rb +60 -0
- data/app/queries/workarea/search/range_filter.rb +25 -0
- data/app/queries/workarea/search/range_parameter.rb +71 -0
- data/app/queries/workarea/search/related_help.rb +58 -0
- data/app/queries/workarea/search/related_products.rb +96 -0
- data/app/queries/workarea/search/search_suggestions.rb +43 -0
- data/app/queries/workarea/search/storefront_search.rb +51 -0
- data/app/queries/workarea/search/storefront_search/exact_matches.rb +34 -0
- data/app/queries/workarea/search/storefront_search/middleware.rb +26 -0
- data/app/queries/workarea/search/storefront_search/product_auto_redirect.rb +19 -0
- data/app/queries/workarea/search/storefront_search/product_multipass.rb +50 -0
- data/app/queries/workarea/search/storefront_search/redirect.rb +17 -0
- data/app/queries/workarea/search/storefront_search/response.rb +72 -0
- data/app/queries/workarea/search/storefront_search/spelling_correction.rb +31 -0
- data/app/queries/workarea/search/storefront_search/template.rb +17 -0
- data/app/queries/workarea/search/term_filter.rb +10 -0
- data/app/queries/workarea/search/terms_facet.rb +62 -0
- data/app/queries/workarea/taxonomy_sitemap.rb +34 -0
- data/app/seeds/workarea/admins_seeds.rb +53 -0
- data/app/seeds/workarea/assets_seeds.rb +23 -0
- data/app/seeds/workarea/browse_navigation_seeds.rb +30 -0
- data/app/seeds/workarea/browsing_pages_seeds.rb +33 -0
- data/app/seeds/workarea/categories_seeds.rb +50 -0
- data/app/seeds/workarea/customer_service_navigation_seeds.rb +16 -0
- data/app/seeds/workarea/customer_service_pages_seeds.rb +33 -0
- data/app/seeds/workarea/customers_seeds.rb +24 -0
- data/app/seeds/workarea/discounts_seeds.rb +79 -0
- data/app/seeds/workarea/dynamic_content_seeds.rb +62 -0
- data/app/seeds/workarea/email_content_seeds.rb +11 -0
- data/app/seeds/workarea/help_seeds.rb +65 -0
- data/app/seeds/workarea/inquiries_seeds.rb +15 -0
- data/app/seeds/workarea/insights_seeds.rb +65 -0
- data/app/seeds/workarea/orders_seeds.rb +113 -0
- data/app/seeds/workarea/products_seeds.rb +104 -0
- data/app/seeds/workarea/search_settings_seeds.rb +31 -0
- data/app/seeds/workarea/shipping_services_seeds.rb +61 -0
- data/app/seeds/workarea/system_content_seeds.rb +90 -0
- data/app/seeds/workarea/tax_seeds.rb +33 -0
- data/app/services/workarea/add_multiple_cart_items.rb +21 -0
- data/app/services/workarea/add_multiple_cart_items/item.rb +79 -0
- data/app/services/workarea/cancel_order.rb +68 -0
- data/app/services/workarea/cart_cleaner.rb +59 -0
- data/app/services/workarea/clean_range_facets.rb +38 -0
- data/app/services/workarea/copy_order.rb +73 -0
- data/app/services/workarea/copy_product.rb +27 -0
- data/app/services/workarea/create_fulfillment.rb +24 -0
- data/app/services/workarea/direct_upload.rb +77 -0
- data/app/services/workarea/direct_upload/asset.rb +14 -0
- data/app/services/workarea/direct_upload/processor.rb +20 -0
- data/app/services/workarea/direct_upload/product_image.rb +42 -0
- data/app/services/workarea/export_report.rb +88 -0
- data/app/services/workarea/hash_update.rb +32 -0
- data/app/services/workarea/inventory_adjustment.rb +45 -0
- data/app/services/workarea/login.rb +39 -0
- data/app/services/workarea/new_discount.rb +17 -0
- data/app/services/workarea/order_merge.rb +34 -0
- data/app/services/workarea/packaging.rb +103 -0
- data/app/services/workarea/save_publishing.rb +34 -0
- data/app/services/workarea/save_taxonomy.rb +39 -0
- data/app/services/workarea/set_navigable.rb +71 -0
- data/app/services/workarea/sort_navigation_menus_by_orders.rb +32 -0
- data/app/services/workarea/tag_update.rb +15 -0
- data/app/view_models/workarea/application_view_model.rb +72 -0
- data/app/view_models/workarea/shipping_carrier_view_model.rb +24 -0
- data/app/workers/sidekiq/callbacks.rb +242 -0
- data/app/workers/sidekiq/callbacks_worker.rb +73 -0
- data/app/workers/workarea/bulk_index_admin.rb +34 -0
- data/app/workers/workarea/bulk_index_products.rb +28 -0
- data/app/workers/workarea/bulk_index_searches.rb +33 -0
- data/app/workers/workarea/bust_discount_cache.rb +16 -0
- data/app/workers/workarea/bust_navigation_cache.rb +18 -0
- data/app/workers/workarea/bust_sku_cache.rb +16 -0
- data/app/workers/workarea/clean_inventory_transactions.rb +9 -0
- data/app/workers/workarea/clean_orders.rb +10 -0
- data/app/workers/workarea/clean_product_recommendations.rb +13 -0
- data/app/workers/workarea/clean_user_activity.rb +11 -0
- data/app/workers/workarea/deactivate_stale_discounts.rb +38 -0
- data/app/workers/workarea/generate_content_metadata.rb +17 -0
- data/app/workers/workarea/generate_insights.rb +37 -0
- data/app/workers/workarea/generate_promo_codes.rb +12 -0
- data/app/workers/workarea/index_admin_search.rb +40 -0
- data/app/workers/workarea/index_categorization.rb +24 -0
- data/app/workers/workarea/index_category.rb +20 -0
- data/app/workers/workarea/index_category_changes.rb +40 -0
- data/app/workers/workarea/index_fulfillment_changes.rb +16 -0
- data/app/workers/workarea/index_help.rb +18 -0
- data/app/workers/workarea/index_page.rb +20 -0
- data/app/workers/workarea/index_payment_transactions.rb +23 -0
- data/app/workers/workarea/index_product.rb +26 -0
- data/app/workers/workarea/index_product_children.rb +20 -0
- data/app/workers/workarea/index_product_rule.rb +22 -0
- data/app/workers/workarea/index_search_customizations.rb +18 -0
- data/app/workers/workarea/index_skus.rb +20 -0
- data/app/workers/workarea/keep_product_index_fresh.rb +32 -0
- data/app/workers/workarea/mark_discounts_as_redeemed.rb +30 -0
- data/app/workers/workarea/order_reminder.rb +16 -0
- data/app/workers/workarea/process_direct_upload.rb +10 -0
- data/app/workers/workarea/process_export.rb +21 -0
- data/app/workers/workarea/process_import.rb +29 -0
- data/app/workers/workarea/process_product_recommendations.rb +31 -0
- data/app/workers/workarea/process_reports_export.rb +20 -0
- data/app/workers/workarea/process_search_recommendations.rb +35 -0
- data/app/workers/workarea/publish_bulk_action.rb +14 -0
- data/app/workers/workarea/publish_release.rb +15 -0
- data/app/workers/workarea/redirect_navigable_slugs.rb +51 -0
- data/app/workers/workarea/save_order_metrics.rb +105 -0
- data/app/workers/workarea/save_user_order_details.rb +72 -0
- data/app/workers/workarea/send_refund_email.rb +17 -0
- data/app/workers/workarea/status_reporter.rb +12 -0
- data/app/workers/workarea/undo_release.rb +15 -0
- data/app/workers/workarea/update_elasticsearch_settings.rb +28 -0
- data/app/workers/workarea/update_payment_profile_email.rb +22 -0
- data/app/workers/workarea/verify_scheduled_releases.rb +35 -0
- data/bin/rails +18 -0
- data/config/i18n-js.yml +2 -0
- data/config/initializers/00_mongoid.rb +2 -0
- data/config/initializers/01_eager_load.rb +1 -0
- data/config/initializers/02_assets.rb +17 -0
- data/config/initializers/03_js_routes.rb +3 -0
- data/config/initializers/04_sidekiq.rb +1 -0
- data/config/initializers/05_scheduled_jobs.rb +92 -0
- data/config/initializers/06_predictor.rb +1 -0
- data/config/initializers/07_dragonfly.rb +117 -0
- data/config/initializers/08_inflections.rb +3 -0
- data/config/initializers/09_geocoder.rb +15 -0
- data/config/initializers/10_rack_middleware.rb +29 -0
- data/config/initializers/11_payment.rb +8 -0
- data/config/initializers/12_filter_parameters.rb +13 -0
- data/config/initializers/13_rack_attack.rb +178 -0
- data/config/initializers/14_content_block_types.rb +240 -0
- data/config/initializers/15_endpoint_monitoring.rb +41 -0
- data/config/initializers/16_turbolinks.rb +1 -0
- data/config/initializers/17_audit_log.rb +1 -0
- data/config/initializers/18_time_formats.rb +11 -0
- data/config/initializers/19_mailer_previews.rb +20 -0
- data/config/initializers/20_i18n_js.rb +3 -0
- data/config/initializers/20_mail_interceptor.rb +1 -0
- data/config/initializers/21_premailer.rb +3 -0
- data/config/initializers/21_serviceworkers.rb +16 -0
- data/config/initializers/22_session_store.rb +11 -0
- data/config/initializers/23_chartkick.rb +3 -0
- data/config/locales/en.yml +168 -0
- data/config/routes.rb +13 -0
- data/data/content_assets/100x100.png +0 -0
- data/data/content_assets/960x470_dark.png +0 -0
- data/data/content_assets/960x470_light.png +0 -0
- data/data/help/howto/add_help_articles/body.md +50 -0
- data/data/help/howto/add_help_articles/summary.md +1 -0
- data/lib/generators/workarea/content_block_type/USAGE +16 -0
- data/lib/generators/workarea/content_block_type/content_block_type_generator.rb +71 -0
- data/lib/generators/workarea/content_block_type/templates/block.svg +1 -0
- data/lib/generators/workarea/content_block_type/templates/initializer.rb +3 -0
- data/lib/generators/workarea/content_block_type/templates/storefront_view.html.haml.erb +4 -0
- data/lib/generators/workarea/content_block_type/templates/stylesheet.scss.erb +7 -0
- data/lib/generators/workarea/content_block_type/templates/view_model.rb.erb +16 -0
- data/lib/generators/workarea/decorator/USAGE +15 -0
- data/lib/generators/workarea/decorator/decorator_generator.rb +79 -0
- data/lib/generators/workarea/decorator/templates/decorator.rb.erb +20 -0
- data/lib/generators/workarea/decorator/templates/test_decorator.rb.erb +13 -0
- data/lib/generators/workarea/discount/USAGE +16 -0
- data/lib/generators/workarea/discount/discount_generator.rb +48 -0
- data/lib/generators/workarea/discount/templates/model.rb.erb +22 -0
- data/lib/generators/workarea/discount/templates/model_test.rb.erb +13 -0
- data/lib/generators/workarea/discount/templates/partial.html.haml +10 -0
- data/lib/generators/workarea/discount/templates/select_type_partial.rb.erb +6 -0
- data/lib/generators/workarea/discount/templates/view_model.rb.erb +11 -0
- data/lib/generators/workarea/discount/templates/view_model_test.rb.erb +11 -0
- data/lib/generators/workarea/docker/USAGE +16 -0
- data/lib/generators/workarea/docker/docker_generator.rb +61 -0
- data/lib/generators/workarea/docker/templates/.env.erb +6 -0
- data/lib/generators/workarea/docker/templates/Dockerfile.erb +48 -0
- data/lib/generators/workarea/docker/templates/docker-compose.yml.erb +72 -0
- data/lib/generators/workarea/docker/templates/docker-entrypoint.sh.erb +6 -0
- data/lib/generators/workarea/docker/templates/docker-sync.yml.erb +8 -0
- data/lib/generators/workarea/docker/templates/docker-wait.sh +11 -0
- data/lib/generators/workarea/docker/templates/docker.env +16 -0
- data/lib/generators/workarea/docker/templates/docker_init.rb.erb +29 -0
- data/lib/generators/workarea/install/USAGE +19 -0
- data/lib/generators/workarea/install/install_generator.rb +71 -0
- data/lib/generators/workarea/install/templates/initializer.rb.erb +22 -0
- data/lib/generators/workarea/js_adapter/USAGE +8 -0
- data/lib/generators/workarea/js_adapter/js_adapter_generator.rb +28 -0
- data/lib/generators/workarea/js_adapter/templates/js_adapter.js.erb +21 -0
- data/lib/generators/workarea/js_module/USAGE +8 -0
- data/lib/generators/workarea/js_module/js_module_generator.rb +30 -0
- data/lib/generators/workarea/js_module/templates/js_module.js.erb +33 -0
- data/lib/generators/workarea/override/USAGE +22 -0
- data/lib/generators/workarea/override/override_generator.rb +85 -0
- data/lib/generators/workarea/pricing_calculator/USAGE +9 -0
- data/lib/generators/workarea/pricing_calculator/pricing_calculator_generator.rb +26 -0
- data/lib/generators/workarea/pricing_calculator/templates/calculator.rb.erb +13 -0
- data/lib/generators/workarea/pricing_calculator/templates/test.rb.erb +13 -0
- data/lib/generators/workarea/product_template/USAGE +11 -0
- data/lib/generators/workarea/product_template/product_template_generator.rb +26 -0
- data/lib/generators/workarea/product_template/templates/view_model.rb.erb +16 -0
- data/lib/generators/workarea/seeds/USAGE +11 -0
- data/lib/generators/workarea/seeds/seeds_generator.rb +15 -0
- data/lib/generators/workarea/seeds/templates/seeds.rb.erb +15 -0
- data/lib/generators/workarea/style_guide/USAGE +24 -0
- data/lib/generators/workarea/style_guide/style_guide_generator.rb +35 -0
- data/lib/generators/workarea/style_guide/templates/style_guide_partial.html.haml.erb +51 -0
- data/lib/minitest/workarea_plugin.rb +11 -0
- data/lib/tasks/assets.rake +3 -0
- data/lib/tasks/cache.rake +40 -0
- data/lib/tasks/cleanup.rake +13 -0
- data/lib/tasks/help.rake +59 -0
- data/lib/tasks/insights.rake +49 -0
- data/lib/tasks/lint.rake +7 -0
- data/lib/tasks/search.rake +89 -0
- data/lib/tasks/services.rake +73 -0
- data/lib/tasks/tests.rake +96 -0
- data/lib/workarea.rb +88 -0
- data/lib/workarea/asset_endpoints/base.rb +23 -0
- data/lib/workarea/asset_endpoints/favicons.rb +22 -0
- data/lib/workarea/asset_endpoints/product_images.rb +16 -0
- data/lib/workarea/asset_endpoints/product_placeholder_images.rb +9 -0
- data/lib/workarea/autoexpire_cache_redis.rb +29 -0
- data/lib/workarea/bogus_carrier.rb +18 -0
- data/lib/workarea/cache.rb +106 -0
- data/lib/workarea/changelog.rake +87 -0
- data/lib/workarea/configuration.rb +1273 -0
- data/lib/workarea/configuration/action_mailer.rb +24 -0
- data/lib/workarea/configuration/asset_host.rb +13 -0
- data/lib/workarea/configuration/cache_store.rb +21 -0
- data/lib/workarea/configuration/dragonfly.rb +43 -0
- data/lib/workarea/configuration/elasticsearch.rb +39 -0
- data/lib/workarea/configuration/error_handling.rb +15 -0
- data/lib/workarea/configuration/headless_chrome.rb +42 -0
- data/lib/workarea/configuration/i18n.rb +12 -0
- data/lib/workarea/configuration/localized_active_fields.rb +26 -0
- data/lib/workarea/configuration/logstasher.rb +16 -0
- data/lib/workarea/configuration/mongoid.rb +27 -0
- data/lib/workarea/configuration/mongoid_client.rb +53 -0
- data/lib/workarea/configuration/puma.rb +37 -0
- data/lib/workarea/configuration/redis.rb +78 -0
- data/lib/workarea/configuration/s3.rb +68 -0
- data/lib/workarea/configuration/sidekiq.rb +120 -0
- data/lib/workarea/constants.rb +29 -0
- data/lib/workarea/core.rb +221 -0
- data/lib/workarea/core/engine.rb +134 -0
- data/lib/workarea/elasticsearch/document.rb +109 -0
- data/lib/workarea/elasticsearch/index.rb +143 -0
- data/lib/workarea/elasticsearch/query_cache.rb +132 -0
- data/lib/workarea/elasticsearch/serializer.rb +43 -0
- data/lib/workarea/ext/active_shipping/workarea.rb +7 -0
- data/lib/workarea/ext/freedom_patches/action_view_cache_helper.rb +26 -0
- data/lib/workarea/ext/freedom_patches/action_view_conditional_url_helper.rb +23 -0
- data/lib/workarea/ext/freedom_patches/action_view_number_helper.rb +23 -0
- data/lib/workarea/ext/freedom_patches/action_view_path_resolver.rb +16 -0
- data/lib/workarea/ext/freedom_patches/bson.rb +11 -0
- data/lib/workarea/ext/freedom_patches/country.rb +15 -0
- data/lib/workarea/ext/freedom_patches/dragonfly_attachment.rb +14 -0
- data/lib/workarea/ext/freedom_patches/dragonfly_callable_url_host.rb +28 -0
- data/lib/workarea/ext/freedom_patches/dragonfly_job_fetch_url.rb +22 -0
- data/lib/workarea/ext/freedom_patches/float.rb +13 -0
- data/lib/workarea/ext/freedom_patches/global_id.rb +24 -0
- data/lib/workarea/ext/freedom_patches/money.rb +23 -0
- data/lib/workarea/ext/freedom_patches/mongoid_simple_tags.rb +87 -0
- data/lib/workarea/ext/freedom_patches/net_http_ssl_connection.rb +19 -0
- data/lib/workarea/ext/freedom_patches/routes_reloader.rb +21 -0
- data/lib/workarea/ext/freedom_patches/string.rb +16 -0
- data/lib/workarea/ext/freedom_patches/uri.rb +7 -0
- data/lib/workarea/ext/jbuilder/jbuilder_append_partials.rb +16 -0
- data/lib/workarea/ext/mongoid/audit_log_entry.decorator +66 -0
- data/lib/workarea/ext/mongoid/each_by.rb +46 -0
- data/lib/workarea/ext/mongoid/error.rb +17 -0
- data/lib/workarea/ext/mongoid/except.rb +5 -0
- data/lib/workarea/ext/mongoid/find_ordered.rb +21 -0
- data/lib/workarea/ext/mongoid/list_field.rb +21 -0
- data/lib/workarea/ext/mongoid/moped_bson.rb +6 -0
- data/lib/workarea/ext/mongoid/timestamps_timeless.rb +51 -0
- data/lib/workarea/ext/sprockets/ruby_processor.rb +19 -0
- data/lib/workarea/ext/sprockets/task.rb +31 -0
- data/lib/workarea/geolocation.rb +71 -0
- data/lib/workarea/i18n.rb +71 -0
- data/lib/workarea/image_optim_processor.rb +13 -0
- data/lib/workarea/lint.rb +89 -0
- data/lib/workarea/lint/inconsistent_details.rb +32 -0
- data/lib/workarea/lint/products_missing_images.rb +13 -0
- data/lib/workarea/lint/products_missing_variants.rb +13 -0
- data/lib/workarea/lint/skus_missing_inventory.rb +19 -0
- data/lib/workarea/lint/skus_missing_pricing.rb +19 -0
- data/lib/workarea/lint/skus_missing_variants.rb +17 -0
- data/lib/workarea/mail_interceptor.rb +15 -0
- data/lib/workarea/monitoring/elasticsearch_check.rb +24 -0
- data/lib/workarea/monitoring/load_balancing_check.rb +9 -0
- data/lib/workarea/monitoring/mongoid_check.rb +23 -0
- data/lib/workarea/monitoring/sidekiq_queue_size_check.rb +16 -0
- data/lib/workarea/mount_point.rb +27 -0
- data/lib/workarea/paged_array.rb +37 -0
- data/lib/workarea/passenger.rb +5 -0
- data/lib/workarea/ping_home_base.rb +69 -0
- data/lib/workarea/plugin.rb +117 -0
- data/lib/workarea/plugin/asset_appends_helper.rb +36 -0
- data/lib/workarea/robots.rb +9 -0
- data/lib/workarea/routes_constraints/redirect.rb +11 -0
- data/lib/workarea/routes_constraints/super_admin.rb +11 -0
- data/lib/workarea/scheduled_jobs.rb +15 -0
- data/lib/workarea/scheduler.rb +44 -0
- data/lib/workarea/seeds.rb +69 -0
- data/lib/workarea/string_id.rb +45 -0
- data/lib/workarea/svg_asset_finder.rb +43 -0
- data/lib/workarea/swappable_list.rb +64 -0
- data/lib/workarea/url_token.rb +24 -0
- data/lib/workarea/validators/email_validator.rb +24 -0
- data/lib/workarea/validators/ip_address_validator.rb +7 -0
- data/lib/workarea/validators/parameter_validator.rb +9 -0
- data/lib/workarea/validators/password_validator.rb +32 -0
- data/lib/workarea/validators/url_validator.rb +11 -0
- data/lib/workarea/version.rb +28 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/images/workarea/core/foo.png +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 +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -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/bin/bundle +3 -0
- data/test/dummy/bin/rails +5 -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.ru +4 -0
- data/test/dummy/config/application.rb +21 -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 +51 -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 +17 -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 +8 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/seeds.rb +10 -0
- data/test/dummy/lib/assets/.keep +0 -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/favicon.ico +1 -0
- data/test/fixtures/label.png +0 -0
- data/test/fixtures/tax_rates.csv +3 -0
- data/test/generators/workarea/content_block_type_generator_test.rb +48 -0
- data/test/generators/workarea/decorator_generator_test.rb +36 -0
- data/test/generators/workarea/discount_generator_test.rb +64 -0
- data/test/generators/workarea/docker_generator_test.rb +156 -0
- data/test/generators/workarea/install_generator_test.rb +92 -0
- data/test/generators/workarea/js_adapter_generator_test.rb +15 -0
- data/test/generators/workarea/override_generator_test.rb +16 -0
- data/test/generators/workarea/pricing_calculator_generator_test.rb +26 -0
- data/test/generators/workarea/product_template_generator_test.rb +36 -0
- data/test/generators/workarea/seeds_generator_test.rb +29 -0
- data/test/helpers/workarea/addresses_helper_test.rb +42 -0
- data/test/helpers/workarea/application_helper_test.rb +67 -0
- data/test/helpers/workarea/conditional_url_helper_test.rb +29 -0
- data/test/helpers/workarea/content_assets_helper_test.rb +23 -0
- data/test/helpers/workarea/facets_helper_test.rb +31 -0
- data/test/helpers/workarea/i18n_helper_test.rb +18 -0
- data/test/helpers/workarea/style_guides_helper_test.rb +63 -0
- data/test/integration/workarea/authentication_test.rb +166 -0
- data/test/integration/workarea/authorization_test.rb +88 -0
- data/test/integration/workarea/cache_varies_integration_test.rb +80 -0
- data/test/integration/workarea/monitoring_integration_test.rb +30 -0
- data/test/integration/workarea/rack_attack_integration_test.rb +168 -0
- data/test/javascripts/cookie_spec.js +37 -0
- data/test/javascripts/date_spec.js +102 -0
- data/test/javascripts/deletion_forms_spec.js +27 -0
- data/test/javascripts/duplicate_id_spec.js +15 -0
- data/test/javascripts/fixtures/deletion_forms.html.haml +3 -0
- data/test/javascripts/fixtures/duplicate_id.html.haml +6 -0
- data/test/javascripts/fixtures/form_submitting_controls.html.haml +4 -0
- data/test/javascripts/fixtures/reveal_password.html.haml +5 -0
- data/test/javascripts/fixtures/workarea_scope.html.haml +5 -0
- data/test/javascripts/form_submitting_controls_spec.js +36 -0
- data/test/javascripts/reveal_password_spec.js +22 -0
- data/test/javascripts/spec_helper.js +26 -0
- data/test/javascripts/string_spec.js +41 -0
- data/test/javascripts/url_spec.js +74 -0
- data/test/javascripts/workarea_spec.js +66 -0
- data/test/lib/workarea/asset_endpoints/favicons_test.rb +39 -0
- data/test/lib/workarea/autoexpire_cache_redis_test.rb +37 -0
- data/test/lib/workarea/constants_test.rb +26 -0
- data/test/lib/workarea/elasticsearch/document_test.rb +125 -0
- data/test/lib/workarea/elasticsearch/query_cache_test.rb +93 -0
- data/test/lib/workarea/ext/freedom_patches/country_test.rb +23 -0
- data/test/lib/workarea/ext/freedom_patches/dragonfly_callable_url_host_test.rb +20 -0
- data/test/lib/workarea/ext/freedom_patches/global_id_test.rb +16 -0
- data/test/lib/workarea/ext/mongoid/audit_log_entry_test.rb +68 -0
- data/test/lib/workarea/ext/mongoid/each_by_test.rb +49 -0
- data/test/lib/workarea/ext/mongoid/except_test.rb +18 -0
- data/test/lib/workarea/ext/mongoid/find_ordered_test.rb +17 -0
- data/test/lib/workarea/ext/mongoid/list_field_test.rb +27 -0
- data/test/lib/workarea/geolocation_test.rb +86 -0
- data/test/lib/workarea/lint/inconsistent_details_test.rb +46 -0
- data/test/lib/workarea/lint/products_missing_images_test.rb +18 -0
- data/test/lib/workarea/lint/products_missing_variants_test.rb +18 -0
- data/test/lib/workarea/lint/skus_missing_inventory_test.rb +30 -0
- data/test/lib/workarea/lint/skus_missing_pricing_test.rb +30 -0
- data/test/lib/workarea/lint/skus_missing_variants_test.rb +34 -0
- data/test/lib/workarea/mail_interceptor_test.rb +69 -0
- data/test/lib/workarea/paged_array_test.rb +11 -0
- data/test/lib/workarea/ping_home_base/request_test.rb +23 -0
- data/test/lib/workarea/plugin_test.rb +100 -0
- data/test/lib/workarea/scheduled_jobs_test.rb +26 -0
- data/test/lib/workarea/scheduler_test.rb +46 -0
- data/test/lib/workarea/string_id_test.rb +43 -0
- data/test/lib/workarea/svg_asset_finder_test.rb +29 -0
- data/test/lib/workarea/swappable_list_test.rb +45 -0
- data/test/lib/workarea/url_token_test.rb +21 -0
- data/test/lib/workarea/validators/email_validator_test.rb +25 -0
- data/test/lib/workarea/validators/parameter_validator_test.rb +19 -0
- data/test/lib/workarea/validators/password_validator_test.rb +60 -0
- data/test/mailers/workarea/application_mailer_test.rb +25 -0
- data/test/middleware/workarea/audit_log_middleware_test.rb +19 -0
- data/test/middleware/workarea/release_server_middleware_test.rb +13 -0
- data/test/models/workarea/address_equality_test.rb +62 -0
- data/test/models/workarea/address_test.rb +112 -0
- data/test/models/workarea/address_validation_test.rb +94 -0
- data/test/models/workarea/application_document_test.rb +39 -0
- data/test/models/workarea/bulk_action/product_edit_test.rb +138 -0
- data/test/models/workarea/bulk_action/sequential_product_edit_test.rb +40 -0
- data/test/models/workarea/bulk_action_test.rb +84 -0
- data/test/models/workarea/catalog/category_test.rb +41 -0
- data/test/models/workarea/catalog/customizations_test.rb +27 -0
- data/test/models/workarea/catalog/product_image_test.rb +39 -0
- data/test/models/workarea/catalog/product_placeholder_image_test.rb +17 -0
- data/test/models/workarea/catalog/product_positions_test.rb +43 -0
- data/test/models/workarea/catalog/product_test.rb +83 -0
- data/test/models/workarea/catalog/variant_test.rb +14 -0
- data/test/models/workarea/checkout/collect_payment_test.rb +51 -0
- data/test/models/workarea/checkout/shipping_options_test.rb +71 -0
- data/test/models/workarea/checkout/steps/addresses_test.rb +127 -0
- data/test/models/workarea/checkout/steps/payment_test.rb +108 -0
- data/test/models/workarea/checkout/steps/shipping_test.rb +106 -0
- data/test/models/workarea/checkout_test.rb +262 -0
- data/test/models/workarea/comment_test.rb +15 -0
- data/test/models/workarea/commentable_test.rb +29 -0
- data/test/models/workarea/content/asset_test.rb +32 -0
- data/test/models/workarea/content/asset_validation_test.rb +68 -0
- data/test/models/workarea/content/block_name_test.rb +25 -0
- data/test/models/workarea/content/block_test.rb +157 -0
- data/test/models/workarea/content/block_type_definition_test.rb +152 -0
- data/test/models/workarea/content/block_type_test.rb +95 -0
- data/test/models/workarea/content/email_test.rb +20 -0
- data/test/models/workarea/content/field_test.rb +15 -0
- data/test/models/workarea/content/fields/asset_test.rb +17 -0
- data/test/models/workarea/content/fields/products_test.rb +14 -0
- data/test/models/workarea/content/page_test.rb +13 -0
- data/test/models/workarea/content_test.rb +28 -0
- data/test/models/workarea/data_file/csv_test.rb +408 -0
- data/test/models/workarea/data_file/export_test.rb +24 -0
- data/test/models/workarea/data_file/format_test.rb +24 -0
- data/test/models/workarea/data_file/import_test.rb +106 -0
- data/test/models/workarea/data_file/json_test.rb +80 -0
- data/test/models/workarea/data_file/operation_test.rb +18 -0
- data/test/models/workarea/data_file/tax_test.rb +59 -0
- data/test/models/workarea/details_test.rb +63 -0
- data/test/models/workarea/discount_ids_test.rb +35 -0
- data/test/models/workarea/fulfillment/item_test.rb +34 -0
- data/test/models/workarea/fulfillment/package_test.rb +43 -0
- data/test/models/workarea/fulfillment_test.rb +217 -0
- data/test/models/workarea/help/article_test.rb +54 -0
- data/test/models/workarea/insights/base_test.rb +41 -0
- data/test/models/workarea/insights/best_customers_test.rb +51 -0
- data/test/models/workarea/insights/best_full_price_customers_test.rb +52 -0
- data/test/models/workarea/insights/cold_products_test.rb +124 -0
- data/test/models/workarea/insights/cold_searches_test.rb +124 -0
- data/test/models/workarea/insights/customer_acquisition_test.rb +44 -0
- data/test/models/workarea/insights/customers_at_risk_test.rb +26 -0
- data/test/models/workarea/insights/hot_products_test.rb +124 -0
- data/test/models/workarea/insights/hot_searches_test.rb +124 -0
- data/test/models/workarea/insights/low_aov_customers_test.rb +30 -0
- data/test/models/workarea/insights/most_discount_given.rb +70 -0
- data/test/models/workarea/insights/most_discounted_products_test.rb +47 -0
- data/test/models/workarea/insights/new_products_test.rb +33 -0
- data/test/models/workarea/insights/non_sellers_test.rb +39 -0
- data/test/models/workarea/insights/popular_searches_test.rb +45 -0
- data/test/models/workarea/insights/popular_searches_without_results_test.rb +28 -0
- data/test/models/workarea/insights/products_purchased_together_test.rb +63 -0
- data/test/models/workarea/insights/products_to_improve_test.rb +134 -0
- data/test/models/workarea/insights/promising_products_test.rb +137 -0
- data/test/models/workarea/insights/release_reminder_test.rb +25 -0
- data/test/models/workarea/insights/repeat_purchase_rate_test.rb +38 -0
- data/test/models/workarea/insights/sales_by_navigation_test.rb +94 -0
- data/test/models/workarea/insights/searches_to_improve_test.rb +134 -0
- data/test/models/workarea/insights/star_products_test.rb +67 -0
- data/test/models/workarea/insights/star_searches_test.rb +67 -0
- data/test/models/workarea/insights/top_categories_test.rb +94 -0
- data/test/models/workarea/insights/top_discounts_test.rb +91 -0
- data/test/models/workarea/insights/top_products_test.rb +94 -0
- data/test/models/workarea/insights/trending_products_test.rb +83 -0
- data/test/models/workarea/insights/trending_searches_test.rb +83 -0
- data/test/models/workarea/insights/upcoming_releases_test.rb +21 -0
- data/test/models/workarea/inventory/capture_test.rb +97 -0
- data/test/models/workarea/inventory/collection_test.rb +35 -0
- data/test/models/workarea/inventory/policies/allow_backorder_test.rb +70 -0
- data/test/models/workarea/inventory/policies/ignore_test.rb +21 -0
- data/test/models/workarea/inventory/policies/standard_test.rb +19 -0
- data/test/models/workarea/inventory/sku_test.rb +97 -0
- data/test/models/workarea/inventory/transaction_test.rb +169 -0
- data/test/models/workarea/inventory_test.rb +29 -0
- data/test/models/workarea/lock_test.rb +47 -0
- data/test/models/workarea/lockable_test.rb +73 -0
- data/test/models/workarea/metrics/by_day_test.rb +145 -0
- data/test/models/workarea/metrics/calculate_percentiles_test.rb +47 -0
- data/test/models/workarea/metrics/product_by_week_test.rb +141 -0
- data/test/models/workarea/metrics/product_for_last_week_test.rb +128 -0
- data/test/models/workarea/metrics/search_by_day_test.rb +40 -0
- data/test/models/workarea/metrics/search_by_week_test.rb +141 -0
- data/test/models/workarea/metrics/search_for_last_week_test.rb +134 -0
- data/test/models/workarea/metrics/user_test.rb +79 -0
- data/test/models/workarea/navigation/breadcrumbs_test.rb +52 -0
- data/test/models/workarea/navigation/menu_test.rb +23 -0
- data/test/models/workarea/navigation/redirect_test.rb +51 -0
- data/test/models/workarea/navigation/search_results_test.rb +32 -0
- data/test/models/workarea/navigation/taxon_test.rb +118 -0
- data/test/models/workarea/normalize_email_test.rb +17 -0
- data/test/models/workarea/order/item_test.rb +60 -0
- data/test/models/workarea/order/queries_test.rb +187 -0
- data/test/models/workarea/order_test.rb +154 -0
- data/test/models/workarea/ordering_test.rb +41 -0
- data/test/models/workarea/payment/address_test.rb +139 -0
- data/test/models/workarea/payment/authorize/credit_card_test.rb +108 -0
- data/test/models/workarea/payment/authorize/store_credit_test.rb +73 -0
- data/test/models/workarea/payment/capture/credit_card_test.rb +66 -0
- data/test/models/workarea/payment/capture/store_credit_test.rb +50 -0
- data/test/models/workarea/payment/capture_test.rb +168 -0
- data/test/models/workarea/payment/credit_card_integration_test.rb +174 -0
- data/test/models/workarea/payment/credit_card_test.rb +111 -0
- data/test/models/workarea/payment/operation_test.rb +143 -0
- data/test/models/workarea/payment/profile_test.rb +48 -0
- data/test/models/workarea/payment/purchase/credit_card_test.rb +95 -0
- data/test/models/workarea/payment/purchase/store_credit_test.rb +72 -0
- data/test/models/workarea/payment/refund/credit_card_test.rb +66 -0
- data/test/models/workarea/payment/refund/store_credit_test.rb +63 -0
- data/test/models/workarea/payment/refund_test.rb +188 -0
- data/test/models/workarea/payment/saved_credit_card_test.rb +32 -0
- data/test/models/workarea/payment/store_credit_card_test.rb +42 -0
- data/test/models/workarea/payment/tender/credit_card_test.rb +52 -0
- data/test/models/workarea/payment/tender/store_credit_test.rb +18 -0
- data/test/models/workarea/payment/tender_test.rb +191 -0
- data/test/models/workarea/payment/transaction_test.rb +126 -0
- data/test/models/workarea/payment_reference_test.rb +17 -0
- data/test/models/workarea/payment_test.rb +172 -0
- data/test/models/workarea/price_adjustment_test.rb +26 -0
- data/test/models/workarea/pricing/cache_key_test.rb +67 -0
- data/test/models/workarea/pricing/calculators/customizations_calculator_test.rb +28 -0
- data/test/models/workarea/pricing/calculators/discount_calculator_test.rb +152 -0
- data/test/models/workarea/pricing/calculators/item_calculator_test.rb +76 -0
- data/test/models/workarea/pricing/calculators/overrides_calculator_test.rb +130 -0
- data/test/models/workarea/pricing/calculators/tax_calculator_test.rb +118 -0
- data/test/models/workarea/pricing/collection_test.rb +101 -0
- data/test/models/workarea/pricing/discount/amount_calculator_test.rb +31 -0
- data/test/models/workarea/pricing/discount/application_group_test.rb +174 -0
- data/test/models/workarea/pricing/discount/buy_some_get_some/order_items_by_product_test.rb +28 -0
- data/test/models/workarea/pricing/discount/buy_some_get_some_test.rb +200 -0
- data/test/models/workarea/pricing/discount/category_test.rb +68 -0
- data/test/models/workarea/pricing/discount/code_list_test.rb +23 -0
- data/test/models/workarea/pricing/discount/collection_test.rb +44 -0
- data/test/models/workarea/pricing/discount/conditions/user_tags_test.rb +43 -0
- data/test/models/workarea/pricing/discount/free_gift_test.rb +65 -0
- data/test/models/workarea/pricing/discount/generated_promo_code_test.rb +14 -0
- data/test/models/workarea/pricing/discount/order_test.rb +60 -0
- data/test/models/workarea/pricing/discount/order_total_test.rb +60 -0
- data/test/models/workarea/pricing/discount/product_attribute_test.rb +81 -0
- data/test/models/workarea/pricing/discount/product_test.rb +63 -0
- data/test/models/workarea/pricing/discount/quantity_fixed_price_test.rb +292 -0
- data/test/models/workarea/pricing/discount/shipping_test.rb +67 -0
- data/test/models/workarea/pricing/discount_test.rb +95 -0
- data/test/models/workarea/pricing/override_test.rb +59 -0
- data/test/models/workarea/pricing/price_distributor_test.rb +40 -0
- data/test/models/workarea/pricing/price_test.rb +58 -0
- data/test/models/workarea/pricing/request_test.rb +86 -0
- data/test/models/workarea/pricing/sku_test.rb +47 -0
- data/test/models/workarea/pricing/tax_applier_test.rb +125 -0
- data/test/models/workarea/pricing_test.rb +1398 -0
- data/test/models/workarea/product_rule_test.rb +55 -0
- data/test/models/workarea/query_string_test.rb +90 -0
- data/test/models/workarea/recommendation/user_activity_test.rb +96 -0
- data/test/models/workarea/releasable_test.rb +479 -0
- data/test/models/workarea/release_test.rb +287 -0
- data/test/models/workarea/reports/export_test.rb +33 -0
- data/test/models/workarea/search/admin/catalog_category_test.rb +44 -0
- data/test/models/workarea/search/admin/catalog_product_test.rb +126 -0
- data/test/models/workarea/search/admin/content_asset_test.rb +54 -0
- data/test/models/workarea/search/admin/content_page_test.rb +18 -0
- data/test/models/workarea/search/admin/content_test.rb +17 -0
- data/test/models/workarea/search/admin/order_test.rb +105 -0
- data/test/models/workarea/search/admin/pricing_discount_test.rb +31 -0
- data/test/models/workarea/search/admin/releasable_test.rb +36 -0
- data/test/models/workarea/search/admin/user_test.rb +53 -0
- data/test/models/workarea/search/admin_test.rb +18 -0
- data/test/models/workarea/search/customization_test.rb +69 -0
- data/test/models/workarea/search/settings_test.rb +18 -0
- data/test/models/workarea/search/storefront/product/categories_test.rb +95 -0
- data/test/models/workarea/search/storefront/product/facets_test.rb +35 -0
- data/test/models/workarea/search/storefront/product/inventory_test.rb +23 -0
- data/test/models/workarea/search/storefront/product/pricing_test.rb +41 -0
- data/test/models/workarea/search/storefront/product/text_test.rb +69 -0
- data/test/models/workarea/search/storefront/product_test.rb +108 -0
- data/test/models/workarea/search/storefront_test.rb +27 -0
- data/test/models/workarea/shipping/address_test.rb +139 -0
- data/test/models/workarea/shipping/location_query_test.rb +60 -0
- data/test/models/workarea/shipping/rate_lookup_test.rb +76 -0
- data/test/models/workarea/shipping/rate_test.rb +19 -0
- data/test/models/workarea/shipping/service_test.rb +40 -0
- data/test/models/workarea/shipping/sku_test.rb +31 -0
- data/test/models/workarea/shipping_option_test.rb +50 -0
- data/test/models/workarea/shipping_test.rb +106 -0
- data/test/models/workarea/tax/category_test.rb +57 -0
- data/test/models/workarea/tax/rate_lookup_test.rb +217 -0
- data/test/models/workarea/tax_test.rb +34 -0
- data/test/models/workarea/user/admin_bookmark_test.rb +39 -0
- data/test/models/workarea/user/admin_visit_test.rb +23 -0
- data/test/models/workarea/user/password_reset_test.rb +30 -0
- data/test/models/workarea/user/recent_password_test.rb +50 -0
- data/test/models/workarea/user/system_users_test.rb +14 -0
- data/test/models/workarea/user_test.rb +312 -0
- data/test/queries/workarea/admin_query_operation_test.rb +67 -0
- data/test/queries/workarea/admin_search_query_wrapper_test.rb +90 -0
- data/test/queries/workarea/alerts_test.rb +131 -0
- data/test/queries/workarea/bulk_action_selections_test.rb +35 -0
- data/test/queries/workarea/categorization_test.rb +88 -0
- data/test/queries/workarea/extract_content_block_text_test.rb +60 -0
- data/test/queries/workarea/find_pipeline_asset_test.rb +21 -0
- data/test/queries/workarea/find_taxonomy_slug_test.rb +20 -0
- data/test/queries/workarea/find_unique_slug_test.rb +14 -0
- data/test/queries/workarea/metadata/catalog_category_test.rb +38 -0
- data/test/queries/workarea/metadata/content_page_test.rb +36 -0
- data/test/queries/workarea/metadata/home_page_test.rb +34 -0
- data/test/queries/workarea/order_item_details_test.rb +43 -0
- data/test/queries/workarea/order_metrics_test.rb +180 -0
- data/test/queries/workarea/pricing_override_params_test.rb +28 -0
- data/test/queries/workarea/product_primary_image_url_test.rb +22 -0
- data/test/queries/workarea/product_primary_navigation_test.rb +49 -0
- data/test/queries/workarea/recommendation/order_based_test.rb +51 -0
- data/test/queries/workarea/recommendation/product_based_test.rb +91 -0
- data/test/queries/workarea/recommendation/searches_test.rb +23 -0
- data/test/queries/workarea/recommendation/user_activity_based_test.rb +37 -0
- data/test/queries/workarea/reports/average_order_value_test.rb +336 -0
- data/test/queries/workarea/reports/customers_test.rb +106 -0
- data/test/queries/workarea/reports/first_time_vs_returning_sales_test.rb +274 -0
- data/test/queries/workarea/reports/low_inventory_test.rb +48 -0
- data/test/queries/workarea/reports/report_test.rb +100 -0
- data/test/queries/workarea/reports/sales_by_category_test.rb +137 -0
- data/test/queries/workarea/reports/sales_by_country_test.rb +130 -0
- data/test/queries/workarea/reports/sales_by_discount_test.rb +122 -0
- data/test/queries/workarea/reports/sales_by_menu_test.rb +130 -0
- data/test/queries/workarea/reports/sales_by_product_test.rb +130 -0
- data/test/queries/workarea/reports/sales_by_sku_test.rb +171 -0
- data/test/queries/workarea/reports/sales_by_traffic_referrer_test.rb +159 -0
- data/test/queries/workarea/reports/sales_over_time_test.rb +539 -0
- data/test/queries/workarea/reports/searches_over_time_test.rb +90 -0
- data/test/queries/workarea/reports/searches_test.rb +179 -0
- data/test/queries/workarea/reports/searches_without_results_over_time_test.rb +100 -0
- data/test/queries/workarea/search/admin_discounts_test.rb +26 -0
- data/test/queries/workarea/search/admin_orders_test.rb +63 -0
- data/test/queries/workarea/search/admin_payment_transactions_test.rb +13 -0
- data/test/queries/workarea/search/admin_releases_test.rb +67 -0
- data/test/queries/workarea/search/admin_search_test.rb +105 -0
- data/test/queries/workarea/search/admin_users_test.rb +20 -0
- data/test/queries/workarea/search/categorization_test.rb +31 -0
- data/test/queries/workarea/search/category_browse_test.rb +334 -0
- data/test/queries/workarea/search/date_filter_test.rb +39 -0
- data/test/queries/workarea/search/facet_matches_test.rb +55 -0
- data/test/queries/workarea/search/facet_sorting/size_test.rb +27 -0
- data/test/queries/workarea/search/facet_sorting_test.rb +127 -0
- data/test/queries/workarea/search/facet_test.rb +108 -0
- data/test/queries/workarea/search/filter_test.rb +68 -0
- data/test/queries/workarea/search/pagination_test.rb +66 -0
- data/test/queries/workarea/search/product_entries_test.rb +14 -0
- data/test/queries/workarea/search/product_facet_sorting_test.rb +90 -0
- data/test/queries/workarea/search/product_rules_test.rb +348 -0
- data/test/queries/workarea/search/product_search_test.rb +413 -0
- data/test/queries/workarea/search/query_test.rb +43 -0
- data/test/queries/workarea/search/range_facet_test.rb +15 -0
- data/test/queries/workarea/search/range_parameter_test.rb +30 -0
- data/test/queries/workarea/search/related_help_test.rb +101 -0
- data/test/queries/workarea/search/related_products_test.rb +81 -0
- data/test/queries/workarea/search/search_suggestions_test.rb +29 -0
- data/test/queries/workarea/search/storefront_search_test.rb +111 -0
- data/test/queries/workarea/search/terms_facet_test.rb +12 -0
- data/test/queries/workarea/taxonomy_sitemap_test.rb +34 -0
- data/test/services/workarea/add_multiple_cart_items/item_test.rb +56 -0
- data/test/services/workarea/add_multiple_cart_items_test.rb +100 -0
- data/test/services/workarea/cancel_order_test.rb +118 -0
- data/test/services/workarea/cart_cleaner_test.rb +66 -0
- data/test/services/workarea/clean_range_facets_test.rb +28 -0
- data/test/services/workarea/copy_order_test.rb +83 -0
- data/test/services/workarea/copy_product_test.rb +25 -0
- data/test/services/workarea/create_fulfillment_test.rb +23 -0
- data/test/services/workarea/direct_upload_test.rb +58 -0
- data/test/services/workarea/export_report_test.rb +66 -0
- data/test/services/workarea/hash_update_test.rb +24 -0
- data/test/services/workarea/inventory_adjustment_test.rb +41 -0
- data/test/services/workarea/login_test.rb +74 -0
- data/test/services/workarea/order_merge_test.rb +30 -0
- data/test/services/workarea/packaging_test.rb +91 -0
- data/test/services/workarea/save_publishing_test.rb +46 -0
- data/test/services/workarea/save_taxonomy_test.rb +72 -0
- data/test/services/workarea/set_navigable_test.rb +54 -0
- data/test/services/workarea/sort_navigation_menus_by_orders_test.rb +25 -0
- data/test/teaspoon_env.rb +6 -0
- data/test/test_helper.rb +10 -0
- data/test/vcr_cassettes/csv_image_upload.yml +49 -0
- data/test/view_models/workarea/shipping_carrier_view_model_test.rb +49 -0
- data/test/workarea_test.rb +9 -0
- data/test/workers/sidekiq/callbacks_test.rb +433 -0
- data/test/workers/workarea/bulk_index_admin_test.rb +30 -0
- data/test/workers/workarea/bulk_index_products_test.rb +18 -0
- data/test/workers/workarea/bulk_index_searches_test.rb +45 -0
- data/test/workers/workarea/clean_inventory_transactions_test.rb +19 -0
- data/test/workers/workarea/clean_orders_test.rb +22 -0
- data/test/workers/workarea/clean_product_recommendations_test.rb +15 -0
- data/test/workers/workarea/deactivate_stale_discounts_test.rb +82 -0
- data/test/workers/workarea/generate_content_metadata_test.rb +32 -0
- data/test/workers/workarea/generate_insights_test.rb +38 -0
- data/test/workers/workarea/index_admin_search_test.rb +10 -0
- data/test/workers/workarea/index_categorization_test.rb +26 -0
- data/test/workers/workarea/index_category_changes_test.rb +63 -0
- data/test/workers/workarea/index_fulfillment_changes_test.rb +14 -0
- data/test/workers/workarea/index_help_test.rb +18 -0
- data/test/workers/workarea/index_payment_transactions_test.rb +42 -0
- data/test/workers/workarea/index_product_rule_test.rb +20 -0
- data/test/workers/workarea/index_product_test.rb +17 -0
- data/test/workers/workarea/index_skus_test.rb +14 -0
- data/test/workers/workarea/keep_product_index_fresh_test.rb +46 -0
- data/test/workers/workarea/mark_discounts_as_redeemed_test.rb +51 -0
- data/test/workers/workarea/order_reminder_test.rb +45 -0
- data/test/workers/workarea/process_import_test.rb +57 -0
- data/test/workers/workarea/process_product_recommendations_test.rb +57 -0
- data/test/workers/workarea/process_search_recommendations_test.rb +27 -0
- data/test/workers/workarea/publish_bulk_action_test.rb +27 -0
- data/test/workers/workarea/publish_release_test.rb +20 -0
- data/test/workers/workarea/redirect_navigable_slugs_test.rb +28 -0
- data/test/workers/workarea/save_order_metrics_test.rb +14 -0
- data/test/workers/workarea/save_user_order_details_test.rb +130 -0
- data/test/workers/workarea/send_refund_email_test.rb +74 -0
- data/test/workers/workarea/status_reporter_test.rb +20 -0
- data/test/workers/workarea/undo_release_test.rb +23 -0
- data/test/workers/workarea/update_payment_profile_email_test.rb +27 -0
- data/test/workers/workarea/verify_scheduled_releases_test.rb +71 -0
- data/vendor/active_shipping/.gitignore +15 -0
- data/vendor/active_shipping/.travis.yml +31 -0
- data/vendor/active_shipping/.yardopts +13 -0
- data/vendor/active_shipping/CHANGELOG.md +218 -0
- data/vendor/active_shipping/CONTRIBUTING.md +23 -0
- data/vendor/active_shipping/Gemfile +3 -0
- data/vendor/active_shipping/MIT-LICENSE +20 -0
- data/vendor/active_shipping/README.md +163 -0
- data/vendor/active_shipping/Rakefile +35 -0
- data/vendor/active_shipping/active_shipping.gemspec +38 -0
- data/vendor/active_shipping/dev.yml +17 -0
- data/vendor/active_shipping/gemfiles/activesupport42.gemfile +5 -0
- data/vendor/active_shipping/gemfiles/activesupport50.gemfile +6 -0
- data/vendor/active_shipping/gemfiles/activesupport51.gemfile +5 -0
- data/vendor/active_shipping/gemfiles/activesupport52.gemfile +5 -0
- data/vendor/active_shipping/gemfiles/activesupport_master.gemfile +5 -0
- data/vendor/active_shipping/lib/active_shipping.rb +26 -0
- data/vendor/active_shipping/lib/active_shipping/address_validation_response.rb +29 -0
- data/vendor/active_shipping/lib/active_shipping/carrier.rb +183 -0
- data/vendor/active_shipping/lib/active_shipping/carriers.rb +34 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/australia_post.rb +248 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/benchmark_carrier.rb +31 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/bogus_carrier.rb +12 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/canada_post.rb +263 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/canada_post_pws.rb +908 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/fedex.rb +796 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/kunaki.rb +155 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/new_zealand_post.rb +260 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/shipwire.rb +178 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/stamps.rb +860 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/ups.rb +1216 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/usps.rb +708 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/usps_returns.rb +85 -0
- data/vendor/active_shipping/lib/active_shipping/delivery_date_estimate.rb +20 -0
- data/vendor/active_shipping/lib/active_shipping/delivery_date_estimates_response.rb +11 -0
- data/vendor/active_shipping/lib/active_shipping/errors.rb +35 -0
- data/vendor/active_shipping/lib/active_shipping/external_return_label_request.rb +417 -0
- data/vendor/active_shipping/lib/active_shipping/external_return_label_response.rb +24 -0
- data/vendor/active_shipping/lib/active_shipping/label.rb +10 -0
- data/vendor/active_shipping/lib/active_shipping/label_response.rb +10 -0
- data/vendor/active_shipping/lib/active_shipping/location.rb +166 -0
- data/vendor/active_shipping/lib/active_shipping/package.rb +165 -0
- data/vendor/active_shipping/lib/active_shipping/package_item.rb +60 -0
- data/vendor/active_shipping/lib/active_shipping/rate_estimate.rb +196 -0
- data/vendor/active_shipping/lib/active_shipping/rate_response.rb +32 -0
- data/vendor/active_shipping/lib/active_shipping/response.rb +43 -0
- data/vendor/active_shipping/lib/active_shipping/shipment_event.rb +22 -0
- data/vendor/active_shipping/lib/active_shipping/shipment_packer.rb +108 -0
- data/vendor/active_shipping/lib/active_shipping/shipping_response.rb +33 -0
- data/vendor/active_shipping/lib/active_shipping/tracking_response.rb +119 -0
- data/vendor/active_shipping/lib/active_shipping/version.rb +3 -0
- data/vendor/active_shipping/lib/certs/eParcel.dtd +111 -0
- data/vendor/active_shipping/shipit.rubygems.yml +1 -0
- data/vendor/active_shipping/test/console.rb +39 -0
- data/vendor/active_shipping/test/credentials.yml +69 -0
- data/vendor/active_shipping/test/fixtures/files/label1.pdf +0 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/calculate_domestic.json +13 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/calculate_domestic_2.json +19 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/calculate_international.json +12 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/calculate_international_2.json +15 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/error_message.json +5 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/service_domestic.json +117 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/service_domestic_2.json +117 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/service_international.json +76 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/service_international_2.json +59 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/domestic_book.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/domestic_default.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/domestic_error.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/domestic_poster.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/domestic_small_half_pound.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/international_book.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/international_new_zealand_wii.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/international_small_half_pound.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/international_wii.json +1 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_request.xml +25 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_response.xml +130 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_response_error.xml +16 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_response_french.xml +122 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_response_with_nil_value.xml +164 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_response_with_postal_outlet.xml +155 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_response_with_postal_outlet_french.xml +274 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_response_with_strange_delivery_date.xml +130 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/dnc_tracking_details_en.xml +112 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/merchant_details_error.xml +7 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/merchant_details_response.xml +7 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/option_response.xml +13 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/option_response_no_conflicts.xml +7 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/rates_info.xml +190 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/rates_info_error.xml +7 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/receipt_response.xml +42 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/receipt_response_no_priced_options.xml +36 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/register_token_error.xml +7 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/register_token_response.xml +3 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/service_options_response.xml +42 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/services_error.xml +6 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/services_response.xml +32 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/shipment_domestic.xml +69 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/shipment_response.xml +20 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/shipment_us.xml +69 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/tracking_details_en.xml +152 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/tracking_details_en_error.xml +7 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/tracking_details_en_undelivered.xml +116 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/tracking_details_fr.xml +156 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/tracking_details_no_expected_delivery_date.xml +40 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/create_shipment_response.xml +2 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/freight_rate_request.xml +82 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/freight_rate_response.xml +506 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/invalid_fedex_reply.xml +27 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/ottawa_to_beverly_hills_commercial_rate_request.xml +79 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/ottawa_to_beverly_hills_no_saturday_rate_request.xml +79 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_request.xml +80 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_response.xml +214 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/raterequest_reply.xml +213 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/raterequest_response_with_ground_home_delivery.xml +206 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/reply_without_notifications.xml +185 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_request.xml +29 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_bad_tracking_number.xml +20 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_delivered_at_door.xml +254 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_delivered_at_facility.xml +403 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_delivered_with_signature.xml +269 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_empty_status_detail.xml +84 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_failure_code_9045.xml +52 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_failure_code_9080.xml +51 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_in_transit.xml +127 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_invalid_tracking_number.xml +52 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_missing_status_code.xml +89 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_multiple_results.xml +100 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_not_found.xml +52 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_shipment_exception.xml +209 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_unable_to_process.xml +32 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_with_blank_state.xml +107 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/unknown_fedex_document_reply.xml +3 -0
- data/vendor/active_shipping/test/fixtures/xml/kunaki/invalid_state_response.xml +3 -0
- data/vendor/active_shipping/test/fixtures/xml/kunaki/no_valid_items_response.xml +3 -0
- data/vendor/active_shipping/test/fixtures/xml/kunaki/successful_rates_response.xml +3 -0
- data/vendor/active_shipping/test/fixtures/xml/kunaki/unsuccessful_rates_response.xml +9 -0
- data/vendor/active_shipping/test/fixtures/xml/shipwire/international_rates_response.xml +17 -0
- data/vendor/active_shipping/test/fixtures/xml/shipwire/new_carrier_rate_response.xml +18 -0
- data/vendor/active_shipping/test/fixtures/xml/shipwire/no_rates_response.xml +7 -0
- data/vendor/active_shipping/test/fixtures/xml/shipwire/rates_response.xml +36 -0
- data/vendor/active_shipping/test/fixtures/xml/shipwire/rates_response_no_estimate.xml +14 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/authenticate_user_request.xml +15 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/authenticate_user_response.xml +10 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/cleanse_address_request.xml +19 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/cleanse_address_response.xml +27 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/create_indicium_request.xml +69 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/create_indicium_response.xml +40 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/expired_authenticator_response.xml +15 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/get_account_info_request.xml +11 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/get_account_info_response.xml +36 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/get_purchase_status_request.xml +12 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/get_purchase_status_response.xml +16 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/get_rates_request.xml +19 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/get_rates_response.xml +351 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/purchase_postage_request.xml +13 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/purchase_postage_response.xml +17 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/track_shipment_request.xml +12 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/track_shipment_response.xml +45 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/api_error_rate_response.xml +53 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/beverly_hills_to_new_york_book_commercial_base_rate_response.xml +2 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/beverly_hills_to_new_york_book_commercial_plus_rate_response.xml +258 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/beverly_hills_to_new_york_book_rate_response.xml +108 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/beverly_hills_to_ottawa_american_wii_commercial_base_rate_response.xml +84 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/beverly_hills_to_ottawa_american_wii_commercial_plus_rate_response.xml +212 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/beverly_hills_to_ottawa_american_wii_rate_response.xml +230 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/first_class_packages_with_invalid_mail_type_response.xml +12 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/first_class_packages_with_mail_type_response.xml +16 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/first_class_packages_without_mail_type_response.xml +12 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/invalid_xml_response.xml +10 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/invalid_xml_tracking_response_error.xml +2 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_request.xml +10 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_request_batch.xml +12 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_response.xml +162 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_response_alt.xml +53 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_response_batch.xml +231 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_response_failure.xml +11 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_response_not_available.xml +12 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_response_test_error.xml +8 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/us_rate_request.xml +18 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/us_rate_request_large.xml +18 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/world_rate_request_only_country.xml +22 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/world_rate_request_with_value.xml +24 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/world_rate_request_without_value.xml +24 -0
- data/vendor/active_shipping/test/fixtures/xml/usps_returns/external_return_label_response.xml +2 -0
- data/vendor/active_shipping/test/fixtures/xml/usps_returns/external_return_label_response_failure.xml +10 -0
- data/vendor/active_shipping/test/remote/australia_post_test.rb +140 -0
- data/vendor/active_shipping/test/remote/canada_post_pws_platform_test.rb +259 -0
- data/vendor/active_shipping/test/remote/canada_post_pws_test.rb +169 -0
- data/vendor/active_shipping/test/remote/canada_post_test.rb +55 -0
- data/vendor/active_shipping/test/remote/fedex_test.rb +400 -0
- data/vendor/active_shipping/test/remote/kunaki_test.rb +37 -0
- data/vendor/active_shipping/test/remote/new_zealand_post_test.rb +149 -0
- data/vendor/active_shipping/test/remote/shipwire_test.rb +84 -0
- data/vendor/active_shipping/test/remote/stamps_test.rb +396 -0
- data/vendor/active_shipping/test/remote/usps_returns_test.rb +72 -0
- data/vendor/active_shipping/test/remote/usps_test.rb +243 -0
- data/vendor/active_shipping/test/test_helper.rb +295 -0
- data/vendor/active_shipping/test/unit/carrier_test.rb +130 -0
- data/vendor/active_shipping/test/unit/carriers/australia_post_test.rb +181 -0
- data/vendor/active_shipping/test/unit/carriers/benchmark_test.rb +18 -0
- data/vendor/active_shipping/test/unit/carriers/canada_post_pws_rating_test.rb +379 -0
- data/vendor/active_shipping/test/unit/carriers/canada_post_pws_register_test.rb +76 -0
- data/vendor/active_shipping/test/unit/carriers/canada_post_pws_shipping_test.rb +258 -0
- data/vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb +59 -0
- data/vendor/active_shipping/test/unit/carriers/canada_post_pws_tracking_test.rb +154 -0
- data/vendor/active_shipping/test/unit/carriers/canada_post_test.rb +148 -0
- data/vendor/active_shipping/test/unit/carriers/fedex_test.rb +693 -0
- data/vendor/active_shipping/test/unit/carriers/kunaki_test.rb +56 -0
- data/vendor/active_shipping/test/unit/carriers/new_zealand_post_test.rb +177 -0
- data/vendor/active_shipping/test/unit/carriers/shipwire_test.rb +188 -0
- data/vendor/active_shipping/test/unit/carriers/stamps_test.rb +245 -0
- data/vendor/active_shipping/test/unit/carriers/usps_returns_test.rb +45 -0
- data/vendor/active_shipping/test/unit/carriers/usps_test.rb +633 -0
- data/vendor/active_shipping/test/unit/carriers_test.rb +16 -0
- data/vendor/active_shipping/test/unit/external_return_label_request_test.rb +258 -0
- data/vendor/active_shipping/test/unit/location_test.rb +234 -0
- data/vendor/active_shipping/test/unit/package_item_test.rb +232 -0
- data/vendor/active_shipping/test/unit/package_test.rb +404 -0
- data/vendor/active_shipping/test/unit/rate_estimate_test.rb +93 -0
- data/vendor/active_shipping/test/unit/response_test.rb +38 -0
- data/vendor/active_shipping/test/unit/shipment_event_test.rb +20 -0
- data/vendor/active_shipping/test/unit/shipment_packer_test.rb +212 -0
- data/vendor/active_shipping/test/unit/tracking_response_test.rb +41 -0
- data/workarea-core.gemspec +98 -0
- metadata +2585 -0
@@ -0,0 +1,1216 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module ActiveShipping
|
4
|
+
class UPS < Carrier
|
5
|
+
self.retry_safe = true
|
6
|
+
self.ssl_version = :TLSv1_2
|
7
|
+
|
8
|
+
cattr_accessor :default_options
|
9
|
+
cattr_reader :name
|
10
|
+
@@name = "UPS"
|
11
|
+
|
12
|
+
TEST_URL = 'https://wwwcie.ups.com'
|
13
|
+
LIVE_URL = 'https://onlinetools.ups.com'
|
14
|
+
|
15
|
+
RESOURCES = {
|
16
|
+
rates: 'ups.app/xml/Rate',
|
17
|
+
track: 'ups.app/xml/Track',
|
18
|
+
ship_confirm: 'ups.app/xml/ShipConfirm',
|
19
|
+
ship_accept: 'ups.app/xml/ShipAccept',
|
20
|
+
delivery_dates: 'ups.app/xml/TimeInTransit',
|
21
|
+
void: 'ups.app/xml/Void',
|
22
|
+
validate_address: 'ups.app/xml/XAV'
|
23
|
+
}
|
24
|
+
|
25
|
+
PICKUP_CODES = HashWithIndifferentAccess.new(
|
26
|
+
daily_pickup: "01",
|
27
|
+
customer_counter: "03",
|
28
|
+
one_time_pickup: "06",
|
29
|
+
on_call_air: "07",
|
30
|
+
suggested_retail_rates: "11",
|
31
|
+
letter_center: "19",
|
32
|
+
air_service_center: "20"
|
33
|
+
)
|
34
|
+
|
35
|
+
CUSTOMER_CLASSIFICATIONS = HashWithIndifferentAccess.new(
|
36
|
+
wholesale: "01",
|
37
|
+
occasional: "03",
|
38
|
+
retail: "04"
|
39
|
+
)
|
40
|
+
|
41
|
+
# these are the defaults described in the UPS API docs,
|
42
|
+
# but they don't seem to apply them under all circumstances,
|
43
|
+
# so we need to take matters into our own hands
|
44
|
+
DEFAULT_CUSTOMER_CLASSIFICATIONS = Hash.new do |hash, key|
|
45
|
+
hash[key] = case key.to_sym
|
46
|
+
when :daily_pickup then :wholesale
|
47
|
+
when :customer_counter then :retail
|
48
|
+
else
|
49
|
+
:occasional
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
DEFAULT_SERVICES = {
|
54
|
+
"01" => "UPS Next Day Air",
|
55
|
+
"02" => "UPS Second Day Air",
|
56
|
+
"03" => "UPS Ground",
|
57
|
+
"07" => "UPS Worldwide Express",
|
58
|
+
"08" => "UPS Worldwide Expedited",
|
59
|
+
"11" => "UPS Standard",
|
60
|
+
"12" => "UPS Three-Day Select",
|
61
|
+
"13" => "UPS Next Day Air Saver",
|
62
|
+
"14" => "UPS Next Day Air Early A.M.",
|
63
|
+
"54" => "UPS Worldwide Express Plus",
|
64
|
+
"59" => "UPS Second Day Air A.M.",
|
65
|
+
"65" => "UPS Saver",
|
66
|
+
"82" => "UPS Today Standard",
|
67
|
+
"83" => "UPS Today Dedicated Courier",
|
68
|
+
"84" => "UPS Today Intercity",
|
69
|
+
"85" => "UPS Today Express",
|
70
|
+
"86" => "UPS Today Express Saver",
|
71
|
+
"92" => "UPS SurePost (USPS) < 1lb",
|
72
|
+
"93" => "UPS SurePost (USPS) > 1lb",
|
73
|
+
"94" => "UPS SurePost (USPS) BPM",
|
74
|
+
"95" => "UPS SurePost (USPS) Media",
|
75
|
+
}
|
76
|
+
|
77
|
+
CANADA_ORIGIN_SERVICES = {
|
78
|
+
"01" => "UPS Express",
|
79
|
+
"02" => "UPS Expedited",
|
80
|
+
"14" => "UPS Express Early A.M."
|
81
|
+
}
|
82
|
+
|
83
|
+
MEXICO_ORIGIN_SERVICES = {
|
84
|
+
"07" => "UPS Express",
|
85
|
+
"08" => "UPS Expedited",
|
86
|
+
"54" => "UPS Express Plus"
|
87
|
+
}
|
88
|
+
|
89
|
+
EU_ORIGIN_SERVICES = {
|
90
|
+
"07" => "UPS Express",
|
91
|
+
"08" => "UPS Expedited"
|
92
|
+
}
|
93
|
+
|
94
|
+
OTHER_NON_US_ORIGIN_SERVICES = {
|
95
|
+
"07" => "UPS Express"
|
96
|
+
}
|
97
|
+
|
98
|
+
RETURN_SERVICE_CODES = {
|
99
|
+
"2" => "UPS Print and Mail (PNM)",
|
100
|
+
"3" => "UPS Return Service 1-Attempt (RS1)",
|
101
|
+
"5" => "UPS Return Service 3-Attempt (RS3)",
|
102
|
+
"8" => "UPS Electronic Return Label (ERL)",
|
103
|
+
"9" => "UPS Print Return Label (PRL)",
|
104
|
+
"10" => "UPS Exchange Print Return Label",
|
105
|
+
"11" => "UPS Pack & Collect Service 1-Attempt Box 1",
|
106
|
+
"12" => "UPS Pack & Collect Service 1-Attempt Box 2",
|
107
|
+
"13" => "UPS Pack & Collect Service 1-Attempt Box 3",
|
108
|
+
"14" => "UPS Pack & Collect Service 1-Attempt Box 4",
|
109
|
+
"15" => "UPS Pack & Collect Service 1-Attempt Box 5",
|
110
|
+
"16" => "UPS Pack & Collect Service 3-Attempt Box 1",
|
111
|
+
"17" => "UPS Pack & Collect Service 3-Attempt Box 2",
|
112
|
+
"18" => "UPS Pack & Collect Service 3-Attempt Box 3",
|
113
|
+
"19" => "UPS Pack & Collect Service 3-Attempt Box 4",
|
114
|
+
"20" => "UPS Pack & Collect Service 3-Attempt Box 5",
|
115
|
+
}
|
116
|
+
|
117
|
+
TRACKING_STATUS_CODES = HashWithIndifferentAccess.new(
|
118
|
+
'I' => :in_transit,
|
119
|
+
'D' => :delivered,
|
120
|
+
'X' => :exception,
|
121
|
+
'P' => :pickup,
|
122
|
+
'M' => :manifest_pickup
|
123
|
+
)
|
124
|
+
|
125
|
+
# From http://en.wikipedia.org/w/index.php?title=European_Union&oldid=174718707 (Current as of November 30, 2007)
|
126
|
+
EU_COUNTRY_CODES = %w(GB AT BE BG CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE)
|
127
|
+
|
128
|
+
US_TERRITORIES_TREATED_AS_COUNTRIES = %w(AS FM GU MH MP PW PR VI)
|
129
|
+
|
130
|
+
IMPERIAL_COUNTRIES = %w(US LR MM)
|
131
|
+
|
132
|
+
COUNTRY_MAPPING = {
|
133
|
+
'XK' => 'KV'
|
134
|
+
}.freeze
|
135
|
+
|
136
|
+
DEFAULT_SERVICE_NAME_TO_CODE = Hash[UPS::DEFAULT_SERVICES.to_a.map(&:reverse)]
|
137
|
+
DEFAULT_SERVICE_NAME_TO_CODE['UPS 2nd Day Air'] = "02"
|
138
|
+
DEFAULT_SERVICE_NAME_TO_CODE['UPS 3 Day Select'] = "12"
|
139
|
+
DEFAULT_SERVICE_NAME_TO_CODE['UPS Next Day Air Early'] = "14"
|
140
|
+
|
141
|
+
SHIPMENT_DELIVERY_CONFIRMATION_CODES = {
|
142
|
+
delivery_confirmation_signature_required: 1,
|
143
|
+
delivery_confirmation_adult_signature_required: 2
|
144
|
+
}
|
145
|
+
|
146
|
+
PACKAGE_DELIVERY_CONFIRMATION_CODES = {
|
147
|
+
delivery_confirmation: 1,
|
148
|
+
delivery_confirmation_signature_required: 2,
|
149
|
+
delivery_confirmation_adult_signature_required: 3,
|
150
|
+
usps_delivery_confirmation: 4
|
151
|
+
}
|
152
|
+
|
153
|
+
def requirements
|
154
|
+
[:key, :login, :password]
|
155
|
+
end
|
156
|
+
|
157
|
+
def find_rates(origin, destination, packages, options = {})
|
158
|
+
origin, destination = upsified_location(origin), upsified_location(destination)
|
159
|
+
options = @options.merge(options)
|
160
|
+
packages = Array(packages)
|
161
|
+
access_request = build_access_request
|
162
|
+
rate_request = build_rate_request(origin, destination, packages, options)
|
163
|
+
response = commit(:rates, save_request(access_request + rate_request), options[:test])
|
164
|
+
parse_rate_response(origin, destination, packages, response, options)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Retrieves tracking information for a previous shipment
|
168
|
+
#
|
169
|
+
# @note Override with whatever you need to get a shipping label
|
170
|
+
#
|
171
|
+
# @param tracking_number [String] The unique identifier of the shipment to track.
|
172
|
+
# @param options [Hash] Carrier-specific parameters.
|
173
|
+
# @option options [Boolean] :mail_innovations Set this to true to track a Mail Innovations Package
|
174
|
+
# @return [ActiveShipping::TrackingResponse] The response from the carrier. This
|
175
|
+
# response should a list of shipment tracking events if successful.
|
176
|
+
def find_tracking_info(tracking_number, options = {})
|
177
|
+
options = @options.merge(options)
|
178
|
+
access_request = build_access_request
|
179
|
+
tracking_request = build_tracking_request(tracking_number, options)
|
180
|
+
response = commit(:track, save_request(access_request + tracking_request), options[:test])
|
181
|
+
parse_tracking_response(response, options)
|
182
|
+
end
|
183
|
+
|
184
|
+
def create_shipment(origin, destination, packages, options = {})
|
185
|
+
options = @options.merge(options)
|
186
|
+
packages = Array(packages)
|
187
|
+
access_request = build_access_request
|
188
|
+
|
189
|
+
# STEP 1: Confirm. Validation step, important for verifying price.
|
190
|
+
confirm_request = build_shipment_request(origin, destination, packages, options)
|
191
|
+
logger.debug(confirm_request) if logger
|
192
|
+
|
193
|
+
confirm_response = commit(:ship_confirm, save_request(access_request + confirm_request), (options[:test] || false))
|
194
|
+
logger.debug(confirm_response) if logger
|
195
|
+
|
196
|
+
# ... now, get the digest, it's needed to get the label. In theory,
|
197
|
+
# one could make decisions based on the price or some such to avoid
|
198
|
+
# surprises. This also has *no* error handling yet.
|
199
|
+
xml = parse_ship_confirm(confirm_response)
|
200
|
+
success = response_success?(xml)
|
201
|
+
message = response_message(xml)
|
202
|
+
raise ActiveShipping::ResponseContentError, StandardError.new(message) unless success
|
203
|
+
digest = response_digest(xml)
|
204
|
+
|
205
|
+
# STEP 2: Accept. Use shipment digest in first response to get the actual label.
|
206
|
+
accept_request = build_accept_request(digest, options)
|
207
|
+
logger.debug(accept_request) if logger
|
208
|
+
|
209
|
+
accept_response = commit(:ship_accept, save_request(access_request + accept_request), (options[:test] || false))
|
210
|
+
logger.debug(accept_response) if logger
|
211
|
+
|
212
|
+
# ...finally, build a map from the response that contains
|
213
|
+
# the label data and tracking information.
|
214
|
+
parse_ship_accept(accept_response)
|
215
|
+
end
|
216
|
+
|
217
|
+
def get_delivery_date_estimates(origin, destination, packages, pickup_date = Date.current, options = {})
|
218
|
+
origin, destination = upsified_location(origin), upsified_location(destination)
|
219
|
+
options = @options.merge(options)
|
220
|
+
packages = Array(packages)
|
221
|
+
access_request = build_access_request
|
222
|
+
dates_request = build_delivery_dates_request(origin, destination, packages, pickup_date, options)
|
223
|
+
response = commit(:delivery_dates, save_request(access_request + dates_request), (options[:test] || false))
|
224
|
+
parse_delivery_dates_response(origin, destination, packages, response, options)
|
225
|
+
end
|
226
|
+
|
227
|
+
def void_shipment(tracking, options = {})
|
228
|
+
options = @options.merge(options)
|
229
|
+
access_request = build_access_request
|
230
|
+
void_request = build_void_request(tracking)
|
231
|
+
response = commit(:void, save_request(access_request + void_request), (options[:test] || false))
|
232
|
+
parse_void_response(response, options)
|
233
|
+
end
|
234
|
+
|
235
|
+
def maximum_address_field_length
|
236
|
+
# http://www.ups.com/worldshiphelp/WS12/ENU/AppHelp/CONNECT/Shipment_Data_Field_Descriptions.htm
|
237
|
+
35
|
238
|
+
end
|
239
|
+
|
240
|
+
# Validates a location with the Street Level Validation service
|
241
|
+
#
|
242
|
+
# @param location [Location] The Location to validate
|
243
|
+
# @return [ActiveShipping::AddressValidationResponse] The response from the validation endpoint. This
|
244
|
+
# response will determine if the given address is valid or not, its commercial/residential classification,
|
245
|
+
# and the cleaned-up address and/or potential candidate addresses if the passed location can't be found
|
246
|
+
def validate_address(location, options = {})
|
247
|
+
location = upsified_location(location)
|
248
|
+
options = @options.merge(options)
|
249
|
+
access_request = build_access_request
|
250
|
+
address_validation_request = build_address_validation_request(location, options)
|
251
|
+
response = commit(:validate_address, save_request(access_request + address_validation_request), options[:test])
|
252
|
+
parse_address_validation_response(location, response, options)
|
253
|
+
end
|
254
|
+
|
255
|
+
protected
|
256
|
+
|
257
|
+
def upsified_location(location)
|
258
|
+
if location.country_code == 'US' && US_TERRITORIES_TREATED_AS_COUNTRIES.include?(location.state)
|
259
|
+
atts = { country: location.state }
|
260
|
+
[:zip, :city, :address1, :address2, :address3, :phone, :fax, :address_type].each do |att|
|
261
|
+
atts[att] = location.send(att)
|
262
|
+
end
|
263
|
+
Location.new(atts)
|
264
|
+
else
|
265
|
+
location
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
def build_access_request
|
270
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
271
|
+
xml.AccessRequest do
|
272
|
+
xml.AccessLicenseNumber(@options[:key])
|
273
|
+
xml.UserId(@options[:login])
|
274
|
+
xml.Password(@options[:password])
|
275
|
+
end
|
276
|
+
end
|
277
|
+
xml_builder.to_xml
|
278
|
+
end
|
279
|
+
|
280
|
+
# Builds an XML node to request UPS shipping rates for the given packages
|
281
|
+
#
|
282
|
+
# @param origin [ActiveShipping::Location] Where the shipment will originate from
|
283
|
+
# @param destination [ActiveShipping::Location] Where the package will go
|
284
|
+
# @param packages [Array<ActiveShipping::Package>] The list of packages that will
|
285
|
+
# be in the shipment
|
286
|
+
# @options options [Hash] rate-specific options
|
287
|
+
# @return [ActiveShipping::RateResponse] The response from the UPS, which
|
288
|
+
# includes 0 or more rate estimates for different shipping products
|
289
|
+
#
|
290
|
+
# options:
|
291
|
+
# * service: name of the service
|
292
|
+
# * pickup_type: symbol for PICKUP_CODES
|
293
|
+
# * customer_classification: symbol for CUSTOMER_CLASSIFICATIONS
|
294
|
+
# * shipper: who is sending the package and where it should be returned
|
295
|
+
# if it is undeliverable.
|
296
|
+
# * imperial: if truthy, measurements will use the metric system
|
297
|
+
# * negotiated_rates: if truthy, negotiated rates will be requested from
|
298
|
+
# UPS. Only valid if shipper account has negotiated rates.
|
299
|
+
def build_rate_request(origin, destination, packages, options = {})
|
300
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
301
|
+
xml.RatingServiceSelectionRequest do
|
302
|
+
xml.Request do
|
303
|
+
xml.RequestAction('Rate')
|
304
|
+
xml.RequestOption((options[:service].nil?) ? 'Shop' : 'Rate')
|
305
|
+
end
|
306
|
+
|
307
|
+
pickup_type = options[:pickup_type] || :daily_pickup
|
308
|
+
|
309
|
+
xml.PickupType do
|
310
|
+
xml.Code(PICKUP_CODES[pickup_type])
|
311
|
+
# not implemented: PickupType/PickupDetails element
|
312
|
+
end
|
313
|
+
|
314
|
+
cc = options[:customer_classification] || DEFAULT_CUSTOMER_CLASSIFICATIONS[pickup_type]
|
315
|
+
xml.CustomerClassification do
|
316
|
+
xml.Code(CUSTOMER_CLASSIFICATIONS[cc])
|
317
|
+
end
|
318
|
+
|
319
|
+
xml.Shipment do
|
320
|
+
# not implemented: Shipment/Description element
|
321
|
+
build_location_node(xml, 'Shipper', (options[:shipper] || origin), options)
|
322
|
+
build_location_node(xml, 'ShipTo', destination, options)
|
323
|
+
build_location_node(xml, 'ShipFrom', origin, options) if options[:shipper] && options[:shipper] != origin
|
324
|
+
|
325
|
+
# not implemented: * Shipment/ShipmentWeight element
|
326
|
+
# * Shipment/ReferenceNumber element
|
327
|
+
# * Shipment/Service element
|
328
|
+
# * Shipment/PickupDate element
|
329
|
+
# * Shipment/ScheduledDeliveryDate element
|
330
|
+
# * Shipment/ScheduledDeliveryTime element
|
331
|
+
# * Shipment/AlternateDeliveryTime element
|
332
|
+
# * Shipment/DocumentsOnly element
|
333
|
+
|
334
|
+
unless options[:service].nil?
|
335
|
+
xml.Service do
|
336
|
+
xml.Code(options[:service])
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
Array(packages).each do |package|
|
341
|
+
options[:imperial] ||= IMPERIAL_COUNTRIES.include?(origin.country_code(:alpha2))
|
342
|
+
build_package_node(xml, package, options)
|
343
|
+
end
|
344
|
+
|
345
|
+
# not implemented: * Shipment/ShipmentServiceOptions element
|
346
|
+
if options[:negotiated_rates]
|
347
|
+
xml.RateInformation do
|
348
|
+
xml.NegotiatedRatesIndicator
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|
353
|
+
end
|
354
|
+
xml_builder.to_xml
|
355
|
+
end
|
356
|
+
|
357
|
+
# Build XML node to request a shipping label for the given packages.
|
358
|
+
#
|
359
|
+
# options:
|
360
|
+
# * origin_account: account number for the shipper
|
361
|
+
# * customer_context: a "guid like substance" -- according to UPS
|
362
|
+
# * shipper: who is sending the package and where it should be returned
|
363
|
+
# if it is undeliverable.
|
364
|
+
# * ship_from: where the package is picked up.
|
365
|
+
# * service_code: default to '03'
|
366
|
+
# * saturday_delivery: any truthy value causes this element to exist
|
367
|
+
# * optional_processing: 'validate' (blank) or 'nonvalidate' or blank
|
368
|
+
# * paperless_invoice: set to truthy if using paperless invoice to ship internationally
|
369
|
+
# * terms_of_shipment: used with paperless invoice to specify who pays duties and taxes
|
370
|
+
# * reference_numbers: Array of hashes with :value => a reference number value and optionally :code => reference number type
|
371
|
+
# * prepay: if truthy the shipper will be bill immediatly. Otherwise the shipper is billed when the label is used.
|
372
|
+
# * negotiated_rates: if truthy negotiated rates will be requested from ups. Only valid if shipper account has negotiated rates.
|
373
|
+
# * delivery_confirmation: Can be set to any key from SHIPMENT_DELIVERY_CONFIRMATION_CODES. Can also be set on package level via package.options
|
374
|
+
# * bill_third_party: When truthy, bill an account other than the shipper's. Specified by billing_(account, zip and country)
|
375
|
+
def build_shipment_request(origin, destination, packages, options = {})
|
376
|
+
packages = Array(packages)
|
377
|
+
shipper = options[:shipper] || origin
|
378
|
+
options[:international] = origin.country.name != destination.country.name
|
379
|
+
options[:imperial] ||= IMPERIAL_COUNTRIES.include?(shipper.country_code(:alpha2))
|
380
|
+
options[:return] = options[:return_service_code].present?
|
381
|
+
options[:reason_for_export] ||= ("RETURN" if options[:return])
|
382
|
+
|
383
|
+
if allow_package_level_reference_numbers(origin, destination)
|
384
|
+
if options[:reference_numbers]
|
385
|
+
packages.each do |package|
|
386
|
+
package.options[:reference_numbers] = options[:reference_numbers]
|
387
|
+
end
|
388
|
+
end
|
389
|
+
options[:reference_numbers] = []
|
390
|
+
end
|
391
|
+
|
392
|
+
handle_delivery_confirmation_options(origin, destination, packages, options)
|
393
|
+
|
394
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
395
|
+
xml.ShipmentConfirmRequest do
|
396
|
+
xml.Request do
|
397
|
+
xml.RequestAction('ShipConfirm')
|
398
|
+
# Required element cotnrols level of address validation.
|
399
|
+
xml.RequestOption(options[:optional_processing] || 'validate')
|
400
|
+
# Optional element to identify transactions between client and server.
|
401
|
+
if options[:customer_context]
|
402
|
+
xml.TransactionReference do
|
403
|
+
xml.CustomerContext(options[:customer_context])
|
404
|
+
end
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
xml.Shipment do
|
409
|
+
xml.Service do
|
410
|
+
xml.Code(options[:service_code] || '03')
|
411
|
+
end
|
412
|
+
|
413
|
+
build_location_node(xml, 'ShipTo', destination, options)
|
414
|
+
build_location_node(xml, 'ShipFrom', origin, options)
|
415
|
+
# Required element. The company whose account is responsible for the label(s).
|
416
|
+
build_location_node(xml, 'Shipper', shipper, options)
|
417
|
+
|
418
|
+
if options[:saturday_delivery]
|
419
|
+
xml.ShipmentServiceOptions do
|
420
|
+
xml.SaturdayDelivery
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
424
|
+
if options[:negotiated_rates]
|
425
|
+
xml.RateInformation do
|
426
|
+
xml.NegotiatedRatesIndicator
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
Array(options[:reference_numbers]).each do |reference_num_info|
|
431
|
+
xml.ReferenceNumber do
|
432
|
+
xml.Code(reference_num_info[:code] || "")
|
433
|
+
xml.Value(reference_num_info[:value])
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
if options[:prepay]
|
438
|
+
xml.PaymentInformation do
|
439
|
+
xml.Prepaid do
|
440
|
+
build_billing_info_node(xml, options)
|
441
|
+
end
|
442
|
+
end
|
443
|
+
else
|
444
|
+
xml.ItemizedPaymentInformation do
|
445
|
+
xml.ShipmentCharge do
|
446
|
+
# Type '01' means 'Transportation'
|
447
|
+
# This node specifies who will be billed for transportation.
|
448
|
+
xml.Type('01')
|
449
|
+
build_billing_info_node(xml, options)
|
450
|
+
end
|
451
|
+
if options[:terms_of_shipment] == 'DDP' && options[:international]
|
452
|
+
# DDP stands for delivery duty paid and means the shipper will cover duties and taxes
|
453
|
+
# Otherwise UPS will charge the receiver
|
454
|
+
xml.ShipmentCharge do
|
455
|
+
xml.Type('02') # Type '02' means 'Duties and Taxes'
|
456
|
+
build_billing_info_node(xml, options.merge(bill_to_consignee: true))
|
457
|
+
end
|
458
|
+
end
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
if options[:international]
|
463
|
+
unless options[:return]
|
464
|
+
build_location_node(xml, 'SoldTo', options[:sold_to] || destination, options)
|
465
|
+
end
|
466
|
+
|
467
|
+
if origin.country_code(:alpha2) == 'US' && ['CA', 'PR'].include?(destination.country_code(:alpha2))
|
468
|
+
# Required for shipments from the US to Puerto Rico or Canada
|
469
|
+
xml.InvoiceLineTotal do
|
470
|
+
total_value = packages.inject(0) { |sum, package| sum + (package.value || 0) }
|
471
|
+
xml.MonetaryValue(total_value)
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
contents_description = packages.map { |p| p.options[:description] }.compact.join(',')
|
476
|
+
unless contents_description.empty?
|
477
|
+
xml.Description(contents_description)
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
if options[:return]
|
482
|
+
xml.ReturnService do
|
483
|
+
xml.Code(options[:return_service_code])
|
484
|
+
end
|
485
|
+
end
|
486
|
+
|
487
|
+
xml.ShipmentServiceOptions do
|
488
|
+
if delivery_confirmation = options[:delivery_confirmation]
|
489
|
+
xml.DeliveryConfirmation do
|
490
|
+
xml.DCISType(SHIPMENT_DELIVERY_CONFIRMATION_CODES[delivery_confirmation])
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
if options[:international]
|
495
|
+
build_international_forms(xml, origin, destination, packages, options)
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
# A request may specify multiple packages.
|
500
|
+
packages.each do |package|
|
501
|
+
build_package_node(xml, package, options)
|
502
|
+
end
|
503
|
+
end
|
504
|
+
|
505
|
+
# Supported label formats:
|
506
|
+
# GIF, EPL, ZPL, STARPL and SPL
|
507
|
+
label_format = options[:label_format] ? options[:label_format].upcase : 'GIF'
|
508
|
+
label_size = options[:label_size] ? options[:label_size] : [4, 6]
|
509
|
+
|
510
|
+
xml.LabelSpecification do
|
511
|
+
xml.LabelStockSize do
|
512
|
+
xml.Height(label_size[0])
|
513
|
+
xml.Width(label_size[1])
|
514
|
+
end
|
515
|
+
|
516
|
+
xml.LabelPrintMethod do
|
517
|
+
xml.Code(label_format)
|
518
|
+
end
|
519
|
+
|
520
|
+
# API requires these only if returning a GIF formated label
|
521
|
+
if label_format == 'GIF'
|
522
|
+
xml.HTTPUserAgent('Mozilla/4.5')
|
523
|
+
xml.LabelImageFormat(label_format) do
|
524
|
+
xml.Code(label_format)
|
525
|
+
end
|
526
|
+
end
|
527
|
+
end
|
528
|
+
end
|
529
|
+
end
|
530
|
+
xml_builder.to_xml
|
531
|
+
end
|
532
|
+
|
533
|
+
def build_delivery_dates_request(origin, destination, packages, pickup_date, options = {})
|
534
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
535
|
+
|
536
|
+
xml.TimeInTransitRequest do
|
537
|
+
xml.Request do
|
538
|
+
xml.RequestAction('TimeInTransit')
|
539
|
+
end
|
540
|
+
|
541
|
+
build_address_artifact_format_location(xml, 'TransitFrom', origin)
|
542
|
+
build_address_artifact_format_location(xml, 'TransitTo', destination)
|
543
|
+
|
544
|
+
xml.ShipmentWeight do
|
545
|
+
xml.UnitOfMeasurement do
|
546
|
+
xml.Code(options[:imperial] ? 'LBS' : 'KGS')
|
547
|
+
end
|
548
|
+
|
549
|
+
value = packages.inject(0) do |sum, package|
|
550
|
+
sum + (options[:imperial] ? package.lbs.to_f : package.kgs.to_f)
|
551
|
+
end
|
552
|
+
|
553
|
+
xml.Weight([value.round(3), 0.1].max)
|
554
|
+
end
|
555
|
+
|
556
|
+
if packages.any? { |package| package.value.present? }
|
557
|
+
xml.InvoiceLineTotal do
|
558
|
+
xml.CurrencyCode('USD')
|
559
|
+
total_value = packages.inject(0) { |sum, package| sum + package.value.to_i }
|
560
|
+
xml.MonetaryValue(total_value)
|
561
|
+
end
|
562
|
+
end
|
563
|
+
|
564
|
+
xml.PickupDate(pickup_date.strftime('%Y%m%d'))
|
565
|
+
end
|
566
|
+
end
|
567
|
+
|
568
|
+
xml_builder.to_xml
|
569
|
+
end
|
570
|
+
|
571
|
+
def build_void_request(tracking)
|
572
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
573
|
+
xml.VoidShipmentRequest do
|
574
|
+
xml.Request do
|
575
|
+
xml.RequestAction('Void')
|
576
|
+
end
|
577
|
+
xml.ShipmentIdentificationNumber(tracking)
|
578
|
+
end
|
579
|
+
end
|
580
|
+
xml_builder.to_xml
|
581
|
+
end
|
582
|
+
|
583
|
+
def build_international_forms(xml, origin, destination, packages, options)
|
584
|
+
if options[:paperless_invoice]
|
585
|
+
xml.InternationalForms do
|
586
|
+
xml.FormType('01') # 01 is "Invoice"
|
587
|
+
xml.InvoiceDate(options[:invoice_date] || Date.today.strftime('%Y%m%d'))
|
588
|
+
xml.ReasonForExport(options[:reason_for_export] || 'SALE')
|
589
|
+
xml.CurrencyCode(options[:currency_code] || 'USD')
|
590
|
+
|
591
|
+
if options[:terms_of_shipment]
|
592
|
+
xml.TermsOfShipment(options[:terms_of_shipment])
|
593
|
+
end
|
594
|
+
|
595
|
+
packages.each do |package|
|
596
|
+
xml.Product do |xml|
|
597
|
+
xml.Description(package.options[:description])
|
598
|
+
xml.CommodityCode(package.options[:commodity_code])
|
599
|
+
xml.OriginCountryCode(origin.country_code(:alpha2))
|
600
|
+
xml.Unit do |xml|
|
601
|
+
xml.Value(package.value / (package.options[:item_count] || 1))
|
602
|
+
xml.Number((package.options[:item_count] || 1))
|
603
|
+
xml.UnitOfMeasurement do |xml|
|
604
|
+
# NMB = number. You can specify units in barrels, boxes, etc. Codes are in the api docs.
|
605
|
+
xml.Code(package.options[:unit_of_item_count] || 'NMB')
|
606
|
+
end
|
607
|
+
end
|
608
|
+
end
|
609
|
+
end
|
610
|
+
end
|
611
|
+
end
|
612
|
+
end
|
613
|
+
|
614
|
+
def build_accept_request(digest, options = {})
|
615
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
616
|
+
xml.ShipmentAcceptRequest do
|
617
|
+
xml.Request do
|
618
|
+
xml.RequestAction('ShipAccept')
|
619
|
+
end
|
620
|
+
xml.ShipmentDigest(digest)
|
621
|
+
end
|
622
|
+
end
|
623
|
+
xml_builder.to_xml
|
624
|
+
end
|
625
|
+
|
626
|
+
def build_tracking_request(tracking_number, options = {})
|
627
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
628
|
+
xml.TrackRequest do
|
629
|
+
xml.TrackingOption(options[:tracking_option]) if options[:tracking_option]
|
630
|
+
xml.Request do
|
631
|
+
xml.RequestAction('Track')
|
632
|
+
xml.RequestOption('1')
|
633
|
+
end
|
634
|
+
xml.TrackingNumber(tracking_number.to_s)
|
635
|
+
xml.TrackingOption('03') if options[:mail_innovations]
|
636
|
+
end
|
637
|
+
end
|
638
|
+
xml_builder.to_xml
|
639
|
+
end
|
640
|
+
|
641
|
+
def build_location_node(xml, name, location, options = {})
|
642
|
+
# not implemented: * Shipment/Shipper/Name element
|
643
|
+
# * Shipment/(ShipTo|ShipFrom)/CompanyName element
|
644
|
+
# * Shipment/(Shipper|ShipTo|ShipFrom)/AttentionName element
|
645
|
+
# * Shipment/(Shipper|ShipTo|ShipFrom)/TaxIdentificationNumber element
|
646
|
+
xml.public_send(name) do
|
647
|
+
if shipper_name = (location.name || location.company_name || options[:origin_name])
|
648
|
+
xml.Name(shipper_name)
|
649
|
+
end
|
650
|
+
xml.PhoneNumber(location.phone.gsub(/[^\d]/, '')) unless location.phone.blank?
|
651
|
+
xml.FaxNumber(location.fax.gsub(/[^\d]/, '')) unless location.fax.blank?
|
652
|
+
|
653
|
+
if (name == 'Shipper') && (origin_account = options[:origin_account] || @options[:origin_account])
|
654
|
+
xml.ShipperNumber(origin_account)
|
655
|
+
elsif (name == 'ShipTo') && (destination_account = options[:destination_account] || @options[:destination_account])
|
656
|
+
xml.ShipperAssignedIdentificationNumber(destination_account)
|
657
|
+
end
|
658
|
+
|
659
|
+
if name = (location.company_name || location.name || options[:origin_name])
|
660
|
+
xml.CompanyName(name)
|
661
|
+
end
|
662
|
+
|
663
|
+
if phone = location.phone
|
664
|
+
xml.PhoneNumber(phone)
|
665
|
+
end
|
666
|
+
|
667
|
+
if attn = location.name
|
668
|
+
xml.AttentionName(attn)
|
669
|
+
end
|
670
|
+
|
671
|
+
xml.Address do
|
672
|
+
xml.AddressLine1(location.address1) unless location.address1.blank?
|
673
|
+
xml.AddressLine2(location.address2) unless location.address2.blank?
|
674
|
+
xml.AddressLine3(location.address3) unless location.address3.blank?
|
675
|
+
xml.City(location.city) unless location.city.blank?
|
676
|
+
xml.StateProvinceCode(location.province) unless location.province.blank?
|
677
|
+
# StateProvinceCode required for negotiated rates but not otherwise, for some reason
|
678
|
+
xml.PostalCode(location.postal_code) unless location.postal_code.blank?
|
679
|
+
xml.CountryCode(mapped_country_code(location.country_code(:alpha2))) unless location.country_code(:alpha2).blank?
|
680
|
+
xml.ResidentialAddressIndicator(true) unless location.commercial? # the default should be that UPS returns residential rates for destinations that it doesn't know about
|
681
|
+
# not implemented: Shipment/(Shipper|ShipTo|ShipFrom)/Address/ResidentialAddressIndicator element
|
682
|
+
end
|
683
|
+
end
|
684
|
+
end
|
685
|
+
|
686
|
+
def build_address_artifact_format_location(xml, name, location)
|
687
|
+
xml.public_send(name) do
|
688
|
+
xml.AddressArtifactFormat do
|
689
|
+
xml.PoliticalDivision2(location.city)
|
690
|
+
xml.PoliticalDivision1(location.province)
|
691
|
+
xml.CountryCode(mapped_country_code(location.country_code(:alpha2)))
|
692
|
+
xml.PostcodePrimaryLow(location.postal_code)
|
693
|
+
xml.ResidentialAddressIndicator(true) unless location.commercial?
|
694
|
+
end
|
695
|
+
end
|
696
|
+
end
|
697
|
+
|
698
|
+
def build_package_node(xml, package, options = {})
|
699
|
+
xml.Package do
|
700
|
+
# not implemented: * Shipment/Package/PackagingType element
|
701
|
+
|
702
|
+
#return requires description
|
703
|
+
if options[:return]
|
704
|
+
contents_description = package.options[:description]
|
705
|
+
xml.Description(contents_description) if contents_description
|
706
|
+
end
|
707
|
+
|
708
|
+
xml.PackagingType do
|
709
|
+
xml.Code('02')
|
710
|
+
end
|
711
|
+
|
712
|
+
xml.Dimensions do
|
713
|
+
xml.UnitOfMeasurement do
|
714
|
+
xml.Code(options[:imperial] ? 'IN' : 'CM')
|
715
|
+
end
|
716
|
+
[:length, :width, :height].each do |axis|
|
717
|
+
value = ((options[:imperial] ? package.inches(axis) : package.cm(axis)).to_f * 1000).round / 1000.0 # 3 decimals
|
718
|
+
xml.public_send(axis.to_s.capitalize, [value, 0.1].max)
|
719
|
+
end
|
720
|
+
end
|
721
|
+
|
722
|
+
xml.PackageWeight do
|
723
|
+
if (options[:service] || options[:service_code]) == DEFAULT_SERVICE_NAME_TO_CODE["UPS SurePost (USPS) < 1lb"]
|
724
|
+
# SurePost < 1lb uses OZS, not LBS
|
725
|
+
code = options[:imperial] ? 'OZS' : 'KGS'
|
726
|
+
weight = options[:imperial] ? package.oz : package.kgs
|
727
|
+
else
|
728
|
+
code = options[:imperial] ? 'LBS' : 'KGS'
|
729
|
+
weight = options[:imperial] ? package.lbs : package.kgs
|
730
|
+
end
|
731
|
+
xml.UnitOfMeasurement do
|
732
|
+
xml.Code(code)
|
733
|
+
end
|
734
|
+
|
735
|
+
value = ((weight).to_f * 1000).round / 1000.0 # 3 decimals
|
736
|
+
xml.Weight([value, 0.1].max)
|
737
|
+
end
|
738
|
+
|
739
|
+
|
740
|
+
Array(package.options[:reference_numbers]).each do |reference_number_info|
|
741
|
+
xml.ReferenceNumber do
|
742
|
+
xml.Code(reference_number_info[:code] || "")
|
743
|
+
xml.Value(reference_number_info[:value])
|
744
|
+
end
|
745
|
+
end
|
746
|
+
|
747
|
+
xml.PackageServiceOptions do
|
748
|
+
if delivery_confirmation = package.options[:delivery_confirmation]
|
749
|
+
xml.DeliveryConfirmation do
|
750
|
+
xml.DCISType(PACKAGE_DELIVERY_CONFIRMATION_CODES[delivery_confirmation])
|
751
|
+
end
|
752
|
+
end
|
753
|
+
|
754
|
+
if dry_ice = package.options[:dry_ice]
|
755
|
+
xml.DryIce do
|
756
|
+
xml.RegulationSet(dry_ice[:regulation_set] || 'CFR')
|
757
|
+
xml.DryIceWeight do
|
758
|
+
xml.UnitOfMeasurement do
|
759
|
+
xml.Code(options[:imperial] ? 'LBS' : 'KGS')
|
760
|
+
end
|
761
|
+
# Cannot be more than package weight.
|
762
|
+
# Should be more than 0.0.
|
763
|
+
# Valid characters are 0-9 and .(Decimal point).
|
764
|
+
# Limit to 1 digit after the decimal. The maximum length
|
765
|
+
# of the field is 5 including . and can hold up
|
766
|
+
# to 1 decimal place.
|
767
|
+
xml.Weight(dry_ice[:weight])
|
768
|
+
end
|
769
|
+
end
|
770
|
+
end
|
771
|
+
|
772
|
+
if package_value = package.options[:insured_value]
|
773
|
+
xml.InsuredValue do
|
774
|
+
xml.CurrencyCode(package.options[:currency] || 'USD')
|
775
|
+
xml.MonetaryValue(package_value.to_f)
|
776
|
+
end
|
777
|
+
end
|
778
|
+
end
|
779
|
+
|
780
|
+
# not implemented: * Shipment/Package/LargePackageIndicator element
|
781
|
+
# * Shipment/Package/AdditionalHandling element
|
782
|
+
end
|
783
|
+
end
|
784
|
+
|
785
|
+
def build_billing_info_node(xml, options = {})
|
786
|
+
if options[:bill_third_party]
|
787
|
+
xml.BillThirdParty do
|
788
|
+
node_type = options[:bill_to_consignee] ? :BillThirdPartyConsignee : :BillThirdPartyShipper
|
789
|
+
xml.public_send(node_type) do
|
790
|
+
xml.AccountNumber(options[:billing_account])
|
791
|
+
xml.ThirdParty do
|
792
|
+
xml.Address do
|
793
|
+
xml.PostalCode(options[:billing_zip])
|
794
|
+
xml.CountryCode(mapped_country_code(options[:billing_country]))
|
795
|
+
end
|
796
|
+
end
|
797
|
+
end
|
798
|
+
end
|
799
|
+
else
|
800
|
+
xml.BillShipper do
|
801
|
+
xml.AccountNumber(options[:origin_account])
|
802
|
+
end
|
803
|
+
end
|
804
|
+
end
|
805
|
+
|
806
|
+
def build_document(xml, expected_root_tag)
|
807
|
+
document = Nokogiri.XML(xml)
|
808
|
+
if document.root.nil? || document.root.name != expected_root_tag
|
809
|
+
raise ActiveShipping::ResponseContentError.new(StandardError.new('Invalid document'), xml)
|
810
|
+
end
|
811
|
+
document
|
812
|
+
rescue Nokogiri::XML::SyntaxError => e
|
813
|
+
raise ActiveShipping::ResponseContentError.new(e, xml)
|
814
|
+
end
|
815
|
+
|
816
|
+
def parse_rate_response(origin, destination, packages, response, options = {})
|
817
|
+
xml = build_document(response, 'RatingServiceSelectionResponse')
|
818
|
+
success = response_success?(xml)
|
819
|
+
message = response_message(xml)
|
820
|
+
|
821
|
+
if success
|
822
|
+
rate_estimates = xml.root.css('> RatedShipment').map do |rated_shipment|
|
823
|
+
service_code = rated_shipment.at('Service/Code').text
|
824
|
+
days_to_delivery = rated_shipment.at('GuaranteedDaysToDelivery').text.to_i
|
825
|
+
days_to_delivery = nil if days_to_delivery == 0
|
826
|
+
warning_messages = rate_warning_messages(rated_shipment)
|
827
|
+
RateEstimate.new(origin, destination, @@name, service_name_for(origin, service_code),
|
828
|
+
total_price: rated_shipment.at('TotalCharges/MonetaryValue').text.to_f,
|
829
|
+
insurance_price: rated_shipment.at('ServiceOptionsCharges/MonetaryValue').text.to_f,
|
830
|
+
currency: rated_shipment.at('TotalCharges/CurrencyCode').text,
|
831
|
+
service_code: service_code,
|
832
|
+
packages: packages,
|
833
|
+
delivery_range: [timestamp_from_business_day(days_to_delivery)],
|
834
|
+
negotiated_rate: rated_shipment.at('NegotiatedRates/NetSummaryCharges/GrandTotal/MonetaryValue').try(:text).to_f,
|
835
|
+
messages: warning_messages
|
836
|
+
)
|
837
|
+
end
|
838
|
+
end
|
839
|
+
RateResponse.new(success, message, Hash.from_xml(response).values.first, rates: rate_estimates, xml: response, request: last_request)
|
840
|
+
end
|
841
|
+
|
842
|
+
def parse_tracking_response(response, options = {})
|
843
|
+
xml = build_document(response, 'TrackResponse')
|
844
|
+
success = response_success?(xml)
|
845
|
+
message = response_message(xml)
|
846
|
+
|
847
|
+
if success
|
848
|
+
delivery_signature = nil
|
849
|
+
exception_event, scheduled_delivery_date, actual_delivery_date = nil
|
850
|
+
delivered, exception = false
|
851
|
+
shipment_events = []
|
852
|
+
|
853
|
+
first_shipment = xml.root.at('Shipment')
|
854
|
+
first_package = first_shipment.at('Package')
|
855
|
+
tracking_number = first_shipment.at_xpath('ShipmentIdentificationNumber | Package/TrackingNumber').text
|
856
|
+
|
857
|
+
# Build status hash
|
858
|
+
status_nodes = first_package.css('Activity > Status > StatusType')
|
859
|
+
|
860
|
+
if status_nodes.present?
|
861
|
+
# Prefer a delivery node
|
862
|
+
status_node = status_nodes.detect { |x| x.at('Code').text == 'D' }
|
863
|
+
status_node ||= status_nodes.first
|
864
|
+
|
865
|
+
status_code = status_node.at('Code').try(:text)
|
866
|
+
status_description = status_node.at('Description').try(:text)
|
867
|
+
status = TRACKING_STATUS_CODES[status_code]
|
868
|
+
|
869
|
+
if status_description =~ /out.*delivery/i
|
870
|
+
status = :out_for_delivery
|
871
|
+
end
|
872
|
+
end
|
873
|
+
|
874
|
+
origin, destination = %w(Shipper ShipTo).map do |location|
|
875
|
+
location_from_address_node(first_shipment.at("#{location}/Address"))
|
876
|
+
end
|
877
|
+
|
878
|
+
# Get scheduled delivery date
|
879
|
+
unless status == :delivered
|
880
|
+
scheduled_delivery_date_node = first_shipment.at('ScheduledDeliveryDate')
|
881
|
+
scheduled_delivery_date_node ||= first_shipment.at('RescheduledDeliveryDate')
|
882
|
+
|
883
|
+
if scheduled_delivery_date_node
|
884
|
+
scheduled_delivery_date = parse_ups_datetime(
|
885
|
+
date: scheduled_delivery_date_node,
|
886
|
+
time: nil
|
887
|
+
)
|
888
|
+
end
|
889
|
+
end
|
890
|
+
|
891
|
+
activities = first_package.css('> Activity')
|
892
|
+
unless activities.empty?
|
893
|
+
shipment_events = activities.map do |activity|
|
894
|
+
description = activity.at('Status/StatusType/Description').try(:text)
|
895
|
+
type_code = activity.at('Status/StatusType/Code').try(:text)
|
896
|
+
zoneless_time = parse_ups_datetime(time: activity.at('Time'), date: activity.at('Date'))
|
897
|
+
location = location_from_address_node(activity.at('ActivityLocation/Address'))
|
898
|
+
ShipmentEvent.new(description, zoneless_time, location, description, type_code)
|
899
|
+
end
|
900
|
+
|
901
|
+
shipment_events = shipment_events.sort_by(&:time)
|
902
|
+
|
903
|
+
# UPS will sometimes archive a shipment, stripping all shipment activity except for the delivery
|
904
|
+
# event (see test/fixtures/xml/delivered_shipment_without_events_tracking_response.xml for an example).
|
905
|
+
# This adds an origin event to the shipment activity in such cases.
|
906
|
+
if origin && !(shipment_events.count == 1 && status == :delivered)
|
907
|
+
first_event = shipment_events[0]
|
908
|
+
origin_event = ShipmentEvent.new(first_event.name, first_event.time, origin, first_event.message, first_event.type_code)
|
909
|
+
|
910
|
+
if within_same_area?(origin, first_event.location)
|
911
|
+
shipment_events[0] = origin_event
|
912
|
+
else
|
913
|
+
shipment_events.unshift(origin_event)
|
914
|
+
end
|
915
|
+
end
|
916
|
+
|
917
|
+
# Has the shipment been delivered?
|
918
|
+
if status == :delivered
|
919
|
+
delivered_activity = activities.first
|
920
|
+
delivery_signature = delivered_activity.at('ActivityLocation/SignedForByName').try(:text)
|
921
|
+
if delivered_activity.at('Status/StatusType/Code').text == 'D'
|
922
|
+
actual_delivery_date = parse_ups_datetime(date: delivered_activity.at('Date'), time: delivered_activity.at('Time'))
|
923
|
+
end
|
924
|
+
unless destination
|
925
|
+
destination = shipment_events[-1].location
|
926
|
+
end
|
927
|
+
shipment_events[-1] = ShipmentEvent.new(shipment_events.last.name, shipment_events.last.time, destination, shipment_events.last.message, shipment_events.last.type_code)
|
928
|
+
end
|
929
|
+
end
|
930
|
+
|
931
|
+
end
|
932
|
+
TrackingResponse.new(success, message, Hash.from_xml(response).values.first,
|
933
|
+
carrier: @@name,
|
934
|
+
xml: response,
|
935
|
+
request: last_request,
|
936
|
+
status: status,
|
937
|
+
status_code: status_code,
|
938
|
+
status_description: status_description,
|
939
|
+
delivery_signature: delivery_signature,
|
940
|
+
scheduled_delivery_date: scheduled_delivery_date,
|
941
|
+
actual_delivery_date: actual_delivery_date,
|
942
|
+
shipment_events: shipment_events,
|
943
|
+
delivered: delivered,
|
944
|
+
exception: exception,
|
945
|
+
exception_event: exception_event,
|
946
|
+
origin: origin,
|
947
|
+
destination: destination,
|
948
|
+
tracking_number: tracking_number)
|
949
|
+
end
|
950
|
+
|
951
|
+
def parse_delivery_dates_response(origin, destination, packages, response, options = {})
|
952
|
+
xml = build_document(response, 'TimeInTransitResponse')
|
953
|
+
success = response_success?(xml)
|
954
|
+
message = response_message(xml)
|
955
|
+
delivery_estimates = []
|
956
|
+
|
957
|
+
if success
|
958
|
+
xml.css('ServiceSummary').each do |service_summary|
|
959
|
+
# Translate the Time in Transit Codes to the service codes used elsewhere
|
960
|
+
service_name = service_summary.at('Service/Description').text
|
961
|
+
service_code = UPS::DEFAULT_SERVICE_NAME_TO_CODE[service_name]
|
962
|
+
date = Date.strptime(service_summary.at('EstimatedArrival/Date').text, '%Y-%m-%d')
|
963
|
+
business_transit_days = service_summary.at('EstimatedArrival/BusinessTransitDays').text.to_i
|
964
|
+
delivery_estimates << DeliveryDateEstimate.new(origin, destination, self.class.class_variable_get(:@@name),
|
965
|
+
service_name,
|
966
|
+
service_code: service_code,
|
967
|
+
guaranteed: service_summary.at('Guaranteed/Code').text == 'Y',
|
968
|
+
date: date,
|
969
|
+
business_transit_days: business_transit_days)
|
970
|
+
end
|
971
|
+
end
|
972
|
+
response = DeliveryDateEstimatesResponse.new(success, message, Hash.from_xml(response).values.first, delivery_estimates: delivery_estimates, xml: response, request: last_request)
|
973
|
+
end
|
974
|
+
|
975
|
+
def parse_void_response(response, options = {})
|
976
|
+
xml = build_document(response, 'VoidShipmentResponse')
|
977
|
+
success = response_success?(xml)
|
978
|
+
message = response_message(xml)
|
979
|
+
if success
|
980
|
+
true
|
981
|
+
else
|
982
|
+
raise ResponseError.new("Void shipment failed with message: #{message}")
|
983
|
+
end
|
984
|
+
end
|
985
|
+
|
986
|
+
def build_address_validation_request(location, options = {})
|
987
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
988
|
+
xml.AddressValidationRequest do
|
989
|
+
xml.Request do
|
990
|
+
xml.RequestAction('XAV')
|
991
|
+
xml.RequestOption('3')
|
992
|
+
|
993
|
+
if options[:customer_context]
|
994
|
+
xml.TransactionReference do
|
995
|
+
xml.CustomerContext(options[:customer_context])
|
996
|
+
xml.XpciVersion("1.0")
|
997
|
+
end
|
998
|
+
end
|
999
|
+
end
|
1000
|
+
|
1001
|
+
xml.AddressKeyFormat do
|
1002
|
+
xml.AddressLine(location.address1)
|
1003
|
+
if location.address2.present?
|
1004
|
+
xml.AddressLine(location.address2)
|
1005
|
+
end
|
1006
|
+
xml.PoliticalDivision2(location.city)
|
1007
|
+
xml.PoliticalDivision1(location.state)
|
1008
|
+
xml.PostcodePrimaryLow(location.postal_code)
|
1009
|
+
xml.CountryCode(mapped_country_code(location.country_code))
|
1010
|
+
end
|
1011
|
+
end
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
xml_builder.to_xml
|
1015
|
+
end
|
1016
|
+
|
1017
|
+
def parse_address_validation_response(address, response, options = {})
|
1018
|
+
xml = build_document(response, 'AddressValidationResponse')
|
1019
|
+
success = response_success?(xml)
|
1020
|
+
message = response_message(xml)
|
1021
|
+
|
1022
|
+
validity = nil
|
1023
|
+
classification_code = nil
|
1024
|
+
classification_description = nil
|
1025
|
+
addresses = []
|
1026
|
+
|
1027
|
+
if success
|
1028
|
+
if xml.at('AddressClassification/Code').present?
|
1029
|
+
classification_code = xml.at('AddressClassification/Code').text
|
1030
|
+
end
|
1031
|
+
|
1032
|
+
classification = case classification_code
|
1033
|
+
when "1"
|
1034
|
+
:commercial
|
1035
|
+
when "2"
|
1036
|
+
:residential
|
1037
|
+
else
|
1038
|
+
:unknown
|
1039
|
+
end
|
1040
|
+
|
1041
|
+
validity = if xml.at("ValidAddressIndicator").present?
|
1042
|
+
:valid
|
1043
|
+
elsif xml.at("AmbiguousAddressIndicator").present?
|
1044
|
+
:ambiguous
|
1045
|
+
elsif xml.at("NoCandidatesIndicator").present?
|
1046
|
+
:invalid
|
1047
|
+
else
|
1048
|
+
:unknown
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
addresses = xml.css('AddressKeyFormat').collect { |node| location_from_address_key_format_node(node) }
|
1052
|
+
end
|
1053
|
+
|
1054
|
+
params = Hash.from_xml(response).values.first
|
1055
|
+
response = AddressValidationResponse.new(success, message, params, validity: validity, classification: classification, candidate_addresses: addresses, xml: response, request: last_request)
|
1056
|
+
end
|
1057
|
+
|
1058
|
+
# Converts from a AddressKeyFormat XML node to a Location
|
1059
|
+
def location_from_address_key_format_node(address)
|
1060
|
+
return nil unless address
|
1061
|
+
country = address.at('CountryCode').try(:text)
|
1062
|
+
country = 'US' if country == 'ZZ' # Sometimes returned by SUREPOST in the US
|
1063
|
+
|
1064
|
+
address_lines = address.css('AddressLine')
|
1065
|
+
|
1066
|
+
Location.new(
|
1067
|
+
country: country,
|
1068
|
+
postal_code: address.at('PostcodePrimaryLow').try(:text),
|
1069
|
+
province: address.at('PoliticalDivision1').try(:text),
|
1070
|
+
city: address.at('PoliticalDivision2').try(:text),
|
1071
|
+
address1: address_lines[0].try(:text),
|
1072
|
+
address2: address_lines[1].try(:text),
|
1073
|
+
address3: address_lines[2].try(:text),
|
1074
|
+
)
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
def location_from_address_node(address)
|
1078
|
+
return nil unless address
|
1079
|
+
country = address.at('CountryCode').try(:text)
|
1080
|
+
country = 'US' if country == 'ZZ' # Sometimes returned by SUREPOST in the US
|
1081
|
+
country = 'XK' if country == 'KV' # ActiveUtils now refers to Kosovo by XK
|
1082
|
+
Location.new(
|
1083
|
+
country: country,
|
1084
|
+
postal_code: address.at('PostalCode').try(:text),
|
1085
|
+
province: address.at('StateProvinceCode').try(:text),
|
1086
|
+
city: address.at('City').try(:text),
|
1087
|
+
address1: address.at('AddressLine1').try(:text),
|
1088
|
+
address2: address.at('AddressLine2').try(:text),
|
1089
|
+
address3: address.at('AddressLine3').try(:text)
|
1090
|
+
)
|
1091
|
+
end
|
1092
|
+
|
1093
|
+
def parse_ups_datetime(options = {})
|
1094
|
+
time, date = options[:time].try(:text), options[:date].text
|
1095
|
+
if time.nil?
|
1096
|
+
hour, minute, second = 0
|
1097
|
+
else
|
1098
|
+
hour, minute, second = time.scan(/\d{2}/)
|
1099
|
+
end
|
1100
|
+
year, month, day = date[0..3], date[4..5], date[6..7]
|
1101
|
+
|
1102
|
+
Time.utc(year, month, day, hour, minute, second)
|
1103
|
+
end
|
1104
|
+
|
1105
|
+
def response_success?(document)
|
1106
|
+
document.root.at('Response/ResponseStatusCode').text == '1'
|
1107
|
+
end
|
1108
|
+
|
1109
|
+
def response_message(document)
|
1110
|
+
status = document.root.at_xpath('Response/ResponseStatusDescription').try(:text)
|
1111
|
+
desc = document.root.at_xpath('Response/Error/ErrorDescription').try(:text)
|
1112
|
+
[status, desc].select(&:present?).join(": ").presence || "UPS could not process the request."
|
1113
|
+
end
|
1114
|
+
|
1115
|
+
def rate_warning_messages(rate_xml)
|
1116
|
+
rate_xml.xpath("RatedShipmentWarning").map { |warning| warning.text }
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
def response_digest(xml)
|
1120
|
+
xml.root.at('ShipmentDigest').text
|
1121
|
+
end
|
1122
|
+
|
1123
|
+
def parse_ship_confirm(response)
|
1124
|
+
build_document(response, 'ShipmentConfirmResponse')
|
1125
|
+
end
|
1126
|
+
|
1127
|
+
def parse_ship_accept(response)
|
1128
|
+
xml = build_document(response, 'ShipmentAcceptResponse')
|
1129
|
+
success = response_success?(xml)
|
1130
|
+
message = response_message(xml)
|
1131
|
+
|
1132
|
+
response_info = Hash.from_xml(response).values.first
|
1133
|
+
packages = response_info["ShipmentResults"]["PackageResults"]
|
1134
|
+
packages = [packages] if Hash === packages
|
1135
|
+
labels = packages.map do |package|
|
1136
|
+
Label.new(package["TrackingNumber"], Base64.decode64(package["LabelImage"]["GraphicImage"]))
|
1137
|
+
end
|
1138
|
+
|
1139
|
+
LabelResponse.new(success, message, response_info, { labels: labels })
|
1140
|
+
end
|
1141
|
+
|
1142
|
+
def commit(action, request, test = false)
|
1143
|
+
response = ssl_post("#{test ? TEST_URL : LIVE_URL}/#{RESOURCES[action]}", request)
|
1144
|
+
response.encode('utf-8', 'iso-8859-1')
|
1145
|
+
end
|
1146
|
+
|
1147
|
+
def within_same_area?(origin, location)
|
1148
|
+
return false unless location
|
1149
|
+
matching_country_codes = origin.country_code(:alpha2) == location.country_code(:alpha2)
|
1150
|
+
matching_or_blank_city = location.city.blank? || location.city == origin.city
|
1151
|
+
matching_country_codes && matching_or_blank_city
|
1152
|
+
end
|
1153
|
+
|
1154
|
+
def service_name_for(origin, code)
|
1155
|
+
origin = origin.country_code(:alpha2)
|
1156
|
+
|
1157
|
+
name = case origin
|
1158
|
+
when "CA" then CANADA_ORIGIN_SERVICES[code]
|
1159
|
+
when "MX" then MEXICO_ORIGIN_SERVICES[code]
|
1160
|
+
when *EU_COUNTRY_CODES then EU_ORIGIN_SERVICES[code]
|
1161
|
+
end
|
1162
|
+
|
1163
|
+
name ||= OTHER_NON_US_ORIGIN_SERVICES[code] unless name == 'US'
|
1164
|
+
name || DEFAULT_SERVICES[code]
|
1165
|
+
end
|
1166
|
+
|
1167
|
+
def allow_package_level_reference_numbers(origin, destination)
|
1168
|
+
# if the package is US -> US or PR -> PR the only type of reference numbers that are allowed are package-level
|
1169
|
+
# Otherwise the only type of reference numbers that are allowed are shipment-level
|
1170
|
+
[['US', 'US'], ['PR', 'PR']].include?([origin, destination].map(&:country_code))
|
1171
|
+
end
|
1172
|
+
|
1173
|
+
def handle_delivery_confirmation_options(origin, destination, packages, options)
|
1174
|
+
if package_level_delivery_confirmation?(origin, destination)
|
1175
|
+
handle_package_level_delivery_confirmation(origin, destination, packages, options)
|
1176
|
+
else
|
1177
|
+
handle_shipment_level_delivery_confirmation(origin, destination, packages, options)
|
1178
|
+
end
|
1179
|
+
end
|
1180
|
+
|
1181
|
+
def handle_package_level_delivery_confirmation(origin, destination, packages, options)
|
1182
|
+
packages.each do |package|
|
1183
|
+
# Transfer shipment-level option to package with no specified delivery_confirmation
|
1184
|
+
package.options[:delivery_confirmation] = options[:delivery_confirmation] unless package.options[:delivery_confirmation]
|
1185
|
+
|
1186
|
+
# Assert that option is valid
|
1187
|
+
if package.options[:delivery_confirmation] && !PACKAGE_DELIVERY_CONFIRMATION_CODES[package.options[:delivery_confirmation]]
|
1188
|
+
raise "Invalid delivery_confirmation option on package: '#{package.options[:delivery_confirmation]}'. Use a key from PACKAGE_DELIVERY_CONFIRMATION_CODES"
|
1189
|
+
end
|
1190
|
+
end
|
1191
|
+
options.delete(:delivery_confirmation)
|
1192
|
+
end
|
1193
|
+
|
1194
|
+
def handle_shipment_level_delivery_confirmation(origin, destination, packages, options)
|
1195
|
+
if packages.any? { |p| p.options[:delivery_confirmation] }
|
1196
|
+
raise "origin/destination pair does not support package level delivery_confirmation options"
|
1197
|
+
end
|
1198
|
+
|
1199
|
+
if options[:delivery_confirmation] && !SHIPMENT_DELIVERY_CONFIRMATION_CODES[options[:delivery_confirmation]]
|
1200
|
+
raise "Invalid delivery_confirmation option: '#{options[:delivery_confirmation]}'. Use a key from SHIPMENT_DELIVERY_CONFIRMATION_CODES"
|
1201
|
+
end
|
1202
|
+
end
|
1203
|
+
|
1204
|
+
# For certain origin/destination pairs, UPS allows each package in a shipment to have a specified delivery_confirmation option
|
1205
|
+
# otherwise the delivery_confirmation option must be specified on the entire shipment.
|
1206
|
+
# See Appendix P of UPS Shipping Package XML Developers Guide for the rules on which the logic below is based.
|
1207
|
+
def package_level_delivery_confirmation?(origin, destination)
|
1208
|
+
origin.country_code == destination.country_code ||
|
1209
|
+
[['US', 'PR'], ['PR', 'US']].include?([origin, destination].map(&:country_code))
|
1210
|
+
end
|
1211
|
+
|
1212
|
+
def mapped_country_code(country_code)
|
1213
|
+
COUNTRY_MAPPING[country_code].presence || country_code
|
1214
|
+
end
|
1215
|
+
end
|
1216
|
+
end
|