MOR API tariff retail import

From Kolmisoft Wiki
Revision as of 13:54, 11 November 2011 by Admin (talk | contribs)
Jump to navigationJump to search

This functionality is available from MOR 11


MOR API Import XML Retail tariff






  • Call: /api/import_tariff_retail
  • Methods: POST
  • Params:
    • u - username to login. Required.
    • p - password to login. Required.
    • xml - retail tariff in xml format. Required.
  • Returns response in xml:
    • Success:
<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></destination_with_time_collisions_in_db>
</response>
    • 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 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 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>






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>