MOR API tariff retail import

From Kolmisoft Wiki

Jump to: navigation, search

Contents

[edit] Description

MOR API Import XML Retail tariff

[edit] Usage

  • From MOR X4 call: /api/tariff_retail_import
  • For Backwards-compatibility old name 'import_tariff_retail' is also usable. Call: /api/import_tariff_retail
  • Methods: POST

[edit] Parametres

  • u - username for authorization. Required.
  • xml - retail tariff in xml format. Required.

[edit] Request

XML structure example

<tariff>
 <name>Tariff</name>
 <id>2</id>
 <destinations>
  <destination>
   <direction/>
   <destination_group_name>Afghanistan</destination_group_name>
   <destination_group_type>FIX</destination_group_type>
   <rates>
    <rate_price>0.02</rate_price>
    <rate_round_by>1</rate_round_by>
    <rate_type>minute</rate_type>
    <rate_start_time>00:00:00</rate_start_time>
    <rate_end_time>21:59:59</rate_end_time>
    <rate_duration>300</rate_duration>
    <day_type>WD</day_type>
   </rates>
   <rates>
    <rate_price>0.1</rate_price>
    <rate_round_by>1</rate_round_by>
    <rate_type>event</rate_type>
    <rate_start_time>08:00:00</rate_start_time>
    <rate_end_time>17:59:59</rate_end_time>
    <rate_duration>0</rate_duration>
    <day_type>FD</day_type>
   </rates>
   <rates>
    <rate_price>0.1</rate_price>
    <rate_round_by>61</rate_round_by>
    <rate_type>minute</rate_type>
    <rate_start_time>18:00:00</rate_start_time>
    <rate_end_time>23:59:59</rate_end_time>
    <rate_duration>-1</rate_duration>
    <day_type>FD</day_type>
   </rates>
   <rates>
    <rate_price>0</rate_price>
    <rate_round_by>1</rate_round_by>
    <rate_type>minute</rate_type>
    <rate_start_time>21:00:00</rate_start_time>
    <rate_end_time>23:59:59</rate_end_time>
    <rate_duration>-1</rate_duration>
    <day_type>WD</day_type>
   </rates>
  </destination>
  <destination>
   <direction/>
   <destination_group_name>Lithuania</destination_group_name>
   <destination_group_type>MOB</destination_group_type>
   <rates>
    <rate_price>0.2</rate_price>
    <rate_round_by>1</rate_round_by>
    <rate_type>minute</rate_type>
    <rate_start_time>00:00:00</rate_start_time>
    <rate_end_time>23:59:59</rate_end_time>
    <rate_duration>2</rate_duration>
    <day_type/>
   </rates>
   <rates>
    <rate_price>0.3</rate_price>
    <rate_round_by>1</rate_round_by>
    <rate_type>event</rate_type>
    <rate_start_time>00:00:00</rate_start_time>
    <rate_end_time>23:59:59</rate_end_time>
    <rate_duration>0</rate_duration>
    <day_type/>
   </rates>
  </destination>
 </destinations>
</tariff>


[edit] Returns

Success

By sending such XML you get the following result shown in an image below:

<tariff>
 <name>test_export_advanced2</name>
 <id>20</id>
 <destinations>
 <destination>
 <direction/>
 <destination_group_name>Afghanistan</destination_group_name>
 <destination_group_type>FIX</destination_group_type>
   <rates>
    <rate_price>0.25</rate_price>
    <rate_round_by>30</rate_round_by>
    <rate_type>minute</rate_type>
    <rate_start_time>00:00:00</rate_start_time>
    <rate_end_time>23:59:59</rate_end_time>
    <rate_duration>30</rate_duration>
    <day_type>WD</day_type>
   </rates>
   <rates>
    <rate_price>0.25</rate_price>
    <rate_round_by>6</rate_round_by>
    <rate_type>minute</rate_type>
    <rate_start_time>00:00:00</rate_start_time>
    <rate_end_time>23:59:59</rate_end_time>
    <rate_duration>-1</rate_duration>
    <day_type>WD</day_type>
   </rates>
 </destination>
 </destinations>
 </tariff>

After you can check rates in GUI:

File:Xml_import.png


Errors

  • if bad xml format:
