Coupon Import Flowchart

This document will help you write a script to sync your website with our coupon database.

There are 2 types of API responses that we support:

Full Feed

Returns all coupons that are live in our database.

Incremental Feed (recommended)

Returns all changes in our database since your last API call. The status of each offer in this case can be either “new”, “updated” or “suspended”.

Below is a quick overview of how you need to process the Coupon API response in each case.

Full Feed

It is easier to write a script to process full feed. However, since it returns all coupons in your subscription, it can cause more load on your server if you have a lot of coupons to process.

Prerequisites

  • Temporary table (where you will save each coupon as received from Coupon API response).

Import steps

  1. Call Coupon API (Full Feed)
  2. Save the Coupons in a temporary table. (So temporary table now contains all coupons that are in our database).
  3. Compare and modify your actual Coupon Table
    1. Insert into coupon table: All coupons which are in temporary table but not in your coupon table.
    2. Update columns of all coupons in your coupon table, which are also present in the temporary table.
    3. Delete coupons from your coupon table, which are not present in the temporary table.
  4. Delete everything from the temporary table.

Incremental Feed

This causes less load on the server, as you only have to process the “new”, “updated” and “suspended” coupons since your last extract.

Prerequisites

  • Temporary table (where you will save each coupon as received from Coupon API response).

Import steps

  1. Call Coupon API (Incremental Feed)
  2. Save the Coupons in a temporary table. (So temporary table now contains all changes that you have to do on your coupon table).
  3. For each row in the temporary table
    1. If status=’new’, then insert this coupon into your coupon table.
    2. If status=’updated’, update all columns of this coupon in your coupon table.
    3. If status=’suspended’, delete this coupon from your coupon table.
    4. Delete this row from the temporary table once processed.

Coupon API incremental feed process flowchart

Article Details

Article ID:
24
Category:
Rating :

Related articles