/**
 * @return string
 */
function getProductXmlCreate(): string {
  return ('<?xml version="1.0" encoding="UTF-8"?>\n'
    + '<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">\n'
    + '  <product>\n'
    + '    <id_manufacturer>1</id_manufacturer>\n'
    + '    <id_supplier>1</id_supplier>\n'
    + '    <id_category_default>9</id_category_default>\n'
    + '    <cache_default_attribute>0</cache_default_attribute>\n'
    + '    <id_default_image><![CDATA[]]></id_default_image>\n'
    + '    <id_default_combination>0</id_default_combination>\n'
    + '    <id_tax_rules_group>1</id_tax_rules_group>\n'
    // @todo : https://github.com/PrestaShop/PrestaShop/issues/14903
    //+ '    <position_in_category>1</position_in_category>\n'
    + '    <type><![CDATA[simple]]></type>\n'
    + '    <id_shop_default>1</id_shop_default>\n'
    + '    <reference><![CDATA[REFERENCE007]]></reference>\n'
    + '    <supplier_reference>\n'
    + '        <![CDATA[]]>\n'
    + '    </supplier_reference>\n'
    + '    <location><![CDATA[]]></location>\n'
    + '    <width>123.000000</width>\n'
    + '    <height>456.000000</height>\n'
    + '    <depth>789.000000</depth>\n'
    + '    <weight>1234.000000</weight>\n'
    + '    <quantity_discount>0</quantity_discount>\n'
    + '    <ean13><![CDATA[9782409038600]]></ean13>\n'
    + '    <isbn><![CDATA[978-2-409-03860-0]]></isbn>\n'
    + '    <upc><![CDATA[987654321098]]></upc>\n'
    + '    <mpn><![CDATA[HSC0424PP]]></mpn>\n'
    + '    <cache_is_pack><![CDATA[0]]></cache_is_pack>\n'
    + '    <cache_has_attachments><![CDATA[0]]></cache_has_attachments>\n'
    + '    <is_virtual><![CDATA[0]]></is_virtual>\n'
    + '    <state><![CDATA[1]]></state>\n'
    + '    <additional_delivery_times><![CDATA[1]]></additional_delivery_times>\n'
    + '    <delivery_in_stock>\n'
    + '        <language id="1"><![CDATA[Available]]></language>\n'
    + '        <language id="2"><![CDATA[Disponible]]></language>\n'
    + '    </delivery_in_stock>\n'
    + '    <delivery_out_stock>\n'
    + '        <language id="1"><![CDATA[Out of stock]]></language>\n'
    + '        <language id="2"><![CDATA[Indisponible]]></language>\n'
    + '    </delivery_out_stock>\n'
    + '    <product_type><![CDATA[standard]]></product_type>\n'
    + '    <on_sale>1</on_sale>\n'
    + '    <online_only>1</online_only>\n'
    + '    <ecotax><![CDATA[1.230000]]></ecotax>\n'
    + '    <minimal_quantity>1</minimal_quantity>\n'
    + '    <low_stock_threshold>2</low_stock_threshold>\n'
    + '    <low_stock_alert>0</low_stock_alert>\n'
    + '    <price><![CDATA[45.670000]]></price>\n'
    + '    <wholesale_price><![CDATA[89.010000]]></wholesale_price>\n'
    + '    <unity>Per kg</unity>\n'
    + '    <unit_price><![CDATA[45.670000]]></unit_price>\n'
    + '    <unit_price_ratio><![CDATA[1.026932]]></unit_price_ratio>\n'
    + '    <additional_shipping_cost><![CDATA[2.340000]]></additional_shipping_cost>\n'
    + '    <customizable><![CDATA[0]]></customizable>\n'
    + '    <text_fields><![CDATA[0]]></text_fields>\n'
    + '    <uploadable_files><![CDATA[0]]></uploadable_files>\n'
    + '    <active><![CDATA[1]]></active>\n'
    + '    <redirect_type>301-product</redirect_type>\n'
    + '    <id_type_redirected>6</id_type_redirected>\n'
    + '    <available_for_order>1</available_for_order>\n'
    + '    <available_date><![CDATA[2023-02-04]]></available_date>\n'
    + '    <show_condition><![CDATA[1]]></show_condition>\n'
    + '    <condition><![CDATA[new]]></condition>\n'
    + '    <show_price>1</show_price>\n'
    + '    <indexed>1</indexed>\n'
    + '    <visibility><![CDATA[both]]></visibility>\n'
    + '    <advanced_stock_management>0</advanced_stock_management>\n'
    + '    <pack_stock_type>3</pack_stock_type>\n'
    + '    <meta_description>\n'
    + '        <language id="1"><![CDATA[Product Meta Description]]></language>\n'
    + '        <language id="2"><![CDATA[Meta Description du produit]]></language>\n'
    + '    </meta_description>\n'
    + '    <meta_title>\n'
    + '        <language id="1"><![CDATA[Product Meta Title]]></language>\n'
    + '        <language id="2"><![CDATA[Meta Title du produit]]></language>\n'
    + '    </meta_title>\n'
    + '    <link_rewrite>\n'
    + '        <language id="1"><![CDATA[product-link]]></language>\n'
    + '        <language id="2"><![CDATA[lien-produit]]></language>\n'
    + '    </link_rewrite>\n'
    + '    <name>\n'
    + '        <language id="1"><![CDATA[Product Name]]></language>\n'
    + '        <language id="2"><![CDATA[Nom du produit]]></language>\n'
    + '    </name>\n'
    + '    <description>\n'
    + '        <language id="1"><![CDATA[Product Description]]></language>\n'
    + '        <language id="2"><![CDATA[Description du produit]]></language>\n'
    + '    </description>\n'
    + '    <description_short>\n'
    + '        <language id="1"><![CDATA[Product Short Description]]></language>\n'
    + '        <language id="2"><![CDATA[Courte Description du produit]]></language>\n'
    + '    </description_short>\n'
    + '    <available_now>\n'
    + '        <language id="1"><![CDATA[Available Now]]></language>\n'
    + '        <language id="2"><![CDATA[Disponible Maintenant]]></language>\n'
    + '    </available_now>\n'
    + '    <available_later>\n'
    + '        <language id="1"><![CDATA[Available Later]]></language>\n'
    + '        <language id="2"><![CDATA[Disponible Plus tard]]></language>\n'
    + '    </available_later>\n'
    + '    <associations>\n'
    + '        <categories>\n'
    + '            <category>\n'
    + '                <id>9</id>\n'
    + '            </category>\n'
    + '        </categories>\n'
    + '    </associations>\n'
    + '</product>\n'
    + '</prestashop>\n');
}

