Skip to content

Commit

Permalink
Update the cookbook
Browse files Browse the repository at this point in the history
  • Loading branch information
TaurusOlson committed May 22, 2019
1 parent c22ac16 commit a5477ea
Show file tree
Hide file tree
Showing 14 changed files with 293 additions and 18 deletions.
Binary file modified docs/_build/doctrees/CHANGELOG.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/advanced_usage.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/api.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/cookbook.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/index.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/quickstart.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/_build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: a1ff0d80a3848982a684e97f532b9f34
config: eaf84f4cf111f072c3ba81481a9340bc
tags: 645f666f9bcd5a90fca523b33c5a78b7
94 changes: 94 additions & 0 deletions docs/_build/html/_sources/cookbook.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,100 @@
Cookbook
========

.. TODO Add a note on ProductCondition (int in the OfferPackage).
------
Offers
------

We'll assume we want to create an offer with the following parameters and values:

================= ================
Parameter Value
================= ================
SellerProductId SKU
ProductCondition AverageState
ProductEan 978-1593274351
Price 35
Stock 10
PreparationTime 1
================= ================

with 3 delivery modes: Standard, Tracked and Registered.

.. note::

- cdiscount.com id: 1
- cdiscountpro.com id: 16


Submit an offer package on cdiscount.com and cdiscountpro.com
-------------------------------------------------------------

Create the offer package with :py:meth:`Offers.generate_offer_package`::

offer = {
'ProductEan': '978-1593274351',
'SellerProductId': 'SKU',
'ProductCondition': 4,
'Price': 35,
'ShippingInformationList': {
'ShippingInformation': [
{'ShippingCharges': 2, 'DeliveryMode': 'Standard', 'AdditionalShippingCharges': 0},
{'ShippingCharges': 3, 'DeliveryMode': 'Registered', 'AdditionalShippingCharges': 0},
{'ShippingCharges': 4, 'DeliveryMode': 'Tracked', 'AdditionalShippingCharges': 0},
]
},
'Stock': 10,
'PreparationTime': 1
}

offer_package_path = api.offers.generate_offer_package(
'books_offers',
[offer_package],
offer_publication_list=[1, 16]
)

Upload the package *books_offers.zip* on a server then submit it with
:py:meth:`Offers.submit_product_package` by specifying the url of the package::

response = api.offers.submit_product_package('http://www.myserver/books_offers.zip')


Update an offer on cdiscount.com
--------------------------------


Purge the inventory for on cdiscount.com
----------------------------------------

..
To remove some offers from your inventory, use the keyword `purge_and_replace`
in :py:meth:`Offers.generate_offer_package`::
offer = {
'ProductEan': '978-1593274351',
'SellerProductId': 'SKU',
'ProductCondition': 4,
'Price': 35,
'ShippingInformationList': {
'ShippingInformation': [
{'ShippingCharges': 2, 'DeliveryMode': 'Standard', 'AdditionalShippingCharges': 0},
{'ShippingCharges': 3, 'DeliveryMode': 'Registered', 'AdditionalShippingCharges': 0},
{'ShippingCharges': 4, 'DeliveryMode': 'Tracked', 'AdditionalShippingCharges': 0},
]
},
'Stock': 10,
'PreparationTime': 1
}

offer_package_path = api.offers.generate_offer_package(
'books_to_remove_from_offers',
[offer_package],
offer_publication_list=[1, 16]
)


------
Orders
------
Expand Down
31 changes: 15 additions & 16 deletions docs/_build/html/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ <h2>Offers<a class="headerlink" href="#offers" title="Permalink to this headline