<response>
 <error> File does not exist </error>
</response> 

or

<response>
 <error> Bad XML data </error>
</response>   
                      
  • if tariff name does not match with existing tariff found by ID:
<response>
 <error> TARIFF NAME WITH THIS ID DO NOT MATCH !!!FOUND tariff_name </error>
</response>
  • if tariff was not found by ID, but tariff with same name exists:
<response>
 <error> TARIFF with same name exists, ID:tariff_id!!! CHANGE NAME OR ID </error>
</response>
  • if trying to update not yours tariff:
<response>
 <error>Tariff belongs to other user!</error>
</response>


  • if no destinations found in xml:
<response>
 <error> No destinations! </error>
 <tariff_id> ID </tariff_id>
 <tariff_name> TARIFF NAME </tariff_name>
</response>
  • if no destination found by destination name or bad destination name:
<response>
 <tariff_id> ID </tariff_id>
 <tariff_name> TARIFF NAME </tariff_name>
 <bad_destinations>
  <destination_group_name> DESTINATION GROUP NAME </destination_group_name>
  <destination_group_type> DESTINATION GROUP TYPE </destination_group_type>
 </bad_destinations>
 <destination_with_bad_rates></destination_with_bad_rates>
 <destination_with_time_collisions_in_xml></destination_with_time_collisions_in_xml>
 <destination_with_time_collisions_in_db></destination_with_time_collisions_in_db>
</response>
  • if you try to import 'Work Day and Free Day' rate only to 'Work Day' or only to 'Free Day' and vice versa


<response>
 <tariff_id> ID </tariff_id>
 <tariff_name> TARIFF NAME </tariff_name>
 <bad_destinations></bad_destinations>
 <destination_with_day_type_collision>
  <destination_group_name> DESTINATION GROUP NAME </destination_group_name>
  <destination_group_type> DESTINATION GROUP TYPE </destination_group_type>
 </destination_with_day_type_collision
 <destination_with_bad_rates></destination_with_bad_rates>
 <destination_with_time_collisions_in_xml></destination_with_time_collisions_in_xml>
 <destination_with_time_collisions_in_db></destination_with_time_collisions_in_db>
</response>
  • if bad rate in destination:
<response>
 <tariff_id> ID </tariff_id>
 <tariff_name> TARIFF NAME </tariff_name>
 <bad_destinations></bad_destinations>
 <destination_with_bad_rates>
  <destination_group_name> DESTINATION GROUP NAME </destination_group_name>
  <destination_group_type> DESTINATION GROUP TYPE </destination_group_type>
  <rate_price> 1 </rate_price>
  <rate_round_by> 588888 </rate_round_by>
  <rate_duration> 7 </rate_duration>
  <rate_type> minute </rate_type>
  <rate_start_time> 00:00:00 </rate_start_time>
  <rate_end_time> 23:99:99 </rate_end_time>
  <day_type/>
 </destination_with_bad_rates>
</response>
  • if time collision in xml destination rates:
<response>
 <tariff_id> ID </tariff_id>
 <tariff_name> TARIFF NAME </tariff_name>
 <bad_destinations></bad_destinations>
 <destination_with_bad_rates></destination_with_bad_rates>
 <destination_with_time_collisions_in_xml>
  <collision_in_time_range> 
   Destination group name Destination group type COLLISION IN rate start AND rate end TIME RANGE 
  </collision_in_time_range>
 </destination_with_time_collisions_in_xml>
 <destination_with_time_collisions_in_db></destination_with_time_collisions_in_db>
</response>
  • if time collision between xml rates and existing rates:
<response>
 <tariff_id> ID </tariff_id>
 <tariff_name> TARIFF NAME </tariff_name>
 <bad_destinations></bad_destinations>
 <destination_with_bad_rates></destination_with_bad_rates>
 <destination_with_time_collisions_in_xml></destination_with_time_collisions_in_xml>
 <destination_with_time_collisions_in_db>
  <collision_in_time_range>
   Destination group name Destination group type COLLISION WITH EXISTING RATES IN rate start AND rate end TIME RANGE
  </collision_in_time_range>
 </destination_with_time_collisions_in_db>
</response>



[edit] See also



Personal tools

Try MOR

Try M2