Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Platform - Line Items API (#11380)
Damian Legawiecc734d0e43a95
diff --git a/api/app/controllers/spree/api/v2/platform/line_items_controller.rb b/api/app/controllers/spree/api/v2/platform/line_items_controller.rbnew file mode 100644index 0000000000..5c59c234fd--- /dev/null+++ b/api/app/controllers/spree/api/v2/platform/line_items_controller.rb@@ -0,0 +1,59 @@+module Spree+ module Api+ module V2+ module Platform+ class LineItemsController < ResourceController+ def create+ order = current_store.orders.find(permitted_resource_params[:order_id])++ result = create_service.call(order: order, line_item_attributes: permitted_resource_params)++ if result.success?+ render_serialized_payload(201) { serialize_resource(result.value) }+ else+ render_error_payload(result.error)+ end+ end++ def update+ result = update_service.call(line_item: resource, line_item_attributes: permitted_resource_params)++ if result.success?+ render_serialized_payload { serialize_resource(result.value) }+ else+ render_error_payload(resource.errors)+ end+ end++ def destroy+ result = destroy_service.call(line_item: resource)++ if result.success?+ head 204+ else+ render_error_payload(result.error)+ end+ end++ private++ def model_class+ Spree::LineItem+ end++ def create_service+ Spree::Api::Dependencies.platform_line_item_create_service.constantize+ end++ def update_service+ Spree::Api::Dependencies.platform_line_item_update_service.constantize+ end++ def destroy_service+ Spree::Api::Dependencies.platform_line_item_destroy_service.constantize+ end+ end+ end+ end+ end+enddiff --git a/api/app/models/spree/api_dependencies.rb b/api/app/models/spree/api_dependencies.rbindex 58f426443c..b4872aeca9 100644--- a/api/app/models/spree/api_dependencies.rb+++ b/api/app/models/spree/api_dependencies.rb@@ -25,7 +25,8 @@ module Spree:platform_admin_user_serializer, :platform_coupon_handler, :platform_order_update_service,:platform_order_use_store_credit_service, :platform_order_remove_store_credit_service,:platform_order_complete_service, :platform_order_empty_service, :platform_order_destroy_service,- :platform_order_next_service, :platform_order_advance_service+ :platform_order_next_service, :platform_order_advance_service,+ :platform_line_item_create_service, :platform_line_item_update_service, :platform_line_item_destroy_service].freezeattr_accessor *INJECTION_POINTS@@ -122,6 +123,7 @@ module Spree@platform_coupon_handler = Spree::Dependencies.coupon_handler# order services+ @platform_order_recalculate_service = Spree::Dependencies.cart_recalculate_service@platform_order_update_service = Spree::Dependencies.checkout_update_service@platform_order_empty_service = Spree::Dependencies.cart_empty_service@platform_order_destroy_service = Spree::Dependencies.cart_destroy_service@@ -130,6 +132,11 @@ module Spree@platform_order_complete_service = Spree::Dependencies.checkout_complete_service@platform_order_use_store_credit_service = Spree::Dependencies.checkout_add_store_credit_service@platform_order_remove_store_credit_service = Spree::Dependencies.checkout_remove_store_credit_service++ # line item services+ @platform_line_item_create_service = Spree::Dependencies.line_item_create_service+ @platform_line_item_update_service = Spree::Dependencies.line_item_update_service+ @platform_line_item_destroy_service = Spree::Dependencies.line_item_destroy_serviceendendenddiff --git a/api/docs/v2/platform/index.yaml b/api/docs/v2/platform/index.yamlindex 1849e32ee1..8ba9736e68 100644--- a/api/docs/v2/platform/index.yaml+++ b/api/docs/v2/platform/index.yaml@@ -63,8 +63,8 @@ paths:state_name:alternative_phone: 555-555-0199company: Company- created_at: '2021-10-05T18:32:17.422Z'- updated_at: '2021-10-05T18:32:17.422Z'+ created_at: '2021-10-07T10:44:27.836Z'+ updated_at: '2021-10-07T10:44:27.836Z'deleted_at:label:relationships:@@ -91,8 +91,8 @@ paths:state_name:alternative_phone: 555-555-0199company: Company- created_at: '2021-10-05T18:32:17.428Z'- updated_at: '2021-10-05T18:32:17.428Z'+ created_at: '2021-10-07T10:44:27.843Z'+ updated_at: '2021-10-07T10:44:27.843Z'deleted_at:label:relationships:@@ -162,8 +162,8 @@ paths:state_name:alternative_phone: 555-555-0199company: Company- created_at: '2021-10-05T18:32:17.636Z'- updated_at: '2021-10-05T18:32:17.636Z'+ created_at: '2021-10-07T10:44:28.112Z'+ updated_at: '2021-10-07T10:44:28.112Z'deleted_at:label:relationships:@@ -253,8 +253,8 @@ paths:state_name:alternative_phone: 555-555-0199company: Company- created_at: '2021-10-05T18:32:17.680Z'- updated_at: '2021-10-05T18:32:17.680Z'+ created_at: '2021-10-07T10:44:28.169Z'+ updated_at: '2021-10-07T10:44:28.169Z'deleted_at:label:relationships:@@ -327,8 +327,8 @@ paths:state_name:alternative_phone: 555-555-0199company: Company- created_at: '2021-10-05T18:32:17.814Z'- updated_at: '2021-10-05T18:32:17.825Z'+ created_at: '2021-10-07T10:44:28.258Z'+ updated_at: '2021-10-07T10:44:28.272Z'deleted_at:label:relationships:@@ -455,8 +455,8 @@ paths:type: classificationattributes:position: 1- created_at: '2021-10-05T18:32:18.386Z'- updated_at: '2021-10-05T18:32:18.386Z'+ created_at: '2021-10-07T10:44:28.840Z'+ updated_at: '2021-10-07T10:44:28.840Z'relationships:product:data:@@ -470,8 +470,8 @@ paths:type: classificationattributes:position: 1- created_at: '2021-10-05T18:32:18.538Z'- updated_at: '2021-10-05T18:32:18.538Z'+ created_at: '2021-10-07T10:44:29.013Z'+ updated_at: '2021-10-07T10:44:29.013Z'relationships:product:data:@@ -528,8 +528,8 @@ paths:type: classificationattributes:position: 1- created_at: '2021-10-05T18:32:19.088Z'- updated_at: '2021-10-05T18:32:19.088Z'+ created_at: '2021-10-07T10:44:29.798Z'+ updated_at: '2021-10-07T10:44:29.798Z'relationships:product:data:@@ -592,8 +592,8 @@ paths:type: classificationattributes:position: 1- created_at: '2021-10-05T18:32:19.289Z'- updated_at: '2021-10-05T18:32:19.289Z'+ created_at: '2021-10-07T10:44:30.030Z'+ updated_at: '2021-10-07T10:44:30.030Z'relationships:product:data:@@ -653,8 +653,8 @@ paths:type: classificationattributes:position: 1- created_at: '2021-10-05T18:32:19.675Z'- updated_at: '2021-10-05T18:32:19.675Z'+ created_at: '2021-10-07T10:44:30.506Z'+ updated_at: '2021-10-07T10:44:30.506Z'relationships:product:data:@@ -764,8 +764,8 @@ paths:type: classificationattributes:position: 2- created_at: '2021-10-05T18:32:20.631Z'- updated_at: '2021-10-05T18:32:20.657Z'+ created_at: '2021-10-07T10:44:31.540Z'+ updated_at: '2021-10-07T10:44:31.567Z'relationships:product:data:@@ -850,34 +850,35 @@ paths:- id: '1'type: cms_pageattributes:- title: Quas quo fugiat quis laborum eos blanditiis.+ title: Laudantium libero pariatur exercitationem praesentium+ temporibus animi ducimus.meta_title:content:meta_description:visible: true- slug: quas-quo-fugiat-quis-laborum-eos-blanditiis+ slug: laudantium-libero-pariatur-exercitationem-praesentium-temporibus-animi-ducimustype: Spree::Cms::Pages::StandardPagelocale: endeleted_at:- created_at: '2021-10-05T18:32:21.077Z'- updated_at: '2021-10-05T18:32:21.077Z'+ created_at: '2021-10-07T10:44:32.021Z'+ updated_at: '2021-10-07T10:44:32.021Z'relationships:cms_sections:data: []- id: '2'type: cms_pageattributes:- title: Corrupti est nihil aspernatur non.+ title: Et eum similique vel aspernatur.meta_title:content:meta_description:visible: true- slug: corrupti-est-nihil-aspernatur-non+ slug: et-eum-similique-vel-aspernaturtype: Spree::Cms::Pages::StandardPagelocale: endeleted_at:- created_at: '2021-10-05T18:32:21.081Z'- updated_at: '2021-10-05T18:32:21.081Z'+ created_at: '2021-10-07T10:44:32.025Z'+ updated_at: '2021-10-07T10:44:32.025Z'relationships:cms_sections:data: []@@ -927,18 +928,18 @@ paths:id: '5'type: cms_pageattributes:- title: Unde ducimus magni accusantium iusto maxime nihil magnam- saepe.+ title: Ipsa excepturi laboriosam quibusdam hic voluptate suscipit+ eius.meta_title:content:meta_description:visible: true- slug: unde-ducimus-magni-accusantium-iusto-maxime-nihil-magnam-saepe+ slug: ipsa-excepturi-laboriosam-quibusdam-hic-voluptate-suscipit-eiustype: Spree::Cms::Pages::StandardPagelocale: endeleted_at:- created_at: '2021-10-05T18:32:21.177Z'- updated_at: '2021-10-05T18:32:21.177Z'+ created_at: '2021-10-07T10:44:32.133Z'+ updated_at: '2021-10-07T10:44:32.133Z'relationships:cms_sections:data: []@@ -994,17 +995,18 @@ paths:id: '6'type: cms_pageattributes:- title: Nihil possimus in dignissimos mollitia error.+ title: Perferendis tenetur suscipit eligendi repellat natus+ quibusdam earum.meta_title:content:meta_description:visible: true- slug: nihil-possimus-in-dignissimos-mollitia-error+ slug: perferendis-tenetur-suscipit-eligendi-repellat-natus-quibusdam-earumtype: Spree::Cms::Pages::StandardPagelocale: endeleted_at:- created_at: '2021-10-05T18:32:21.223Z'- updated_at: '2021-10-05T18:32:21.223Z'+ created_at: '2021-10-07T10:44:32.183Z'+ updated_at: '2021-10-07T10:44:32.183Z'relationships:cms_sections:data: []@@ -1062,12 +1064,12 @@ paths:content:meta_description:visible: true- slug: odio-optio-facere-recusandae-reprehenderit-illo-amet+ slug: rerum-delectus-soluta-quod-dolor-nisi-magni-pariatur-nesciunttype: Spree::Cms::Pages::StandardPagelocale: endeleted_at:- created_at: '2021-10-05T18:32:21.291Z'- updated_at: '2021-10-05T18:32:21.303Z'+ created_at: '2021-10-07T10:44:32.254Z'+ updated_at: '2021-10-07T10:44:32.267Z'relationships:cms_sections:data: []@@ -1181,8 +1183,8 @@ paths:- id: '1'type: cms_sectionattributes:- name: Culpa quasi quaerat ipsam quis inventore consectetur- assumenda illo.+ name: Recusandae ab labore nemo beatae dolor accusantium doloribus+ exercitationem.content: {}settings:gutters: No Gutters@@ -1191,8 +1193,8 @@ paths:type: Spree::Cms::Sections::HeroImageposition: 1linked_resource_type: Spree::Taxon- created_at: '2021-10-05T18:32:21.506Z'- updated_at: '2021-10-05T18:32:21.506Z'+ created_at: '2021-10-07T10:44:32.484Z'+ updated_at: '2021-10-07T10:44:32.484Z'relationships:cms_page:data:@@ -1203,8 +1205,7 @@ paths:- id: '2'type: cms_sectionattributes:- name: Adipisci impedit repellendus eveniet ipsam voluptate- explicabo perferendis.+ name: Quis odit quidem repellat omnis laborum.content:link_type_one: Spree::Taxonlink_type_two: Spree::Taxon@@ -1216,8 +1217,8 @@ paths:type: Spree::Cms::Sections::ImageGalleryposition: 2linked_resource_type:- created_at: '2021-10-05T18:32:21.510Z'- updated_at: '2021-10-05T18:32:21.510Z'+ created_at: '2021-10-07T10:44:32.489Z'+ updated_at: '2021-10-07T10:44:32.489Z'relationships:cms_page:data:@@ -1228,8 +1229,7 @@ paths:- id: '3'type: cms_sectionattributes:- name: Quo voluptatem veritatis nesciunt libero tenetur fugiat- facilis quidem.+ name: Minima ducimus vel autem laboriosam quam incidunt.content: {}settings:gutters: No Gutters@@ -1238,8 +1238,8 @@ paths:type: Spree::Cms::Sections::FeaturedArticleposition: 3linked_resource_type: Spree::Taxon- created_at: '2021-10-05T18:32:21.523Z'- updated_at: '2021-10-05T18:32:21.523Z'+ created_at: '2021-10-07T10:44:32.501Z'+ updated_at: '2021-10-07T10:44:32.501Z'relationships:cms_page:data:@@ -1250,7 +1250,7 @@ paths:- id: '4'type: cms_sectionattributes:- name: Culpa ad magnam nobis doloribus consequuntur vero incidunt.+ name: Iste nam neque alias numquam.content: {}settings:gutters: No Gutters@@ -1259,8 +1259,8 @@ paths:type: Spree::Cms::Sections::HeroImageposition: 4linked_resource_type: Spree::Product- created_at: '2021-10-05T18:32:21.535Z'- updated_at: '2021-10-05T18:32:21.535Z'+ created_at: '2021-10-07T10:44:32.513Z'+ updated_at: '2021-10-07T10:44:32.513Z'relationships:cms_page:data:@@ -1273,7 +1273,7 @@ paths:- id: '5'type: cms_sectionattributes:- name: Tenetur reiciendis itaque laborum at fuga.+ name: Harum veniam ab ipsam laudantium qui velit.content: {}settings:gutters: No Gutters@@ -1282,8 +1282,8 @@ paths:type: Spree::Cms::Sections::HeroImageposition: 5linked_resource_type: Spree::Product- created_at: '2021-10-05T18:32:21.547Z'- updated_at: '2021-10-05T18:32:21.547Z'+ created_at: '2021-10-07T10:44:32.525Z'+ updated_at: '2021-10-07T10:44:32.525Z'relationships:cms_page:data:@@ -1339,7 +1339,7 @@ paths:id: '14'type: cms_sectionattributes:- name: Ipsum ullam temporibus eius beatae minus.+ name: Excepturi optio quidem quasi debitis eum a atque quas.content: {}settings:gutters: No Gutters@@ -1348,8 +1348,8 @@ paths:type: Spree::Cms::Sections::HeroImageposition: 4linked_resource_type: Spree::Product- created_at: '2021-10-05T18:32:21.737Z'- updated_at: '2021-10-05T18:32:21.737Z'+ created_at: '2021-10-07T10:44:32.729Z'+ updated_at: '2021-10-07T10:44:32.729Z'relationships:cms_page:data:@@ -1411,7 +1411,8 @@ paths:id: '21'type: cms_sectionattributes:- name: Soluta neque numquam commodi odit molestiae quam exercitationem.+ name: Officia id praesentium accusamus quam temporibus laborum+ quos.content: {}settings:gutters: No Gutters@@ -1420,8 +1421,8 @@ paths:type: Spree::Cms::Sections::HeroImageposition: 4linked_resource_type: Spree::Product- created_at: '2021-10-05T18:32:21.896Z'- updated_at: '2021-10-05T18:32:21.896Z'+ created_at: '2021-10-07T10:44:32.884Z'+ updated_at: '2021-10-07T10:44:32.884Z'relationships:cms_page:data:@@ -1489,8 +1490,8 @@ paths:type: Spree::Cms::Sections::HeroImageposition: 4linked_resource_type: Spree::Product- created_at: '2021-10-05T18:32:22.148Z'- updated_at: '2021-10-05T18:32:22.162Z'+ created_at: '2021-10-07T10:44:33.136Z'+ updated_at: '2021-10-07T10:44:33.154Z'relationships:cms_page:data:@@ -1592,7 +1593,8 @@ paths:id: '58'type: cms_sectionattributes:- name: Iusto beatae quaerat nihil magni veniam eveniet quod.+ name: Neque qui vitae quasi libero possimus perspiciatis occaecati+ temporibus.content: {}settings:gutters: No Gutters@@ -1601,8 +1603,8 @@ paths:type: Spree::Cms::Sections::HeroImageposition: 3linked_resource_type: Spree::Product- created_at: '2021-10-05T18:32:22.768Z'- updated_at: '2021-10-05T18:32:22.787Z'+ created_at: '2021-10-07T10:44:33.774Z'+ updated_at: '2021-10-07T10:44:33.789Z'relationships:cms_page:data:@@ -1660,9 +1662,9 @@ paths:name: United States of Americanumcode: 840states_required: true- updated_at: '2021-10-05T18:32:22.958Z'+ updated_at: '2021-10-07T10:44:33.967Z'zipcode_required: true- created_at: '2021-10-05T18:32:22.958Z'+ created_at: '2021-10-07T10:44:33.967Z'relationships:states:data: []@@ -1675,9 +1677,9 @@ paths:name: NAME_2numcode: 840states_required: false- updated_at: '2021-10-05T18:32:22.965Z'+ updated_at: '2021-10-07T10:44:33.974Z'zipcode_required: true- created_at: '2021-10-05T18:32:22.965Z'+ created_at: '2021-10-07T10:44:33.974Z'relationships:states:data: []@@ -1690,9 +1692,9 @@ paths:name: NAME_3numcode: 840states_required: false- updated_at: '2021-10-05T18:32:22.967Z'+ updated_at: '2021-10-07T10:44:33.977Z'zipcode_required: true- created_at: '2021-10-05T18:32:22.967Z'+ created_at: '2021-10-07T10:44:33.977Z'relationships:states:data: []@@ -1747,9 +1749,9 @@ paths:name: NAME_6numcode: 840states_required: false- updated_at: '2021-10-05T18:32:23.030Z'+ updated_at: '2021-10-07T10:44:34.036Z'zipcode_required: true- created_at: '2021-10-05T18:32:23.030Z'+ created_at: '2021-10-07T10:44:34.036Z'relationships:states:data: []@@ -1769,6 +1771,479 @@ paths:Example:value:error: The access token is invalid+ "/api/v2/platform/line_items":+ get:+ summary: Returns a list of Line Items+ tags:+ - Line Items+ security:+ - bearer_auth: []+ description: Returns a list of Line Items+ operationId: line-items-list+ parameters:+ - name: page+ in: query+ example: 1+ schema:+ type: integer+ - name: per_page+ in: query+ example: 50+ schema:+ type: integer+ - name: include+ in: query+ description: 'Select which associated resources you would like to fetch, see:+ <a href="https://jsonapi.org/format/#fetching-includes">https://jsonapi.org/format/#fetching-includes</a>'+ example: order,tax_category,variant.product+ schema:+ type: string+ - name: filter+ in: query+ description: ''+ example: order_id_eq=1+ schema:+ type: string+ responses:+ '200':+ description: Records returned+ content:+ application/vnd.api+json:+ examples:+ Example:+ value:+ data:+ - id: '1'+ type: line_item+ attributes:+ quantity: 1+ price: '10.0'+ created_at: '2021-10-07T10:44:34.194Z'+ updated_at: '2021-10-07T10:44:34.209Z'+ currency: USD+ cost_price: '17.0'+ adjustment_total: '0.0'+ additional_tax_total: '0.0'+ promo_total: '0.0'+ included_tax_total: '0.0'+ pre_tax_amount: '10.0'+ taxable_adjustment_total: '0.0'+ non_taxable_adjustment_total: '0.0'+ display_price: "$10.00"+ single_display_amount: "$10.00"+ display_discounted_amount: "$10.00"+ display_total: "$10.00"+ display_subtotal: "$10.00"+ display_final_amount: "$10.00"+ display_adjustment_total: "$0.00"+ display_additional_tax_total: "$0.00"+ display_promo_total: "$0.00"+ display_included_tax_total: "$0.00"+ display_pre_tax_amount: "$10.00"+ display_amount: "$10.00"+ relationships:+ order:+ data:+ id: '1'+ type: order+ tax_category:+ data:+ id: '31'+ type: tax_category+ variant:+ data:+ id: '33'+ type: variant+ adjustments:+ data: []+ inventory_units:+ data: []+ - id: '2'+ type: line_item+ attributes:+ quantity: 1+ price: '10.0'+ created_at: '2021-10-07T10:44:34.245Z'+ updated_at: '2021-10-07T10:44:34.251Z'+ currency: USD+ cost_price: '17.0'+ adjustment_total: '0.0'+ additional_tax_total: '0.0'+ promo_total: '0.0'+ included_tax_total: '0.0'+ pre_tax_amount: '10.0'+ taxable_adjustment_total: '0.0'+ non_taxable_adjustment_total: '0.0'+ display_price: "$10.00"+ single_display_amount: "$10.00"+ display_discounted_amount: "$10.00"+ display_total: "$10.00"+ display_subtotal: "$10.00"+ display_final_amount: "$10.00"+ display_adjustment_total: "$0.00"+ display_additional_tax_total: "$0.00"+ display_promo_total: "$0.00"+ display_included_tax_total: "$0.00"+ display_pre_tax_amount: "$10.00"+ display_amount: "$10.00"+ relationships:+ order:+ data:+ id: '1'+ type: order+ tax_category:+ data:+ id: '31'+ type: tax_category+ variant:+ data:+ id: '34'+ type: variant+ adjustments:+ data: []+ inventory_units:+ data: []+ meta:+ count: 2+ total_count: 2+ total_pages: 1+ links:+ self: http://www.example.com/api/v2/platform/line_items?page=1&per_page=&include=&filter=+ next: http://www.example.com/api/v2/platform/line_items?include=&page=1&per_page=+ prev: http://www.example.com/api/v2/platform/line_items?include=&page=1&per_page=+ last: http://www.example.com/api/v2/platform/line_items?include=&page=1&per_page=+ first: http://www.example.com/api/v2/platform/line_items?include=&page=1&per_page=+ '401':+ description: Authentication Failed+ content:+ application/vnd.api+json:+ examples:+ Example:+ value:+ error: The access token is invalid+ post:+ summary: Creates a Line Item+ tags:+ - Line Items+ security:+ - bearer_auth: []+ description: Creates a Line Item+ operationId: create-line-item+ parameters:+ - name: include+ in: query+ description: 'Select which associated resources you would like to fetch, see:+ <a href="https://jsonapi.org/format/#fetching-includes">https://jsonapi.org/format/#fetching-includes</a>'+ example: order,tax_category,variant.product+ schema:+ type: string+ responses:+ '201':+ description: record created+ content:+ application/vnd.api+json:+ examples:+ Example:+ value:+ data:+ id: '5'+ type: line_item+ attributes:+ quantity: 1+ price: '10.0'+ created_at: '2021-10-07T10:44:34.518Z'+ updated_at: '2021-10-07T10:44:34.551Z'+ currency: USD+ cost_price: '17.0'+ adjustment_total: '0.0'+ additional_tax_total: '0.0'+ promo_total: '0.0'+ included_tax_total: '0.0'+ pre_tax_amount: '10.0'+ taxable_adjustment_total: '0.0'+ non_taxable_adjustment_total: '0.0'+ display_price: "$10.00"+ single_display_amount: "$10.00"+ display_discounted_amount: "$10.00"+ display_total: "$10.00"+ display_subtotal: "$10.00"+ display_final_amount: "$10.00"+ display_adjustment_total: "$0.00"+ display_additional_tax_total: "$0.00"+ display_promo_total: "$0.00"+ display_included_tax_total: "$0.00"+ display_pre_tax_amount: "$10.00"+ display_amount: "$10.00"+ relationships:+ order:+ data:+ id: '3'+ type: order+ tax_category:+ data:+ id: '33'+ type: tax_category+ variant:+ data:+ id: '37'+ type: variant+ adjustments:+ data: []+ inventory_units:+ data: []+ '422':+ description: invalid request+ content:+ application/vnd.api+json:+ examples:+ Example:+ value:+ error: Variant can't be blank, Price is not a number, Currency+ Must match order currency+ errors:+ variant:+ - can't be blank+ price:+ - is not a number+ currency:+ - Must match order currency+ requestBody:+ content:+ application/json:+ schema:+ "$ref": "#/components/schemas/line_item_params"+ "/api/v2/platform/line_items/{id}":+ get:+ summary: Returns a Line Item+ tags:+ - Line Items+ security:+ - bearer_auth: []+ description: Returns a Line Item+ operationId: show-line-item+ parameters:+ - name: id+ in: path+ required: true+ schema:+ type: string+ - name: include+ in: query+ description: 'Select which associated resources you would like to fetch, see:+ <a href="https://jsonapi.org/format/#fetching-includes">https://jsonapi.org/format/#fetching-includes</a>'+ example: order,tax_category,variant.product+ schema:+ type: string+ responses:+ '200':+ description: Record found+ content:+ application/vnd.api+json:+ examples:+ Example:+ value:+ data:+ id: '6'+ type: line_item+ attributes:+ quantity: 1+ price: '10.0'+ created_at: '2021-10-07T10:44:34.716Z'+ updated_at: '2021-10-07T10:44:34.723Z'+ currency: USD+ cost_price: '17.0'+ adjustment_total: '0.0'+ additional_tax_total: '0.0'+ promo_total: '0.0'+ included_tax_total: '0.0'+ pre_tax_amount: '10.0'+ taxable_adjustment_total: '0.0'+ non_taxable_adjustment_total: '0.0'+ display_price: "$10.00"+ single_display_amount: "$10.00"+ display_discounted_amount: "$10.00"+ display_total: "$10.00"+ display_subtotal: "$10.00"+ display_final_amount: "$10.00"+ display_adjustment_total: "$0.00"+ display_additional_tax_total: "$0.00"+ display_promo_total: "$0.00"+ display_included_tax_total: "$0.00"+ display_pre_tax_amount: "$10.00"+ display_amount: "$10.00"+ relationships:+ order:+ data:+ id: '5'+ type: order+ tax_category:+ data:+ id: '34'+ type: tax_category+ variant:+ data:+ id: '38'+ type: variant+ adjustments:+ data: []+ inventory_units:+ data: []+ '404':+ description: Record not found+ content:+ application/vnd.api+json:+ examples:+ Example:+ value:+ error: The resource you were looking for could not be found.+ '401':+ description: Authentication Failed+ content:+ application/vnd.api+json:+ examples:+ Example:+ value:+ error: The access token is invalid+ put:+ summary: Updates a Line Item+ tags:+ - Line Items+ security:+ - bearer_auth: []+ description: Updates a Line Item+ operationId: update-line-item+ parameters:+ - name: id+ in: path+ required: true+ schema:+ type: string+ - name: include+ in: query+ description: 'Select which associated resources you would like to fetch, see:+ <a href="https://jsonapi.org/format/#fetching-includes">https://jsonapi.org/format/#fetching-includes</a>'+ example: order,tax_category,variant.product+ schema:+ type: string+ responses:+ '200':+ description: record updated+ content:+ application/vnd.api+json:+ examples:+ Example:+ value:+ data:+ id: '8'+ type: line_item+ attributes:+ quantity: 4+ price: '10.0'+ created_at: '2021-10-07T10:44:34.996Z'+ updated_at: '2021-10-07T10:44:35.042Z'+ currency: USD+ cost_price: '17.0'+ adjustment_total: '0.0'+ additional_tax_total: '0.0'+ promo_total: '0.0'+ included_tax_total: '0.0'+ pre_tax_amount: '40.0'+ taxable_adjustment_total: '0.0'+ non_taxable_adjustment_total: '0.0'+ display_price: "$10.00"+ single_display_amount: "$10.00"+ display_discounted_amount: "$40.00"+ display_total: "$40.00"+ display_subtotal: "$40.00"+ display_final_amount: "$40.00"+ display_adjustment_total: "$0.00"+ display_additional_tax_total: "$0.00"+ display_promo_total: "$0.00"+ display_included_tax_total: "$0.00"+ display_pre_tax_amount: "$40.00"+ display_amount: "$40.00"+ relationships:+ order:+ data:+ id: '7'+ type: order+ tax_category:+ data:+ id: '36'+ type: tax_category+ variant:+ data:+ id: '42'+ type: variant+ adjustments:+ data: []+ inventory_units:+ data: []+ '422':+ description: invalid request+ content:+ application/vnd.api+json:+ examples:+ Example:+ value:+ error: 'Quantity selected of "Product #44 - 3561" is not available.'+ errors:+ quantity:+ - 'selected of "Product #44 - 3561" is not available.'+ '404':+ description: Record not found+ content:+ application/vnd.api+json:+ examples:+ Example:+ value:+ error: The resource you were looking for could not be found.+ '401':+ description: Authentication Failed+ content:+ application/vnd.api+json:+ examples:+ Example:+ value:+ error: The access token is invalid+ requestBody:+ content:+ application/json:+ schema:+ "$ref": "#/components/schemas/line_item_params"+ delete:+ summary: Deletes a Line Item+ tags:+ - Line Items+ security:+ - bearer_auth: []+ description: Deletes a Line Item+ operationId: delete-line-item+ parameters:+ - name: id+ in: path+ required: true+ schema:+ type: string+ responses:+ '204':+ description: Record deleted+ '404':+ description: Record not found+ content:+ application/vnd.api+json:+ examples:+ Example:+ value:+ error: The resource you were looking for could not be found.+ '401':+ description: Authentication Failed+ content:+ application/vnd.api+json:+ examples:+ Example:+ value:+ error: The access token is invalid"/api/v2/platform/menu_items":get:summary: Returns a list of Menu Items@@ -1824,8 +2299,8 @@ paths:lft: 2rgt: 3depth: 1- created_at: '2021-10-05T18:32:23.256Z'- updated_at: '2021-10-05T18:32:23.264Z'+ created_at: '2021-10-07T10:44:35.767Z'+ updated_at: '2021-10-07T10:44:35.775Z'link:is_container: falseis_root: false@@ -1861,8 +2336,8 @@ paths:lft: 4rgt: 5depth: 1- created_at: '2021-10-05T18:32:23.355Z'- updated_at: '2021-10-05T18:32:23.363Z'+ created_at: '2021-10-07T10:44:35.862Z'+ updated_at: '2021-10-07T10:44:35.868Z'link:is_container: falseis_root: false@@ -1898,8 +2373,8 @@ paths:lft: 6rgt: 7depth: 1- created_at: '2021-10-05T18:32:23.437Z'- updated_at: '2021-10-05T18:32:23.443Z'+ created_at: '2021-10-07T10:44:35.953Z'+ updated_at: '2021-10-07T10:44:35.960Z'link:is_container: falseis_root: false@@ -1935,8 +2410,8 @@ paths:lft: 8rgt: 9depth: 1- created_at: '2021-10-05T18:32:23.520Z'- updated_at: '2021-10-05T18:32:23.527Z'+ created_at: '2021-10-07T10:44:36.042Z'+ updated_at: '2021-10-07T10:44:36.049Z'link:is_container: falseis_root: false@@ -1972,8 +2447,8 @@ paths:lft: 10rgt: 11depth: 1- created_at: '2021-10-05T18:32:23.602Z'- updated_at: '2021-10-05T18:32:23.610Z'+ created_at: '2021-10-07T10:44:36.136Z'+ updated_at: '2021-10-07T10:44:36.144Z'link:is_container: falseis_root: false@@ -2009,8 +2484,8 @@ paths:lft: 12rgt: 13depth: 1- created_at: '2021-10-05T18:32:23.684Z'- updated_at: '2021-10-05T18:32:23.691Z'+ created_at: '2021-10-07T10:44:36.229Z'+ updated_at: '2021-10-07T10:44:36.236Z'link:is_container: falseis_root: false@@ -2046,8 +2521,8 @@ paths:lft: 14rgt: 15depth: 1- created_at: '2021-10-05T18:32:23.767Z'- updated_at: '2021-10-05T18:32:23.772Z'+ created_at: '2021-10-07T10:44:36.321Z'+ updated_at: '2021-10-07T10:44:36.328Z'link:is_container: falseis_root: false@@ -2073,8 +2548,7 @@ paths:- id: '1'type: menu_itemattributes:- name: Est asperiores nisi quod aliquid accusamus repellendus- dolores.+ name: Doloribus esse cupiditate ipsa fugit excepturi vitae.subtitle:destination:new_window: false@@ -2084,8 +2558,8 @@ paths:lft: 1rgt: 16depth: 0- created_at: '2021-10-05T18:32:23.170Z'- updated_at: '2021-10-05T18:32:23.784Z'+ created_at: '2021-10-07T10:44:35.681Z'+ updated_at: '2021-10-07T10:44:36.343Z'link:is_container: trueis_root: true@@ -2174,8 +2648,8 @@ paths:lft: 8rgt: 9depth: 1- created_at: '2021-10-05T18:32:24.829Z'- updated_at: '2021-10-05T18:32:24.834Z'+ created_at: '2021-10-07T10:44:37.414Z'+ updated_at: '2021-10-07T10:44:37.420Z'link:is_container: falseis_root: false@@ -2261,8 +2735,8 @@ paths:lft: 8rgt: 9depth: 1- created_at: '2021-10-05T18:32:25.502Z'- updated_at: '2021-10-05T18:32:25.509Z'+ created_at: '2021-10-07T10:44:38.134Z'+ updated_at: '2021-10-07T10:44:38.141Z'link:is_container: falseis_root: false@@ -2344,8 +2818,8 @@ paths:lft: 8rgt: 9depth: 1- created_at: '2021-10-05T18:32:26.576Z'- updated_at: '2021-10-05T18:32:26.610Z'+ created_at: '2021-10-07T10:44:39.291Z'+ updated_at: '2021-10-07T10:44:39.327Z'link:is_container: falseis_root: false@@ -2470,8 +2944,8 @@ paths:lft: 5rgt: 6depth: 2- created_at: '2021-10-05T18:32:29.052Z'- updated_at: '2021-10-05T18:32:29.087Z'+ created_at: '2021-10-07T10:44:42.045Z'+ updated_at: '2021-10-07T10:44:42.084Z'link:is_container: falseis_root: false@@ -2563,8 +3037,8 @@ paths:name: Main Menulocation: headerlocale: en- created_at: '2021-10-05T18:32:29.768Z'- updated_at: '2021-10-05T18:32:29.985Z'+ created_at: '2021-10-07T10:44:42.879Z'+ updated_at: '2021-10-07T10:44:43.088Z'relationships:menu_items:data:@@ -2580,8 +3054,8 @@ paths:name: Footer Menulocation: footerlocale: en- created_at: '2021-10-05T18:32:29.779Z'- updated_at: '2021-10-05T18:32:30.145Z'+ created_at: '2021-10-07T10:44:42.892Z'+ updated_at: '2021-10-07T10:44:43.278Z'relationships:menu_items:data:@@ -2640,8 +3114,8 @@ paths:name: Main Menulocation: headerlocale: en- created_at: '2021-10-05T18:32:30.574Z'- updated_at: '2021-10-05T18:32:30.582Z'+ created_at: '2021-10-07T10:44:43.774Z'+ updated_at: '2021-10-07T10:44:43.783Z'relationships:menu_items:data:@@ -2705,8 +3179,8 @@ paths:name: Main Menulocation: headerlocale: en- created_at: '2021-10-05T18:32:30.629Z'- updated_at: '2021-10-05T18:32:30.640Z'+ created_at: '2021-10-07T10:44:43.834Z'+ updated_at: '2021-10-07T10:44:43.843Z'relationships:menu_items:data:@@ -2764,8 +3238,8 @@ paths:name: Main Menulocation: headerlocale: en- created_at: '2021-10-05T18:32:30.731Z'- updated_at: '2021-10-05T18:32:30.739Z'+ created_at: '2021-10-07T10:44:43.926Z'+ updated_at: '2021-10-07T10:44:43.934Z'relationships:menu_items:data:@@ -2889,8 +3363,8 @@ paths:name: foo-size-1presentation: Sizeposition: 1- created_at: '2021-10-05T18:32:30.953Z'- updated_at: '2021-10-05T18:32:30.953Z'+ created_at: '2021-10-07T10:44:44.164Z'+ updated_at: '2021-10-07T10:44:44.164Z'filterable: truerelationships:option_values:@@ -2901,8 +3375,8 @@ paths:name: foo-size-2presentation: Sizeposition: 2- created_at: '2021-10-05T18:32:30.956Z'- updated_at: '2021-10-05T18:32:30.956Z'+ created_at: '2021-10-07T10:44:44.167Z'+ updated_at: '2021-10-07T10:44:44.167Z'filterable: truerelationships:option_values:@@ -2956,8 +3430,8 @@ paths:name: foo-size-5presentation: Sizeposition: 1- created_at: '2021-10-05T18:32:31.029Z'- updated_at: '2021-10-05T18:32:31.029Z'+ created_at: '2021-10-07T10:44:44.242Z'+ updated_at: '2021-10-07T10:44:44.242Z'filterable: truerelationships:option_values:@@ -3017,8 +3491,8 @@ paths:name: foo-size-6presentation: Sizeposition: 1- created_at: '2021-10-05T18:32:31.071Z'- updated_at: '2021-10-05T18:32:31.071Z'+ created_at: '2021-10-07T10:44:44.282Z'+ updated_at: '2021-10-07T10:44:44.282Z'filterable: truerelationships:option_values:@@ -3075,8 +3549,8 @@ paths:name: Size-Xpresentation: Sizeposition: 1- created_at: '2021-10-05T18:32:31.136Z'- updated_at: '2021-10-05T18:32:31.150Z'+ created_at: '2021-10-07T10:44:44.346Z'+ updated_at: '2021-10-07T10:44:44.356Z'filterable: truerelationships:option_values:@@ -3194,8 +3668,8 @@ paths:position: 1name: Size-1presentation: S- created_at: '2021-10-05T18:32:31.298Z'- updated_at: '2021-10-05T18:32:31.298Z'+ created_at: '2021-10-07T10:44:44.506Z'+ updated_at: '2021-10-07T10:44:44.506Z'relationships:option_type:data:@@ -3207,8 +3681,8 @@ paths:position: 1name: Size-2presentation: S- created_at: '2021-10-05T18:32:31.305Z'- updated_at: '2021-10-05T18:32:31.305Z'+ created_at: '2021-10-07T10:44:44.514Z'+ updated_at: '2021-10-07T10:44:44.514Z'relationships:option_type:data:@@ -3263,8 +3737,8 @@ paths:position: 1name: Size-5presentation: S- created_at: '2021-10-05T18:32:31.373Z'- updated_at: '2021-10-05T18:32:31.373Z'+ created_at: '2021-10-07T10:44:44.597Z'+ updated_at: '2021-10-07T10:44:44.597Z'relationships:option_type:data:@@ -3323,8 +3797,8 @@ paths:position: 1name: Size-6presentation: S- created_at: '2021-10-05T18:32:31.417Z'- updated_at: '2021-10-05T18:32:31.417Z'+ created_at: '2021-10-07T10:44:44.642Z'+ updated_at: '2021-10-07T10:44:44.642Z'relationships:option_type:data:@@ -3382,8 +3856,8 @@ paths:position: 1name: Mpresentation: S- created_at: '2021-10-05T18:32:31.485Z'- updated_at: '2021-10-05T18:32:31.498Z'+ created_at: '2021-10-07T10:44:44.718Z'+ updated_at: '2021-10-07T10:44:44.730Z'relationships:option_type:data:@@ -3496,10 +3970,10 @@ paths:Example:value:data:- - id: '1'+ - id: '12'type: orderattributes:- number: R349337254+ number: R187528997item_total: '0.0'total: '0.0'state: cart@@ -3508,10 +3982,10 @@ paths:payment_total: '0.0'shipment_state:payment_state:- email: [email protected]+ email: [email protected]special_instructions:- created_at: '2021-10-05T18:32:31.687Z'- updated_at: '2021-10-05T18:32:31.687Z'+ created_at: '2021-10-07T10:44:44.920Z'+ updated_at: '2021-10-07T10:44:44.920Z'currency: USDlast_ip_address:shipment_total: '0.0'@@ -3548,7 +4022,7 @@ paths:relationships:user:data:- id: '2'+ id: '13'type: usercreated_by:data:@@ -3558,7 +4032,7 @@ paths:data:bill_address:data:- id: '13'+ id: '24'type: addressship_address:data:@@ -3580,10 +4054,10 @@ paths:data: []order_promotions:data: []- - id: '2'+ - id: '13'type: orderattributes:- number: R649808280+ number: R812920759item_total: '0.0'total: '0.0'state: cart@@ -3592,10 +4066,10 @@ paths:payment_total: '0.0'shipment_state:payment_state:- email: [email protected]+ email: [email protected]special_instructions:- created_at: '2021-10-05T18:32:31.699Z'- updated_at: '2021-10-05T18:32:31.699Z'+ created_at: '2021-10-07T10:44:44.932Z'+ updated_at: '2021-10-07T10:44:44.932Z'currency: USDlast_ip_address:shipment_total: '0.0'@@ -3632,7 +4106,7 @@ paths:relationships:user:data:- id: '3'+ id: '14'type: usercreated_by:data:@@ -3642,7 +4116,7 @@ paths:data:bill_address:data:- id: '14'+ id: '25'type: addressship_address:data:@@ -3707,10 +4181,10 @@ paths:Example:value:data:- id: '5'+ id: '16'type: orderattributes:- number: R104353616+ number: R982789159item_total: '0.0'total: '0.0'state: cart@@ -3721,8 +4195,8 @@ paths:payment_state:email:special_instructions:- created_at: '2021-10-05T18:32:32.063Z'- updated_at: '2021-10-05T18:32:32.084Z'+ created_at: '2021-10-07T10:44:45.305Z'+ updated_at: '2021-10-07T10:44:45.324Z'currency: USDlast_ip_address:shipment_total: '0.0'@@ -3767,15 +4241,15 @@ paths:data:bill_address:data:- id: '17'+ id: '28'type: addressship_address:data:- id: '17'+ id: '28'type: addressline_items:data:- - id: '1'+ - id: '13'type: line_itempayments:data:@@ -3831,10 +4305,10 @@ paths:Example:value:data:- id: '6'+ id: '17'type: orderattributes:- number: R105897309+ number: R814654664item_total: '10.0'total: '110.0'state: delivery@@ -3843,10 +4317,10 @@ paths:payment_total: '0.0'shipment_state:payment_state:- email: [email protected]+ email: [email protected]special_instructions:- created_at: '2021-10-05T18:32:32.132Z'- updated_at: '2021-10-05T18:32:32.412Z'+ created_at: '2021-10-07T10:44:45.384Z'+ updated_at: '2021-10-07T10:44:45.586Z'currency: USDlast_ip_address:shipment_total: '100.0'@@ -3883,7 +4357,7 @@ paths:relationships:user:data:- id: '6'+ id: '17'type: usercreated_by:data:@@ -3893,15 +4367,15 @@ paths:data:bill_address:data:- id: '18'+ id: '29'type: addressship_address:data:- id: '19'+ id: '30'type: addressline_items:data:- - id: '2'+ - id: '14'type: line_itempayments:data: []@@ -3967,10 +4441,10 @@ paths:Example:value:data:- id: '8'+ id: '19'type: orderattributes:- number: R153917278+ number: R447646390item_total: '10.0'total: '110.0'state: delivery@@ -3981,8 +4455,8 @@ paths:payment_state:email: [email protected]special_instructions:- created_at: '2021-10-05T18:32:32.636Z'- updated_at: '2021-10-05T18:32:32.750Z'+ created_at: '2021-10-07T10:44:45.881Z'+ updated_at: '2021-10-07T10:44:46.082Z'currency: USDlast_ip_address:shipment_total: '100.0'@@ -4019,7 +4493,7 @@ paths:relationships:user:data:- id: '8'+ id: '19'type: usercreated_by:data:@@ -4029,15 +4503,15 @@ paths:data:bill_address:data:- id: '22'+ id: '33'type: addressship_address:data:- id: '23'+ id: '34'type: addressline_items:data:- - id: '4'+ - id: '16'type: line_itempayments:data: []@@ -4153,10 +4627,10 @@ paths:Example:value:data:- id: '13'+ id: '24'type: orderattributes:- number: R277647588+ number: R971363567item_total: '10.0'total: '110.0'state: payment@@ -4165,10 +4639,10 @@ paths:payment_total: '0.0'shipment_state:payment_state:- email: [email protected]+ email: [email protected]special_instructions:- created_at: '2021-10-05T18:32:33.473Z'- updated_at: '2021-10-05T18:32:33.804Z'+ created_at: '2021-10-07T10:44:47.061Z'+ updated_at: '2021-10-07T10:44:47.258Z'currency: USDlast_ip_address:shipment_total: '100.0'@@ -4205,7 +4679,7 @@ paths:relationships:user:data:- id: '13'+ id: '24'type: usercreated_by:data:@@ -4215,15 +4689,15 @@ paths:data:bill_address:data:- id: '32'+ id: '43'type: addressship_address:data:- id: '33'+ id: '44'type: addressline_items:data:- - id: '9'+ - id: '21'type: line_itempayments:data: []@@ -4292,10 +4766,10 @@ paths:Example:value:data:- id: '15'+ id: '26'type: orderattributes:- number: R255756171+ number: R414368865item_total: '10.0'total: '110.0'state: payment@@ -4304,10 +4778,10 @@ paths:payment_total: '0.0'shipment_state:payment_state:- email: [email protected]+ email: [email protected]special_instructions:- created_at: '2021-10-05T18:32:34.015Z'- updated_at: '2021-10-05T18:32:34.165Z'+ created_at: '2021-10-07T10:44:47.501Z'+ updated_at: '2021-10-07T10:44:47.691Z'currency: USDlast_ip_address:shipment_total: '100.0'@@ -4344,7 +4818,7 @@ paths:relationships:user:data:- id: '15'+ id: '26'type: usercreated_by:data:@@ -4354,15 +4828,15 @@ paths:data:bill_address:data:- id: '36'+ id: '47'type: addressship_address:data:- id: '37'+ id: '48'type: addressline_items:data:- - id: '11'+ - id: '23'type: line_itempayments:data: []@@ -4431,22 +4905,22 @@ paths:Example:value:data:- id: '17'+ id: '28'type: orderattributes:- number: R376064539+ number: R994817364item_total: '10.0'total: '110.0'state: completeadjustment_total: '0.0'- completed_at: '2021-10-05T18:32:34.604Z'+ completed_at: '2021-10-07T10:44:48.241Z'payment_total: '0.0'shipment_state: pendingpayment_state: balance_due- email: [email protected]+ email: [email protected]special_instructions:- created_at: '2021-10-05T18:32:34.362Z'- updated_at: '2021-10-05T18:32:34.604Z'+ created_at: '2021-10-07T10:44:47.939Z'+ updated_at: '2021-10-07T10:44:48.241Z'currency: USDlast_ip_address:shipment_total: '100.0'@@ -4483,7 +4957,7 @@ paths:relationships:user:data:- id: '17'+ id: '28'type: usercreated_by:data:@@ -4493,15 +4967,15 @@ paths:data:bill_address:data:- id: '40'+ id: '51'type: addressship_address:data:- id: '41'+ id: '52'type: addressline_items:data:- - id: '13'+ - id: '25'type: line_itempayments:data:@@ -4581,10 +5055,10 @@ paths:Example:value:data:- id: '20'+ id: '31'type: orderattributes:- number: R050114369+ number: R427992001item_total: '0.0'total: '0.0'state: cart@@ -4593,10 +5067,10 @@ paths:payment_total: '0.0'shipment_state:payment_state:- email: [email protected]+ email: [email protected]special_instructions:- created_at: '2021-10-05T18:32:34.937Z'- updated_at: '2021-10-05T18:32:35.063Z'+ created_at: '2021-10-07T10:44:48.704Z'+ updated_at: '2021-10-07T10:44:48.906Z'currency: USDlast_ip_address:shipment_total: '0.0'@@ -4633,7 +5107,7 @@ paths:relationships:user:data:- id: '20'+ id: '31'type: usercreated_by:data:@@ -4643,11 +5117,11 @@ paths:data:bill_address:data:- id: '46'+ id: '57'type: addressship_address:data:- id: '47'+ id: '58'type: addressline_items:data: []@@ -4714,10 +5188,10 @@ paths:Example:value:data:- id: '22'+ id: '33'type: orderattributes:- number: R607458776+ number: R742603804item_total: '10.0'total: '110.0'state: delivery@@ -4726,10 +5200,10 @@ paths:payment_total: '0.0'shipment_state:payment_state:- email: [email protected]+ email: [email protected]special_instructions:- created_at: '2021-10-05T18:32:35.265Z'- updated_at: '2021-10-05T18:32:35.420Z'+ created_at: '2021-10-07T10:44:49.263Z'+ updated_at: '2021-10-07T10:44:49.579Z'currency: USDlast_ip_address:shipment_total: '100.0'@@ -4766,7 +5240,7 @@ paths:relationships:user:data:- id: '22'+ id: '33'type: usercreated_by:data:@@ -4776,15 +5250,15 @@ paths:data:bill_address:data:- id: '50'+ id: '61'type: addressship_address:data:- id: '51'+ id: '62'type: addressline_items:data:- - id: '18'+ - id: '30'type: line_itempayments:data:@@ -4867,10 +5341,10 @@ paths:Example:value:data:- id: '25'+ id: '36'type: orderattributes:- number: R934098315+ number: R538417532item_total: '10.0'total: '10.0'state: delivery@@ -4879,10 +5353,10 @@ paths:payment_total: '0.0'shipment_state:payment_state:- email: [email protected]+ email: [email protected]special_instructions:- created_at: '2021-10-05T18:32:35.799Z'- updated_at: '2021-10-05T18:32:35.950Z'+ created_at: '2021-10-07T10:44:50.154Z'+ updated_at: '2021-10-07T10:44:50.354Z'currency: USDlast_ip_address:shipment_total: '100.0'@@ -4919,7 +5393,7 @@ paths:relationships:user:data:- id: '26'+ id: '37'type: usercreated_by:data:@@ -4929,15 +5403,15 @@ paths:data:bill_address:data:- id: '56'+ id: '67'type: addressship_address:data:- id: '57'+ id: '68'type: addressline_items:data:- - id: '21'+ - id: '33'type: line_itempayments:data: []@@ -5041,8 +5515,8 @@ paths:lft: 2rgt: 3description:- created_at: '2021-10-05T18:32:36.363Z'- updated_at: '2021-10-05T18:32:36.368Z'+ created_at: '2021-10-07T10:44:50.851Z'+ updated_at: '2021-10-07T10:44:50.857Z'meta_title:meta_description:meta_keywords:@@ -5076,8 +5550,8 @@ paths:lft: 4rgt: 5description:- created_at: '2021-10-05T18:32:36.444Z'- updated_at: '2021-10-05T18:32:36.449Z'+ created_at: '2021-10-07T10:44:50.950Z'+ updated_at: '2021-10-07T10:44:50.956Z'meta_title:meta_description:meta_keywords:@@ -5111,8 +5585,8 @@ paths:lft: 1rgt: 6description:- created_at: '2021-10-05T18:32:36.287Z'- updated_at: '2021-10-05T18:32:36.463Z'+ created_at: '2021-10-07T10:44:50.757Z'+ updated_at: '2021-10-07T10:44:50.970Z'meta_title:meta_description:meta_keywords:@@ -5189,8 +5663,8 @@ paths:lft: 2rgt: 3description:- created_at: '2021-10-05T18:32:36.779Z'- updated_at: '2021-10-05T18:32:36.785Z'+ created_at: '2021-10-07T10:44:51.364Z'+ updated_at: '2021-10-07T10:44:51.372Z'meta_title:meta_description:meta_keywords:@@ -5271,8 +5745,8 @@ paths:lft: 2rgt: 3description:- created_at: '2021-10-05T18:32:36.919Z'- updated_at: '2021-10-05T18:32:36.925Z'+ created_at: '2021-10-07T10:44:51.544Z'+ updated_at: '2021-10-07T10:44:51.550Z'meta_title:meta_description:meta_keywords:@@ -5354,8 +5828,8 @@ paths:lft: 2rgt: 3description:- created_at: '2021-10-05T18:32:37.207Z'- updated_at: '2021-10-05T18:32:37.241Z'+ created_at: '2021-10-07T10:44:51.909Z'+ updated_at: '2021-10-07T10:44:51.950Z'meta_title:meta_description:meta_keywords:@@ -5487,12 +5961,12 @@ paths:Example:value:data:- - id: '29'+ - id: '40'type: userattributes:- email: [email protected]- created_at: '2021-10-05T18:32:37.831Z'- updated_at: '2021-10-05T18:32:37.831Z'+ email: [email protected]+ created_at: '2021-10-07T10:44:52.709Z'+ updated_at: '2021-10-07T10:44:52.709Z'average_order_value: []lifetime_value: []store_credits: []@@ -5501,12 +5975,12 @@ paths:data:ship_address:data:- - id: '30'+ - id: '41'type: userattributes:- email: [email protected]- created_at: '2021-10-05T18:32:37.838Z'- updated_at: '2021-10-05T18:32:37.838Z'+ email: [email protected]+ created_at: '2021-10-07T10:44:52.719Z'+ updated_at: '2021-10-07T10:44:52.719Z'average_order_value: []lifetime_value: []store_credits: []@@ -5515,12 +5989,12 @@ paths:data:ship_address:data:- - id: '31'+ - id: '42'type: userattributes:- email: [email protected]- created_at: '2021-10-05T18:32:37.840Z'- updated_at: '2021-10-05T18:32:37.840Z'+ email: [email protected]+ created_at: '2021-10-07T10:44:52.721Z'+ updated_at: '2021-10-07T10:44:52.721Z'average_order_value: []lifetime_value: []store_credits: []@@ -5572,12 +6046,12 @@ paths:Example:value:data:- id: '36'+ id: '47'type: userattributes:- email: [email protected]- created_at: '2021-10-05T18:32:37.931Z'- updated_at: '2021-10-05T18:32:37.931Z'+ email: [email protected]+ created_at: '2021-10-07T10:44:52.827Z'+ updated_at: '2021-10-07T10:44:52.827Z'average_order_value: []lifetime_value: []store_credits: []@@ -5633,12 +6107,12 @@ paths:Example:value:data:- id: '39'+ id: '50'type: userattributes:- email: [email protected]- created_at: '2021-10-05T18:32:37.989Z'- updated_at: '2021-10-05T18:32:37.989Z'+ email: [email protected]+ created_at: '2021-10-07T10:44:52.897Z'+ updated_at: '2021-10-07T10:44:52.897Z'average_order_value: []lifetime_value: []store_credits: []@@ -5693,12 +6167,12 @@ paths:Example:value:data:- id: '44'+ id: '55'type: userattributes:email: [email protected]- created_at: '2021-10-05T18:32:38.077Z'- updated_at: '2021-10-05T18:32:38.089Z'+ created_at: '2021-10-07T10:44:52.998Z'+ updated_at: '2021-10-07T10:44:53.016Z'average_order_value: []lifetime_value: []store_credits: []@@ -5812,8 +6286,8 @@ paths:type: wished_itemattributes:quantity: 1- created_at: '2021-10-05T18:32:38.450Z'- updated_at: '2021-10-05T18:32:38.450Z'+ created_at: '2021-10-07T10:44:53.506Z'+ updated_at: '2021-10-07T10:44:53.506Z'display_total: "$19.99"display_price: "$19.99"price: '19.99'@@ -5821,14 +6295,14 @@ paths:relationships:variant:data:- id: '60'+ id: '79'type: variant- id: '2'type: wished_itemattributes:quantity: 1- created_at: '2021-10-05T18:32:38.510Z'- updated_at: '2021-10-05T18:32:38.510Z'+ created_at: '2021-10-07T10:44:53.578Z'+ updated_at: '2021-10-07T10:44:53.578Z'display_total: "$19.99"display_price: "$19.99"price: '19.99'@@ -5836,14 +6310,14 @@ paths:relationships:variant:data:- id: '62'+ id: '81'type: variant- id: '3'type: wished_itemattributes:quantity: 1- created_at: '2021-10-05T18:32:38.567Z'- updated_at: '2021-10-05T18:32:38.567Z'+ created_at: '2021-10-07T10:44:53.667Z'+ updated_at: '2021-10-07T10:44:53.667Z'display_total: "$19.99"display_price: "$19.99"price: '19.99'@@ -5851,14 +6325,14 @@ paths:relationships:variant:data:- id: '64'+ id: '83'type: variant- id: '4'type: wished_itemattributes:quantity: 1- created_at: '2021-10-05T18:32:38.623Z'- updated_at: '2021-10-05T18:32:38.623Z'+ created_at: '2021-10-07T10:44:53.762Z'+ updated_at: '2021-10-07T10:44:53.762Z'display_total: "$19.99"display_price: "$19.99"price: '19.99'@@ -5866,7 +6340,7 @@ paths:relationships:variant:data:- id: '66'+ id: '85'type: variantmeta:count: 4@@ -5915,8 +6389,8 @@ paths:type: wished_itemattributes:quantity: 1- created_at: '2021-10-05T18:32:39.076Z'- updated_at: '2021-10-05T18:32:39.076Z'+ created_at: '2021-10-07T10:44:54.382Z'+ updated_at: '2021-10-07T10:44:54.382Z'display_total: "$19.99"display_price: "$19.99"price: '19.99'@@ -5924,7 +6398,7 @@ paths:relationships:variant:data:- id: '78'+ id: '97'type: variant'422':description: invalid request@@ -5982,8 +6456,8 @@ paths:type: wished_itemattributes:quantity: 1- created_at: '2021-10-05T18:32:39.354Z'- updated_at: '2021-10-05T18:32:39.354Z'+ created_at: '2021-10-07T10:44:54.686Z'+ updated_at: '2021-10-07T10:44:54.686Z'display_total: "$19.99"display_price: "$19.99"price: '19.99'@@ -5991,7 +6465,7 @@ paths:relationships:variant:data:- id: '84'+ id: '103'type: variant'404':description: Record not found@@ -6043,8 +6517,8 @@ paths:type: wished_itemattributes:quantity: 3- created_at: '2021-10-05T18:32:39.761Z'- updated_at: '2021-10-05T18:32:39.774Z'+ created_at: '2021-10-07T10:44:55.211Z'+ updated_at: '2021-10-07T10:44:55.223Z'display_total: "$59.97"display_price: "$19.99"price: '19.99'@@ -6052,7 +6526,7 @@ paths:relationships:variant:data:- id: '94'+ id: '113'type: variant'422':description: invalid request@@ -6167,9 +6641,9 @@ paths:name: Black Fridayis_private: trueis_default: false- created_at: '2021-10-05T18:32:40.616Z'- updated_at: '2021-10-05T18:32:40.616Z'- token: Li9PJPWVSbfvghmAiLWbB6Ec+ created_at: '2021-10-07T10:44:56.356Z'+ updated_at: '2021-10-07T10:44:56.356Z'+ token: 8vboRz9CrUDmU2Kos18ZLmrhvariant_included: falserelationships:wished_items:@@ -6184,9 +6658,9 @@ paths:name: Birthdayis_private: trueis_default: false- created_at: '2021-10-05T18:32:40.618Z'- updated_at: '2021-10-05T18:32:40.618Z'- token: HNSzC4KqpDv1ye9uZQh2e2KZ+ created_at: '2021-10-07T10:44:56.359Z'+ updated_at: '2021-10-07T10:44:56.359Z'+ token: 3edJqLzmNwhbzPnV6tksxHQKvariant_included: falserelationships:wished_items:@@ -6244,9 +6718,9 @@ paths:name: Wishlist_26is_private: trueis_default: false- created_at: '2021-10-05T18:32:41.174Z'- updated_at: '2021-10-05T18:32:41.174Z'- token: PKiEz7fPn5tZC53fyVJqqwan+ created_at: '2021-10-07T10:44:57.220Z'+ updated_at: '2021-10-07T10:44:57.220Z'+ token: H4n9wsJq62fypLXZoYdjYQqPvariant_included: falserelationships:wished_items:@@ -6306,9 +6780,9 @@ paths:name: My Wishlistis_private: trueis_default: false- created_at: '2021-10-05T18:32:41.219Z'- updated_at: '2021-10-05T18:32:41.219Z'- token: bLEaVAqXnuXbqo5NvAoQXUiN+ created_at: '2021-10-07T10:44:57.275Z'+ updated_at: '2021-10-07T10:44:57.275Z'+ token: Twwn8JZykLB78a5ZHNSyue8Cvariant_included: falserelationships:wished_items:@@ -6365,9 +6839,9 @@ paths:name: My Super Wishlistis_private: trueis_default: false- created_at: '2021-10-05T18:32:41.294Z'- updated_at: '2021-10-05T18:32:41.306Z'- token: gddJXFBkfxM3NEFrXMamD443+ created_at: '2021-10-07T10:44:57.367Z'+ updated_at: '2021-10-07T10:44:57.386Z'+ token: aUQfXLc3pJ4e4hKYWENdTv6Jvariant_included: falserelationships:wished_items:@@ -6448,6 +6922,7 @@ tags:- name: Countries- name: CMS Pages- name: CMS Sections+- name: Line Items- name: Menu Items- name: Menus- name: Option Types@@ -6501,6 +6976,41 @@ components:type: stringposition:type: integer+ line_item_params:+ type: object+ properties:+ order_id:+ type: string+ variant_id:+ type: string+ quantity:+ type: integer+ price:+ type: number+ cost_price:+ type: number+ currency:+ type: string+ tax_category_id:+ type: string+ adjustment_total:+ type: number+ additional_tax_total:+ type: number+ promo_total:+ type: number+ included_tax_total:+ type: number+ pre_tax_amount:+ type: number+ taxable_adjustment_total:+ type: number+ non_taxable_adjustment_total:+ type: number+ required:+ - order_id+ - variant_id+ - quantityoption_type_params:type: objectproperties:diff --git a/api/spec/integration/api/v2/platform/line_items_spec.rb b/api/spec/integration/api/v2/platform/line_items_spec.rbnew file mode 100644index 0000000000..ee2aa8b92d--- /dev/null+++ b/api/spec/integration/api/v2/platform/line_items_spec.rb@@ -0,0 +1,30 @@+require 'swagger_helper'++describe 'Line Items API', swagger: true do+ include_context 'Platform API v2'++ resource_name = 'Line Item'+ include_example = 'order,tax_category,variant.product'+ filter_example = 'order_id_eq=1'++ let(:product) { create(:product_in_stock, :without_backorder, stores: [store]) }+ let(:variant) { product.master }+ let(:id) { create(:line_item, order: order, variant: variant).id }+ let(:order) { create(:order, store: store) }+ let(:records_list) { create_list(:line_item, 2, order: order) }+ let(:valid_create_param_value) { build(:line_item, order: order).attributes }+ let(:valid_update_param_value) do+ {+ quantity: 4+ }+ end+ let(:invalid_param_value) do+ {+ order_id: order.id,+ # trying to add too much qty+ quantity: 10_000,+ }+ end++ include_examples 'CRUD examples', resource_name, include_example, filter_example+enddiff --git a/api/spec/swagger_helper.rb b/api/spec/swagger_helper.rbindex 6591dc6611..0262b63a32 100644--- a/api/spec/swagger_helper.rb+++ b/api/spec/swagger_helper.rb@@ -45,6 +45,7 @@ RSpec.configure do |config|{ name: 'Countries' },{ name: 'CMS Pages' },{ name: 'CMS Sections' },+ { name: 'Line Items' },{ name: 'Menu Items' },{ name: 'Menus' },{ name: 'Option Types' },@@ -89,6 +90,26 @@ RSpec.configure do |config|position: { type: :integer }}},+ line_item_params: {+ type: :object,+ properties: {+ order_id: { type: :string },+ variant_id: { type: :string },+ quantity: { type: :integer },+ price: { type: :number },+ cost_price: { type: :number },+ currency: { type: :string },+ tax_category_id: { type: :string },+ adjustment_total: { type: :number },+ additional_tax_total: { type: :number },+ promo_total: { type: :number },+ included_tax_total: { type: :number },+ pre_tax_amount: { type: :number },+ taxable_adjustment_total: { type: :number },+ non_taxable_adjustment_total: { type: :number }+ },+ required: %w[order_id variant_id quantity]+ },option_type_params: {type: :object,properties: {diff --git a/core/app/models/spree/app_dependencies.rb b/core/app/models/spree/app_dependencies.rbindex 41d993da58..02259ff7d5 100644--- a/core/app/models/spree/app_dependencies.rb+++ b/core/app/models/spree/app_dependencies.rb@@ -13,7 +13,8 @@ module Spree:products_finder, :taxon_finder, :line_item_by_variant_finder, :cart_estimate_shipping_rates_service,:account_create_address_service, :account_update_address_service, :account_create_service, :account_update_service,:address_finder, :collection_sorter, :error_handler, :current_store_finder, :cart_empty_service, :cart_destroy_service,- :classification_reposition_service, :credit_cards_destroy_service, :cart_associate_service, :cart_change_currency_service+ :classification_reposition_service, :credit_cards_destroy_service, :cart_associate_service, :cart_change_currency_service,+ :line_item_create_service, :line_item_update_service, :line_item_destroy_service].freezeattr_accessor *INJECTION_POINTS@@ -76,8 +77,15 @@ module Spree# credit cards@credit_cards_destroy_service = 'Spree::CreditCards::Destroy'+ # classifications@classification_reposition_service = 'Spree::Classifications::Reposition'+ # line items+ @line_item_create_service = 'Spree::LineItems::Create'+ @line_item_update_service = 'Spree::LineItems::Update'+ @line_item_destroy_service = 'Spree::LineItems::Destroy'++ # errors@error_handler = 'Spree::ErrorReporter'enddiff --git a/core/app/models/spree/line_item.rb b/core/app/models/spree/line_item.rbindex 6f841af8fb..6e3e254e8d 100644--- a/core/app/models/spree/line_item.rb+++ b/core/app/models/spree/line_item.rb@@ -27,7 +27,7 @@ module Spreevalidates :price, numericality: true- validates_with Spree::Stock::AvailabilityValidator+ validates_with Spree::Stock::AvailabilityValidator, if: -> { variant.present? }validate :ensure_proper_currency, if: -> { order.present? }before_destroy :verify_order_inventory_before_destroy, if: -> { order.has_checkout_step?('delivery') }diff --git a/core/app/services/spree/line_items/create.rb b/core/app/services/spree/line_items/create.rbnew file mode 100644index 0000000000..3adbd97906--- /dev/null+++ b/core/app/services/spree/line_items/create.rb@@ -0,0 +1,20 @@+module Spree+ module LineItems+ class Create+ prepend Spree::ServiceModule::Base+ include Helper++ def call(order:, line_item_attributes: {}, options: {})+ line_item = order.line_items.new(line_item_attributes)++ ActiveRecord::Base.transaction do+ return failure(line_item) unless line_item.save++ recalculate_service.call(order: order, line_item: line_item, options: options)+ end++ success(line_item)+ end+ end+ end+enddiff --git a/core/app/services/spree/line_items/destroy.rb b/core/app/services/spree/line_items/destroy.rbnew file mode 100644index 0000000000..cdda16c077--- /dev/null+++ b/core/app/services/spree/line_items/destroy.rb@@ -0,0 +1,18 @@+module Spree+ module LineItems+ class Destroy+ prepend Spree::ServiceModule::Base+ include Helper++ def call(line_item:, options: {})+ order = line_item.order++ ActiveRecord::Base.transaction do+ line_item.destroy!+ recalculate_service.call(order: order, line_item: line_item, options: options)+ end+ success(line_item)+ end+ end+ end+enddiff --git a/core/app/services/spree/line_items/helper.rb b/core/app/services/spree/line_items/helper.rbnew file mode 100644index 0000000000..3d4bc22bbe--- /dev/null+++ b/core/app/services/spree/line_items/helper.rb@@ -0,0 +1,11 @@+module Spree+ module LineItems+ module Helper+ protected++ def recalculate_service+ Spree::Dependencies.cart_recalculate_service.constantize+ end+ end+ end+enddiff --git a/core/app/services/spree/line_items/update.rb b/core/app/services/spree/line_items/update.rbnew file mode 100644index 0000000000..c1933885f0--- /dev/null+++ b/core/app/services/spree/line_items/update.rb@@ -0,0 +1,17 @@+module Spree+ module LineItems+ class Update+ prepend Spree::ServiceModule::Base+ include Helper++ def call(line_item:, line_item_attributes: {}, options: {})+ ActiveRecord::Base.transaction do+ return failure(line_item) unless line_item.update(line_item_attributes)++ recalculate_service.call(order: line_item.order, line_item: line_item, options: options)+ end+ success(line_item)+ end+ end+ end+enddiff --git a/core/spec/services/spree/line_items/create_spec.rb b/core/spec/services/spree/line_items/create_spec.rbnew file mode 100644index 0000000000..6bf9afd025--- /dev/null+++ b/core/spec/services/spree/line_items/create_spec.rb@@ -0,0 +1,23 @@+require 'spec_helper'++module Spree+ describe LineItems::Create do+ subject { described_class }++ let(:order) { create :order }+ let(:variant) { create :variant, price: 20 }+ let(:execute) { subject.call(order: order, line_item_attributes: attributes_for(:line_item, variant: variant, currency: order.currency)) }+ let(:value) { execute.value }+ let(:line_item_attributes) { { quantity: 11 } }++ context 'creates a line item' do+ it 'with any quantity' do+ expect(order.amount).to eq(0)+ expect(order.quantity).to eq(0)+ expect { execute }.to change(order, :quantity).by(1)+ expect(execute).to be_success+ expect(value).to be_kind_of(Spree::LineItem)+ end+ end+ end+enddiff --git a/core/spec/services/spree/line_items/destroy_spec.rb b/core/spec/services/spree/line_items/destroy_spec.rbnew file mode 100644index 0000000000..0c7341323e--- /dev/null+++ b/core/spec/services/spree/line_items/destroy_spec.rb@@ -0,0 +1,45 @@+require 'spec_helper'++module Spree+ describe LineItems::Destroy do+ subject { described_class }++ let(:order) { create :order, line_items: [line_item] }+ let(:line_item) { create :line_item, variant: variant, price: nil, quantity: 10 }+ let(:variant) { create :variant, price: 20 }+ let(:execute) { subject.call(line_item: line_item) }+ let(:value) { execute.value }++ context 'remove line item' do+ it 'with any quantity' do+ expect(order.amount).to eq 200+ expect { execute }.to change { order.line_items.count }.by(-1)+ expect(execute).to be_success+ expect(value).to eq line_item+ order.reload+ expect(order.amount).to eq 0+ end+ end++ context 'given a shipment' do+ let(:shipment) { create :shipment }+ let(:options) { { shipment: shipment } }+ let(:execute) { subject.call(line_item: line_item, options: options) }++ it 'ensure shipment calls update_amounts instead of order calling ensure_updated_shipments' do+ expect(order).not_to receive(:ensure_updated_shipments)+ expect(shipment).to receive(:update_amounts)+ expect(execute).to be_success+ end+ end++ context 'not given a shipment' do+ let(:execute) { subject.call(line_item: line_item) }++ it 'ensures updated shipments' do+ expect(order).to receive(:ensure_updated_shipments)+ expect(execute).to be_success+ end+ end+ end+enddiff --git a/core/spec/services/spree/line_items/update_spec.rb b/core/spec/services/spree/line_items/update_spec.rbnew file mode 100644index 0000000000..aa276640f4--- /dev/null+++ b/core/spec/services/spree/line_items/update_spec.rb@@ -0,0 +1,46 @@+require 'spec_helper'++module Spree+ describe LineItems::Update do+ subject { described_class }++ let(:order) { create :order, line_items: [line_item] }+ let!(:line_item) { create :line_item, variant: variant, price: nil, quantity: 10 }+ let(:variant) { create :variant, price: 20 }+ let(:execute) { subject.call(line_item: line_item, line_item_attributes: line_item_attributes) }+ let(:value) { execute.value }+ let(:line_item_attributes) { { quantity: 11 } }++ context 'updates line item' do+ it 'with any quantity' do+ expect(order.amount).to eq(200)+ expect(order.quantity).to eq(10)+ expect { execute }.to change(order, :quantity).by(1)+ expect(order.item_count).to eq(11)+ expect(execute).to be_success+ expect(value).to eq line_item+ end+ end++ context 'given a shipment' do+ let(:shipment) { create :shipment }+ let(:options) { { shipment: shipment } }+ let(:execute) { subject.call(line_item: line_item, line_item_attributes: line_item_attributes, options: options) }++ it 'ensure shipment calls update_amounts instead of order calling ensure_updated_shipments' do+ expect(order).not_to receive(:ensure_updated_shipments)+ expect(shipment).to receive(:update_amounts)+ expect(execute).to be_success+ end+ end++ context 'not given a shipment' do+ let(:execute) { subject.call(line_item: line_item, line_item_attributes: line_item_attributes) }++ it 'ensures updated shipments' do+ expect(order).to receive(:ensure_updated_shipments)+ expect(execute).to be_success+ end+ end+ end+end