API - Update Coupon

Update Coupon

This API is used to update a coupon by specifying the coupon id.

 

API Details

 

Signature of API call

connection.invokeApi(String uri, String realUserName, Map<String, String> requestParameters);

See details about invoking API in general

 

Parameter 1 - URI

couponService.do

 

Parameter 2 - UserName

Username of the site admin

 

Parameter 3 - Request Parameters

Name Value
dispatch updateCoupon
xml true
id Coupon id
valueCount number of times the coupon can be used (can't be less than already used count)
valueAmount

numeric total discount amount value for coupon (if type is AMOUNT)

numeric total amount (credit) available via coupon (if type is TOTAL_AMOUNT)

valuePercent numeric % discount value for coupon (if type is PERCENT)
expDate Expiration date of the coupon (optional), represented as epoch time in milliseconds - number of milliseconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds
setMembershipExpiration

Boolean (true | false)

If true - sets user's membership expiration same as coupon expiration.

addUserToCouponsGroup

Boolean (true | false)

If true - adds the user to coupon's authorized group if the user is not already a member

requireApproval

Boolean (true | false)

If true - usage will require coupon's authorized group admin to approve

previewAccessOnly

Boolean (true | false)

If true - the user will get only limited time access to course session / program session

status ACTIVE | INACTIVE (only active coupon can be used)
comment Comments

 

Response

Response on successfully updating the coupon

HTTP Response Code = HttpServletResponse.SC_OK

Response XML

<response code="0">
   <msgs>
      <msg>
         <code>0223</code>
         <value>
            <![CDATA[Coupon updated successfully]]>
         </value>
      </msg>
   </msgs>
</response>

 

Code Snippet

/* Check API Call for detail */

Map<String, String> parameters = new HashMap<String, String>();
populateMapForCouponUpdate(parameters);
String result = connection.invokeApi("couponService.do", "adminusername", parameters);
System.out.println(result);
 
private void populateMapForCouponUpdate(Map<String, String> parameters) {
    parameters.put("dispatch", "updateCoupon");
    parameters.put("xml", String.valueOf(true));
    parameters.put("id", "xxxx-xxxx-xxxx-xxxx");
    parameters.put("valueCount", "1234");
    parameters.put("expDate", "1495163497116");
}
 

 


Rating: