From b5ac844f34efa2b5d181186d31c837326cdfc07f Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 2 Aug 2017 14:33:03 -0700 Subject: [PATCH 1/9] Add jbuilder dependency to API --- api/lib/spree_api.rb | 1 + api/solidus_api.gemspec | 1 + 2 files changed, 2 insertions(+) diff --git a/api/lib/spree_api.rb b/api/lib/spree_api.rb index ab9bf2f954..d8f6ec9ff6 100644 --- a/api/lib/spree_api.rb +++ b/api/lib/spree_api.rb @@ -1,3 +1,4 @@ require 'spree/api' require 'spree/api/responders' require 'versioncake' +require 'jbuilder' diff --git a/api/solidus_api.gemspec b/api/solidus_api.gemspec index ebeb84daa3..845055e553 100644 --- a/api/solidus_api.gemspec +++ b/api/solidus_api.gemspec @@ -24,5 +24,6 @@ Gem::Specification.new do |gem| gem.add_dependency 'rabl', '0.13.1' gem.add_dependency 'versioncake', '~> 3.0' gem.add_dependency 'responders' + gem.add_dependency 'jbuilder', '~> 2.6' gem.add_dependency 'kaminari', '>= 0.17', '< 2.0' end From aa95018127035b47b7463c185b443154382a8fe0 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Thu, 3 Aug 2017 12:22:47 -0700 Subject: [PATCH 2/9] Rewrite API RABL views as Jbuilder --- .../api/address_books/show.json.jbuilder | 11 ++++ .../spree/api/address_books/show.v1.rabl | 7 --- .../api/addresses/_address.json.jbuilder | 9 +++ .../spree/api/addresses/show.json.jbuilder | 1 + .../views/spree/api/addresses/show.v1.rabl | 10 ---- .../api/adjustments/_adjustment.json.jbuilder | 2 + .../views/spree/api/adjustments/show.v1.rabl | 4 -- .../spree/api/config/money.json.jbuilder | 1 + api/app/views/spree/api/config/money.v1.rabl | 2 - .../views/spree/api/config/show.json.jbuilder | 2 + api/app/views/spree/api/config/show.v1.rabl | 3 - .../spree/api/countries/index.json.jbuilder | 4 ++ .../views/spree/api/countries/index.v1.rabl | 7 --- .../spree/api/countries/show.json.jbuilder | 4 ++ .../views/spree/api/countries/show.v1.rabl | 5 -- .../credit_cards/_credit_card.json.jbuilder | 6 ++ .../api/credit_cards/index.json.jbuilder | 6 ++ .../spree/api/credit_cards/index.v1.rabl | 7 --- .../spree/api/credit_cards/show.json.jbuilder | 1 + .../views/spree/api/credit_cards/show.v1.rabl | 7 --- .../errors/delete_restriction.json.jbuilder | 1 + .../api/errors/delete_restriction.v1.rabl | 2 - .../api/errors/gateway_error.json.jbuilder | 1 + .../spree/api/errors/gateway_error.v1.rabl | 2 - .../api/errors/invalid_api_key.json.jbuilder | 1 + .../spree/api/errors/invalid_api_key.v1.rabl | 2 - .../api/errors/invalid_resource.json.jbuilder | 2 + .../spree/api/errors/invalid_resource.v1.rabl | 3 - .../errors/must_specify_api_key.json.jbuilder | 1 + .../api/errors/must_specify_api_key.v1.rabl | 2 - .../spree/api/errors/not_found.json.jbuilder | 1 + .../views/spree/api/errors/not_found.v1.rabl | 2 - .../api/errors/unauthorized.json.jbuilder | 1 + .../spree/api/errors/unauthorized.v1.rabl | 2 - ...ariant_not_in_stock_transfer.json.jbuilder | 1 + .../variant_not_in_stock_transfer.v1.rabl | 2 - .../spree/api/images/_image.json.jbuilder | 5 ++ .../spree/api/images/index.json.jbuilder | 3 + api/app/views/spree/api/images/index.v1.rabl | 4 -- .../views/spree/api/images/show.json.jbuilder | 1 + api/app/views/spree/api/images/show.v1.rabl | 6 -- .../api/inventory_units/show.json.jbuilder | 1 + .../views/spree/api/inventory_units/show.rabl | 2 - .../api/line_items/_line_item.json.jbuilder | 14 +++++ .../spree/api/line_items/new.json.jbuilder | 2 + .../views/spree/api/line_items/new.v1.rabl | 3 - .../spree/api/line_items/show.json.jbuilder | 1 + .../views/spree/api/line_items/show.v1.rabl | 15 ----- .../option_types/_option_type.json.jbuilder | 4 ++ .../api/option_types/index.json.jbuilder | 3 + .../spree/api/option_types/index.v1.rabl | 3 - .../spree/api/option_types/show.json.jbuilder | 1 + .../views/spree/api/option_types/show.v1.rabl | 5 -- .../option_values/_option_value.json.jbuilder | 1 + .../api/option_values/index.json.jbuilder | 3 + .../spree/api/option_values/index.v1.rabl | 3 - .../api/option_values/show.json.jbuilder | 1 + .../spree/api/option_values/show.v1.rabl | 2 - .../views/spree/api/orders/_big.json.jbuilder | 40 ++++++++++++++ .../spree/api/orders/_order.json.jbuilder | 8 +++ .../could_not_apply_coupon.json.jbuilder | 1 + .../api/orders/could_not_apply_coupon.v1.rabl | 2 - .../orders/could_not_transition.json.jbuilder | 2 + .../api/orders/could_not_transition.v1.rabl | 3 - .../expected_total_mismatch.json.jbuilder | 1 + .../orders/expected_total_mismatch.v1.rabl | 2 - .../spree/api/orders/index.json.jbuilder | 6 ++ api/app/views/spree/api/orders/index.v1.rabl | 7 --- .../invalid_shipping_method.json.jbuilder | 1 + .../orders/invalid_shipping_method.v1.rabl | 2 - .../views/spree/api/orders/mine.json.jbuilder | 6 ++ api/app/views/spree/api/orders/mine.v1.rabl | 9 --- api/app/views/spree/api/orders/order.v1.rabl | 9 --- .../views/spree/api/orders/show.json.jbuilder | 1 + api/app/views/spree/api/orders/show.v1.rabl | 53 ------------------ .../payments/credit_over_limit.json.jbuilder | 1 + .../api/payments/credit_over_limit.v1.rabl | 2 - .../spree/api/payments/index.json.jbuilder | 4 ++ .../views/spree/api/payments/index.v1.rabl | 7 --- .../spree/api/payments/new.json.jbuilder | 4 ++ api/app/views/spree/api/payments/new.v1.rabl | 5 -- .../spree/api/payments/show.json.jbuilder | 1 + api/app/views/spree/api/payments/show.v1.rabl | 2 - .../payments/update_forbidden.json.jbuilder | 1 + .../api/payments/update_forbidden.v1.rabl | 2 - .../product_properties/index.json.jbuilder | 6 ++ .../api/product_properties/index.v1.rabl | 7 --- .../api/product_properties/new.json.jbuilder | 2 + .../spree/api/product_properties/new.v1.rabl | 2 - .../api/product_properties/show.json.jbuilder | 1 + .../spree/api/product_properties/show.v1.rabl | 2 - .../spree/api/products/_product.json.jbuilder | 31 +++++++++++ .../spree/api/products/index.json.jbuilder | 8 +++ .../views/spree/api/products/index.v1.rabl | 9 --- .../spree/api/products/new.json.jbuilder | 2 + api/app/views/spree/api/products/new.v1.rabl | 3 - .../views/spree/api/products/product.v1.rabl | 1 - .../spree/api/products/show.json.jbuilder | 1 + api/app/views/spree/api/products/show.v1.rabl | 42 -------------- .../api/promotions/handler.json.jbuilder | 4 ++ .../spree/api/promotions/handler.v1.rabl | 5 -- .../spree/api/promotions/show.json.jbuilder | 1 + .../views/spree/api/promotions/show.v1.rabl | 2 - .../spree/api/properties/index.json.jbuilder | 6 ++ .../views/spree/api/properties/index.v1.rabl | 7 --- .../spree/api/properties/new.json.jbuilder | 2 + .../views/spree/api/properties/new.v1.rabl | 2 - .../spree/api/properties/show.json.jbuilder | 1 + .../views/spree/api/properties/show.v1.rabl | 2 - .../return_authorizations/index.json.jbuilder | 6 ++ .../api/return_authorizations/index.v1.rabl | 7 --- .../return_authorizations/new.json.jbuilder | 2 + .../api/return_authorizations/new.v1.rabl | 3 - .../return_authorizations/show.json.jbuilder | 1 + .../api/return_authorizations/show.v1.rabl | 2 - .../spree/api/shipments/_big.json.jbuilder | 43 +++++++++++++++ .../spree/api/shipments/_small.json.jbuilder | 28 ++++++++++ api/app/views/spree/api/shipments/big.v1.rabl | 55 ------------------- .../cannot_ready_shipment.json.jbuilder | 1 + .../shipments/cannot_ready_shipment.v1.rabl | 2 - .../spree/api/shipments/mine.json.jbuilder | 6 ++ .../views/spree/api/shipments/mine.v1.rabl | 9 --- .../spree/api/shipments/show.json.jbuilder | 27 +++++++++ .../views/spree/api/shipments/show.v1.rabl | 32 ----------- .../views/spree/api/shipments/small.v1.rabl | 37 ------------- .../_shipping_rate.json.jbuilder | 2 + .../spree/api/shipping_rates/show.v1.rabl | 2 - .../spree/api/states/index.json.jbuilder | 7 +++ api/app/views/spree/api/states/index.v1.rabl | 14 ----- .../views/spree/api/states/show.json.jbuilder | 1 + api/app/views/spree/api/states/show.v1.rabl | 2 - .../api/stock_items/_stock_item.json.jbuilder | 4 ++ .../spree/api/stock_items/index.json.jbuilder | 6 ++ .../views/spree/api/stock_items/index.v1.rabl | 7 --- .../spree/api/stock_items/show.json.jbuilder | 1 + .../views/spree/api/stock_items/show.v1.rabl | 5 -- .../_stock_location.json.jbuilder | 7 +++ .../api/stock_locations/index.json.jbuilder | 6 ++ .../spree/api/stock_locations/index.v1.rabl | 7 --- .../api/stock_locations/show.json.jbuilder | 1 + .../spree/api/stock_locations/show.v1.rabl | 8 --- .../_stock_movement.json.jbuilder | 4 ++ .../api/stock_movements/index.json.jbuilder | 6 ++ .../spree/api/stock_movements/index.v1.rabl | 7 --- .../api/stock_movements/show.json.jbuilder | 1 + .../spree/api/stock_movements/show.v1.rabl | 5 -- .../api/stock_transfers/receive.json.jbuilder | 4 ++ .../spree/api/stock_transfers/receive.v1.rabl | 5 -- .../store_credit_events/mine.json.jbuilder | 7 +++ .../api/store_credit_events/mine.v1.rabl | 10 ---- .../spree/api/stores/index.json.jbuilder | 1 + api/app/views/spree/api/stores/index.v1.rabl | 4 -- .../views/spree/api/stores/show.json.jbuilder | 1 + api/app/views/spree/api/stores/show.v1.rabl | 2 - .../api/taxonomies/_nested.json.jbuilder | 8 +++ .../api/taxonomies/_taxonomy.json.jbuilder | 11 ++++ .../spree/api/taxonomies/index.json.jbuilder | 6 ++ .../views/spree/api/taxonomies/index.v1.rabl | 7 --- .../spree/api/taxonomies/jstree.json.jbuilder | 6 ++ .../views/spree/api/taxonomies/jstree.rabl | 8 --- .../views/spree/api/taxonomies/nested.v1.rabl | 11 ---- .../spree/api/taxonomies/new.json.jbuilder | 2 + .../views/spree/api/taxonomies/new.v1.rabl | 3 - .../spree/api/taxonomies/show.json.jbuilder | 1 + .../views/spree/api/taxonomies/show.v1.rabl | 15 ----- .../spree/api/taxons/_taxon.json.jbuilder | 2 + .../spree/api/taxons/_taxons.json.jbuilder | 4 ++ .../spree/api/taxons/index.json.jbuilder | 11 ++++ api/app/views/spree/api/taxons/index.v1.rabl | 12 ---- .../spree/api/taxons/jstree.json.jbuilder | 8 +++ api/app/views/spree/api/taxons/jstree.rabl | 8 --- .../views/spree/api/taxons/new.json.jbuilder | 2 + api/app/views/spree/api/taxons/new.v1.rabl | 3 - .../views/spree/api/taxons/show.json.jbuilder | 1 + api/app/views/spree/api/taxons/show.v1.rabl | 6 -- api/app/views/spree/api/taxons/taxons.v1.rabl | 5 -- .../_transfer_item.json.jbuilder | 5 ++ .../api/transfer_items/show.json.jbuilder | 1 + .../spree/api/transfer_items/show.v1.rabl | 6 -- .../views/spree/api/users/_user.json.jbuilder | 7 +++ .../views/spree/api/users/index.json.jbuilder | 6 ++ api/app/views/spree/api/users/index.v1.rabl | 7 --- .../views/spree/api/users/new.json.jbuilder | 2 + api/app/views/spree/api/users/new.v1.rabl | 3 - .../views/spree/api/users/show.json.jbuilder | 1 + api/app/views/spree/api/users/show.v1.rabl | 10 ---- .../spree/api/variants/_big.json.jbuilder | 11 ++++ .../spree/api/variants/_small.json.jbuilder | 14 +++++ api/app/views/spree/api/variants/big.v1.rabl | 20 ------- .../spree/api/variants/index.json.jbuilder | 7 +++ .../views/spree/api/variants/index.v1.rabl | 9 --- .../spree/api/variants/new.json.jbuilder | 2 + api/app/views/spree/api/variants/new.v1.rabl | 2 - .../spree/api/variants/show.json.jbuilder | 1 + api/app/views/spree/api/variants/show.v1.rabl | 3 - .../views/spree/api/variants/small.v1.rabl | 17 ------ .../views/spree/api/zones/_zone.json.jbuilder | 4 ++ .../views/spree/api/zones/index.json.jbuilder | 6 ++ api/app/views/spree/api/zones/index.v1.rabl | 7 --- .../views/spree/api/zones/show.json.jbuilder | 1 + api/app/views/spree/api/zones/show.v1.rabl | 6 -- .../spree/api/widgets/_widget.json.jbuilder | 1 + .../spree/api/widgets/index.json.jbuilder | 7 +++ .../spree/api/widgets/index.v1.rabl | 7 --- .../spree/api/widgets/new.json.jbuilder | 1 + .../test_views/spree/api/widgets/new.v1.rabl | 2 - .../spree/api/widgets/show.json.jbuilder | 1 + .../test_views/spree/api/widgets/show.v1.rabl | 2 - 208 files changed, 551 insertions(+), 705 deletions(-) create mode 100644 api/app/views/spree/api/address_books/show.json.jbuilder delete mode 100644 api/app/views/spree/api/address_books/show.v1.rabl create mode 100644 api/app/views/spree/api/addresses/_address.json.jbuilder create mode 100644 api/app/views/spree/api/addresses/show.json.jbuilder delete mode 100644 api/app/views/spree/api/addresses/show.v1.rabl create mode 100644 api/app/views/spree/api/adjustments/_adjustment.json.jbuilder delete mode 100644 api/app/views/spree/api/adjustments/show.v1.rabl create mode 100644 api/app/views/spree/api/config/money.json.jbuilder delete mode 100644 api/app/views/spree/api/config/money.v1.rabl create mode 100644 api/app/views/spree/api/config/show.json.jbuilder delete mode 100644 api/app/views/spree/api/config/show.v1.rabl create mode 100644 api/app/views/spree/api/countries/index.json.jbuilder delete mode 100644 api/app/views/spree/api/countries/index.v1.rabl create mode 100644 api/app/views/spree/api/countries/show.json.jbuilder delete mode 100644 api/app/views/spree/api/countries/show.v1.rabl create mode 100644 api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder create mode 100644 api/app/views/spree/api/credit_cards/index.json.jbuilder delete mode 100644 api/app/views/spree/api/credit_cards/index.v1.rabl create mode 100644 api/app/views/spree/api/credit_cards/show.json.jbuilder delete mode 100644 api/app/views/spree/api/credit_cards/show.v1.rabl create mode 100644 api/app/views/spree/api/errors/delete_restriction.json.jbuilder delete mode 100644 api/app/views/spree/api/errors/delete_restriction.v1.rabl create mode 100644 api/app/views/spree/api/errors/gateway_error.json.jbuilder delete mode 100644 api/app/views/spree/api/errors/gateway_error.v1.rabl create mode 100644 api/app/views/spree/api/errors/invalid_api_key.json.jbuilder delete mode 100644 api/app/views/spree/api/errors/invalid_api_key.v1.rabl create mode 100644 api/app/views/spree/api/errors/invalid_resource.json.jbuilder delete mode 100644 api/app/views/spree/api/errors/invalid_resource.v1.rabl create mode 100644 api/app/views/spree/api/errors/must_specify_api_key.json.jbuilder delete mode 100644 api/app/views/spree/api/errors/must_specify_api_key.v1.rabl create mode 100644 api/app/views/spree/api/errors/not_found.json.jbuilder delete mode 100644 api/app/views/spree/api/errors/not_found.v1.rabl create mode 100644 api/app/views/spree/api/errors/unauthorized.json.jbuilder delete mode 100644 api/app/views/spree/api/errors/unauthorized.v1.rabl create mode 100644 api/app/views/spree/api/errors/variant_not_in_stock_transfer.json.jbuilder delete mode 100644 api/app/views/spree/api/errors/variant_not_in_stock_transfer.v1.rabl create mode 100644 api/app/views/spree/api/images/_image.json.jbuilder create mode 100644 api/app/views/spree/api/images/index.json.jbuilder delete mode 100644 api/app/views/spree/api/images/index.v1.rabl create mode 100644 api/app/views/spree/api/images/show.json.jbuilder delete mode 100644 api/app/views/spree/api/images/show.v1.rabl create mode 100644 api/app/views/spree/api/inventory_units/show.json.jbuilder delete mode 100644 api/app/views/spree/api/inventory_units/show.rabl create mode 100644 api/app/views/spree/api/line_items/_line_item.json.jbuilder create mode 100644 api/app/views/spree/api/line_items/new.json.jbuilder delete mode 100644 api/app/views/spree/api/line_items/new.v1.rabl create mode 100644 api/app/views/spree/api/line_items/show.json.jbuilder delete mode 100644 api/app/views/spree/api/line_items/show.v1.rabl create mode 100644 api/app/views/spree/api/option_types/_option_type.json.jbuilder create mode 100644 api/app/views/spree/api/option_types/index.json.jbuilder delete mode 100644 api/app/views/spree/api/option_types/index.v1.rabl create mode 100644 api/app/views/spree/api/option_types/show.json.jbuilder delete mode 100644 api/app/views/spree/api/option_types/show.v1.rabl create mode 100644 api/app/views/spree/api/option_values/_option_value.json.jbuilder create mode 100644 api/app/views/spree/api/option_values/index.json.jbuilder delete mode 100644 api/app/views/spree/api/option_values/index.v1.rabl create mode 100644 api/app/views/spree/api/option_values/show.json.jbuilder delete mode 100644 api/app/views/spree/api/option_values/show.v1.rabl create mode 100644 api/app/views/spree/api/orders/_big.json.jbuilder create mode 100644 api/app/views/spree/api/orders/_order.json.jbuilder create mode 100644 api/app/views/spree/api/orders/could_not_apply_coupon.json.jbuilder delete mode 100644 api/app/views/spree/api/orders/could_not_apply_coupon.v1.rabl create mode 100644 api/app/views/spree/api/orders/could_not_transition.json.jbuilder delete mode 100644 api/app/views/spree/api/orders/could_not_transition.v1.rabl create mode 100644 api/app/views/spree/api/orders/expected_total_mismatch.json.jbuilder delete mode 100644 api/app/views/spree/api/orders/expected_total_mismatch.v1.rabl create mode 100644 api/app/views/spree/api/orders/index.json.jbuilder delete mode 100644 api/app/views/spree/api/orders/index.v1.rabl create mode 100644 api/app/views/spree/api/orders/invalid_shipping_method.json.jbuilder delete mode 100644 api/app/views/spree/api/orders/invalid_shipping_method.v1.rabl create mode 100644 api/app/views/spree/api/orders/mine.json.jbuilder delete mode 100644 api/app/views/spree/api/orders/mine.v1.rabl delete mode 100644 api/app/views/spree/api/orders/order.v1.rabl create mode 100644 api/app/views/spree/api/orders/show.json.jbuilder delete mode 100644 api/app/views/spree/api/orders/show.v1.rabl create mode 100644 api/app/views/spree/api/payments/credit_over_limit.json.jbuilder delete mode 100644 api/app/views/spree/api/payments/credit_over_limit.v1.rabl create mode 100644 api/app/views/spree/api/payments/index.json.jbuilder delete mode 100644 api/app/views/spree/api/payments/index.v1.rabl create mode 100644 api/app/views/spree/api/payments/new.json.jbuilder delete mode 100644 api/app/views/spree/api/payments/new.v1.rabl create mode 100644 api/app/views/spree/api/payments/show.json.jbuilder delete mode 100644 api/app/views/spree/api/payments/show.v1.rabl create mode 100644 api/app/views/spree/api/payments/update_forbidden.json.jbuilder delete mode 100644 api/app/views/spree/api/payments/update_forbidden.v1.rabl create mode 100644 api/app/views/spree/api/product_properties/index.json.jbuilder delete mode 100644 api/app/views/spree/api/product_properties/index.v1.rabl create mode 100644 api/app/views/spree/api/product_properties/new.json.jbuilder delete mode 100644 api/app/views/spree/api/product_properties/new.v1.rabl create mode 100644 api/app/views/spree/api/product_properties/show.json.jbuilder delete mode 100644 api/app/views/spree/api/product_properties/show.v1.rabl create mode 100644 api/app/views/spree/api/products/_product.json.jbuilder create mode 100644 api/app/views/spree/api/products/index.json.jbuilder delete mode 100644 api/app/views/spree/api/products/index.v1.rabl create mode 100644 api/app/views/spree/api/products/new.json.jbuilder delete mode 100644 api/app/views/spree/api/products/new.v1.rabl delete mode 100644 api/app/views/spree/api/products/product.v1.rabl create mode 100644 api/app/views/spree/api/products/show.json.jbuilder delete mode 100644 api/app/views/spree/api/products/show.v1.rabl create mode 100644 api/app/views/spree/api/promotions/handler.json.jbuilder delete mode 100644 api/app/views/spree/api/promotions/handler.v1.rabl create mode 100644 api/app/views/spree/api/promotions/show.json.jbuilder delete mode 100644 api/app/views/spree/api/promotions/show.v1.rabl create mode 100644 api/app/views/spree/api/properties/index.json.jbuilder delete mode 100644 api/app/views/spree/api/properties/index.v1.rabl create mode 100644 api/app/views/spree/api/properties/new.json.jbuilder delete mode 100644 api/app/views/spree/api/properties/new.v1.rabl create mode 100644 api/app/views/spree/api/properties/show.json.jbuilder delete mode 100644 api/app/views/spree/api/properties/show.v1.rabl create mode 100644 api/app/views/spree/api/return_authorizations/index.json.jbuilder delete mode 100644 api/app/views/spree/api/return_authorizations/index.v1.rabl create mode 100644 api/app/views/spree/api/return_authorizations/new.json.jbuilder delete mode 100644 api/app/views/spree/api/return_authorizations/new.v1.rabl create mode 100644 api/app/views/spree/api/return_authorizations/show.json.jbuilder delete mode 100644 api/app/views/spree/api/return_authorizations/show.v1.rabl create mode 100644 api/app/views/spree/api/shipments/_big.json.jbuilder create mode 100644 api/app/views/spree/api/shipments/_small.json.jbuilder delete mode 100644 api/app/views/spree/api/shipments/big.v1.rabl create mode 100644 api/app/views/spree/api/shipments/cannot_ready_shipment.json.jbuilder delete mode 100644 api/app/views/spree/api/shipments/cannot_ready_shipment.v1.rabl create mode 100644 api/app/views/spree/api/shipments/mine.json.jbuilder delete mode 100644 api/app/views/spree/api/shipments/mine.v1.rabl create mode 100644 api/app/views/spree/api/shipments/show.json.jbuilder delete mode 100644 api/app/views/spree/api/shipments/show.v1.rabl delete mode 100644 api/app/views/spree/api/shipments/small.v1.rabl create mode 100644 api/app/views/spree/api/shipping_rates/_shipping_rate.json.jbuilder delete mode 100644 api/app/views/spree/api/shipping_rates/show.v1.rabl create mode 100644 api/app/views/spree/api/states/index.json.jbuilder delete mode 100644 api/app/views/spree/api/states/index.v1.rabl create mode 100644 api/app/views/spree/api/states/show.json.jbuilder delete mode 100644 api/app/views/spree/api/states/show.v1.rabl create mode 100644 api/app/views/spree/api/stock_items/_stock_item.json.jbuilder create mode 100644 api/app/views/spree/api/stock_items/index.json.jbuilder delete mode 100644 api/app/views/spree/api/stock_items/index.v1.rabl create mode 100644 api/app/views/spree/api/stock_items/show.json.jbuilder delete mode 100644 api/app/views/spree/api/stock_items/show.v1.rabl create mode 100644 api/app/views/spree/api/stock_locations/_stock_location.json.jbuilder create mode 100644 api/app/views/spree/api/stock_locations/index.json.jbuilder delete mode 100644 api/app/views/spree/api/stock_locations/index.v1.rabl create mode 100644 api/app/views/spree/api/stock_locations/show.json.jbuilder delete mode 100644 api/app/views/spree/api/stock_locations/show.v1.rabl create mode 100644 api/app/views/spree/api/stock_movements/_stock_movement.json.jbuilder create mode 100644 api/app/views/spree/api/stock_movements/index.json.jbuilder delete mode 100644 api/app/views/spree/api/stock_movements/index.v1.rabl create mode 100644 api/app/views/spree/api/stock_movements/show.json.jbuilder delete mode 100644 api/app/views/spree/api/stock_movements/show.v1.rabl create mode 100644 api/app/views/spree/api/stock_transfers/receive.json.jbuilder delete mode 100644 api/app/views/spree/api/stock_transfers/receive.v1.rabl create mode 100644 api/app/views/spree/api/store_credit_events/mine.json.jbuilder delete mode 100644 api/app/views/spree/api/store_credit_events/mine.v1.rabl create mode 100644 api/app/views/spree/api/stores/index.json.jbuilder delete mode 100644 api/app/views/spree/api/stores/index.v1.rabl create mode 100644 api/app/views/spree/api/stores/show.json.jbuilder delete mode 100644 api/app/views/spree/api/stores/show.v1.rabl create mode 100644 api/app/views/spree/api/taxonomies/_nested.json.jbuilder create mode 100644 api/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder create mode 100644 api/app/views/spree/api/taxonomies/index.json.jbuilder delete mode 100644 api/app/views/spree/api/taxonomies/index.v1.rabl create mode 100644 api/app/views/spree/api/taxonomies/jstree.json.jbuilder delete mode 100644 api/app/views/spree/api/taxonomies/jstree.rabl delete mode 100644 api/app/views/spree/api/taxonomies/nested.v1.rabl create mode 100644 api/app/views/spree/api/taxonomies/new.json.jbuilder delete mode 100644 api/app/views/spree/api/taxonomies/new.v1.rabl create mode 100644 api/app/views/spree/api/taxonomies/show.json.jbuilder delete mode 100644 api/app/views/spree/api/taxonomies/show.v1.rabl create mode 100644 api/app/views/spree/api/taxons/_taxon.json.jbuilder create mode 100644 api/app/views/spree/api/taxons/_taxons.json.jbuilder create mode 100644 api/app/views/spree/api/taxons/index.json.jbuilder delete mode 100644 api/app/views/spree/api/taxons/index.v1.rabl create mode 100644 api/app/views/spree/api/taxons/jstree.json.jbuilder delete mode 100644 api/app/views/spree/api/taxons/jstree.rabl create mode 100644 api/app/views/spree/api/taxons/new.json.jbuilder delete mode 100644 api/app/views/spree/api/taxons/new.v1.rabl create mode 100644 api/app/views/spree/api/taxons/show.json.jbuilder delete mode 100644 api/app/views/spree/api/taxons/show.v1.rabl delete mode 100644 api/app/views/spree/api/taxons/taxons.v1.rabl create mode 100644 api/app/views/spree/api/transfer_items/_transfer_item.json.jbuilder create mode 100644 api/app/views/spree/api/transfer_items/show.json.jbuilder delete mode 100644 api/app/views/spree/api/transfer_items/show.v1.rabl create mode 100644 api/app/views/spree/api/users/_user.json.jbuilder create mode 100644 api/app/views/spree/api/users/index.json.jbuilder delete mode 100644 api/app/views/spree/api/users/index.v1.rabl create mode 100644 api/app/views/spree/api/users/new.json.jbuilder delete mode 100644 api/app/views/spree/api/users/new.v1.rabl create mode 100644 api/app/views/spree/api/users/show.json.jbuilder delete mode 100644 api/app/views/spree/api/users/show.v1.rabl create mode 100644 api/app/views/spree/api/variants/_big.json.jbuilder create mode 100644 api/app/views/spree/api/variants/_small.json.jbuilder delete mode 100644 api/app/views/spree/api/variants/big.v1.rabl create mode 100644 api/app/views/spree/api/variants/index.json.jbuilder delete mode 100644 api/app/views/spree/api/variants/index.v1.rabl create mode 100644 api/app/views/spree/api/variants/new.json.jbuilder delete mode 100644 api/app/views/spree/api/variants/new.v1.rabl create mode 100644 api/app/views/spree/api/variants/show.json.jbuilder delete mode 100644 api/app/views/spree/api/variants/show.v1.rabl delete mode 100644 api/app/views/spree/api/variants/small.v1.rabl create mode 100644 api/app/views/spree/api/zones/_zone.json.jbuilder create mode 100644 api/app/views/spree/api/zones/index.json.jbuilder delete mode 100644 api/app/views/spree/api/zones/index.v1.rabl create mode 100644 api/app/views/spree/api/zones/show.json.jbuilder delete mode 100644 api/app/views/spree/api/zones/show.v1.rabl create mode 100644 api/spec/test_views/spree/api/widgets/_widget.json.jbuilder create mode 100644 api/spec/test_views/spree/api/widgets/index.json.jbuilder delete mode 100644 api/spec/test_views/spree/api/widgets/index.v1.rabl create mode 100644 api/spec/test_views/spree/api/widgets/new.json.jbuilder delete mode 100644 api/spec/test_views/spree/api/widgets/new.v1.rabl create mode 100644 api/spec/test_views/spree/api/widgets/show.json.jbuilder delete mode 100644 api/spec/test_views/spree/api/widgets/show.v1.rabl diff --git a/api/app/views/spree/api/address_books/show.json.jbuilder b/api/app/views/spree/api/address_books/show.json.jbuilder new file mode 100644 index 0000000000..f8d7c57efa --- /dev/null +++ b/api/app/views/spree/api/address_books/show.json.jbuilder @@ -0,0 +1,11 @@ +json.array! @user_addresses do |user_address| + json.partial!("spree/api/addresses/address", address: user_address.address) + + json.default user_address.default + + # This is a bit of a hack. + # This attribute is only shown on the update action + if @address + json.update_target @address == user_address.address + end +end diff --git a/api/app/views/spree/api/address_books/show.v1.rabl b/api/app/views/spree/api/address_books/show.v1.rabl deleted file mode 100644 index 79fe5bd280..0000000000 --- a/api/app/views/spree/api/address_books/show.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -collection @user_addresses -node do |user_address| - partial("spree/api/addresses/show", object: user_address.address).merge( - default: user_address.default, - update_target: @address == user_address.address, - ) -end diff --git a/api/app/views/spree/api/addresses/_address.json.jbuilder b/api/app/views/spree/api/addresses/_address.json.jbuilder new file mode 100644 index 0000000000..6b9ad06c35 --- /dev/null +++ b/api/app/views/spree/api/addresses/_address.json.jbuilder @@ -0,0 +1,9 @@ +if address + json.(address, *address_attributes) + if address.country + json.country { json.(address.country, *country_attributes) } + end + if address.state + json.state { json.(address.state, *state_attributes) } + end +end diff --git a/api/app/views/spree/api/addresses/show.json.jbuilder b/api/app/views/spree/api/addresses/show.json.jbuilder new file mode 100644 index 0000000000..24e5e465fb --- /dev/null +++ b/api/app/views/spree/api/addresses/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/addresses/address", address: @address) diff --git a/api/app/views/spree/api/addresses/show.v1.rabl b/api/app/views/spree/api/addresses/show.v1.rabl deleted file mode 100644 index c341601380..0000000000 --- a/api/app/views/spree/api/addresses/show.v1.rabl +++ /dev/null @@ -1,10 +0,0 @@ -object @address -cache [I18n.locale, root_object] -attributes *address_attributes - -child(:country) do |address| - attributes *country_attributes -end -child(:state) do |address| - attributes *state_attributes -end diff --git a/api/app/views/spree/api/adjustments/_adjustment.json.jbuilder b/api/app/views/spree/api/adjustments/_adjustment.json.jbuilder new file mode 100644 index 0000000000..c052dadbf0 --- /dev/null +++ b/api/app/views/spree/api/adjustments/_adjustment.json.jbuilder @@ -0,0 +1,2 @@ +json.(adjustment, *adjustment_attributes) +json.display_amount(adjustment.display_amount.to_s) diff --git a/api/app/views/spree/api/adjustments/show.v1.rabl b/api/app/views/spree/api/adjustments/show.v1.rabl deleted file mode 100644 index e88c3d801d..0000000000 --- a/api/app/views/spree/api/adjustments/show.v1.rabl +++ /dev/null @@ -1,4 +0,0 @@ -object @adjustment -cache [I18n.locale, root_object] -attributes *adjustment_attributes -node(:display_amount) { |a| a.display_amount.to_s } diff --git a/api/app/views/spree/api/config/money.json.jbuilder b/api/app/views/spree/api/config/money.json.jbuilder new file mode 100644 index 0000000000..187543c3a8 --- /dev/null +++ b/api/app/views/spree/api/config/money.json.jbuilder @@ -0,0 +1 @@ +json.symbol(::Money.new(1, Spree::Config[:currency]).symbol) diff --git a/api/app/views/spree/api/config/money.v1.rabl b/api/app/views/spree/api/config/money.v1.rabl deleted file mode 100644 index fdc22120ee..0000000000 --- a/api/app/views/spree/api/config/money.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:symbol) { ::Money.new(1, Spree::Config[:currency]).symbol } diff --git a/api/app/views/spree/api/config/show.json.jbuilder b/api/app/views/spree/api/config/show.json.jbuilder new file mode 100644 index 0000000000..50664974cf --- /dev/null +++ b/api/app/views/spree/api/config/show.json.jbuilder @@ -0,0 +1,2 @@ +json.default_country_id(Spree::Country.default.id) +json.default_country_iso(Spree::Config[:default_country_iso]) diff --git a/api/app/views/spree/api/config/show.v1.rabl b/api/app/views/spree/api/config/show.v1.rabl deleted file mode 100644 index 3e7121af74..0000000000 --- a/api/app/views/spree/api/config/show.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:default_country_id) { Spree::Country.default.id } -node(:default_country_iso) { Spree::Config[:default_country_iso] } diff --git a/api/app/views/spree/api/countries/index.json.jbuilder b/api/app/views/spree/api/countries/index.json.jbuilder new file mode 100644 index 0000000000..6e210c07c6 --- /dev/null +++ b/api/app/views/spree/api/countries/index.json.jbuilder @@ -0,0 +1,4 @@ +json.countries(@countries) { |country| json.(country, *country_attributes) } +json.count(@countries.count) +json.current_page(@countries.current_page) +json.pages(@countries.total_pages) diff --git a/api/app/views/spree/api/countries/index.v1.rabl b/api/app/views/spree/api/countries/index.v1.rabl deleted file mode 100644 index a2c81b5d3d..0000000000 --- a/api/app/views/spree/api/countries/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@countries => :countries) do - attributes *country_attributes -end -node(:count) { @countries.count } -node(:current_page) { @countries.current_page } -node(:pages) { @countries.total_pages } diff --git a/api/app/views/spree/api/countries/show.json.jbuilder b/api/app/views/spree/api/countries/show.json.jbuilder new file mode 100644 index 0000000000..125bc4b49c --- /dev/null +++ b/api/app/views/spree/api/countries/show.json.jbuilder @@ -0,0 +1,4 @@ +json.(@country, *country_attributes) +json.states(@country.states) do |state| + json.(state, :id, :name, :abbr, :country_id) +end diff --git a/api/app/views/spree/api/countries/show.v1.rabl b/api/app/views/spree/api/countries/show.v1.rabl deleted file mode 100644 index 19d4322a9c..0000000000 --- a/api/app/views/spree/api/countries/show.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -object @country -attributes *country_attributes -child :states => :states do - attributes :id, :name, :abbr, :country_id -end diff --git a/api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder b/api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder new file mode 100644 index 0000000000..c1798846c3 --- /dev/null +++ b/api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder @@ -0,0 +1,6 @@ +json.(credit_card, *creditcard_attributes) +json.address do + if credit_card.address + json.partial!("spree/api/addresses/address", address: credit_card.address) + end +end diff --git a/api/app/views/spree/api/credit_cards/index.json.jbuilder b/api/app/views/spree/api/credit_cards/index.json.jbuilder new file mode 100644 index 0000000000..06cda32d8a --- /dev/null +++ b/api/app/views/spree/api/credit_cards/index.json.jbuilder @@ -0,0 +1,6 @@ +json.credit_cards(@credit_cards) do |credit_card| + json.partial!("spree/api/credit_cards/credit_card", credit_card: credit_card) +end +json.count(@credit_cards.count) +json.current_page(@credit_cards.current_page) +json.pages(@credit_cards.total_pages) diff --git a/api/app/views/spree/api/credit_cards/index.v1.rabl b/api/app/views/spree/api/credit_cards/index.v1.rabl deleted file mode 100644 index 73d0420be2..0000000000 --- a/api/app/views/spree/api/credit_cards/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@credit_cards => :credit_cards) do - extends "spree/api/credit_cards/show" -end -node(:count) { @credit_cards.count } -node(:current_page) { @credit_cards.current_page } -node(:pages) { @credit_cards.total_pages } diff --git a/api/app/views/spree/api/credit_cards/show.json.jbuilder b/api/app/views/spree/api/credit_cards/show.json.jbuilder new file mode 100644 index 0000000000..9d9d861306 --- /dev/null +++ b/api/app/views/spree/api/credit_cards/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/credit_cards/credit_card", credit_card: @credit_card) diff --git a/api/app/views/spree/api/credit_cards/show.v1.rabl b/api/app/views/spree/api/credit_cards/show.v1.rabl deleted file mode 100644 index f0a69b39b8..0000000000 --- a/api/app/views/spree/api/credit_cards/show.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object @credit_card -cache [I18n.locale, root_object] -attributes *creditcard_attributes - -child :address do - extends "spree/api/addresses/show" -end diff --git a/api/app/views/spree/api/errors/delete_restriction.json.jbuilder b/api/app/views/spree/api/errors/delete_restriction.json.jbuilder new file mode 100644 index 0000000000..7f0a6496bb --- /dev/null +++ b/api/app/views/spree/api/errors/delete_restriction.json.jbuilder @@ -0,0 +1 @@ +json.error I18n.t(:delete_restriction_error, scope: "spree.api") diff --git a/api/app/views/spree/api/errors/delete_restriction.v1.rabl b/api/app/views/spree/api/errors/delete_restriction.v1.rabl deleted file mode 100644 index 804d8f49e0..0000000000 --- a/api/app/views/spree/api/errors/delete_restriction.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:delete_restriction_error, scope: "spree.api") } diff --git a/api/app/views/spree/api/errors/gateway_error.json.jbuilder b/api/app/views/spree/api/errors/gateway_error.json.jbuilder new file mode 100644 index 0000000000..ea722bd58c --- /dev/null +++ b/api/app/views/spree/api/errors/gateway_error.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:gateway_error, scope: "spree.api", text: @error)) diff --git a/api/app/views/spree/api/errors/gateway_error.v1.rabl b/api/app/views/spree/api/errors/gateway_error.v1.rabl deleted file mode 100644 index cb79f951a5..0000000000 --- a/api/app/views/spree/api/errors/gateway_error.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:gateway_error, scope: "spree.api", text: @error) } diff --git a/api/app/views/spree/api/errors/invalid_api_key.json.jbuilder b/api/app/views/spree/api/errors/invalid_api_key.json.jbuilder new file mode 100644 index 0000000000..5b4db64cb0 --- /dev/null +++ b/api/app/views/spree/api/errors/invalid_api_key.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:invalid_api_key, key: api_key, scope: "spree.api")) diff --git a/api/app/views/spree/api/errors/invalid_api_key.v1.rabl b/api/app/views/spree/api/errors/invalid_api_key.v1.rabl deleted file mode 100644 index 9bd5e8a7e6..0000000000 --- a/api/app/views/spree/api/errors/invalid_api_key.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:invalid_api_key, :key => api_key, :scope => "spree.api") } diff --git a/api/app/views/spree/api/errors/invalid_resource.json.jbuilder b/api/app/views/spree/api/errors/invalid_resource.json.jbuilder new file mode 100644 index 0000000000..4522fe816f --- /dev/null +++ b/api/app/views/spree/api/errors/invalid_resource.json.jbuilder @@ -0,0 +1,2 @@ +json.error(I18n.t(:invalid_resource, scope: "spree.api")) +json.errors(@resource.errors.to_hash) diff --git a/api/app/views/spree/api/errors/invalid_resource.v1.rabl b/api/app/views/spree/api/errors/invalid_resource.v1.rabl deleted file mode 100644 index c7a0a8f92a..0000000000 --- a/api/app/views/spree/api/errors/invalid_resource.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:error) { I18n.t(:invalid_resource, :scope => "spree.api") } -node(:errors) { @resource.errors.to_hash } diff --git a/api/app/views/spree/api/errors/must_specify_api_key.json.jbuilder b/api/app/views/spree/api/errors/must_specify_api_key.json.jbuilder new file mode 100644 index 0000000000..4f62cea630 --- /dev/null +++ b/api/app/views/spree/api/errors/must_specify_api_key.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:must_specify_api_key, scope: "spree.api")) diff --git a/api/app/views/spree/api/errors/must_specify_api_key.v1.rabl b/api/app/views/spree/api/errors/must_specify_api_key.v1.rabl deleted file mode 100644 index ec85c24be5..0000000000 --- a/api/app/views/spree/api/errors/must_specify_api_key.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:must_specify_api_key, :scope => "spree.api") } diff --git a/api/app/views/spree/api/errors/not_found.json.jbuilder b/api/app/views/spree/api/errors/not_found.json.jbuilder new file mode 100644 index 0000000000..0d2e0677ed --- /dev/null +++ b/api/app/views/spree/api/errors/not_found.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:resource_not_found, scope: "spree.api")) diff --git a/api/app/views/spree/api/errors/not_found.v1.rabl b/api/app/views/spree/api/errors/not_found.v1.rabl deleted file mode 100644 index 0ea0bb4c19..0000000000 --- a/api/app/views/spree/api/errors/not_found.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:resource_not_found, :scope => "spree.api") } diff --git a/api/app/views/spree/api/errors/unauthorized.json.jbuilder b/api/app/views/spree/api/errors/unauthorized.json.jbuilder new file mode 100644 index 0000000000..d761df0fa2 --- /dev/null +++ b/api/app/views/spree/api/errors/unauthorized.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:unauthorized, scope: "spree.api")) diff --git a/api/app/views/spree/api/errors/unauthorized.v1.rabl b/api/app/views/spree/api/errors/unauthorized.v1.rabl deleted file mode 100644 index 0a692c0933..0000000000 --- a/api/app/views/spree/api/errors/unauthorized.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:unauthorized, :scope => "spree.api") } diff --git a/api/app/views/spree/api/errors/variant_not_in_stock_transfer.json.jbuilder b/api/app/views/spree/api/errors/variant_not_in_stock_transfer.json.jbuilder new file mode 100644 index 0000000000..ac158148cf --- /dev/null +++ b/api/app/views/spree/api/errors/variant_not_in_stock_transfer.json.jbuilder @@ -0,0 +1 @@ +json.error(Spree.t(:item_not_in_stock_transfer)) diff --git a/api/app/views/spree/api/errors/variant_not_in_stock_transfer.v1.rabl b/api/app/views/spree/api/errors/variant_not_in_stock_transfer.v1.rabl deleted file mode 100644 index f091e28ab2..0000000000 --- a/api/app/views/spree/api/errors/variant_not_in_stock_transfer.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { Spree.t(:item_not_in_stock_transfer) } diff --git a/api/app/views/spree/api/images/_image.json.jbuilder b/api/app/views/spree/api/images/_image.json.jbuilder new file mode 100644 index 0000000000..b29191eebd --- /dev/null +++ b/api/app/views/spree/api/images/_image.json.jbuilder @@ -0,0 +1,5 @@ +json.(image, *image_attributes) +json.(image, :viewable_type, :viewable_id) +Spree::Image.attachment_definitions[:attachment][:styles].each do |k, _v| + json.set! "#{k}_url", image.attachment.url(k) +end diff --git a/api/app/views/spree/api/images/index.json.jbuilder b/api/app/views/spree/api/images/index.json.jbuilder new file mode 100644 index 0000000000..b13655051f --- /dev/null +++ b/api/app/views/spree/api/images/index.json.jbuilder @@ -0,0 +1,3 @@ +json.images(@images) do |image| + json.partial!("spree/api/images/image", image: image) +end diff --git a/api/app/views/spree/api/images/index.v1.rabl b/api/app/views/spree/api/images/index.v1.rabl deleted file mode 100644 index 6fcdd48dbf..0000000000 --- a/api/app/views/spree/api/images/index.v1.rabl +++ /dev/null @@ -1,4 +0,0 @@ -object false -child(@images => :images) do - extends "spree/api/images/show" -end diff --git a/api/app/views/spree/api/images/show.json.jbuilder b/api/app/views/spree/api/images/show.json.jbuilder new file mode 100644 index 0000000000..c515c19742 --- /dev/null +++ b/api/app/views/spree/api/images/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/images/image", image: @image) diff --git a/api/app/views/spree/api/images/show.v1.rabl b/api/app/views/spree/api/images/show.v1.rabl deleted file mode 100644 index d019ed8bdd..0000000000 --- a/api/app/views/spree/api/images/show.v1.rabl +++ /dev/null @@ -1,6 +0,0 @@ -object @image -attributes *image_attributes -attributes :viewable_type, :viewable_id -Spree::Image.attachment_definitions[:attachment][:styles].each do |k,v| - node("#{k}_url") { |i| i.attachment.url(k) } -end diff --git a/api/app/views/spree/api/inventory_units/show.json.jbuilder b/api/app/views/spree/api/inventory_units/show.json.jbuilder new file mode 100644 index 0000000000..6c27ca6a67 --- /dev/null +++ b/api/app/views/spree/api/inventory_units/show.json.jbuilder @@ -0,0 +1 @@ +json.(@inventory_unit, *inventory_unit_attributes) diff --git a/api/app/views/spree/api/inventory_units/show.rabl b/api/app/views/spree/api/inventory_units/show.rabl deleted file mode 100644 index d9e7960b50..0000000000 --- a/api/app/views/spree/api/inventory_units/show.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @inventory_unit -attributes *inventory_unit_attributes diff --git a/api/app/views/spree/api/line_items/_line_item.json.jbuilder b/api/app/views/spree/api/line_items/_line_item.json.jbuilder new file mode 100644 index 0000000000..895aeb1867 --- /dev/null +++ b/api/app/views/spree/api/line_items/_line_item.json.jbuilder @@ -0,0 +1,14 @@ +json.(line_item, *line_item_attributes) +json.single_display_amount(line_item.single_display_amount.to_s) +json.display_amount(line_item.display_amount.to_s) +json.total(line_item.total) +json.variant do + json.partial!("spree/api/variants/small", variant: line_item.variant) + json.(line_item.variant, :product_id) + json.images(line_item.variant.images) do |image| + json.partial!("spree/api/images/image", image: image) + end +end +json.adjustments(line_item.adjustments) do |adjustment| + json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) +end diff --git a/api/app/views/spree/api/line_items/new.json.jbuilder b/api/app/views/spree/api/line_items/new.json.jbuilder new file mode 100644 index 0000000000..65583e8b62 --- /dev/null +++ b/api/app/views/spree/api/line_items/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes(([*line_item_attributes] - [:id])) +json.required_attributes([:variant_id, :quantity]) diff --git a/api/app/views/spree/api/line_items/new.v1.rabl b/api/app/views/spree/api/line_items/new.v1.rabl deleted file mode 100644 index 6269ff819e..0000000000 --- a/api/app/views/spree/api/line_items/new.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:attributes) { [*line_item_attributes] - [:id] } -node(:required_attributes) { [:variant_id, :quantity] } diff --git a/api/app/views/spree/api/line_items/show.json.jbuilder b/api/app/views/spree/api/line_items/show.json.jbuilder new file mode 100644 index 0000000000..7cb92fe75c --- /dev/null +++ b/api/app/views/spree/api/line_items/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/line_items/line_item", line_item: @line_item) diff --git a/api/app/views/spree/api/line_items/show.v1.rabl b/api/app/views/spree/api/line_items/show.v1.rabl deleted file mode 100644 index e64a979643..0000000000 --- a/api/app/views/spree/api/line_items/show.v1.rabl +++ /dev/null @@ -1,15 +0,0 @@ -object @line_item -cache [I18n.locale, root_object] -attributes *line_item_attributes -node(:single_display_amount) { |li| li.single_display_amount.to_s } -node(:display_amount) { |li| li.display_amount.to_s } -node(:total) { |li| li.total } -child :variant do - extends "spree/api/variants/small" - attributes :product_id - child(:images => :images) { extends "spree/api/images/show" } -end - -child :adjustments => :adjustments do - extends "spree/api/adjustments/show" -end diff --git a/api/app/views/spree/api/option_types/_option_type.json.jbuilder b/api/app/views/spree/api/option_types/_option_type.json.jbuilder new file mode 100644 index 0000000000..3ef65b01d0 --- /dev/null +++ b/api/app/views/spree/api/option_types/_option_type.json.jbuilder @@ -0,0 +1,4 @@ +json.(option_type, *option_type_attributes) +json.option_values(option_type.option_values) do |option_value| + json.(option_value, *option_value_attributes) +end diff --git a/api/app/views/spree/api/option_types/index.json.jbuilder b/api/app/views/spree/api/option_types/index.json.jbuilder new file mode 100644 index 0000000000..77f9c795fe --- /dev/null +++ b/api/app/views/spree/api/option_types/index.json.jbuilder @@ -0,0 +1,3 @@ +json.array! @option_types do |option_type| + json.partial!("spree/api/option_types/option_type", option_type: option_type) +end diff --git a/api/app/views/spree/api/option_types/index.v1.rabl b/api/app/views/spree/api/option_types/index.v1.rabl deleted file mode 100644 index 839273c05b..0000000000 --- a/api/app/views/spree/api/option_types/index.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -collection @option_types - -extends "spree/api/option_types/show" diff --git a/api/app/views/spree/api/option_types/show.json.jbuilder b/api/app/views/spree/api/option_types/show.json.jbuilder new file mode 100644 index 0000000000..d5e4705148 --- /dev/null +++ b/api/app/views/spree/api/option_types/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/option_types/option_type", option_type: @option_type) diff --git a/api/app/views/spree/api/option_types/show.v1.rabl b/api/app/views/spree/api/option_types/show.v1.rabl deleted file mode 100644 index e3c71a255a..0000000000 --- a/api/app/views/spree/api/option_types/show.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -object @option_type -attributes *option_type_attributes -child :option_values => :option_values do - attributes *option_value_attributes -end \ No newline at end of file diff --git a/api/app/views/spree/api/option_values/_option_value.json.jbuilder b/api/app/views/spree/api/option_values/_option_value.json.jbuilder new file mode 100644 index 0000000000..f9b4e7f37d --- /dev/null +++ b/api/app/views/spree/api/option_values/_option_value.json.jbuilder @@ -0,0 +1 @@ +json.(option_value, *option_value_attributes) diff --git a/api/app/views/spree/api/option_values/index.json.jbuilder b/api/app/views/spree/api/option_values/index.json.jbuilder new file mode 100644 index 0000000000..6877a72228 --- /dev/null +++ b/api/app/views/spree/api/option_values/index.json.jbuilder @@ -0,0 +1,3 @@ +json.array! @option_values do |option_value| + json.partial!("spree/api/option_values/option_value", option_value: option_value) +end diff --git a/api/app/views/spree/api/option_values/index.v1.rabl b/api/app/views/spree/api/option_values/index.v1.rabl deleted file mode 100644 index 0bdfd33be3..0000000000 --- a/api/app/views/spree/api/option_values/index.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -collection @option_values - -extends "spree/api/option_values/show" diff --git a/api/app/views/spree/api/option_values/show.json.jbuilder b/api/app/views/spree/api/option_values/show.json.jbuilder new file mode 100644 index 0000000000..2dad95c922 --- /dev/null +++ b/api/app/views/spree/api/option_values/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/option_values/option_value", option_value: @option_value) diff --git a/api/app/views/spree/api/option_values/show.v1.rabl b/api/app/views/spree/api/option_values/show.v1.rabl deleted file mode 100644 index 5ed499ef22..0000000000 --- a/api/app/views/spree/api/option_values/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @option_value -attributes *option_value_attributes \ No newline at end of file diff --git a/api/app/views/spree/api/orders/_big.json.jbuilder b/api/app/views/spree/api/orders/_big.json.jbuilder new file mode 100644 index 0000000000..d21fc014ad --- /dev/null +++ b/api/app/views/spree/api/orders/_big.json.jbuilder @@ -0,0 +1,40 @@ +json.partial!("spree/api/orders/order", order: order) +json.payment_methods(order.available_payment_methods) do |payment_method| + json.(payment_method, :id, :name, :partial_name) + json.method_type payment_method.partial_name +end +json.bill_address do + json.partial!("spree/api/addresses/address", address: order.billing_address) +end +json.ship_address do + json.partial!("spree/api/addresses/address", address: order.shipping_address) +end +json.line_items(order.line_items) do |line_item| + json.partial!("spree/api/line_items/line_item", line_item: line_item) +end +json.payments(order.payments) do |payment| + json.(payment, *payment_attributes) + json.payment_method { json.(payment.payment_method, :id, :name) } + if payment.source + json.source do + json.(payment.source, *payment_source_attributes) + if @current_user_roles.include?("admin") + json.(payment.source, *(payment_source_attributes + [:gateway_customer_profile_id, :gateway_payment_profile_id])) + else + json.(payment.source, *payment_source_attributes) + end + end + end +end +json.shipments(order.shipments) do |shipment| + json.partial!("spree/api/shipments/small", shipment: shipment) +end +json.adjustments(order.adjustments) do |adjustment| + json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) +end +json.permissions do + json.can_update current_ability.can?(:update, order) +end +json.credit_cards(order.valid_credit_cards) do |credit_card| + json.partial!("spree/api/credit_cards/credit_card", credit_card: credit_card) +end diff --git a/api/app/views/spree/api/orders/_order.json.jbuilder b/api/app/views/spree/api/orders/_order.json.jbuilder new file mode 100644 index 0000000000..c11bb92f41 --- /dev/null +++ b/api/app/views/spree/api/orders/_order.json.jbuilder @@ -0,0 +1,8 @@ +json.(order, *order_attributes) +json.display_item_total(order.display_item_total.to_s) +json.total_quantity(order.line_items.sum(:quantity)) +json.display_total(order.display_total.to_s) +json.display_ship_total(order.display_ship_total) +json.display_tax_total(order.display_tax_total) +json.token(order.guest_token) +json.checkout_steps(order.checkout_steps) diff --git a/api/app/views/spree/api/orders/could_not_apply_coupon.json.jbuilder b/api/app/views/spree/api/orders/could_not_apply_coupon.json.jbuilder new file mode 100644 index 0000000000..90cd632f9a --- /dev/null +++ b/api/app/views/spree/api/orders/could_not_apply_coupon.json.jbuilder @@ -0,0 +1 @@ +json.error(@coupon_message) diff --git a/api/app/views/spree/api/orders/could_not_apply_coupon.v1.rabl b/api/app/views/spree/api/orders/could_not_apply_coupon.v1.rabl deleted file mode 100644 index 0a45713063..0000000000 --- a/api/app/views/spree/api/orders/could_not_apply_coupon.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { @coupon_message } diff --git a/api/app/views/spree/api/orders/could_not_transition.json.jbuilder b/api/app/views/spree/api/orders/could_not_transition.json.jbuilder new file mode 100644 index 0000000000..20de3a7065 --- /dev/null +++ b/api/app/views/spree/api/orders/could_not_transition.json.jbuilder @@ -0,0 +1,2 @@ +json.error(I18n.t(:could_not_transition, scope: "spree.api.order")) +json.errors(@order.errors.to_hash) diff --git a/api/app/views/spree/api/orders/could_not_transition.v1.rabl b/api/app/views/spree/api/orders/could_not_transition.v1.rabl deleted file mode 100644 index 6157703be6..0000000000 --- a/api/app/views/spree/api/orders/could_not_transition.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:error) { I18n.t(:could_not_transition, scope: "spree.api.order") } -node(:errors) { @order.errors.to_hash } diff --git a/api/app/views/spree/api/orders/expected_total_mismatch.json.jbuilder b/api/app/views/spree/api/orders/expected_total_mismatch.json.jbuilder new file mode 100644 index 0000000000..42484dd785 --- /dev/null +++ b/api/app/views/spree/api/orders/expected_total_mismatch.json.jbuilder @@ -0,0 +1 @@ +json.errors(expected_total: [I18n.t(:expected_total_mismatch, scope: "spree.api.order")]) diff --git a/api/app/views/spree/api/orders/expected_total_mismatch.v1.rabl b/api/app/views/spree/api/orders/expected_total_mismatch.v1.rabl deleted file mode 100644 index 9fe0eb1157..0000000000 --- a/api/app/views/spree/api/orders/expected_total_mismatch.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:errors) { {expected_total: [I18n.t(:expected_total_mismatch, scope: "spree.api.order")]} } diff --git a/api/app/views/spree/api/orders/index.json.jbuilder b/api/app/views/spree/api/orders/index.json.jbuilder new file mode 100644 index 0000000000..a1cb0c85b8 --- /dev/null +++ b/api/app/views/spree/api/orders/index.json.jbuilder @@ -0,0 +1,6 @@ +json.orders(@orders) do |order| + json.partial!("spree/api/orders/order", order: order) +end +json.count(@orders.count) +json.current_page(@orders.current_page) +json.pages(@orders.total_pages) diff --git a/api/app/views/spree/api/orders/index.v1.rabl b/api/app/views/spree/api/orders/index.v1.rabl deleted file mode 100644 index 03868f7fd3..0000000000 --- a/api/app/views/spree/api/orders/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@orders => :orders) do - extends "spree/api/orders/order" -end -node(:count) { @orders.count } -node(:current_page) { @orders.current_page } -node(:pages) { @orders.total_pages } diff --git a/api/app/views/spree/api/orders/invalid_shipping_method.json.jbuilder b/api/app/views/spree/api/orders/invalid_shipping_method.json.jbuilder new file mode 100644 index 0000000000..00a902ae0c --- /dev/null +++ b/api/app/views/spree/api/orders/invalid_shipping_method.json.jbuilder @@ -0,0 +1 @@ +json.errors([I18n.t(:invalid_shipping_method, scope: "spree.api.order")]) diff --git a/api/app/views/spree/api/orders/invalid_shipping_method.v1.rabl b/api/app/views/spree/api/orders/invalid_shipping_method.v1.rabl deleted file mode 100644 index 3bd499fb84..0000000000 --- a/api/app/views/spree/api/orders/invalid_shipping_method.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:errors) { [I18n.t(:invalid_shipping_method, :scope => "spree.api.order")] } diff --git a/api/app/views/spree/api/orders/mine.json.jbuilder b/api/app/views/spree/api/orders/mine.json.jbuilder new file mode 100644 index 0000000000..97ba0101ed --- /dev/null +++ b/api/app/views/spree/api/orders/mine.json.jbuilder @@ -0,0 +1,6 @@ +json.orders(@orders) do |order| + json.partial!("spree/api/orders/big", order: order) +end +json.count(@orders.count) +json.current_page(@orders.current_page) +json.pages(@orders.total_pages) diff --git a/api/app/views/spree/api/orders/mine.v1.rabl b/api/app/views/spree/api/orders/mine.v1.rabl deleted file mode 100644 index a18e1066d8..0000000000 --- a/api/app/views/spree/api/orders/mine.v1.rabl +++ /dev/null @@ -1,9 +0,0 @@ -object false - -child(@orders => :orders) do - extends "spree/api/orders/show" -end - -node(:count) { @orders.count } -node(:current_page) { @orders.current_page } -node(:pages) { @orders.total_pages } diff --git a/api/app/views/spree/api/orders/order.v1.rabl b/api/app/views/spree/api/orders/order.v1.rabl deleted file mode 100644 index a511dd34e4..0000000000 --- a/api/app/views/spree/api/orders/order.v1.rabl +++ /dev/null @@ -1,9 +0,0 @@ -cache [I18n.locale, root_object] -attributes *order_attributes -node(:display_item_total) { |o| o.display_item_total.to_s } -node(:total_quantity) { |o| o.line_items.sum(:quantity) } -node(:display_total) { |o| o.display_total.to_s } -node(:display_ship_total) { |o| o.display_ship_total } -node(:display_tax_total) { |o| o.display_tax_total } -node(:token) { |o| o.guest_token } -node(:checkout_steps) { |o| o.checkout_steps } diff --git a/api/app/views/spree/api/orders/show.json.jbuilder b/api/app/views/spree/api/orders/show.json.jbuilder new file mode 100644 index 0000000000..d861cbe284 --- /dev/null +++ b/api/app/views/spree/api/orders/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/orders/big", order: @order) diff --git a/api/app/views/spree/api/orders/show.v1.rabl b/api/app/views/spree/api/orders/show.v1.rabl deleted file mode 100644 index 4bf2767137..0000000000 --- a/api/app/views/spree/api/orders/show.v1.rabl +++ /dev/null @@ -1,53 +0,0 @@ -object @order -extends "spree/api/orders/order" - -child :available_payment_methods => :payment_methods do - attributes :id, :name, :partial_name - attributes :partial_name, as: :method_type -end - -child :billing_address => :bill_address do - extends "spree/api/addresses/show" -end - -child :shipping_address => :ship_address do - extends "spree/api/addresses/show" -end - -child :line_items => :line_items do - extends "spree/api/line_items/show" -end - -child :payments => :payments do - attributes *payment_attributes - - child :payment_method => :payment_method do - attributes :id, :name - end - - child :source => :source do - attributes *payment_source_attributes - if @current_user_roles.include?('admin') - attributes *(payment_source_attributes + [:gateway_customer_profile_id, :gateway_payment_profile_id]) - else - attributes *payment_source_attributes - end - end -end - -child :shipments => :shipments do - extends "spree/api/shipments/small" -end - -child :adjustments => :adjustments do - extends "spree/api/adjustments/show" -end - -# Necessary for backend's order interface -node :permissions do - { can_update: current_ability.can?(:update, root_object) } -end - -child :valid_credit_cards => :credit_cards do - extends "spree/api/credit_cards/show" -end diff --git a/api/app/views/spree/api/payments/credit_over_limit.json.jbuilder b/api/app/views/spree/api/payments/credit_over_limit.json.jbuilder new file mode 100644 index 0000000000..47b254dd64 --- /dev/null +++ b/api/app/views/spree/api/payments/credit_over_limit.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:credit_over_limit, limit: @payment.credit_allowed, scope: "spree.api.payment")) diff --git a/api/app/views/spree/api/payments/credit_over_limit.v1.rabl b/api/app/views/spree/api/payments/credit_over_limit.v1.rabl deleted file mode 100644 index 3cbf95ad4f..0000000000 --- a/api/app/views/spree/api/payments/credit_over_limit.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:credit_over_limit, :limit => @payment.credit_allowed, :scope => 'spree.api.payment') } diff --git a/api/app/views/spree/api/payments/index.json.jbuilder b/api/app/views/spree/api/payments/index.json.jbuilder new file mode 100644 index 0000000000..9308bf917b --- /dev/null +++ b/api/app/views/spree/api/payments/index.json.jbuilder @@ -0,0 +1,4 @@ +json.payments(@payments) { |payment| json.(payment, *payment_attributes) } +json.count(@payments.count) +json.current_page(@payments.current_page) +json.pages(@payments.total_pages) diff --git a/api/app/views/spree/api/payments/index.v1.rabl b/api/app/views/spree/api/payments/index.v1.rabl deleted file mode 100644 index f989da6213..0000000000 --- a/api/app/views/spree/api/payments/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@payments => :payments) do - attributes *payment_attributes -end -node(:count) { @payments.count } -node(:current_page) { @payments.current_page } -node(:pages) { @payments.total_pages } diff --git a/api/app/views/spree/api/payments/new.json.jbuilder b/api/app/views/spree/api/payments/new.json.jbuilder new file mode 100644 index 0000000000..7bc5516752 --- /dev/null +++ b/api/app/views/spree/api/payments/new.json.jbuilder @@ -0,0 +1,4 @@ +json.attributes([*payment_attributes]) +json.payment_methods(@payment_methods) do |payment_method| + json.(payment_method, *payment_method_attributes) +end diff --git a/api/app/views/spree/api/payments/new.v1.rabl b/api/app/views/spree/api/payments/new.v1.rabl deleted file mode 100644 index 05d227cf83..0000000000 --- a/api/app/views/spree/api/payments/new.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -object false -node(:attributes) { [*payment_attributes] } -child @payment_methods => :payment_methods do - attributes *payment_method_attributes -end diff --git a/api/app/views/spree/api/payments/show.json.jbuilder b/api/app/views/spree/api/payments/show.json.jbuilder new file mode 100644 index 0000000000..971e10508b --- /dev/null +++ b/api/app/views/spree/api/payments/show.json.jbuilder @@ -0,0 +1 @@ +json.(@payment, *payment_attributes) diff --git a/api/app/views/spree/api/payments/show.v1.rabl b/api/app/views/spree/api/payments/show.v1.rabl deleted file mode 100644 index e2f48cb940..0000000000 --- a/api/app/views/spree/api/payments/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @payment -attributes *payment_attributes diff --git a/api/app/views/spree/api/payments/update_forbidden.json.jbuilder b/api/app/views/spree/api/payments/update_forbidden.json.jbuilder new file mode 100644 index 0000000000..7b868519a8 --- /dev/null +++ b/api/app/views/spree/api/payments/update_forbidden.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:update_forbidden, state: @payment.state, scope: "spree.api.payment")) diff --git a/api/app/views/spree/api/payments/update_forbidden.v1.rabl b/api/app/views/spree/api/payments/update_forbidden.v1.rabl deleted file mode 100644 index 7f51e9c3a8..0000000000 --- a/api/app/views/spree/api/payments/update_forbidden.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:update_forbidden, :state => @payment.state, :scope => 'spree.api.payment') } diff --git a/api/app/views/spree/api/product_properties/index.json.jbuilder b/api/app/views/spree/api/product_properties/index.json.jbuilder new file mode 100644 index 0000000000..5cf1555498 --- /dev/null +++ b/api/app/views/spree/api/product_properties/index.json.jbuilder @@ -0,0 +1,6 @@ +json.product_properties(@product_properties) do |product_property| + json.(product_property, *product_property_attributes) +end +json.count(@product_properties.count) +json.current_page(@product_properties.current_page) +json.pages(@product_properties.total_pages) diff --git a/api/app/views/spree/api/product_properties/index.v1.rabl b/api/app/views/spree/api/product_properties/index.v1.rabl deleted file mode 100644 index 272180f0bc..0000000000 --- a/api/app/views/spree/api/product_properties/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@product_properties => :product_properties) do - attributes *product_property_attributes -end -node(:count) { @product_properties.count } -node(:current_page) { @product_properties.current_page } -node(:pages) { @product_properties.total_pages } diff --git a/api/app/views/spree/api/product_properties/new.json.jbuilder b/api/app/views/spree/api/product_properties/new.json.jbuilder new file mode 100644 index 0000000000..a03b53b2ed --- /dev/null +++ b/api/app/views/spree/api/product_properties/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*product_property_attributes]) +json.required_attributes([]) diff --git a/api/app/views/spree/api/product_properties/new.v1.rabl b/api/app/views/spree/api/product_properties/new.v1.rabl deleted file mode 100644 index 9556ea4132..0000000000 --- a/api/app/views/spree/api/product_properties/new.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -node(:attributes) { [*product_property_attributes] } -node(:required_attributes) { [] } \ No newline at end of file diff --git a/api/app/views/spree/api/product_properties/show.json.jbuilder b/api/app/views/spree/api/product_properties/show.json.jbuilder new file mode 100644 index 0000000000..23af9bd4d0 --- /dev/null +++ b/api/app/views/spree/api/product_properties/show.json.jbuilder @@ -0,0 +1 @@ +json.(@product_property, *product_property_attributes) diff --git a/api/app/views/spree/api/product_properties/show.v1.rabl b/api/app/views/spree/api/product_properties/show.v1.rabl deleted file mode 100644 index 12e24137b5..0000000000 --- a/api/app/views/spree/api/product_properties/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @product_property -attributes *product_property_attributes diff --git a/api/app/views/spree/api/products/_product.json.jbuilder b/api/app/views/spree/api/products/_product.json.jbuilder new file mode 100644 index 0000000000..4fd73b2107 --- /dev/null +++ b/api/app/views/spree/api/products/_product.json.jbuilder @@ -0,0 +1,31 @@ +@product_attributes ||= product_attributes +json.(product, *@product_attributes) +json.display_price(product.display_price.to_s) +@exclude_data ||= {} +unless @exclude_data[:variants] + json.has_variants(product.has_variants?) + json.master do + json.partial!("spree/api/variants/small", variant: product.master) + end + json.variants(product.variants) do |variant| + json.partial!("spree/api/variants/small", variant: variant) + end +end +unless @exclude_data[:option_types] + json.option_types(product.option_types) do |option_type| + json.(option_type, *option_type_attributes) + end +end +unless @exclude_data[:product_properties] + json.product_properties(product.product_properties) do |product_property| + json.(product_property, *product_property_attributes) + end +end +unless @exclude_data[:classifications] + json.classifications(product.classifications) do |classification| + json.(classification, :taxon_id, :position) + json.taxon do + json.partial!("spree/api/taxons/taxon", taxon: classification.taxon) + end + end +end diff --git a/api/app/views/spree/api/products/index.json.jbuilder b/api/app/views/spree/api/products/index.json.jbuilder new file mode 100644 index 0000000000..3c774991fe --- /dev/null +++ b/api/app/views/spree/api/products/index.json.jbuilder @@ -0,0 +1,8 @@ +json.count(@products.size) +json.total_count(@products.total_count) +json.current_page(@products.current_page) +json.per_page(@products.limit_value) +json.pages(@products.total_pages) +json.products(@products) do |product| + json.partial!("spree/api/products/product", product: product) +end diff --git a/api/app/views/spree/api/products/index.v1.rabl b/api/app/views/spree/api/products/index.v1.rabl deleted file mode 100644 index 6c4e861d0a..0000000000 --- a/api/app/views/spree/api/products/index.v1.rabl +++ /dev/null @@ -1,9 +0,0 @@ -object false -node(:count) { @products.size } -node(:total_count) { @products.total_count } -node(:current_page) { @products.current_page } -node(:per_page) { @products.limit_value } -node(:pages) { @products.total_pages } -child(@products => :products) do - extends "spree/api/products/show" -end diff --git a/api/app/views/spree/api/products/new.json.jbuilder b/api/app/views/spree/api/products/new.json.jbuilder new file mode 100644 index 0000000000..7f0cdbdbb9 --- /dev/null +++ b/api/app/views/spree/api/products/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*product_attributes]) +json.required_attributes(required_fields_for(Spree::Product)) diff --git a/api/app/views/spree/api/products/new.v1.rabl b/api/app/views/spree/api/products/new.v1.rabl deleted file mode 100644 index 71861f9183..0000000000 --- a/api/app/views/spree/api/products/new.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:attributes) { [*product_attributes] } -node(:required_attributes) { required_fields_for(Spree::Product) } diff --git a/api/app/views/spree/api/products/product.v1.rabl b/api/app/views/spree/api/products/product.v1.rabl deleted file mode 100644 index ba18e3f709..0000000000 --- a/api/app/views/spree/api/products/product.v1.rabl +++ /dev/null @@ -1 +0,0 @@ -attributes *product_attributes diff --git a/api/app/views/spree/api/products/show.json.jbuilder b/api/app/views/spree/api/products/show.json.jbuilder new file mode 100644 index 0000000000..91e5ebe4fe --- /dev/null +++ b/api/app/views/spree/api/products/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/products/product", product: @product) diff --git a/api/app/views/spree/api/products/show.v1.rabl b/api/app/views/spree/api/products/show.v1.rabl deleted file mode 100644 index 9f7d84ae00..0000000000 --- a/api/app/views/spree/api/products/show.v1.rabl +++ /dev/null @@ -1,42 +0,0 @@ -object @product -cache [I18n.locale, @current_user_roles.include?('admin'), current_pricing_options, root_object] - -@product_attributes ||= product_attributes -attributes(*@product_attributes) - -node(:display_price) { |p| p.display_price.to_s } - -@exclude_data ||= {} -unless @exclude_data[:variants] - node(:has_variants) { |p| p.has_variants? } - - child :master => :master do - extends "spree/api/variants/small" - end - - child :variants => :variants do - extends "spree/api/variants/small" - end -end - -unless @exclude_data[:option_types] - child :option_types => :option_types do - attributes(*option_type_attributes) - end -end - -unless @exclude_data[:product_properties] - child :product_properties => :product_properties do - attributes(*product_property_attributes) - end -end - -unless @exclude_data[:classifications] - child :classifications => :classifications do - attributes :taxon_id, :position - - child(:taxon) do - extends "spree/api/taxons/show" - end - end -end diff --git a/api/app/views/spree/api/promotions/handler.json.jbuilder b/api/app/views/spree/api/promotions/handler.json.jbuilder new file mode 100644 index 0000000000..7a14ccd351 --- /dev/null +++ b/api/app/views/spree/api/promotions/handler.json.jbuilder @@ -0,0 +1,4 @@ +json.success(@handler.success) +json.error(@handler.error) +json.successful(@handler.successful?) +json.status_code(@handler.status_code) diff --git a/api/app/views/spree/api/promotions/handler.v1.rabl b/api/app/views/spree/api/promotions/handler.v1.rabl deleted file mode 100644 index e08a89b08e..0000000000 --- a/api/app/views/spree/api/promotions/handler.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -object false -node(:success) { @handler.success } -node(:error) { @handler.error } -node(:successful) { @handler.successful? } -node(:status_code) { @handler.status_code } diff --git a/api/app/views/spree/api/promotions/show.json.jbuilder b/api/app/views/spree/api/promotions/show.json.jbuilder new file mode 100644 index 0000000000..fc4661139d --- /dev/null +++ b/api/app/views/spree/api/promotions/show.json.jbuilder @@ -0,0 +1 @@ +json.(@promotion, *promotion_attributes) diff --git a/api/app/views/spree/api/promotions/show.v1.rabl b/api/app/views/spree/api/promotions/show.v1.rabl deleted file mode 100644 index 90a577d22a..0000000000 --- a/api/app/views/spree/api/promotions/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @promotion -attributes *promotion_attributes diff --git a/api/app/views/spree/api/properties/index.json.jbuilder b/api/app/views/spree/api/properties/index.json.jbuilder new file mode 100644 index 0000000000..4aee811e59 --- /dev/null +++ b/api/app/views/spree/api/properties/index.json.jbuilder @@ -0,0 +1,6 @@ +json.properties(@properties) do |property| + json.(property, *property_attributes) +end +json.count(@properties.count) +json.current_page(@properties.current_page) +json.pages(@properties.total_pages) diff --git a/api/app/views/spree/api/properties/index.v1.rabl b/api/app/views/spree/api/properties/index.v1.rabl deleted file mode 100644 index 27eafc9649..0000000000 --- a/api/app/views/spree/api/properties/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@properties => :properties) do - attributes *property_attributes -end -node(:count) { @properties.count } -node(:current_page) { @properties.current_page } -node(:pages) { @properties.total_pages } diff --git a/api/app/views/spree/api/properties/new.json.jbuilder b/api/app/views/spree/api/properties/new.json.jbuilder new file mode 100644 index 0000000000..0b578258ec --- /dev/null +++ b/api/app/views/spree/api/properties/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*property_attributes]) +json.required_attributes([]) diff --git a/api/app/views/spree/api/properties/new.v1.rabl b/api/app/views/spree/api/properties/new.v1.rabl deleted file mode 100644 index 76f03444e8..0000000000 --- a/api/app/views/spree/api/properties/new.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -node(:attributes) { [*property_attributes] } -node(:required_attributes) { [] } diff --git a/api/app/views/spree/api/properties/show.json.jbuilder b/api/app/views/spree/api/properties/show.json.jbuilder new file mode 100644 index 0000000000..1767652e3f --- /dev/null +++ b/api/app/views/spree/api/properties/show.json.jbuilder @@ -0,0 +1 @@ +json.(@property, *property_attributes) diff --git a/api/app/views/spree/api/properties/show.v1.rabl b/api/app/views/spree/api/properties/show.v1.rabl deleted file mode 100644 index 08cfbe5e9b..0000000000 --- a/api/app/views/spree/api/properties/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @property -attributes *property_attributes diff --git a/api/app/views/spree/api/return_authorizations/index.json.jbuilder b/api/app/views/spree/api/return_authorizations/index.json.jbuilder new file mode 100644 index 0000000000..c88ba58ff7 --- /dev/null +++ b/api/app/views/spree/api/return_authorizations/index.json.jbuilder @@ -0,0 +1,6 @@ +json.return_authorizations(@return_authorizations) do |return_authorization| + json.(return_authorization, *return_authorization_attributes) +end +json.count(@return_authorizations.count) +json.current_page(@return_authorizations.current_page) +json.pages(@return_authorizations.total_pages) diff --git a/api/app/views/spree/api/return_authorizations/index.v1.rabl b/api/app/views/spree/api/return_authorizations/index.v1.rabl deleted file mode 100644 index 879b9a4f0f..0000000000 --- a/api/app/views/spree/api/return_authorizations/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@return_authorizations => :return_authorizations) do - attributes *return_authorization_attributes -end -node(:count) { @return_authorizations.count } -node(:current_page) { @return_authorizations.current_page } -node(:pages) { @return_authorizations.total_pages } diff --git a/api/app/views/spree/api/return_authorizations/new.json.jbuilder b/api/app/views/spree/api/return_authorizations/new.json.jbuilder new file mode 100644 index 0000000000..7e1315a407 --- /dev/null +++ b/api/app/views/spree/api/return_authorizations/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*return_authorization_attributes]) +json.required_attributes(required_fields_for(Spree::ReturnAuthorization)) diff --git a/api/app/views/spree/api/return_authorizations/new.v1.rabl b/api/app/views/spree/api/return_authorizations/new.v1.rabl deleted file mode 100644 index 362fa8ac9d..0000000000 --- a/api/app/views/spree/api/return_authorizations/new.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:attributes) { [*return_authorization_attributes] } -node(:required_attributes) { required_fields_for(Spree::ReturnAuthorization) } diff --git a/api/app/views/spree/api/return_authorizations/show.json.jbuilder b/api/app/views/spree/api/return_authorizations/show.json.jbuilder new file mode 100644 index 0000000000..2ce0691630 --- /dev/null +++ b/api/app/views/spree/api/return_authorizations/show.json.jbuilder @@ -0,0 +1 @@ +json.(@return_authorization, *return_authorization_attributes) diff --git a/api/app/views/spree/api/return_authorizations/show.v1.rabl b/api/app/views/spree/api/return_authorizations/show.v1.rabl deleted file mode 100644 index 00b07a3b1c..0000000000 --- a/api/app/views/spree/api/return_authorizations/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @return_authorization -attributes *return_authorization_attributes \ No newline at end of file diff --git a/api/app/views/spree/api/shipments/_big.json.jbuilder b/api/app/views/spree/api/shipments/_big.json.jbuilder new file mode 100644 index 0000000000..f854c97357 --- /dev/null +++ b/api/app/views/spree/api/shipments/_big.json.jbuilder @@ -0,0 +1,43 @@ +json.(shipment, *shipment_attributes) +if shipment.selected_shipping_rate + json.selected_shipping_rate do + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipment.selected_shipping_rate) + end +end +json.inventory_units(shipment.inventory_units) do |inventory_unit| + json.(inventory_unit, *inventory_unit_attributes) + json.variant do + json.partial!("spree/api/variants/small", variant: inventory_unit.variant) + json.(inventory_unit.variant, :product_id) + json.images(inventory_unit.variant.images) do |image| + json.partial!("spree/api/images/image", image: image) + end + end + json.line_item do + json.(inventory_unit.line_item, *line_item_attributes) + json.single_display_amount(inventory_unit.line_item.single_display_amount.to_s) + json.display_amount(inventory_unit.line_item.display_amount.to_s) + json.total(inventory_unit.line_item.total) + end +end +json.order do + json.partial!("spree/api/orders/order", order: shipment.order) + json.bill_address do + json.partial!("spree/api/addresses/address", address: shipment.order.billing_address) + end + json.ship_address do + json.partial!("spree/api/addresses/address", address: shipment.order.shipping_address) + end + json.adjustments(shipment.order.adjustments) do |adjustment| + json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) + end + json.payments(shipment.order.payments) do |payment| + json.(payment, :id, :amount, :display_amount, :state) + json.source do + attrs = [:id] + (attrs << :cc_type) if payment.source.respond_to?(:cc_type) + json.(payment.source, *attrs) + end + json.payment_method { json.(payment.payment_method, :id, :name) } + end +end diff --git a/api/app/views/spree/api/shipments/_small.json.jbuilder b/api/app/views/spree/api/shipments/_small.json.jbuilder new file mode 100644 index 0000000000..9e5c07853f --- /dev/null +++ b/api/app/views/spree/api/shipments/_small.json.jbuilder @@ -0,0 +1,28 @@ +json.(shipment, *shipment_attributes) +json.order_id(shipment.order.number) +json.stock_location_name(shipment.stock_location.name) +json.shipping_rates(shipment.shipping_rates) do |shipping_rate| + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipping_rate) +end +if shipment.selected_shipping_rate + json.selected_shipping_rate do + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipment.selected_shipping_rate) + end +end +json.shipping_methods(shipment.shipping_methods) do |shipping_method| + json.(shipping_method, :id, :code, :name) + json.zones(shipping_method.zones) do |zone| + json.(zone, :id, :name, :description) + end + json.shipping_categories(shipping_method.shipping_categories) do |shipping_category| + json.(shipping_category, :id, :name) + end +end +json.manifest(shipment.manifest) do |manifest_item| + json.variant_id manifest_item.variant.id + json.quantity(manifest_item.quantity) + json.states(manifest_item.states) +end +json.adjustments(shipment.adjustments) do |adjustment| + json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) +end diff --git a/api/app/views/spree/api/shipments/big.v1.rabl b/api/app/views/spree/api/shipments/big.v1.rabl deleted file mode 100644 index ebfeb23574..0000000000 --- a/api/app/views/spree/api/shipments/big.v1.rabl +++ /dev/null @@ -1,55 +0,0 @@ -object @shipment -cache @shipment -attributes *shipment_attributes - -child selected_shipping_rate: :selected_shipping_rate do - extends "spree/api/shipping_rates/show" -end - -child inventory_units: :inventory_units do - object @inventory_unit - attributes *inventory_unit_attributes - - child :variant do - extends "spree/api/variants/small" - attributes :product_id - child(images: :images) { extends "spree/api/images/show" } - end - - child :line_item do - attributes *line_item_attributes - node(:single_display_amount) { |li| li.single_display_amount.to_s } - node(:display_amount) { |li| li.display_amount.to_s } - node(:total) { |li| li.total } - end -end - -child order: :order do - extends "spree/api/orders/order" - - child billing_address: :bill_address do - extends "spree/api/addresses/show" - end - - child shipping_address: :ship_address do - extends "spree/api/addresses/show" - end - - child adjustments: :adjustments do - extends "spree/api/adjustments/show" - end - - child payments: :payments do - attributes :id, :amount, :display_amount, :state - child source: :source do |s| - attrs = [:id] - if s.respond_to?(:cc_type) - attrs << :cc_type - end - attributes *attrs - end - child payment_method: :payment_method do - attributes :id, :name - end - end -end diff --git a/api/app/views/spree/api/shipments/cannot_ready_shipment.json.jbuilder b/api/app/views/spree/api/shipments/cannot_ready_shipment.json.jbuilder new file mode 100644 index 0000000000..7744861841 --- /dev/null +++ b/api/app/views/spree/api/shipments/cannot_ready_shipment.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:cannot_ready, scope: "spree.api.shipment")) diff --git a/api/app/views/spree/api/shipments/cannot_ready_shipment.v1.rabl b/api/app/views/spree/api/shipments/cannot_ready_shipment.v1.rabl deleted file mode 100644 index aab55663d0..0000000000 --- a/api/app/views/spree/api/shipments/cannot_ready_shipment.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:cannot_ready, :scope => "spree.api.shipment") } diff --git a/api/app/views/spree/api/shipments/mine.json.jbuilder b/api/app/views/spree/api/shipments/mine.json.jbuilder new file mode 100644 index 0000000000..abedfbbf0e --- /dev/null +++ b/api/app/views/spree/api/shipments/mine.json.jbuilder @@ -0,0 +1,6 @@ +json.count(@shipments.count) +json.current_page(@shipments.current_page) +json.pages(@shipments.total_pages) +json.shipments(@shipments) do |shipment| + json.partial!("spree/api/shipments/big", shipment: shipment) +end diff --git a/api/app/views/spree/api/shipments/mine.v1.rabl b/api/app/views/spree/api/shipments/mine.v1.rabl deleted file mode 100644 index 6b2192bffc..0000000000 --- a/api/app/views/spree/api/shipments/mine.v1.rabl +++ /dev/null @@ -1,9 +0,0 @@ -object false - -node(:count) { @shipments.count } -node(:current_page) { @shipments.current_page } -node(:pages) { @shipments.total_pages } - -child(@shipments => :shipments) do - extends "spree/api/shipments/big" -end diff --git a/api/app/views/spree/api/shipments/show.json.jbuilder b/api/app/views/spree/api/shipments/show.json.jbuilder new file mode 100644 index 0000000000..5998d86f6d --- /dev/null +++ b/api/app/views/spree/api/shipments/show.json.jbuilder @@ -0,0 +1,27 @@ +json.(@shipment, *shipment_attributes) +json.order_id(@shipment.order.number) +json.stock_location_name(@shipment.stock_location.name) +json.shipping_rates(@shipment.shipping_rates) do |shipping_rate| + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipping_rate) +end +if @shipment.selected_shipping_rate + json.selected_shipping_rate do + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: @shipment.selected_shipping_rate) + end +end +json.shipping_methods(@shipment.shipping_methods) do |shipping_method| + json.(shipping_method, :id, :name) + json.zones(shipping_method.zones) do |zone| + json.(zone, :id, :name, :description) + end + json.shipping_categories(shipping_method.shipping_categories) do |shipping_category| + json.(shipping_category, :id, :name) + end +end +json.manifest(@shipment.manifest) do |manifest_item| + json.variant do + json.partial!("spree/api/variants/small", variant: manifest_item.variant) + end + json.quantity(manifest_item.quantity) + json.states(manifest_item.states) +end diff --git a/api/app/views/spree/api/shipments/show.v1.rabl b/api/app/views/spree/api/shipments/show.v1.rabl deleted file mode 100644 index 03b72bbc9d..0000000000 --- a/api/app/views/spree/api/shipments/show.v1.rabl +++ /dev/null @@ -1,32 +0,0 @@ -object @shipment -cache [I18n.locale, root_object] -attributes *shipment_attributes -node(:order_id) { |shipment| shipment.order.number } -node(:stock_location_name) { |shipment| shipment.stock_location.name } - -child :shipping_rates => :shipping_rates do - extends "spree/api/shipping_rates/show" -end - -child :selected_shipping_rate => :selected_shipping_rate do - extends "spree/api/shipping_rates/show" -end - -child :shipping_methods => :shipping_methods do - attributes :id, :name - child :zones => :zones do - attributes :id, :name, :description - end - - child :shipping_categories => :shipping_categories do - attributes :id, :name - end -end - -child :manifest => :manifest do - child :variant => :variant do - extends "spree/api/variants/small" - end - node(:quantity) { |m| m.quantity } - node(:states) { |m| m.states } -end diff --git a/api/app/views/spree/api/shipments/small.v1.rabl b/api/app/views/spree/api/shipments/small.v1.rabl deleted file mode 100644 index 3b8ef49118..0000000000 --- a/api/app/views/spree/api/shipments/small.v1.rabl +++ /dev/null @@ -1,37 +0,0 @@ -object @shipment -cache [I18n.locale, 'small_shipment', root_object] - -attributes *shipment_attributes -node(:order_id) { |shipment| shipment.order.number } -node(:stock_location_name) { |shipment| shipment.stock_location.name } - -child :shipping_rates => :shipping_rates do - extends "spree/api/shipping_rates/show" -end - -child :selected_shipping_rate => :selected_shipping_rate do - extends "spree/api/shipping_rates/show" -end - -child :shipping_methods => :shipping_methods do - attributes :id, :code, :name - child :zones => :zones do - attributes :id, :name, :description - end - - child :shipping_categories => :shipping_categories do - attributes :id, :name - end -end - -child :manifest => :manifest do - glue(:variant) do - attribute :id => :variant_id - end - node(:quantity) { |m| m.quantity } - node(:states) { |m| m.states } -end - -child :adjustments => :adjustments do - extends "spree/api/adjustments/show" -end diff --git a/api/app/views/spree/api/shipping_rates/_shipping_rate.json.jbuilder b/api/app/views/spree/api/shipping_rates/_shipping_rate.json.jbuilder new file mode 100644 index 0000000000..1e8d40b18b --- /dev/null +++ b/api/app/views/spree/api/shipping_rates/_shipping_rate.json.jbuilder @@ -0,0 +1,2 @@ +json.(shipping_rate, :id, :name, :cost, :selected, :shipping_method_id, :shipping_method_code) +json.display_cost(shipping_rate.display_cost.to_s) diff --git a/api/app/views/spree/api/shipping_rates/show.v1.rabl b/api/app/views/spree/api/shipping_rates/show.v1.rabl deleted file mode 100644 index 64809f39ed..0000000000 --- a/api/app/views/spree/api/shipping_rates/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -attributes :id, :name, :cost, :selected, :shipping_method_id, :shipping_method_code -node(:display_cost) { |sr| sr.display_cost.to_s } diff --git a/api/app/views/spree/api/states/index.json.jbuilder b/api/app/views/spree/api/states/index.json.jbuilder new file mode 100644 index 0000000000..63b95ba89e --- /dev/null +++ b/api/app/views/spree/api/states/index.json.jbuilder @@ -0,0 +1,7 @@ +json.states_required(@country.states_required) if @country +json.states(@states) { |state| json.(state, *state_attributes) } +if @states.respond_to?(:total_pages) + json.count(@states.count) + json.current_page(@states.current_page) + json.pages(@states.total_pages) +end diff --git a/api/app/views/spree/api/states/index.v1.rabl b/api/app/views/spree/api/states/index.v1.rabl deleted file mode 100644 index c0fc8e3ffc..0000000000 --- a/api/app/views/spree/api/states/index.v1.rabl +++ /dev/null @@ -1,14 +0,0 @@ -object false -if @country - node(:states_required) { @country.states_required } -end - -child(@states => :states) do - attributes *state_attributes -end - -if @states.respond_to?(:total_pages) - node(:count) { @states.count } - node(:current_page) { @states.current_page } - node(:pages) { @states.total_pages } -end diff --git a/api/app/views/spree/api/states/show.json.jbuilder b/api/app/views/spree/api/states/show.json.jbuilder new file mode 100644 index 0000000000..4cf31b89d6 --- /dev/null +++ b/api/app/views/spree/api/states/show.json.jbuilder @@ -0,0 +1 @@ +json.(@state, *state_attributes) diff --git a/api/app/views/spree/api/states/show.v1.rabl b/api/app/views/spree/api/states/show.v1.rabl deleted file mode 100644 index 3b7533d511..0000000000 --- a/api/app/views/spree/api/states/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @state -attributes *state_attributes diff --git a/api/app/views/spree/api/stock_items/_stock_item.json.jbuilder b/api/app/views/spree/api/stock_items/_stock_item.json.jbuilder new file mode 100644 index 0000000000..4d38a389fc --- /dev/null +++ b/api/app/views/spree/api/stock_items/_stock_item.json.jbuilder @@ -0,0 +1,4 @@ +json.(stock_item, *stock_item_attributes) +json.variant do + json.partial!("spree/api/variants/small", variant: stock_item.variant) +end diff --git a/api/app/views/spree/api/stock_items/index.json.jbuilder b/api/app/views/spree/api/stock_items/index.json.jbuilder new file mode 100644 index 0000000000..9484871619 --- /dev/null +++ b/api/app/views/spree/api/stock_items/index.json.jbuilder @@ -0,0 +1,6 @@ +json.stock_items(@stock_items) do |stock_item| + json.partial!("spree/api/stock_items/stock_item", stock_item: stock_item) +end +json.count(@stock_items.count) +json.current_page(@stock_items.current_page) +json.pages(@stock_items.total_pages) diff --git a/api/app/views/spree/api/stock_items/index.v1.rabl b/api/app/views/spree/api/stock_items/index.v1.rabl deleted file mode 100644 index 742c829843..0000000000 --- a/api/app/views/spree/api/stock_items/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@stock_items => :stock_items) do - extends 'spree/api/stock_items/show' -end -node(:count) { @stock_items.count } -node(:current_page) { @stock_items.current_page } -node(:pages) { @stock_items.total_pages } diff --git a/api/app/views/spree/api/stock_items/show.json.jbuilder b/api/app/views/spree/api/stock_items/show.json.jbuilder new file mode 100644 index 0000000000..ca7bc82d7e --- /dev/null +++ b/api/app/views/spree/api/stock_items/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/stock_items/stock_item", stock_item: @stock_item) diff --git a/api/app/views/spree/api/stock_items/show.v1.rabl b/api/app/views/spree/api/stock_items/show.v1.rabl deleted file mode 100644 index bc96704cdb..0000000000 --- a/api/app/views/spree/api/stock_items/show.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -object @stock_item -attributes *stock_item_attributes -child(:variant) do - extends "spree/api/variants/small" -end diff --git a/api/app/views/spree/api/stock_locations/_stock_location.json.jbuilder b/api/app/views/spree/api/stock_locations/_stock_location.json.jbuilder new file mode 100644 index 0000000000..cd1b1634e1 --- /dev/null +++ b/api/app/views/spree/api/stock_locations/_stock_location.json.jbuilder @@ -0,0 +1,7 @@ +json.(stock_location, *stock_location_attributes) +if stock_location.country + json.country { json.(stock_location.country, *country_attributes) } +end +if stock_location.state + json.state { json.(stock_location.state, *state_attributes) } +end diff --git a/api/app/views/spree/api/stock_locations/index.json.jbuilder b/api/app/views/spree/api/stock_locations/index.json.jbuilder new file mode 100644 index 0000000000..28a9e34f87 --- /dev/null +++ b/api/app/views/spree/api/stock_locations/index.json.jbuilder @@ -0,0 +1,6 @@ +json.stock_locations(@stock_locations) do |stock_location| + json.partial!("spree/api/stock_locations/stock_location", stock_location: stock_location) +end +json.count(@stock_locations.count) +json.current_page(@stock_locations.current_page) +json.pages(@stock_locations.total_pages) diff --git a/api/app/views/spree/api/stock_locations/index.v1.rabl b/api/app/views/spree/api/stock_locations/index.v1.rabl deleted file mode 100644 index 9f73c2edb1..0000000000 --- a/api/app/views/spree/api/stock_locations/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@stock_locations => :stock_locations) do - extends 'spree/api/stock_locations/show' -end -node(:count) { @stock_locations.count } -node(:current_page) { @stock_locations.current_page } -node(:pages) { @stock_locations.total_pages } diff --git a/api/app/views/spree/api/stock_locations/show.json.jbuilder b/api/app/views/spree/api/stock_locations/show.json.jbuilder new file mode 100644 index 0000000000..ce36b6ac8f --- /dev/null +++ b/api/app/views/spree/api/stock_locations/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/stock_locations/stock_location", stock_location: @stock_location) diff --git a/api/app/views/spree/api/stock_locations/show.v1.rabl b/api/app/views/spree/api/stock_locations/show.v1.rabl deleted file mode 100644 index 898e12e88c..0000000000 --- a/api/app/views/spree/api/stock_locations/show.v1.rabl +++ /dev/null @@ -1,8 +0,0 @@ -object @stock_location -attributes *stock_location_attributes -child(:country) do |address| - attributes *country_attributes -end -child(:state) do |address| - attributes *state_attributes -end diff --git a/api/app/views/spree/api/stock_movements/_stock_movement.json.jbuilder b/api/app/views/spree/api/stock_movements/_stock_movement.json.jbuilder new file mode 100644 index 0000000000..707ec5ecb1 --- /dev/null +++ b/api/app/views/spree/api/stock_movements/_stock_movement.json.jbuilder @@ -0,0 +1,4 @@ +json.(stock_movement, *stock_movement_attributes) +json.stock_item do + json.partial!("spree/api/stock_items/stock_item", stock_item: stock_movement.stock_item) +end diff --git a/api/app/views/spree/api/stock_movements/index.json.jbuilder b/api/app/views/spree/api/stock_movements/index.json.jbuilder new file mode 100644 index 0000000000..e4448fa288 --- /dev/null +++ b/api/app/views/spree/api/stock_movements/index.json.jbuilder @@ -0,0 +1,6 @@ +json.stock_movements(@stock_movements) do |stock_movement| + json.partial!("spree/api/stock_movements/stock_movement", stock_movement: stock_movement) +end +json.count(@stock_movements.count) +json.current_page(@stock_movements.current_page) +json.pages(@stock_movements.total_pages) diff --git a/api/app/views/spree/api/stock_movements/index.v1.rabl b/api/app/views/spree/api/stock_movements/index.v1.rabl deleted file mode 100644 index a1e95af2e2..0000000000 --- a/api/app/views/spree/api/stock_movements/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@stock_movements => :stock_movements) do - extends 'spree/api/stock_movements/show' -end -node(:count) { @stock_movements.count } -node(:current_page) { @stock_movements.current_page } -node(:pages) { @stock_movements.total_pages } diff --git a/api/app/views/spree/api/stock_movements/show.json.jbuilder b/api/app/views/spree/api/stock_movements/show.json.jbuilder new file mode 100644 index 0000000000..4d80c79a6a --- /dev/null +++ b/api/app/views/spree/api/stock_movements/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/stock_movements/stock_movement", stock_movement: @stock_movement) diff --git a/api/app/views/spree/api/stock_movements/show.v1.rabl b/api/app/views/spree/api/stock_movements/show.v1.rabl deleted file mode 100644 index 93dff52e7b..0000000000 --- a/api/app/views/spree/api/stock_movements/show.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -object @stock_movement -attributes *stock_movement_attributes -child :stock_item do - extends "spree/api/stock_items/show" -end diff --git a/api/app/views/spree/api/stock_transfers/receive.json.jbuilder b/api/app/views/spree/api/stock_transfers/receive.json.jbuilder new file mode 100644 index 0000000000..94f7c66b87 --- /dev/null +++ b/api/app/views/spree/api/stock_transfers/receive.json.jbuilder @@ -0,0 +1,4 @@ +json.(@stock_transfer, *stock_transfer_attributes) +json.received_item do + json.partial!("spree/api/transfer_items/transfer_item", transfer_item: @transfer_item) +end diff --git a/api/app/views/spree/api/stock_transfers/receive.v1.rabl b/api/app/views/spree/api/stock_transfers/receive.v1.rabl deleted file mode 100644 index d165912e80..0000000000 --- a/api/app/views/spree/api/stock_transfers/receive.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -object @stock_transfer -attributes *stock_transfer_attributes -node(:received_item) do - partial('spree/api/transfer_items/show', object: @transfer_item) -end diff --git a/api/app/views/spree/api/store_credit_events/mine.json.jbuilder b/api/app/views/spree/api/store_credit_events/mine.json.jbuilder new file mode 100644 index 0000000000..84a81ca2ac --- /dev/null +++ b/api/app/views/spree/api/store_credit_events/mine.json.jbuilder @@ -0,0 +1,7 @@ +json.store_credit_events(@store_credit_events) do |store_credit_event| + json.(store_credit_event, *store_credit_history_attributes) + json.order_number(store_credit_event.order.try(:number)) +end +json.count(@store_credit_events.count) +json.current_page(@store_credit_events.current_page) +json.pages(@store_credit_events.total_pages) diff --git a/api/app/views/spree/api/store_credit_events/mine.v1.rabl b/api/app/views/spree/api/store_credit_events/mine.v1.rabl deleted file mode 100644 index 34a4d8b20e..0000000000 --- a/api/app/views/spree/api/store_credit_events/mine.v1.rabl +++ /dev/null @@ -1,10 +0,0 @@ -object false - -child(@store_credit_events => :store_credit_events) do - attributes *store_credit_history_attributes - node(:order_number) { |event| event.order.try(:number) } -end - -node(:count) { @store_credit_events.count } -node(:current_page) { @store_credit_events.current_page } -node(:pages) { @store_credit_events.total_pages } diff --git a/api/app/views/spree/api/stores/index.json.jbuilder b/api/app/views/spree/api/stores/index.json.jbuilder new file mode 100644 index 0000000000..9d0e0c6f1e --- /dev/null +++ b/api/app/views/spree/api/stores/index.json.jbuilder @@ -0,0 +1 @@ +json.stores(@stores) { |store| json.(store, *store_attributes) } diff --git a/api/app/views/spree/api/stores/index.v1.rabl b/api/app/views/spree/api/stores/index.v1.rabl deleted file mode 100644 index ae547356bb..0000000000 --- a/api/app/views/spree/api/stores/index.v1.rabl +++ /dev/null @@ -1,4 +0,0 @@ -object false -child(@stores => :stores) do - attributes *store_attributes -end diff --git a/api/app/views/spree/api/stores/show.json.jbuilder b/api/app/views/spree/api/stores/show.json.jbuilder new file mode 100644 index 0000000000..cbd0823e78 --- /dev/null +++ b/api/app/views/spree/api/stores/show.json.jbuilder @@ -0,0 +1 @@ +json.(@store, *store_attributes) diff --git a/api/app/views/spree/api/stores/show.v1.rabl b/api/app/views/spree/api/stores/show.v1.rabl deleted file mode 100644 index a0e1941b72..0000000000 --- a/api/app/views/spree/api/stores/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @store -attributes *store_attributes diff --git a/api/app/views/spree/api/taxonomies/_nested.json.jbuilder b/api/app/views/spree/api/taxonomies/_nested.json.jbuilder new file mode 100644 index 0000000000..e64ca55d8b --- /dev/null +++ b/api/app/views/spree/api/taxonomies/_nested.json.jbuilder @@ -0,0 +1,8 @@ +json.(taxonomy, *taxonomy_attributes) +json.root do + json.(taxonomy.root, *taxon_attributes) + json.taxons(taxonomy.root.children) do |taxon| + json.(taxon, *taxon_attributes) + json.partial!("spree/api/taxons/taxons", taxon: taxon) + end +end diff --git a/api/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder b/api/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder new file mode 100644 index 0000000000..35f321ed13 --- /dev/null +++ b/api/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder @@ -0,0 +1,11 @@ +if params[:set] == "nested" + json.partial!("spree/api/taxonomies/nested", taxonomy: taxonomy) +else + json.(taxonomy, *taxonomy_attributes) + json.root do + json.(taxonomy.root, *taxon_attributes) + json.taxons(taxonomy.root.children) do |taxon| + json.(taxon, *taxon_attributes) + end + end +end diff --git a/api/app/views/spree/api/taxonomies/index.json.jbuilder b/api/app/views/spree/api/taxonomies/index.json.jbuilder new file mode 100644 index 0000000000..3709de6358 --- /dev/null +++ b/api/app/views/spree/api/taxonomies/index.json.jbuilder @@ -0,0 +1,6 @@ +json.taxonomies(@taxonomies) do |taxonomy| + json.partial!("spree/api/taxonomies/taxonomy", taxonomy: taxonomy) +end +json.count(@taxonomies.count) +json.current_page(@taxonomies.current_page) +json.pages(@taxonomies.total_pages) diff --git a/api/app/views/spree/api/taxonomies/index.v1.rabl b/api/app/views/spree/api/taxonomies/index.v1.rabl deleted file mode 100644 index 1d6d75893e..0000000000 --- a/api/app/views/spree/api/taxonomies/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@taxonomies => :taxonomies) do - extends "spree/api/taxonomies/show" -end -node(:count) { @taxonomies.count } -node(:current_page) { @taxonomies.current_page } -node(:pages) { @taxonomies.total_pages } diff --git a/api/app/views/spree/api/taxonomies/jstree.json.jbuilder b/api/app/views/spree/api/taxonomies/jstree.json.jbuilder new file mode 100644 index 0000000000..1dbbd6ff29 --- /dev/null +++ b/api/app/views/spree/api/taxonomies/jstree.json.jbuilder @@ -0,0 +1,6 @@ +json.data @taxonomy.root.name +json.attr do + json.id @taxonomy.root.id + json.name @taxonomy.root.name +end +json.state "closed" diff --git a/api/app/views/spree/api/taxonomies/jstree.rabl b/api/app/views/spree/api/taxonomies/jstree.rabl deleted file mode 100644 index 01b25aa4cc..0000000000 --- a/api/app/views/spree/api/taxonomies/jstree.rabl +++ /dev/null @@ -1,8 +0,0 @@ -object false -node(:data) { @taxonomy.root.name } -node(:attr) do - { :id => @taxonomy.root.id, - :name => @taxonomy.root.name - } -end -node(:state) { "closed" } diff --git a/api/app/views/spree/api/taxonomies/nested.v1.rabl b/api/app/views/spree/api/taxonomies/nested.v1.rabl deleted file mode 100644 index 312c29140a..0000000000 --- a/api/app/views/spree/api/taxonomies/nested.v1.rabl +++ /dev/null @@ -1,11 +0,0 @@ -attributes *taxonomy_attributes - -child :root => :root do - attributes *taxon_attributes - - child :children => :taxons do - attributes *taxon_attributes - - extends "spree/api/taxons/taxons" - end -end diff --git a/api/app/views/spree/api/taxonomies/new.json.jbuilder b/api/app/views/spree/api/taxonomies/new.json.jbuilder new file mode 100644 index 0000000000..e1d8889880 --- /dev/null +++ b/api/app/views/spree/api/taxonomies/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*taxonomy_attributes]) +json.required_attributes(required_fields_for(Spree::Taxonomy)) diff --git a/api/app/views/spree/api/taxonomies/new.v1.rabl b/api/app/views/spree/api/taxonomies/new.v1.rabl deleted file mode 100644 index a3dd32d4ef..0000000000 --- a/api/app/views/spree/api/taxonomies/new.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:attributes) { [*taxonomy_attributes] } -node(:required_attributes) { required_fields_for(Spree::Taxonomy) } diff --git a/api/app/views/spree/api/taxonomies/show.json.jbuilder b/api/app/views/spree/api/taxonomies/show.json.jbuilder new file mode 100644 index 0000000000..dac36f65e1 --- /dev/null +++ b/api/app/views/spree/api/taxonomies/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/taxonomies/taxonomy", taxonomy: @taxonomy) diff --git a/api/app/views/spree/api/taxonomies/show.v1.rabl b/api/app/views/spree/api/taxonomies/show.v1.rabl deleted file mode 100644 index 37d2a1615b..0000000000 --- a/api/app/views/spree/api/taxonomies/show.v1.rabl +++ /dev/null @@ -1,15 +0,0 @@ -object @taxonomy - -if params[:set] == 'nested' - extends "spree/api/taxonomies/nested" -else - attributes *taxonomy_attributes - - child :root => :root do - attributes *taxon_attributes - - child :children => :taxons do - attributes *taxon_attributes - end - end -end diff --git a/api/app/views/spree/api/taxons/_taxon.json.jbuilder b/api/app/views/spree/api/taxons/_taxon.json.jbuilder new file mode 100644 index 0000000000..88ff92e6a4 --- /dev/null +++ b/api/app/views/spree/api/taxons/_taxon.json.jbuilder @@ -0,0 +1,2 @@ +json.(taxon, *taxon_attributes) +json.taxons(taxon.children) { |taxon| json.(taxon, *taxon_attributes) } diff --git a/api/app/views/spree/api/taxons/_taxons.json.jbuilder b/api/app/views/spree/api/taxons/_taxons.json.jbuilder new file mode 100644 index 0000000000..96d8170ea6 --- /dev/null +++ b/api/app/views/spree/api/taxons/_taxons.json.jbuilder @@ -0,0 +1,4 @@ +json.taxons(taxon.children) do |taxon| + json.(taxon, *taxon_attributes) + json.partial!("spree/api/taxons/taxons", taxon: taxon) +end diff --git a/api/app/views/spree/api/taxons/index.json.jbuilder b/api/app/views/spree/api/taxons/index.json.jbuilder new file mode 100644 index 0000000000..8fa85e5ffb --- /dev/null +++ b/api/app/views/spree/api/taxons/index.json.jbuilder @@ -0,0 +1,11 @@ +json.count(@taxons.count) +json.total_count(@taxons.total_count) +json.current_page(@taxons.current_page) +json.per_page(@taxons.limit_value) +json.pages(@taxons.total_pages) +json.taxons(@taxons) do |taxon| + json.(taxon, *taxon_attributes) + unless params[:without_children] + json.partial!("spree/api/taxons/taxons", taxon: taxon) + end +end diff --git a/api/app/views/spree/api/taxons/index.v1.rabl b/api/app/views/spree/api/taxons/index.v1.rabl deleted file mode 100644 index c6e520cdb7..0000000000 --- a/api/app/views/spree/api/taxons/index.v1.rabl +++ /dev/null @@ -1,12 +0,0 @@ -object false -node(:count) { @taxons.count } -node(:total_count) { @taxons.total_count } -node(:current_page) { @taxons.current_page } -node(:per_page) { @taxons.limit_value } -node(:pages) { @taxons.total_pages } -child @taxons => :taxons do - attributes *taxon_attributes - unless params[:without_children] - extends "spree/api/taxons/taxons" - end -end diff --git a/api/app/views/spree/api/taxons/jstree.json.jbuilder b/api/app/views/spree/api/taxons/jstree.json.jbuilder new file mode 100644 index 0000000000..2962875f99 --- /dev/null +++ b/api/app/views/spree/api/taxons/jstree.json.jbuilder @@ -0,0 +1,8 @@ +json.array!(@taxon.children) do |taxon| + json.data taxon.name + json.attr do + json.id taxon.id + json.name taxon.name + end + json.state "closed" +end diff --git a/api/app/views/spree/api/taxons/jstree.rabl b/api/app/views/spree/api/taxons/jstree.rabl deleted file mode 100644 index aed500e0f3..0000000000 --- a/api/app/views/spree/api/taxons/jstree.rabl +++ /dev/null @@ -1,8 +0,0 @@ -collection @taxon.children, :object_root => false -node(:data) { |taxon| taxon.name } -node(:attr) do |taxon| - { :id => taxon.id, - :name => taxon.name - } -end -node(:state) { "closed" } diff --git a/api/app/views/spree/api/taxons/new.json.jbuilder b/api/app/views/spree/api/taxons/new.json.jbuilder new file mode 100644 index 0000000000..dce58bf133 --- /dev/null +++ b/api/app/views/spree/api/taxons/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*taxon_attributes]) +json.required_attributes(required_fields_for(Spree::Taxon)) diff --git a/api/app/views/spree/api/taxons/new.v1.rabl b/api/app/views/spree/api/taxons/new.v1.rabl deleted file mode 100644 index f85dbece9e..0000000000 --- a/api/app/views/spree/api/taxons/new.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:attributes) { [*taxon_attributes] } -node(:required_attributes) { required_fields_for(Spree::Taxon) } diff --git a/api/app/views/spree/api/taxons/show.json.jbuilder b/api/app/views/spree/api/taxons/show.json.jbuilder new file mode 100644 index 0000000000..acf20b0d7c --- /dev/null +++ b/api/app/views/spree/api/taxons/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/taxons/taxon", taxon: @taxon) diff --git a/api/app/views/spree/api/taxons/show.v1.rabl b/api/app/views/spree/api/taxons/show.v1.rabl deleted file mode 100644 index 37a1c1bd90..0000000000 --- a/api/app/views/spree/api/taxons/show.v1.rabl +++ /dev/null @@ -1,6 +0,0 @@ -object @taxon -attributes *taxon_attributes - -child :children => :taxons do - attributes *taxon_attributes -end diff --git a/api/app/views/spree/api/taxons/taxons.v1.rabl b/api/app/views/spree/api/taxons/taxons.v1.rabl deleted file mode 100644 index e7a1e4239e..0000000000 --- a/api/app/views/spree/api/taxons/taxons.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -child :children => :taxons do - attributes *taxon_attributes - - extends "spree/api/taxons/taxons" -end diff --git a/api/app/views/spree/api/transfer_items/_transfer_item.json.jbuilder b/api/app/views/spree/api/transfer_items/_transfer_item.json.jbuilder new file mode 100644 index 0000000000..a5d7db5f4d --- /dev/null +++ b/api/app/views/spree/api/transfer_items/_transfer_item.json.jbuilder @@ -0,0 +1,5 @@ +json.(transfer_item, *transfer_item_attributes) +json.variant do + json.partial!("spree/api/variants/small", variant: transfer_item.variant) + json.(transfer_item.variant, *transfer_item_variant_attributes) +end diff --git a/api/app/views/spree/api/transfer_items/show.json.jbuilder b/api/app/views/spree/api/transfer_items/show.json.jbuilder new file mode 100644 index 0000000000..d7f1545e36 --- /dev/null +++ b/api/app/views/spree/api/transfer_items/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/transfer_items/transfer_item", transfer_item: @transfer_item) diff --git a/api/app/views/spree/api/transfer_items/show.v1.rabl b/api/app/views/spree/api/transfer_items/show.v1.rabl deleted file mode 100644 index 062adc054a..0000000000 --- a/api/app/views/spree/api/transfer_items/show.v1.rabl +++ /dev/null @@ -1,6 +0,0 @@ -object @transfer_item -attributes *transfer_item_attributes -child(:variant) do - extends "spree/api/variants/small" - attributes *transfer_item_variant_attributes -end diff --git a/api/app/views/spree/api/users/_user.json.jbuilder b/api/app/views/spree/api/users/_user.json.jbuilder new file mode 100644 index 0000000000..a09ae14732 --- /dev/null +++ b/api/app/views/spree/api/users/_user.json.jbuilder @@ -0,0 +1,7 @@ +json.(user, *user_attributes) +json.bill_address do + json.partial!("spree/api/addresses/address", address: user.bill_address) +end +json.ship_address do + json.partial!("spree/api/addresses/address", address: user.ship_address) +end diff --git a/api/app/views/spree/api/users/index.json.jbuilder b/api/app/views/spree/api/users/index.json.jbuilder new file mode 100644 index 0000000000..8df9fb496b --- /dev/null +++ b/api/app/views/spree/api/users/index.json.jbuilder @@ -0,0 +1,6 @@ +json.users(@users) do |user| + json.partial!("spree/api/users/user", user: user) +end +json.count(@users.count) +json.current_page(@users.current_page) +json.pages(@users.total_pages) diff --git a/api/app/views/spree/api/users/index.v1.rabl b/api/app/views/spree/api/users/index.v1.rabl deleted file mode 100644 index ff8da9768f..0000000000 --- a/api/app/views/spree/api/users/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@users => :users) do - extends "spree/api/users/show" -end -node(:count) { @users.count } -node(:current_page) { @users.current_page } -node(:pages) { @users.total_pages } diff --git a/api/app/views/spree/api/users/new.json.jbuilder b/api/app/views/spree/api/users/new.json.jbuilder new file mode 100644 index 0000000000..79154283fb --- /dev/null +++ b/api/app/views/spree/api/users/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*user_attributes]) +json.required_attributes(required_fields_for(Spree.user_class)) diff --git a/api/app/views/spree/api/users/new.v1.rabl b/api/app/views/spree/api/users/new.v1.rabl deleted file mode 100644 index f3e36dd7d3..0000000000 --- a/api/app/views/spree/api/users/new.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:attributes) { [*user_attributes] } -node(:required_attributes) { required_fields_for(Spree.user_class) } diff --git a/api/app/views/spree/api/users/show.json.jbuilder b/api/app/views/spree/api/users/show.json.jbuilder new file mode 100644 index 0000000000..9490ace2f3 --- /dev/null +++ b/api/app/views/spree/api/users/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/users/user", user: @user) diff --git a/api/app/views/spree/api/users/show.v1.rabl b/api/app/views/spree/api/users/show.v1.rabl deleted file mode 100644 index 4448a3e7ed..0000000000 --- a/api/app/views/spree/api/users/show.v1.rabl +++ /dev/null @@ -1,10 +0,0 @@ -object @user - -attributes *user_attributes -child(:bill_address => :bill_address) do - extends "spree/api/addresses/show" -end - -child(:ship_address => :ship_address) do - extends "spree/api/addresses/show" -end \ No newline at end of file diff --git a/api/app/views/spree/api/variants/_big.json.jbuilder b/api/app/views/spree/api/variants/_big.json.jbuilder new file mode 100644 index 0000000000..612980edcf --- /dev/null +++ b/api/app/views/spree/api/variants/_big.json.jbuilder @@ -0,0 +1,11 @@ +json.(variant, *variant_attributes) +json.partial!("spree/api/variants/small", variant: variant) +json.total_on_hand(variant.total_on_hand) +json.variant_properties(variant.variant_properties) do |variant_property| + json.(variant_property, *variant_property_attributes) +end +json.stock_items(variant.stock_items.accessible_by(current_ability)) do |stock_item| + json.(stock_item, :id, :count_on_hand, :stock_location_id, :backorderable) + json.available stock_item.available? + json.stock_location_name(stock_item.stock_location.name) +end diff --git a/api/app/views/spree/api/variants/_small.json.jbuilder b/api/app/views/spree/api/variants/_small.json.jbuilder new file mode 100644 index 0000000000..ab94dfc91e --- /dev/null +++ b/api/app/views/spree/api/variants/_small.json.jbuilder @@ -0,0 +1,14 @@ +json.(variant, *variant_attributes) +json.display_price(variant.display_price.to_s) +json.options_text(variant.options_text) +json.track_inventory(variant.should_track_inventory?) +json.in_stock(variant.in_stock?) +json.is_backorderable(variant.is_backorderable?) +json.total_on_hand(variant.total_on_hand) +json.is_destroyed(variant.destroyed?) +json.option_values(variant.option_values) do |option_value| + json.(option_value, *option_value_attributes) +end +json.images(variant.images) do |image| + json.partial!("spree/api/images/image", image: image) +end diff --git a/api/app/views/spree/api/variants/big.v1.rabl b/api/app/views/spree/api/variants/big.v1.rabl deleted file mode 100644 index 4fd6d94a02..0000000000 --- a/api/app/views/spree/api/variants/big.v1.rabl +++ /dev/null @@ -1,20 +0,0 @@ -object @variant -attributes *variant_attributes - -cache [I18n.locale, Spree::StockLocation.accessible_by(current_ability).pluck(:id).sort.join(":"), 'big_variant', root_object] - -extends "spree/api/variants/small" - -node :total_on_hand do - root_object.total_on_hand -end - -child :variant_properties => :variant_properties do - attributes *variant_property_attributes -end - -child(root_object.stock_items.accessible_by(current_ability) => :stock_items) do - attributes :id, :count_on_hand, :stock_location_id, :backorderable - attribute :available? => :available - node(:stock_location_name) { |si| si.stock_location.name } -end diff --git a/api/app/views/spree/api/variants/index.json.jbuilder b/api/app/views/spree/api/variants/index.json.jbuilder new file mode 100644 index 0000000000..48e561ed61 --- /dev/null +++ b/api/app/views/spree/api/variants/index.json.jbuilder @@ -0,0 +1,7 @@ +json.count(@variants.count) +json.total_count(@variants.total_count) +json.current_page(@variants.current_page) +json.pages(@variants.total_pages) +json.variants(@variants) do |variant| + json.partial!("spree/api/variants/big", variant: variant) +end diff --git a/api/app/views/spree/api/variants/index.v1.rabl b/api/app/views/spree/api/variants/index.v1.rabl deleted file mode 100644 index 5c9485da3e..0000000000 --- a/api/app/views/spree/api/variants/index.v1.rabl +++ /dev/null @@ -1,9 +0,0 @@ -object false -node(:count) { @variants.count } -node(:total_count) { @variants.total_count } -node(:current_page) { @variants.current_page } -node(:pages) { @variants.total_pages } - -child(@variants => :variants) do - extends "spree/api/variants/big" -end diff --git a/api/app/views/spree/api/variants/new.json.jbuilder b/api/app/views/spree/api/variants/new.json.jbuilder new file mode 100644 index 0000000000..a779203e8a --- /dev/null +++ b/api/app/views/spree/api/variants/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*variant_attributes]) +json.required_attributes([]) diff --git a/api/app/views/spree/api/variants/new.v1.rabl b/api/app/views/spree/api/variants/new.v1.rabl deleted file mode 100644 index 26cf41db3b..0000000000 --- a/api/app/views/spree/api/variants/new.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -node(:attributes) { [*variant_attributes] } -node(:required_attributes) { [] } diff --git a/api/app/views/spree/api/variants/show.json.jbuilder b/api/app/views/spree/api/variants/show.json.jbuilder new file mode 100644 index 0000000000..ed96ac719c --- /dev/null +++ b/api/app/views/spree/api/variants/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/variants/big", variant: @variant) diff --git a/api/app/views/spree/api/variants/show.v1.rabl b/api/app/views/spree/api/variants/show.v1.rabl deleted file mode 100644 index b097e25551..0000000000 --- a/api/app/views/spree/api/variants/show.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object @variant -cache [I18n.locale, @current_user_roles.include?('admin'), 'show', root_object] -extends "spree/api/variants/big" diff --git a/api/app/views/spree/api/variants/small.v1.rabl b/api/app/views/spree/api/variants/small.v1.rabl deleted file mode 100644 index d6c025ba05..0000000000 --- a/api/app/views/spree/api/variants/small.v1.rabl +++ /dev/null @@ -1,17 +0,0 @@ -cache [I18n.locale, 'small_variant', root_object] - -attributes *variant_attributes - -node(:display_price) { |p| p.display_price.to_s } -node(:options_text) { |v| v.options_text } -node(:track_inventory) { |v| v.should_track_inventory? } -node(:in_stock) { |v| v.in_stock? } -node(:is_backorderable) { |v| v.is_backorderable? } -node(:total_on_hand) { |v| v.total_on_hand } -node(:is_destroyed) { |v| v.destroyed? } - -child :option_values => :option_values do - attributes *option_value_attributes -end - -child(:images => :images) { extends "spree/api/images/show" } diff --git a/api/app/views/spree/api/zones/_zone.json.jbuilder b/api/app/views/spree/api/zones/_zone.json.jbuilder new file mode 100644 index 0000000000..5a61e09561 --- /dev/null +++ b/api/app/views/spree/api/zones/_zone.json.jbuilder @@ -0,0 +1,4 @@ +json.(zone, :id, :name, :description) +json.zone_members(zone.zone_members) do |zone_member| + json.(zone_member, :id, :name, :zoneable_type, :zoneable_id) +end diff --git a/api/app/views/spree/api/zones/index.json.jbuilder b/api/app/views/spree/api/zones/index.json.jbuilder new file mode 100644 index 0000000000..a209f89573 --- /dev/null +++ b/api/app/views/spree/api/zones/index.json.jbuilder @@ -0,0 +1,6 @@ +json.zones(@zones) do |zone| + json.partial!("spree/api/zones/zone", zone: zone) +end +json.count(@zones.count) +json.current_page(@zones.current_page) +json.pages(@zones.total_pages) diff --git a/api/app/views/spree/api/zones/index.v1.rabl b/api/app/views/spree/api/zones/index.v1.rabl deleted file mode 100644 index f837124a2c..0000000000 --- a/api/app/views/spree/api/zones/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@zones => :zones) do - extends 'spree/api/zones/show' -end -node(:count) { @zones.count } -node(:current_page) { @zones.current_page } -node(:pages) { @zones.total_pages } diff --git a/api/app/views/spree/api/zones/show.json.jbuilder b/api/app/views/spree/api/zones/show.json.jbuilder new file mode 100644 index 0000000000..c6f16d5add --- /dev/null +++ b/api/app/views/spree/api/zones/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/zones/zone", zone: @zone) diff --git a/api/app/views/spree/api/zones/show.v1.rabl b/api/app/views/spree/api/zones/show.v1.rabl deleted file mode 100644 index c8c58d469c..0000000000 --- a/api/app/views/spree/api/zones/show.v1.rabl +++ /dev/null @@ -1,6 +0,0 @@ -object @zone -attributes :id, :name, :description - -child :zone_members => :zone_members do - attributes :id, :name, :zoneable_type, :zoneable_id -end diff --git a/api/spec/test_views/spree/api/widgets/_widget.json.jbuilder b/api/spec/test_views/spree/api/widgets/_widget.json.jbuilder new file mode 100644 index 0000000000..01468d5202 --- /dev/null +++ b/api/spec/test_views/spree/api/widgets/_widget.json.jbuilder @@ -0,0 +1 @@ +json.(widget, :id, :name, :position) diff --git a/api/spec/test_views/spree/api/widgets/index.json.jbuilder b/api/spec/test_views/spree/api/widgets/index.json.jbuilder new file mode 100644 index 0000000000..a0b8cd990b --- /dev/null +++ b/api/spec/test_views/spree/api/widgets/index.json.jbuilder @@ -0,0 +1,7 @@ + +json.widgets(@collection) do |widget| + json.partial!("spree/api/widgets/widget", widget: widget) +end +json.count @collection.count +json.current_page (params[:page] or 1) +json.pages @collection.total_pages diff --git a/api/spec/test_views/spree/api/widgets/index.v1.rabl b/api/spec/test_views/spree/api/widgets/index.v1.rabl deleted file mode 100644 index 403d65ea50..0000000000 --- a/api/spec/test_views/spree/api/widgets/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@collection => :widgets) do - extends "spree/api/widgets/show" -end -node(:count) { @collection.count } -node(:current_page) { params[:page] || 1 } -node(:pages) { @collection.total_pages } diff --git a/api/spec/test_views/spree/api/widgets/new.json.jbuilder b/api/spec/test_views/spree/api/widgets/new.json.jbuilder new file mode 100644 index 0000000000..487b7fa90b --- /dev/null +++ b/api/spec/test_views/spree/api/widgets/new.json.jbuilder @@ -0,0 +1 @@ +json.attributes [:name] diff --git a/api/spec/test_views/spree/api/widgets/new.v1.rabl b/api/spec/test_views/spree/api/widgets/new.v1.rabl deleted file mode 100644 index f1a3ddd5fc..0000000000 --- a/api/spec/test_views/spree/api/widgets/new.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:attributes) { [:name] } diff --git a/api/spec/test_views/spree/api/widgets/show.json.jbuilder b/api/spec/test_views/spree/api/widgets/show.json.jbuilder new file mode 100644 index 0000000000..ef552cf43a --- /dev/null +++ b/api/spec/test_views/spree/api/widgets/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/widgets/widget", widget: @object) diff --git a/api/spec/test_views/spree/api/widgets/show.v1.rabl b/api/spec/test_views/spree/api/widgets/show.v1.rabl deleted file mode 100644 index 7e5b6a7262..0000000000 --- a/api/spec/test_views/spree/api/widgets/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @object -attributes :id, :name, :position From 7be366deabff683510a740642bb7ff03b14cc576 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 9 Aug 2017 10:26:16 -0700 Subject: [PATCH 3/9] Remove RABL from API --- api/lib/spree/api.rb | 1 - api/lib/spree/api/engine.rb | 10 ---------- api/solidus_api.gemspec | 1 - 3 files changed, 12 deletions(-) diff --git a/api/lib/spree/api.rb b/api/lib/spree/api.rb index 889152191d..77f0b87f44 100644 --- a/api/lib/spree/api.rb +++ b/api/lib/spree/api.rb @@ -1,6 +1,5 @@ require 'spree/core' -require 'rabl' require 'responders' module Spree diff --git a/api/lib/spree/api/engine.rb b/api/lib/spree/api/engine.rb index 0aa431aa30..6e77b6c9e3 100644 --- a/api/lib/spree/api/engine.rb +++ b/api/lib/spree/api/engine.rb @@ -6,16 +6,6 @@ class Engine < Rails::Engine isolate_namespace Spree engine_name 'spree_api' - Rabl.configure do |config| - config.include_json_root = false - config.include_child_root = false - - # Motivation here it make it call as_json when rendering timestamps - # and therefore display miliseconds. Otherwise it would fall to - # JSON.dump which doesn't display the miliseconds - config.json_engine = ActiveSupport::JSON - end - initializer "spree.api.environment", before: :load_config_initializers do |_app| Spree::Api::Config = Spree::ApiConfiguration.new end diff --git a/api/solidus_api.gemspec b/api/solidus_api.gemspec index 845055e553..d9b2910361 100644 --- a/api/solidus_api.gemspec +++ b/api/solidus_api.gemspec @@ -21,7 +21,6 @@ Gem::Specification.new do |gem| gem.required_rubygems_version = '>= 1.8.23' gem.add_dependency 'solidus_core', gem.version - gem.add_dependency 'rabl', '0.13.1' gem.add_dependency 'versioncake', '~> 3.0' gem.add_dependency 'responders' gem.add_dependency 'jbuilder', '~> 2.6' From e96a17f7e64abc62e065bb770bbdc3a326286af9 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Thu, 10 Aug 2017 14:53:01 -0700 Subject: [PATCH 4/9] Add rubocop for API views --- api/app/views/.rubocop.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 api/app/views/.rubocop.yml diff --git a/api/app/views/.rubocop.yml b/api/app/views/.rubocop.yml new file mode 100644 index 0000000000..d1e622db37 --- /dev/null +++ b/api/app/views/.rubocop.yml @@ -0,0 +1,4 @@ +inherit_from: ../../../.rubocop.yml + +Style/LambdaCall: + EnforcedStyle: braces From a6002e7f8579ea563de22abe91a2b1a0d5ecc283 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 16 Aug 2017 16:45:41 -0700 Subject: [PATCH 5/9] Re-add caching to API templates This copies the JSON caching previously employed by RABL, without serious consideration of its correctness or utility. --- .../api/addresses/_address.json.jbuilder | 14 ++-- .../api/adjustments/_adjustment.json.jbuilder | 6 +- .../credit_cards/_credit_card.json.jbuilder | 10 ++- .../api/line_items/_line_item.json.jbuilder | 26 ++++--- .../spree/api/orders/_order.json.jbuilder | 18 +++-- .../spree/api/products/_product.json.jbuilder | 51 +++++++------ .../spree/api/shipments/_big.json.jbuilder | 76 ++++++++++--------- .../spree/api/shipments/_small.json.jbuilder | 50 ++++++------ .../spree/api/shipments/show.json.jbuilder | 46 +++++------ .../spree/api/variants/_big.json.jbuilder | 22 +++--- .../spree/api/variants/_small.json.jbuilder | 28 +++---- 11 files changed, 185 insertions(+), 162 deletions(-) diff --git a/api/app/views/spree/api/addresses/_address.json.jbuilder b/api/app/views/spree/api/addresses/_address.json.jbuilder index 6b9ad06c35..ef5a714f66 100644 --- a/api/app/views/spree/api/addresses/_address.json.jbuilder +++ b/api/app/views/spree/api/addresses/_address.json.jbuilder @@ -1,9 +1,11 @@ if address - json.(address, *address_attributes) - if address.country - json.country { json.(address.country, *country_attributes) } - end - if address.state - json.state { json.(address.state, *state_attributes) } + json.cache! address do + json.(address, *address_attributes) + if address.country + json.country { json.(address.country, *country_attributes) } + end + if address.state + json.state { json.(address.state, *state_attributes) } + end end end diff --git a/api/app/views/spree/api/adjustments/_adjustment.json.jbuilder b/api/app/views/spree/api/adjustments/_adjustment.json.jbuilder index c052dadbf0..fd6b1e5e09 100644 --- a/api/app/views/spree/api/adjustments/_adjustment.json.jbuilder +++ b/api/app/views/spree/api/adjustments/_adjustment.json.jbuilder @@ -1,2 +1,4 @@ -json.(adjustment, *adjustment_attributes) -json.display_amount(adjustment.display_amount.to_s) +json.cache! [I18n.locale, adjustment] do + json.(adjustment, *adjustment_attributes) + json.display_amount(adjustment.display_amount.to_s) +end diff --git a/api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder b/api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder index c1798846c3..1f5933ff15 100644 --- a/api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder +++ b/api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder @@ -1,6 +1,8 @@ -json.(credit_card, *creditcard_attributes) -json.address do - if credit_card.address - json.partial!("spree/api/addresses/address", address: credit_card.address) +json.cache! [I18n.locale, credit_card] do + json.(credit_card, *creditcard_attributes) + json.address do + if credit_card.address + json.partial!("spree/api/addresses/address", address: credit_card.address) + end end end diff --git a/api/app/views/spree/api/line_items/_line_item.json.jbuilder b/api/app/views/spree/api/line_items/_line_item.json.jbuilder index 895aeb1867..f22b2e0979 100644 --- a/api/app/views/spree/api/line_items/_line_item.json.jbuilder +++ b/api/app/views/spree/api/line_items/_line_item.json.jbuilder @@ -1,14 +1,16 @@ -json.(line_item, *line_item_attributes) -json.single_display_amount(line_item.single_display_amount.to_s) -json.display_amount(line_item.display_amount.to_s) -json.total(line_item.total) -json.variant do - json.partial!("spree/api/variants/small", variant: line_item.variant) - json.(line_item.variant, :product_id) - json.images(line_item.variant.images) do |image| - json.partial!("spree/api/images/image", image: image) +json.cache! [I18n.locale, line_item] do + json.(line_item, *line_item_attributes) + json.single_display_amount(line_item.single_display_amount.to_s) + json.display_amount(line_item.display_amount.to_s) + json.total(line_item.total) + json.variant do + json.partial!("spree/api/variants/small", variant: line_item.variant) + json.(line_item.variant, :product_id) + json.images(line_item.variant.images) do |image| + json.partial!("spree/api/images/image", image: image) + end + end + json.adjustments(line_item.adjustments) do |adjustment| + json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) end -end -json.adjustments(line_item.adjustments) do |adjustment| - json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) end diff --git a/api/app/views/spree/api/orders/_order.json.jbuilder b/api/app/views/spree/api/orders/_order.json.jbuilder index c11bb92f41..39dc51866d 100644 --- a/api/app/views/spree/api/orders/_order.json.jbuilder +++ b/api/app/views/spree/api/orders/_order.json.jbuilder @@ -1,8 +1,10 @@ -json.(order, *order_attributes) -json.display_item_total(order.display_item_total.to_s) -json.total_quantity(order.line_items.sum(:quantity)) -json.display_total(order.display_total.to_s) -json.display_ship_total(order.display_ship_total) -json.display_tax_total(order.display_tax_total) -json.token(order.guest_token) -json.checkout_steps(order.checkout_steps) +json.cache! [I18n.locale, order] do + json.(order, *order_attributes) + json.display_item_total(order.display_item_total.to_s) + json.total_quantity(order.line_items.sum(:quantity)) + json.display_total(order.display_total.to_s) + json.display_ship_total(order.display_ship_total) + json.display_tax_total(order.display_tax_total) + json.token(order.guest_token) + json.checkout_steps(order.checkout_steps) +end diff --git a/api/app/views/spree/api/products/_product.json.jbuilder b/api/app/views/spree/api/products/_product.json.jbuilder index 4fd73b2107..089acc4c2d 100644 --- a/api/app/views/spree/api/products/_product.json.jbuilder +++ b/api/app/views/spree/api/products/_product.json.jbuilder @@ -1,31 +1,34 @@ @product_attributes ||= product_attributes -json.(product, *@product_attributes) -json.display_price(product.display_price.to_s) -@exclude_data ||= {} -unless @exclude_data[:variants] - json.has_variants(product.has_variants?) - json.master do - json.partial!("spree/api/variants/small", variant: product.master) - end - json.variants(product.variants) do |variant| - json.partial!("spree/api/variants/small", variant: variant) +json.cache! [I18n.locale, @current_user_roles.include?('admin'), current_pricing_options, @product_attributes, @exclude_data, product] do + json.(product, *@product_attributes) + json.display_price(product.display_price.to_s) + + @exclude_data ||= {} + unless @exclude_data[:variants] + json.has_variants(product.has_variants?) + json.master do + json.partial!("spree/api/variants/small", variant: product.master) + end + json.variants(product.variants) do |variant| + json.partial!("spree/api/variants/small", variant: variant) + end end -end -unless @exclude_data[:option_types] - json.option_types(product.option_types) do |option_type| - json.(option_type, *option_type_attributes) + unless @exclude_data[:option_types] + json.option_types(product.option_types) do |option_type| + json.(option_type, *option_type_attributes) + end end -end -unless @exclude_data[:product_properties] - json.product_properties(product.product_properties) do |product_property| - json.(product_property, *product_property_attributes) + unless @exclude_data[:product_properties] + json.product_properties(product.product_properties) do |product_property| + json.(product_property, *product_property_attributes) + end end -end -unless @exclude_data[:classifications] - json.classifications(product.classifications) do |classification| - json.(classification, :taxon_id, :position) - json.taxon do - json.partial!("spree/api/taxons/taxon", taxon: classification.taxon) + unless @exclude_data[:classifications] + json.classifications(product.classifications) do |classification| + json.(classification, :taxon_id, :position) + json.taxon do + json.partial!("spree/api/taxons/taxon", taxon: classification.taxon) + end end end end diff --git a/api/app/views/spree/api/shipments/_big.json.jbuilder b/api/app/views/spree/api/shipments/_big.json.jbuilder index f854c97357..2864c9892c 100644 --- a/api/app/views/spree/api/shipments/_big.json.jbuilder +++ b/api/app/views/spree/api/shipments/_big.json.jbuilder @@ -1,43 +1,45 @@ -json.(shipment, *shipment_attributes) -if shipment.selected_shipping_rate - json.selected_shipping_rate do - json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipment.selected_shipping_rate) - end -end -json.inventory_units(shipment.inventory_units) do |inventory_unit| - json.(inventory_unit, *inventory_unit_attributes) - json.variant do - json.partial!("spree/api/variants/small", variant: inventory_unit.variant) - json.(inventory_unit.variant, :product_id) - json.images(inventory_unit.variant.images) do |image| - json.partial!("spree/api/images/image", image: image) +json.cache! [I18n.locale, shipment] do + json.(shipment, *shipment_attributes) + if shipment.selected_shipping_rate + json.selected_shipping_rate do + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipment.selected_shipping_rate) end end - json.line_item do - json.(inventory_unit.line_item, *line_item_attributes) - json.single_display_amount(inventory_unit.line_item.single_display_amount.to_s) - json.display_amount(inventory_unit.line_item.display_amount.to_s) - json.total(inventory_unit.line_item.total) - end -end -json.order do - json.partial!("spree/api/orders/order", order: shipment.order) - json.bill_address do - json.partial!("spree/api/addresses/address", address: shipment.order.billing_address) - end - json.ship_address do - json.partial!("spree/api/addresses/address", address: shipment.order.shipping_address) - end - json.adjustments(shipment.order.adjustments) do |adjustment| - json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) + json.inventory_units(shipment.inventory_units) do |inventory_unit| + json.(inventory_unit, *inventory_unit_attributes) + json.variant do + json.partial!("spree/api/variants/small", variant: inventory_unit.variant) + json.(inventory_unit.variant, :product_id) + json.images(inventory_unit.variant.images) do |image| + json.partial!("spree/api/images/image", image: image) + end + end + json.line_item do + json.(inventory_unit.line_item, *line_item_attributes) + json.single_display_amount(inventory_unit.line_item.single_display_amount.to_s) + json.display_amount(inventory_unit.line_item.display_amount.to_s) + json.total(inventory_unit.line_item.total) + end end - json.payments(shipment.order.payments) do |payment| - json.(payment, :id, :amount, :display_amount, :state) - json.source do - attrs = [:id] - (attrs << :cc_type) if payment.source.respond_to?(:cc_type) - json.(payment.source, *attrs) + json.order do + json.partial!("spree/api/orders/order", order: shipment.order) + json.bill_address do + json.partial!("spree/api/addresses/address", address: shipment.order.billing_address) + end + json.ship_address do + json.partial!("spree/api/addresses/address", address: shipment.order.shipping_address) + end + json.adjustments(shipment.order.adjustments) do |adjustment| + json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) + end + json.payments(shipment.order.payments) do |payment| + json.(payment, :id, :amount, :display_amount, :state) + json.source do + attrs = [:id] + (attrs << :cc_type) if payment.source.respond_to?(:cc_type) + json.(payment.source, *attrs) + end + json.payment_method { json.(payment.payment_method, :id, :name) } end - json.payment_method { json.(payment.payment_method, :id, :name) } end end diff --git a/api/app/views/spree/api/shipments/_small.json.jbuilder b/api/app/views/spree/api/shipments/_small.json.jbuilder index 9e5c07853f..409ce8d457 100644 --- a/api/app/views/spree/api/shipments/_small.json.jbuilder +++ b/api/app/views/spree/api/shipments/_small.json.jbuilder @@ -1,28 +1,30 @@ -json.(shipment, *shipment_attributes) -json.order_id(shipment.order.number) -json.stock_location_name(shipment.stock_location.name) -json.shipping_rates(shipment.shipping_rates) do |shipping_rate| - json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipping_rate) -end -if shipment.selected_shipping_rate - json.selected_shipping_rate do - json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipment.selected_shipping_rate) +json.cache! [I18n.locale, shipment] do + json.(shipment, *shipment_attributes) + json.order_id(shipment.order.number) + json.stock_location_name(shipment.stock_location.name) + json.shipping_rates(shipment.shipping_rates) do |shipping_rate| + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipping_rate) end -end -json.shipping_methods(shipment.shipping_methods) do |shipping_method| - json.(shipping_method, :id, :code, :name) - json.zones(shipping_method.zones) do |zone| - json.(zone, :id, :name, :description) + if shipment.selected_shipping_rate + json.selected_shipping_rate do + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipment.selected_shipping_rate) + end end - json.shipping_categories(shipping_method.shipping_categories) do |shipping_category| - json.(shipping_category, :id, :name) + json.shipping_methods(shipment.shipping_methods) do |shipping_method| + json.(shipping_method, :id, :code, :name) + json.zones(shipping_method.zones) do |zone| + json.(zone, :id, :name, :description) + end + json.shipping_categories(shipping_method.shipping_categories) do |shipping_category| + json.(shipping_category, :id, :name) + end + end + json.manifest(shipment.manifest) do |manifest_item| + json.variant_id manifest_item.variant.id + json.quantity(manifest_item.quantity) + json.states(manifest_item.states) + end + json.adjustments(shipment.adjustments) do |adjustment| + json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) end -end -json.manifest(shipment.manifest) do |manifest_item| - json.variant_id manifest_item.variant.id - json.quantity(manifest_item.quantity) - json.states(manifest_item.states) -end -json.adjustments(shipment.adjustments) do |adjustment| - json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) end diff --git a/api/app/views/spree/api/shipments/show.json.jbuilder b/api/app/views/spree/api/shipments/show.json.jbuilder index 5998d86f6d..d43cb98928 100644 --- a/api/app/views/spree/api/shipments/show.json.jbuilder +++ b/api/app/views/spree/api/shipments/show.json.jbuilder @@ -1,27 +1,29 @@ -json.(@shipment, *shipment_attributes) -json.order_id(@shipment.order.number) -json.stock_location_name(@shipment.stock_location.name) -json.shipping_rates(@shipment.shipping_rates) do |shipping_rate| - json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipping_rate) -end -if @shipment.selected_shipping_rate - json.selected_shipping_rate do - json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: @shipment.selected_shipping_rate) +json.cache! [I18n.locale, @shipment] do + json.(@shipment, *shipment_attributes) + json.order_id(@shipment.order.number) + json.stock_location_name(@shipment.stock_location.name) + json.shipping_rates(@shipment.shipping_rates) do |shipping_rate| + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipping_rate) end -end -json.shipping_methods(@shipment.shipping_methods) do |shipping_method| - json.(shipping_method, :id, :name) - json.zones(shipping_method.zones) do |zone| - json.(zone, :id, :name, :description) + if @shipment.selected_shipping_rate + json.selected_shipping_rate do + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: @shipment.selected_shipping_rate) + end end - json.shipping_categories(shipping_method.shipping_categories) do |shipping_category| - json.(shipping_category, :id, :name) + json.shipping_methods(@shipment.shipping_methods) do |shipping_method| + json.(shipping_method, :id, :name) + json.zones(shipping_method.zones) do |zone| + json.(zone, :id, :name, :description) + end + json.shipping_categories(shipping_method.shipping_categories) do |shipping_category| + json.(shipping_category, :id, :name) + end end -end -json.manifest(@shipment.manifest) do |manifest_item| - json.variant do - json.partial!("spree/api/variants/small", variant: manifest_item.variant) + json.manifest(@shipment.manifest) do |manifest_item| + json.variant do + json.partial!("spree/api/variants/small", variant: manifest_item.variant) + end + json.quantity(manifest_item.quantity) + json.states(manifest_item.states) end - json.quantity(manifest_item.quantity) - json.states(manifest_item.states) end diff --git a/api/app/views/spree/api/variants/_big.json.jbuilder b/api/app/views/spree/api/variants/_big.json.jbuilder index 612980edcf..1eaa38ecfc 100644 --- a/api/app/views/spree/api/variants/_big.json.jbuilder +++ b/api/app/views/spree/api/variants/_big.json.jbuilder @@ -1,11 +1,13 @@ -json.(variant, *variant_attributes) -json.partial!("spree/api/variants/small", variant: variant) -json.total_on_hand(variant.total_on_hand) -json.variant_properties(variant.variant_properties) do |variant_property| - json.(variant_property, *variant_property_attributes) -end -json.stock_items(variant.stock_items.accessible_by(current_ability)) do |stock_item| - json.(stock_item, :id, :count_on_hand, :stock_location_id, :backorderable) - json.available stock_item.available? - json.stock_location_name(stock_item.stock_location.name) +json.cache! [I18n.locale, Spree::StockLocation.accessible_by(current_ability), variant] do + json.(variant, *variant_attributes) + json.partial!("spree/api/variants/small", variant: variant) + json.total_on_hand(variant.total_on_hand) + json.variant_properties(variant.variant_properties) do |variant_property| + json.(variant_property, *variant_property_attributes) + end + json.stock_items(variant.stock_items.accessible_by(current_ability)) do |stock_item| + json.(stock_item, :id, :count_on_hand, :stock_location_id, :backorderable) + json.available stock_item.available? + json.stock_location_name(stock_item.stock_location.name) + end end diff --git a/api/app/views/spree/api/variants/_small.json.jbuilder b/api/app/views/spree/api/variants/_small.json.jbuilder index ab94dfc91e..a6749610c5 100644 --- a/api/app/views/spree/api/variants/_small.json.jbuilder +++ b/api/app/views/spree/api/variants/_small.json.jbuilder @@ -1,14 +1,16 @@ -json.(variant, *variant_attributes) -json.display_price(variant.display_price.to_s) -json.options_text(variant.options_text) -json.track_inventory(variant.should_track_inventory?) -json.in_stock(variant.in_stock?) -json.is_backorderable(variant.is_backorderable?) -json.total_on_hand(variant.total_on_hand) -json.is_destroyed(variant.destroyed?) -json.option_values(variant.option_values) do |option_value| - json.(option_value, *option_value_attributes) -end -json.images(variant.images) do |image| - json.partial!("spree/api/images/image", image: image) +json.cache! [I18n.locale, variant] do + json.(variant, *variant_attributes) + json.display_price(variant.display_price.to_s) + json.options_text(variant.options_text) + json.track_inventory(variant.should_track_inventory?) + json.in_stock(variant.in_stock?) + json.is_backorderable(variant.is_backorderable?) + json.total_on_hand(variant.total_on_hand) + json.is_destroyed(variant.destroyed?) + json.option_values(variant.option_values) do |option_value| + json.(option_value, *option_value_attributes) + end + json.images(variant.images) do |image| + json.partial!("spree/api/images/image", image: image) + end end From 54bb3ea90ef5af9d4ce6876ace688afb2538e995 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 16 Aug 2017 16:28:14 -0700 Subject: [PATCH 6/9] Failing spec for taxon product caching This spec failed under the previous RABL caching. --- .../spree/api/taxons_controller_spec.rb | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/api/spec/requests/spree/api/taxons_controller_spec.rb b/api/spec/requests/spree/api/taxons_controller_spec.rb index 502b5ff5bc..8a078e80b6 100644 --- a/api/spec/requests/spree/api/taxons_controller_spec.rb +++ b/api/spec/requests/spree/api/taxons_controller_spec.rb @@ -120,6 +120,31 @@ module Spree delete spree.api_taxonomy_taxon_path(taxonomy, taxon.id) assert_unauthorized! end + + context "with caching enabled" do + let!(:product) { create(:product, taxons: [taxon]) } + + before do + ActionController::Base.perform_caching = true + end + + it "handles exclude_data correctly" do + get spree.api_taxon_products_path, params: { id: taxon.id, simple: true } + expect(response).to be_success + simple_response = json_response + + get spree.api_taxon_products_path, params: { id: taxon.id } + expect(response).to be_success + full_response = json_response + + expect(simple_response["products"][0]["description"]).to be_nil + expect(full_response["products"][0]["description"]).not_to be_nil + end + + after do + ActionController::Base.perform_caching = false + end + end end context "as an admin" do From 01569a7b9119a2e6653392d555efa7bf3f9e51fc Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Thu, 17 Aug 2017 16:20:19 -0700 Subject: [PATCH 7/9] Don't render address partial with nil values --- .../spree/api/addresses/_address.json.jbuilder | 16 +++++++--------- .../views/spree/api/orders/_big.json.jbuilder | 8 ++++++-- .../views/spree/api/users/_user.json.jbuilder | 8 ++++++-- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/api/app/views/spree/api/addresses/_address.json.jbuilder b/api/app/views/spree/api/addresses/_address.json.jbuilder index ef5a714f66..1ff4efb832 100644 --- a/api/app/views/spree/api/addresses/_address.json.jbuilder +++ b/api/app/views/spree/api/addresses/_address.json.jbuilder @@ -1,11 +1,9 @@ -if address - json.cache! address do - json.(address, *address_attributes) - if address.country - json.country { json.(address.country, *country_attributes) } - end - if address.state - json.state { json.(address.state, *state_attributes) } - end +json.cache! address do + json.(address, *address_attributes) + if address.country + json.country { json.(address.country, *country_attributes) } + end + if address.state + json.state { json.(address.state, *state_attributes) } end end diff --git a/api/app/views/spree/api/orders/_big.json.jbuilder b/api/app/views/spree/api/orders/_big.json.jbuilder index d21fc014ad..5533f2bc91 100644 --- a/api/app/views/spree/api/orders/_big.json.jbuilder +++ b/api/app/views/spree/api/orders/_big.json.jbuilder @@ -4,10 +4,14 @@ json.payment_methods(order.available_payment_methods) do |payment_method| json.method_type payment_method.partial_name end json.bill_address do - json.partial!("spree/api/addresses/address", address: order.billing_address) + if order.billing_address + json.partial!("spree/api/addresses/address", address: order.billing_address) + end end json.ship_address do - json.partial!("spree/api/addresses/address", address: order.shipping_address) + if order.shipping_address + json.partial!("spree/api/addresses/address", address: order.shipping_address) + end end json.line_items(order.line_items) do |line_item| json.partial!("spree/api/line_items/line_item", line_item: line_item) diff --git a/api/app/views/spree/api/users/_user.json.jbuilder b/api/app/views/spree/api/users/_user.json.jbuilder index a09ae14732..eff32d3a93 100644 --- a/api/app/views/spree/api/users/_user.json.jbuilder +++ b/api/app/views/spree/api/users/_user.json.jbuilder @@ -1,7 +1,11 @@ json.(user, *user_attributes) json.bill_address do - json.partial!("spree/api/addresses/address", address: user.bill_address) + if user.bill_address + json.partial!("spree/api/addresses/address", address: user.bill_address) + end end json.ship_address do - json.partial!("spree/api/addresses/address", address: user.ship_address) + if user.ship_address + json.partial!("spree/api/addresses/address", address: user.ship_address) + end end From 30138342480f5c115d0d0c72f812518fb98888ac Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Thu, 17 Aug 2017 16:21:43 -0700 Subject: [PATCH 8/9] Simplify payment source attributes in order/_big --- api/app/views/spree/api/orders/_big.json.jbuilder | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/api/app/views/spree/api/orders/_big.json.jbuilder b/api/app/views/spree/api/orders/_big.json.jbuilder index 5533f2bc91..fede3d1d25 100644 --- a/api/app/views/spree/api/orders/_big.json.jbuilder +++ b/api/app/views/spree/api/orders/_big.json.jbuilder @@ -22,10 +22,9 @@ json.payments(order.payments) do |payment| if payment.source json.source do json.(payment.source, *payment_source_attributes) + if @current_user_roles.include?("admin") - json.(payment.source, *(payment_source_attributes + [:gateway_customer_profile_id, :gateway_payment_profile_id])) - else - json.(payment.source, *payment_source_attributes) + json.(payment.source, :gateway_customer_profile_id, :gateway_payment_profile_id) end end end From 81a56380282c9232649b403d5ac921cab42bab8d Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 22 Aug 2017 15:52:51 -0700 Subject: [PATCH 9/9] Display JSON null for missing associations --- .../spree/api/addresses/_address.json.jbuilder | 16 ++++++++++++---- .../api/credit_cards/_credit_card.json.jbuilder | 2 ++ .../views/spree/api/orders/_big.json.jbuilder | 10 ++++++++-- .../views/spree/api/shipments/_big.json.jbuilder | 12 +++++++++--- .../spree/api/shipments/_small.json.jbuilder | 6 ++++-- .../views/spree/api/shipments/show.json.jbuilder | 6 ++++-- .../_stock_location.json.jbuilder | 16 ++++++++++++---- .../views/spree/api/users/_user.json.jbuilder | 4 ++++ 8 files changed, 55 insertions(+), 17 deletions(-) diff --git a/api/app/views/spree/api/addresses/_address.json.jbuilder b/api/app/views/spree/api/addresses/_address.json.jbuilder index 1ff4efb832..eddb0e3e69 100644 --- a/api/app/views/spree/api/addresses/_address.json.jbuilder +++ b/api/app/views/spree/api/addresses/_address.json.jbuilder @@ -1,9 +1,17 @@ json.cache! address do json.(address, *address_attributes) - if address.country - json.country { json.(address.country, *country_attributes) } + json.country do + if address.country + json.(address.country, *country_attributes) + else + json.nil! + end end - if address.state - json.state { json.(address.state, *state_attributes) } + json.state do + if address.state + json.(address.state, *state_attributes) + else + json.nil! + end end end diff --git a/api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder b/api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder index 1f5933ff15..93482cd2ca 100644 --- a/api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder +++ b/api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder @@ -3,6 +3,8 @@ json.cache! [I18n.locale, credit_card] do json.address do if credit_card.address json.partial!("spree/api/addresses/address", address: credit_card.address) + else + json.nil! end end end diff --git a/api/app/views/spree/api/orders/_big.json.jbuilder b/api/app/views/spree/api/orders/_big.json.jbuilder index fede3d1d25..256928bc5a 100644 --- a/api/app/views/spree/api/orders/_big.json.jbuilder +++ b/api/app/views/spree/api/orders/_big.json.jbuilder @@ -6,11 +6,15 @@ end json.bill_address do if order.billing_address json.partial!("spree/api/addresses/address", address: order.billing_address) + else + json.nil! end end json.ship_address do if order.shipping_address json.partial!("spree/api/addresses/address", address: order.shipping_address) + else + json.nil! end end json.line_items(order.line_items) do |line_item| @@ -19,13 +23,15 @@ end json.payments(order.payments) do |payment| json.(payment, *payment_attributes) json.payment_method { json.(payment.payment_method, :id, :name) } - if payment.source - json.source do + json.source do + if payment.source json.(payment.source, *payment_source_attributes) if @current_user_roles.include?("admin") json.(payment.source, :gateway_customer_profile_id, :gateway_payment_profile_id) end + else + json.nil! end end end diff --git a/api/app/views/spree/api/shipments/_big.json.jbuilder b/api/app/views/spree/api/shipments/_big.json.jbuilder index 2864c9892c..eb60c8656d 100644 --- a/api/app/views/spree/api/shipments/_big.json.jbuilder +++ b/api/app/views/spree/api/shipments/_big.json.jbuilder @@ -1,8 +1,10 @@ json.cache! [I18n.locale, shipment] do json.(shipment, *shipment_attributes) - if shipment.selected_shipping_rate - json.selected_shipping_rate do + json.selected_shipping_rate do + if shipment.selected_shipping_rate json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipment.selected_shipping_rate) + else + json.nil! end end json.inventory_units(shipment.inventory_units) do |inventory_unit| @@ -24,7 +26,11 @@ json.cache! [I18n.locale, shipment] do json.order do json.partial!("spree/api/orders/order", order: shipment.order) json.bill_address do - json.partial!("spree/api/addresses/address", address: shipment.order.billing_address) + if shipment.order.billing_address + json.partial!("spree/api/addresses/address", address: shipment.order.billing_address) + else + json.nil! + end end json.ship_address do json.partial!("spree/api/addresses/address", address: shipment.order.shipping_address) diff --git a/api/app/views/spree/api/shipments/_small.json.jbuilder b/api/app/views/spree/api/shipments/_small.json.jbuilder index 409ce8d457..797f607416 100644 --- a/api/app/views/spree/api/shipments/_small.json.jbuilder +++ b/api/app/views/spree/api/shipments/_small.json.jbuilder @@ -5,9 +5,11 @@ json.cache! [I18n.locale, shipment] do json.shipping_rates(shipment.shipping_rates) do |shipping_rate| json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipping_rate) end - if shipment.selected_shipping_rate - json.selected_shipping_rate do + json.selected_shipping_rate do + if shipment.selected_shipping_rate json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipment.selected_shipping_rate) + else + json.nil! end end json.shipping_methods(shipment.shipping_methods) do |shipping_method| diff --git a/api/app/views/spree/api/shipments/show.json.jbuilder b/api/app/views/spree/api/shipments/show.json.jbuilder index d43cb98928..54feca58c8 100644 --- a/api/app/views/spree/api/shipments/show.json.jbuilder +++ b/api/app/views/spree/api/shipments/show.json.jbuilder @@ -5,9 +5,11 @@ json.cache! [I18n.locale, @shipment] do json.shipping_rates(@shipment.shipping_rates) do |shipping_rate| json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipping_rate) end - if @shipment.selected_shipping_rate - json.selected_shipping_rate do + json.selected_shipping_rate do + if @shipment.selected_shipping_rate json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: @shipment.selected_shipping_rate) + else + json.nil! end end json.shipping_methods(@shipment.shipping_methods) do |shipping_method| diff --git a/api/app/views/spree/api/stock_locations/_stock_location.json.jbuilder b/api/app/views/spree/api/stock_locations/_stock_location.json.jbuilder index cd1b1634e1..814e54754e 100644 --- a/api/app/views/spree/api/stock_locations/_stock_location.json.jbuilder +++ b/api/app/views/spree/api/stock_locations/_stock_location.json.jbuilder @@ -1,7 +1,15 @@ json.(stock_location, *stock_location_attributes) -if stock_location.country - json.country { json.(stock_location.country, *country_attributes) } +json.country do + if stock_location.country + json.(stock_location.country, *country_attributes) + else + json.nil! + end end -if stock_location.state - json.state { json.(stock_location.state, *state_attributes) } +json.state do + if stock_location.state + json.(stock_location.state, *state_attributes) + else + json.nil! + end end diff --git a/api/app/views/spree/api/users/_user.json.jbuilder b/api/app/views/spree/api/users/_user.json.jbuilder index eff32d3a93..9a69277da1 100644 --- a/api/app/views/spree/api/users/_user.json.jbuilder +++ b/api/app/views/spree/api/users/_user.json.jbuilder @@ -2,10 +2,14 @@ json.(user, *user_attributes) json.bill_address do if user.bill_address json.partial!("spree/api/addresses/address", address: user.bill_address) + else + json.nil! end end json.ship_address do if user.ship_address json.partial!("spree/api/addresses/address", address: user.ship_address) + else + json.nil! end end