/**
 * @param idProduct {string}
 * @return string
 */
function getProductXmlUpdate(idProduct: string): string {
  return ('<?xml version="1.0" encoding="UTF-8"?>\n'
    + '<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">\n'
    + '  <product>\n'
    + `    <id><![CDATA[${idProduct}]]></id>`
    + '    <id_manufacturer>2</id_manufacturer>\n'
    + '    <id_supplier>2</id_supplier>\n'
    + '    <id_category_default>9</id_category_default>\n'
    + '    <cache_default_attribute>0</cache_default_attribute>\n'
    + '    <id_default_image><![CDATA[]]></id_default_image>\n'
    + '    <id_default_combination>0</id_default_combination>\n'
    + '    <id_tax_rules_group>2</id_tax_rules_group>\n'
    // @todo : https://github.com/PrestaShop/PrestaShop/issues/14903
    //+ '    <position_in_category>2</position_in_category>\n'
    + '    <type><![CDATA[simple]]></type>\n'
    + '    <id_shop_default>1</id_shop_default>\n'
    + '    <reference><![CDATA[UPDATEREFERENCE007]]></reference>\n'
    + '    <supplier_reference><![CDATA[]]></supplier_reference>\n'
    + '    <location><![CDATA[]]></location>\n'
    + '    <width>456.000000</width>\n'
    + '    <height>789.000000</height>\n'
    + '    <depth>123.000000</depth>\n'
    + '    <weight>4567.000000</weight>\n'
    + '    <quantity_discount>0</quantity_discount>\n'
    + '    <ean13><![CDATA[9782409038600]]></ean13>\n'
    + '    <isbn><![CDATA[978-1-837-63596-2]]></isbn>\n'
    + '    <upc><![CDATA[987654321098]]></upc>\n'
    + '    <mpn><![CDATA[ABC1234DE]]></mpn>\n'
    + '    <cache_is_pack><![CDATA[0]]></cache_is_pack>\n'
    + '    <cache_has_attachments><![CDATA[0]]></cache_has_attachments>\n'
    + '    <is_virtual><![CDATA[0]]></is_virtual>\n'
    + '    <state><![CDATA[1]]></state>\n'
    + '    <additional_delivery_times><![CDATA[0]]></additional_delivery_times>\n'
    + '    <delivery_in_stock>\n'
    + '        <language id="1"><![CDATA[Update Available]]></language>\n'
    + '        <language id="2"><![CDATA[Update Disponible]]></language>\n'
    + '    </delivery_in_stock>\n'
    + '    <delivery_out_stock>\n'
    + '        <language id="1"><![CDATA[Update Out of stock]]></language>\n'
    + '        <language id="2"><![CDATA[Update Indisponible]]></language>\n'
    + '    </delivery_out_stock>\n'
    + '    <product_type><![CDATA[standard]]></product_type>\n'
    + '    <on_sale>1</on_sale>\n'
    + '    <online_only>0</online_only>\n'
    + '    <ecotax><![CDATA[4.560000]]></ecotax>\n'
    + '    <minimal_quantity>2</minimal_quantity>\n'
    + '    <low_stock_threshold>2</low_stock_threshold>\n'
    + '    <low_stock_alert>1</low_stock_alert>\n'
    + '    <price><![CDATA[89.010000]]></price>\n'
    + '    <wholesale_price><![CDATA[234.560000]]></wholesale_price>\n'
    + '    <unity>Per unit</unity>\n'
    + '    <unit_price><![CDATA[78.900000]]></unit_price>\n'
    + '    <unit_price_ratio><![CDATA[1.185931]]></unit_price_ratio>\n'
    + '    <additional_shipping_cost><![CDATA[5.670000]]></additional_shipping_cost>\n'
    + '    <customizable><![CDATA[0]]></customizable>\n'
    + '    <text_fields><![CDATA[0]]></text_fields>\n'
    + '    <uploadable_files><![CDATA[0]]></uploadable_files>\n'
    + '    <active><![CDATA[0]]></active>\n'
    + '    <redirect_type>301-product</redirect_type>\n'
    + '    <id_type_redirected>12</id_type_redirected>\n'
    + '    <available_for_order>1</available_for_order>\n'
    + '    <available_date><![CDATA[2023-03-06]]></available_date>\n'
    + '    <show_condition><![CDATA[0]]></show_condition>\n'
    + '    <condition><![CDATA[new]]></condition>\n'
    + '    <show_price>0</show_price>\n'
    + '    <indexed>0</indexed>\n'
    + '    <visibility><![CDATA[both]]></visibility>\n'
    + '    <advanced_stock_management>0</advanced_stock_management>\n'
    + '    <date_add><![CDATA[2023-01-02 03:45:06]]></date_add>\n'
    + '    <date_upd><![CDATA[2023-01-02 03:45:06]]></date_upd>\n'
    + '    <pack_stock_type>3</pack_stock_type>\n'
    + '    <meta_description>\n'
    + '        <language id="1"><![CDATA[Update Product Meta Description]]></language>\n'
    + '        <language id="2"><![CDATA[Update Meta Description du produit]]></language>\n'
    + '    </meta_description>\n'
    + '    <meta_title>\n'
    + '        <language id="1"><![CDATA[Update Product Meta Title]]></language>\n'
    + '        <language id="2"><![CDATA[Update Meta Title du produit]]></language>\n'
    + '    </meta_title>\n'
    + '    <link_rewrite>\n'
    + '        <language id="1"><![CDATA[update-product-link]]></language>\n'
    + '        <language id="2"><![CDATA[update-lien-produit]]></language>\n'
    + '    </link_rewrite>\n'
    + '    <name>\n'
    + '        <language id="1"><![CDATA[Update Product Name]]></language>\n'
    + '        <language id="2"><![CDATA[Update Nom du produit]]></language>\n'
    + '    </name>\n'
    + '    <description>\n'
    + '        <language id="1"><![CDATA[Update Product Description]]></language>\n'
    + '        <language id="2"><![CDATA[Update Description du produit]]></language>\n'
    + '    </description>\n'
    + '    <description_short>\n'
    + '        <language id="1"><![CDATA[Update Product Short Description]]></language>\n'
    + '        <language id="2"><![CDATA[Update Courte Description du produit]]></language>\n'
    + '    </description_short>\n'
    + '    <available_now>\n'
    + '        <language id="1"><![CDATA[Update Available Now]]></language>\n'
    + '        <language id="2"><![CDATA[Update Disponible Maintenant]]></language>\n'
    + '    </available_now>\n'
    + '    <available_later>\n'
    + '        <language id="1"><![CDATA[Update Available Later]]></language>\n'
    + '        <language id="2"><![CDATA[Update Disponible Plus tard]]></language>\n'
    + '    </available_later>\n'
    + '    <associations>\n'
    + '        <categories>\n'
    + '            <category>\n'
    + '                <id>9</id>\n'
    + '            </category>\n'
    + '        </categories>\n'
    + '    </associations>\n'
    + '  </product>\n'
    + '</prestashop>\n');
}

/**
 * Get xml of product to put on POST/PUT request
 * @param idProduct {string|null}
 */
export default function getProductXml(idProduct : string | null = null): string {
  if (idProduct) {
    return getProductXmlUpdate(idProduct);
  }

  return getProductXmlCreate();
}