<dl class="staticmethod">
<dt id="cdiscountapi.cdiscountapi.Offers.generate_offer_package">
<em class="property">static </em><code class="descname">generate_offer_package</code><span class="sig-paren">(</span><em>output_dir</em>, <em>offers_list</em>, <em>pool_list=[]</em>, <em>purge_and_replace=False</em><span class="sig-paren">)</span><a class="headerlink" href="#cdiscountapi.cdiscountapi.Offers.generate_offer_package" title="Permalink to this definition"></a></dt>
<em class="property">static </em><code class="descname">generate_offer_package</code><span class="sig-paren">(</span><em>package_name</em>, <em>offers_list</em>, <em>offer_publication_list=[]</em>, <em>purge_and_replace=False</em><span class="sig-paren">)</span><a class="headerlink" href="#cdiscountapi.cdiscountapi.Offers.generate_offer_package" title="Permalink to this definition"></a></dt>
<dd><p>Generate a zip offers package as cdiscount wanted.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>output_dir</strong> (<em>str</em>) – [mandatory] path to generate package</p></li>
<li><p><strong>pool_list</strong> (<em>list</em>) – [optional]</p></li>
<li><p><strong>package_name</strong> (<em>str</em>) – [mandatory] the full path to the offer package (without .zip)</p></li>
<li><p><strong>offer_publication_list</strong> (<em>list</em>) – [optional]</p></li>
<li><p><strong>purge_and_replace</strong> (<em>bool</em>) – [optional]</p></li>
<li><p><strong>offers_list</strong> (<em>list</em>) – <p>list of dict [{offer, shipping}, …]:</p>
<dl class="option-list">
Expand All @@ -222,17 +222,17 @@ <h2>Offers<a class="headerlink" href="#offers" title="Permalink to this headline
<li><p>SellerProductId <em>(str)</em></p></li>
<li><dl class="simple">
<dt>ProductCondition <em>(int)</em>:</dt><dd><ul>
<li><p>LikeNew’,</p></li>
<li><p>VeryGoodState’,</p></li>
<li><p>GoodState’,</p></li>
<li><p>AverageState’,</p></li>
<li><p>Refurbished’,</p></li>
<li><p>New’,</p></li>
<li><p>1: ‘LikeNew’,</p></li>
<li><p>2: ‘VeryGoodState’,</p></li>
<li><p>3: ‘GoodState’,</p></li>
<li><p>4: ‘AverageState’,</p></li>
<li><p>5: ‘Refurbished’,</p></li>
<li><p>6: ‘New’,</p></li>
</ul>
</dd>
</dl>
</li>
<li><p>Price <em>(int)</em></p></li>
<li><p>Price <em>(float)</em></p></li>
<li><p>EcoPart <em>(float)</em></p></li>
<li><p>Vat <em>(float)</em></p></li>
<li><p>DeaTax <em>(float)</em></p></li>
Expand Down Expand Up @@ -313,15 +313,16 @@ <h2>Offers<a class="headerlink" href="#offers" title="Permalink to this headline
</dl>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">response</span> <span class="o">=</span> <span class="n">api</span><span class="o">.</span><span class="n">offers</span><span class="o">.</span><span class="n">generate_offer_package</span><span class="p">(</span>
<span class="n">package_name</span><span class="p">,</span>
<span class="n">offers_list</span><span class="p">,</span>
<span class="n">pool_list</span><span class="o">=</span><span class="n">pool_list</span><span class="p">,</span>
<span class="n">offer_publication_list</span><span class="o">=</span><span class="n">offer_publication_list</span><span class="p">,</span>
<span class="n">purge_and_replace</span><span class="o">=</span><span class="n">purge_and_replace</span>
<span class="p">)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>the id of package or -1</p>
<dd class="field-odd"><p>None</p>
</dd>
</dl>
</dd></dl>
Expand Down Expand Up @@ -938,8 +939,8 @@ <h2>Products<a class="headerlink" href="#products" title="Permalink to this head
</dl>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">response</span> <span class="o">=</span> <span class="n">api</span><span class="o">.</span><span class="n">products</span><span class="o">.</span><span class="n">generate_product_package</span><span class="p">(</span>
<span class="n">products_list</span><span class="p">,</span>
<span class="n">url</span><span class="o">=</span><span class="s2">&quot;path_to_upload.com&quot;</span>
<span class="n">products_list</span>
<span class="p">)</span>
</pre></div>
</div>
</dd></dl>
Expand Down Expand Up @@ -1849,8 +1850,6 @@ <h2>Discussions<a class="headerlink" href="#discussions" title="Permalink to thi
</dd>
</dl>
</li>
<li><p>ProductEANList</p></li>
<li><p>ProductSellerReferenceList</p></li>
</ul>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">response</span> <span class="o">=</span> <span class="n">api</span><span class="o">.</span><span class="n">get_order_question_list</span><span class="p">(</span>
Expand Down
87 changes: 87 additions & 0 deletions docs/_build/html/cookbook.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,87 @@ <h3>Navigation</h3>

<div class="section" id="cookbook">
<h1>Cookbook<a class="headerlink" href="#cookbook" title="Permalink to this headline"></a></h1>
<div class="section" id="offers">
<h2>Offers<a class="headerlink" href="#offers" title="Permalink to this headline"></a></h2>
<p>We’ll assume we want to create an offer with the following parameters and values:</p>
<table class="docutils align-center">
<colgroup>
<col style="width: 52%" />
<col style="width: 48%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Parameter</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SellerProductId</p></td>
<td><p>SKU</p></td>
</tr>
<tr class="row-odd"><td><p>ProductCondition</p></td>
<td><p>AverageState</p></td>
</tr>
<tr class="row-even"><td><p>ProductEan</p></td>
<td><p>978-1593274351</p></td>
</tr>
<tr class="row-odd"><td><p>Price</p></td>
<td><p>35</p></td>
</tr>
<tr class="row-even"><td><p>Stock</p></td>
<td><p>10</p></td>
</tr>
<tr class="row-odd"><td><p>PreparationTime</p></td>
<td><p>1</p></td>
</tr>
</tbody>
</table>
<p>with 3 delivery modes: Standard, Tracked and Registered.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<ul class="simple">
<li><p>cdiscount.com id: 1</p></li>
<li><p>cdiscountpro.com id: 16</p></li>
</ul>
</div>
<div class="section" id="submit-an-offer-package-on-cdiscount-com-and-cdiscountpro-com">
<h3>Submit an offer package on cdiscount.com and cdiscountpro.com<a class="headerlink" href="#submit-an-offer-package-on-cdiscount-com-and-cdiscountpro-com" title="Permalink to this headline"></a></h3>
<p>Create the offer package with <code class="xref py py-meth docutils literal notranslate"><span class="pre">Offers.generate_offer_package()</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">offer</span> <span class="o">=</span> <span class="p">{</span>
<span class="s1">&#39;ProductEan&#39;</span><span class="p">:</span> <span class="s1">&#39;978-1593274351&#39;</span><span class="p">,</span>
<span class="s1">&#39;SellerProductId&#39;</span><span class="p">:</span> <span class="s1">&#39;SKU&#39;</span><span class="p">,</span>
<span class="s1">&#39;ProductCondition&#39;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
<span class="s1">&#39;Price&#39;</span><span class="p">:</span> <span class="mi">35</span><span class="p">,</span>
<span class="s1">&#39;ShippingInformationList&#39;</span><span class="p">:</span> <span class="p">{</span>
<span class="s1">&#39;ShippingInformation&#39;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span><span class="s1">&#39;ShippingCharges&#39;</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="s1">&#39;DeliveryMode&#39;</span><span class="p">:</span> <span class="s1">&#39;Standard&#39;</span><span class="p">,</span> <span class="s1">&#39;AdditionalShippingCharges&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
<span class="p">{</span><span class="s1">&#39;ShippingCharges&#39;</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span> <span class="s1">&#39;DeliveryMode&#39;</span><span class="p">:</span> <span class="s1">&#39;Registered&#39;</span><span class="p">,</span> <span class="s1">&#39;AdditionalShippingCharges&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
<span class="p">{</span><span class="s1">&#39;ShippingCharges&#39;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span> <span class="s1">&#39;DeliveryMode&#39;</span><span class="p">:</span> <span class="s1">&#39;Tracked&#39;</span><span class="p">,</span> <span class="s1">&#39;AdditionalShippingCharges&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="s1">&#39;Stock&#39;</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span>
<span class="s1">&#39;PreparationTime&#39;</span><span class="p">:</span> <span class="mi">1</span>
<span class="p">}</span>

<span class="n">offer_package_path</span> <span class="o">=</span> <span class="n">api</span><span class="o">.</span><span class="n">offers</span><span class="o">.</span><span class="n">generate_offer_package</span><span class="p">(</span>
<span class="s1">&#39;books_offers&#39;</span><span class="p">,</span>
<span class="p">[</span><span class="n">offer_package</span><span class="p">],</span>
<span class="n">offer_publication_list</span><span class="o">=</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">16</span><span class="p">]</span>
<span class="p">)</span>
</pre></div>
</div>
<p>Upload the package <em>books_offers.zip</em> on a server then submit it with
<code class="xref py py-meth docutils literal notranslate"><span class="pre">Offers.submit_product_package()</span></code> by specifying the url of the package:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">response</span> <span class="o">=</span> <span class="n">api</span><span class="o">.</span><span class="n">offers</span><span class="o">.</span><span class="n">submit_product_package</span><span class="p">(</span><span class="s1">&#39;http://www.myserver/books_offers.zip&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="update-an-offer-on-cdiscount-com">
<h3>Update an offer on cdiscount.com<a class="headerlink" href="#update-an-offer-on-cdiscount-com" title="Permalink to this headline"></a></h3>
</div>
<div class="section" id="purge-the-inventory-for-on-cdiscount-com">
<h3>Purge the inventory for on cdiscount.com<a class="headerlink" href="#purge-the-inventory-for-on-cdiscount-com" title="Permalink to this headline"></a></h3>
</div>
</div>
<div class="section" id="orders">
<h2>Orders<a class="headerlink" href="#orders" title="Permalink to this headline"></a></h2>
<p>We’ll assume there is an order with one order line with the following parameters and values:</p>
Expand Down Expand Up @@ -139,6 +220,12 @@ <h3>Refund the customer<a class="headerlink" href="#refund-the-customer" title="
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Cookbook</a><ul>
<li><a class="reference internal" href="#offers">Offers</a><ul>
<li><a class="reference internal" href="#submit-an-offer-package-on-cdiscount-com-and-cdiscountpro-com">Submit an offer package on cdiscount.com and cdiscountpro.com</a></li>
<li><a class="reference internal" href="#update-an-offer-on-cdiscount-com">Update an offer on cdiscount.com</a></li>
<li><a class="reference internal" href="#purge-the-inventory-for-on-cdiscount-com">Purge the inventory for on cdiscount.com</a></li>
</ul>
</li>
<li><a class="reference internal" href="#orders">Orders</a><ul>
<li><a class="reference internal" href="#accept-the-order">Accept the order</a></li>
<li><a class="reference internal" href="#refuse-the-shipment-of-an-order">Refuse the shipment of an order</a></li>
Expand Down
1 change: 1 addition & 0 deletions docs/_build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ <h1>Welcome to CdiscountAPI’s documentation!<a class="headerlink" href="#welco
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="cookbook.html">Cookbook</a><ul>
<li class="toctree-l2"><a class="reference internal" href="cookbook.html#offers">Offers</a></li>
<li class="toctree-l2"><a class="reference internal" href="cookbook.html#orders">Orders</a></li>
</ul>
</li>
Expand Down
Loading

0 comments on commit a5477ea

Please sign in to comment.