---
# System prepended metadata

title: Hung Fook Tong Demo API Document

---


# Hung Fook Tong Demo API Document


# Get record
| Item | Description |
| -------- | -------- | 
| net suite API      | https://tstdrv2641016.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=5    |
| Contact      |{   "q": "SELECT * FROM contact where id=3113"}  |
| Membership      |{ "q": "SELECT * FROM customrecord_acws_membership where id = 001000"}  |
| Spending      |{"q": "SELECT * FROM customrecord_acws_spending where custrecord_acws_member = 001000"}|
| Point Transaction      |{   "q": "SELECT * FROM customrecord_acws_pointtransaction where custrecord_acws_pointtransaction_member = 001000"} |


# **Reward List**


**Description：** 

- Select top 5 rewards by last modified date

**URL：** 
-https://tstdrv2641016.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=5
  
**Method：**
- POST

**Request:**
```jsonld
{
   "q": "select * from customrecord_acws_reward order by lastmodified desc"
} 
```
**Response:**


```json
{
            "links": [],
            "created": "03/10/2022",
            "custrecord_acws_reward_category": "3",
            "custrecord_acws_reward_code": "LM20180520",
            "custrecord_acws_reward_currency": "6",
            "custrecord_acws_reward_displayinapps": "F",
            "custrecord_acws_reward_displayinconierge": "F",
            "custrecord_acws_reward_facevalue": "300000",
            "custrecord_acws_reward_hasmemberquota": "F",
            "custrecord_acws_reward_loyaltyprogram": "1",
            "custrecord_acws_reward_name_sc": "GURUS - Dyson ????????????",
            "custrecord_acws_reward_name_tc": "GURUS - Dyson ????????????",
            "custrecord_acws_reward_padding": "F",
            "custrecord_acws_reward_pointsrequired": "7500",
            "custrecord_acws_reward_redemptioneddate": "30/04/2023",
            "custrecord_acws_reward_redemptionstdate": "01/05/2022",
            "custrecord_acws_reward_rewardname": "GURUS - Dyson Hand and Hair Care Kit",
            "custrecord_acws_reward_shortdes_en": "GURUS - Dyson Hand and Hair Care Kit",
            "custrecord_acws_reward_type": "2",
            "id": "116",
            "isinactive": "F",
            "lastmodified": "03/10/2022",
            "name": "0000000116",
            "owner": "-5",
            "scriptid": "VAL_115062_T2641016_824"
        }
```
# **Wallet (Redemption Transaction)**


**Description：** 

- Select Voucher Filter:Available, Used, Expired

**URL：** 
-https://tstdrv2641016.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=5
  
**Method：**
- POST

**Request:**

 Available
```jsonld
{
   "q": "select * from customrecord_acws_voucher where custrecord_acws_voucher_txstatus=2"
} 
```
 Used
```jsonld
{
   "q": "select * from customrecord_acws_voucher where custrecord_acws_voucher_txstatus=3"
} 
```
 Expired
```jsonld
{
   "q": "select * from customrecord_acws_voucher where custrecord_acws_voucher_txstatus=4"
} 
```
**Response:**
```json

{
            "links": [],
            "created": "10/01/2023",
            "custrecord_acws_voucher_dynamicscode": "KJJDK9888",
            "custrecord_acws_voucher_facevalue": "100",
            "custrecord_acws_voucher_format": "2",
            "custrecord_acws_voucher_membership": "1000",
            "custrecord_acws_voucher_reward": "101",
            "custrecord_acws_voucher_transactionid": "0001",
            "custrecord_acws_voucher_txstatus": "4",
            "custrecord_acws_voucher_voucherno": "VOU10000001",
            "id": "101",
            "isinactive": "F",
            "lastmodified": "10/01/2023",
            "name": "VCH0000000101",
            "owner": "3110",
            "scriptid": "VAL_117352_T2641016_764"
        }
```

# Post Redeem 

**Description：** 
Post Redeem on Reward page

**URL：** 
https://tstdrv2641016.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=1087&deploy=1

**Method：**
- POST

**Request:**
| Field  | Description| Required |
| -------- | -------- |----------|
| recordtype     | `customrecord_acws_voucher` | Y |
| custrecord_acws_voucher_reward     | - | Y |
| custrecord_acws_voucher_membership     | - | Y |


```json
{
    "recordtype":"customrecord_acws_voucher",       
    "custrecord_acws_voucher_reward": "0000000113",  
    "custrecord_acws_voucher_membership":"001005"   
} 

```

**Response**

```json
{
    "id": 183
}
```

# Social Messages



**Description：** 

- Create Social Messages on Netsuite

**URL：** 
- https://tstdrv2641016.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=1085&deploy=1
 - https://netsuitemiddleware.azurewebsites.net/api/socialmessage?code=VY1k0Gnghd9HpyYt9QiCkauWQ_HXoWXGlJ8bYIMKZtHRAzFu1G9n2Q==

**Method：**
- POST


**Request:**
```json
    {
        "recordtype":"customrecord_acws_socialmessages",
        "name":"Hello ! Messages from Whats App", 
        "custrecord_acws_sm_contact": "3141",
        "custrecord_acws_sm_channel": "1",
        "custrecord_acws_smz_socialprofile": "1",
        "custrecord_acws_sm_type": "1",
        "custrecord_acws_sm_direction": "1"     
    } 
```


 **Response**
```json
    {
        "socialMessages": 3
    }
```
# Generic Insert

**Description：** 

Generic Insert for any netsuite recordtype

**url:**
https://tstdrv2641016.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=1089&deploy=1

**Method：**
- Post

**Request:**

| Field  |  Required |
| -------- | ----------|
| recordtype| Y |
| fieldname     |  Y |


| Field Type  | Description|
| -------- | -------- |
| Date    | "11/30/2022" < include "/" | 
| Boolean     | true ,false | 



**Request:**
```jsonld

{
  {   
    "recordtype":"customrecord_acws_spending",    
    "custrecord_acws_invoiceno":"inv-28112022",
    "custrecord_acws_loyaltyamount":"1500",
    "custrecord_acws_invoicedate":"11/30/2022",
    "custrecord_acws_netamount":1000,
    "custrecord_acws_nopointoffer":true 
     
}   
} 
```
**Response**

```jsonld
{
        "Id": 257
}
```


# Create Contact with Membership

**Description：** 

Create Contact with Membership

**url:**
https://tstdrv2641016.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=1141&deploy=1

**Method：**
- Post

**Request:**

| Field  |  Required |
| -------- | ----------|
| recordtype| Y |
| firstname     |  Y |
| subsidiary     |  Y |





**Request:**
```jsonld

{
    "recordtype":"contact", 
    "firstname":"Black Moon Ltd : Nana Cheung",
    "subsidiary":8
}
  
```
**Response**

```jsonld
{
        "Id": 3864
}
```

# Update Voucher Status

**Description：** 

Update Voucher Status

**url:**
https://tstdrv2641016.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=1088&deploy=1

**Method：**
- PUT

**Request:**

| Field  | Description| Required |
| -------- | -------- |----------|
| recordtype     | `customrecord_acws_voucher` | Y |
| id     | key | Y |
| name     | key | Y |
| custrecord_acws_voucher_txstatus     | check below mapping | Y |

| value  | custrecord_acws_voucher_txstatus|
| -------- | -------- |
| 1    | Not Assigned | 
| 2     | Active | 
| 3    | Used  | 
| 4     | Expired | 
| 5     | Void |
| 6     | Hold  | 


**Request:**
```jsonld

{
    "recordtype":"customrecord_acws_voucher",
    "id":"101",
    "name":"VCH0000000101",    
    "custrecord_acws_voucher_txstatus":"2"    
} 
```
**Response**

```jsonld
{
    "voucherId": 101
}
```





# **Spending + Point**

**Description：** 

- Create Spending + Point

**url:**
https://tstdrv2641016.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=1084&deploy=1 

**Request:**
```json
{   
    "recordtype":"customrecord_acws_spending",    
    "custrecord_acws_invoiceno":"inv-28/11/2022",
    "custrecord_acws_loyaltyamount":"1500",
    "custrecord_acws_invoicedate":"11/30/2022",
    "custrecord_acws_nopointoffer":"",
    "custrecord_acws_member":"001001",
    "custrecord_acws_netamount":1000  
     
} 
``` 




 **Response**
```json 
{
    "links": [
        {
            "rel": "self",
            "href": "https://tstdrv2641016.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=5"
        }
    ],
    "count": 1,
    "hasMore": false,
    "items": [
        {
            "links": [],
            "created": "29/08/2022",
            "custrecord_acws_contact": "3113",
            "custrecord_acws_enddate": "30/04/2023",
            "custrecord_acws_loyaltyprogram": "1",
            "custrecord_acws_memberstatus": "2",
            "custrecord_acws_membertype": "1",
            "custrecord_acws_startdate": "01/05/2022",
            "custrecord_acws_tier": "1",
            "id": "1000",
            "isinactive": "F",
            "lastmodified": "30/09/2022",
            "name": "001000",
            "owner": "-5",
            "scriptid": "VAL_114701_T2641016_990"
        }
    ],
    "offset": 0,
    "totalResults": 1
}
```



------
### Function app version



| Name | Value | Description |
| -------- | -------- | -------- |
| url     | https://netsuitemiddleware.azurewebsites.net     | Text     |
| code     | `PDo7KwJu15pSQV21VQhoHXzwPbbnPlPRTwgpU_v-HaqKAzFu9H-4Uw%3D%3D`  or `VY1k0Gnghd9HpyYt9QiCkauWQ_HXoWXGlJ8bYIMKZtHRAzFu1G9n2Q==`  | Text     |
| endpoint     | contact     | Text     |
| sample url     | https://netsuitemiddleware.azurewebsites.net/api/contact?code=PDo7KwJu15pSQV21VQhoHXzwPbbnPlPRTwgpU_v-HaqKAzFu9H-4Uw%3D%3D     | Text     |
| proxy     | https://shiny-poetry-28e5.simonlkch.workers.dev     | solve CORS     |
| proxy sample url     | https://shiny-poetry-28e5.simonlkch.workers.dev/?https://netsuitemiddleware.azurewebsites.net/api/contact?code=VY1k0Gnghd9HpyYt9QiCkauWQ_HXoWXGlJ8bYIMKZtHRAzFu1G9n2Q==     | `proxy`/?`url` `endpoint`?code=`code`     |

### All endpoint
| Endpoint | Method | Description |
| -------- | -------- |  -------- | 
| contact      | GET    | query record    |
| member       | GET    | query record    |
| pointtransaction      | GET    | query record    |
| spending      | GET    | query record    |
| reward      | GET    | query record    |
| voucher      | GET    | query record    |
| spending      | POST    | create spending with point transaction    |
| socialmessage      | POST    | create record    |
| voucher      | POST    | redeem  reward    |
| voucher      | PUT    | use voucher    |

### Query record filter
- Header

| endpoint | field name | Description |
| -------- | -------- |  -------- | 
| contact      | contactId    | optional   |
| member       | memberId    | optional    |
| pointtransaction      | memberId    | optional    |
| spending      | memberId    | optional    |
| reward      | -    | no need filter    |
| voucher      | txStatus    | optional, Available = 2, Used = 3, Expired = 4    |


# Web Loyalty

## create record
**Description：** 

create record
- there have two way to create record
    - with key_id, and the field need to include key_id
        - will find record with key_id, if found, dont create
    - with out key_id

**url:**
/api/{tablename}

**Method：**
- POST

**Request:**

| Field  | Description| Required |
| -------- | -------- |----------|
| key_id | -------- | N |




**Request:**
- with key_id
```jsonld
{
    "key_id": "id",
    "id":"101",
    "name":"VCH0000000101",    
    "custrecord_acws_voucher_txstatus":"2"    
} 
```
- with out key_id
```jsonld
{
    "id":"101",
    "name":"VCH0000000101",    
    "custrecord_acws_voucher_txstatus":"2"    
} 
```

**Response**

```jsonld
{
  "replyText": "OK",
  "replyCode": 200,
  "data": {
    "id": 1503
  }
}
```


## update record
**Description：** 

update record

**url:**
/api/{tablename}

**Method：**
- PUT

**Request:**

| Field  | Description| Required |
| -------- | -------- |----------|


**Request:**
```jsonld

{
    "key_id": "id",
    "id":"101",
    "name":"VCH0000000101",    
    "custrecord_acws_voucher_txstatus":"2"    
} 
```
**Response**

```jsonld
{
    "id": 101
}
```

## query record
**Description：** 

query record

**url:**
/api/{tablename}/getdata

**Method：**
- POST

**Request:**

| Field  | Description| Required |
| -------- | -------- |----------|
|*|get all record|-|


**Request:**
```jsonld
// get all record
{
    "key_id": ["custrecord_acws_member"],
    "key_operator": ["="],
    "keyValues": ["001002"],
    "fields": ["*"],
    "page_no": 1,
    "page_size": 10
}

// /customrecord_acws_spending/getdata
{
    "key_id": ["custrecord_acws_member"],
    "key_operator": ["="],
    "keyValues": ["001002"],
    "fields": ["custrecord_acws_affiliatespending","custrecord_acws_invoicedate"],
    "page_no": 1,
    "page_size": 10
}
```
**Response**

```jsonld
{
    "replyText": "OK",
    "replyCode": 200,
    "data": [
        {
            "links": [],
            "custrecord_acws_affiliatespending": "F",
            "custrecord_acws_invoicedate": "30/11/2022"
        },
        {
            "links": [],
            "custrecord_acws_affiliatespending": "F",
            "custrecord_acws_invoicedate": "30/11/2022"
        },
        {
            "links": [],
            "custrecord_acws_affiliatespending": "F",
            "custrecord_acws_invoicedate": "30/11/2022"
        }
    ]
}
```

## Check mapping
**Description：** 

query record

**url:**
/api/cust/getMapping

**Method：**
- POST/GET

**Response**

```jsonld
{
    "replyText": "OK",
    "replyCode": 200,
    "mappings": {
        "contact": {
            "custentity_acws_personalid": "personalId",
            "firstname": "firstName",
            "lastName": "lastName",
            "entityid": "fullName",
            "custentity_awcs_chinesename": "chineseName",
            "custentity_awcs_nickname": "nickname",
            "custentity_acws_contactgender": "gender",
            "custentity_awcs_contactagegroup": "ageGroup",
            "custentity_awcs_monthofbirth": "monthOfBirth",
            "custentity_awcs_dayofbirth": "dayOfBirth",
            "custentity_awcs_yearofbirth": "yearOfBirth",
            "email": "email",
            "custentity_acws_zipcode": "zipCode",
            "custentity_acws_contactcountry": "country",
            "custentity_awcs_accepttc": "acceptTerms&Conditions",
            "custentity_acws_allowsms": "marketingViaSMS",
            "custentity_acws_allowemail": "marketingViaEmail"
        },
        "customrecord_acws_membership": {
            "name": "memberId",
            "custrecord_acws_contact": "contactId",
            "custrecord_acws_membernumber": "profileId",
            "custrecord_acws_loyaltyprogram": "loyaltyProgram",
            "custrecord_acws_tier": "tier",
            "custrecord_acws_pointtonexttier": "pointsToNextTier",
            "custrecord_acws_pointavailable": "pointsAvailable",
            "custrecord_acws_renewaldate": "dateOfRenewal",
            "custrecord_acws_memberstatus": "memberStatus",
            "custrecord_acws_pointbalance": "currentPointsBalance",
            "custrecord_acws_accumulatedspendingup": "accumulatedSpending",
            "custrecord_acws_accumulatedpoint": "accumulatedPoints",
            "custrecord_acws_spendingtoupgrade": "spendingToNextTier",
            "custrecord_acws_pointtorenewal": "pointToRenew",
            "custrecord_acws_spendingtorenewal": "spendingToRenew",
            "custrecord_acws_startdate": "startDate",
            "custrecord_acws_enddate": "expiryDate",
            "custrecord_acws_hidepointbalance": "hidePointBal",
            "custrecord_acws_memberno": "memberNo"
        },
        "customrecord_acws_reward": {
            "custrecord_acws_reward_loyaltyprogram": "loyalProgramView",
            "custrecord_acws_rewardtier": "tierView",
            "name": "couponIdView",
            "custrecord_acws_reward_code": "couponCodeView",
            "custrecord_acws_reward_category": "categoryView",
            "custrecord_acws_reward_pictureurl": "rewardPhotoURLView",
            "custrecord_acws_reward_redemptionstdate": "startDateView",
            "custrecord_acws_reward_redemptioneddate": "endDateView",
            "custrecord_acws_reward_rewardname": "rewardNameEnView",
            "custrecord_acws_reward_name_tc": "rewardNameTCView",
            "custrecord_acws_reward_rewardname_2": "rewardNameJPView",
            "custrecord_acws_reward_rewardname_3": "rewardNameKRView",
            "custrecord_acws_reward_shortdes_en": "shortDescriptionEngView",
            "custrecord_acws_reward_shortdes_tc": "shortDescriptionTCView",
            "custrecord_acws_reward_shortdes_3": "shortDescriptionJPView",
            "custrecord_acws_reward_shortdes_4": "shortDescriptionKRView",
            "custrecord_acws_reward_des_en": "rewardDescriptionEnView",
            "custrecord_acws_reward_des_tc": "rewardDescriptionTCView",
            "custrecord_acws_reward_des_3": "rewardDescriptionJPView",
            "custrecord_acws_reward_des_4": "rewardDescriptionKRView",
            "custrecord_acws_reward_tc_en": "tcEnView",
            "custrecord_acws_reward_tc_tc": "tcTcView",
            "custrecord_acws_reward_tc_3": "tcJpView",
            "custrecord_acws_reward_tc_4": "tcKrView",
            "custrecord_acws_publishstatus": "rewardStatusView",
            "custrecord_acws_reward_pointsrequired": "pointRequiredView"
        },
        "customrecord_acws_spending": {
            "custrecord_acws_invoiceno": "memoIdView",
            "custrecord_acws_member": "memberIdView",
            "custrecord_acws_spendingcurrency": "memoCurrencyView",
            "custrecord_acws_invoicedate": "memoDateView",
            "custrecord_acws_netamount": "memoAmountView",
            "custrecord_acws_memostore": "storeCodeView"
        },
        "customrecord_acws_pointtransaction": {
            "name": "pointTransactionIdView",
            "custrecord_acws_pointtransaction_member": "pointMemberIdView",
            "custrecord_acws_pointtransaction_points": "pointValueView",
            "custrecord_acws_pointtransaction_entype": "pointEntryTypeView",
            "custrecord_acws_pointtransstore": "storeCodeView",
            "custrecord_acws_pointtransaction_trdate": "pointTransactionDateView"
        },
        "customrecord_acws_tier": {
            "name": "tierNameView",
            "custrecord_acws_tierhidepointbalance": "amountOrPointView",
            "custrecord_acws_tier_loyaltyprogram": "loyalProgramView",
            "custrecord_acws_tier_upgradecalculation": "upgradeCalculationView",
            "custrecord_acws_nexttier": "nextTierView",
            "custrecord_acws_tiersequence": "sequenceView",
            "custrecord_acws_tier_showchart": "showChartView",
            "custrecord_acws_tier_showpicture": "showPictureView",
            "custrecord_acws_tier_pictureurl": "pictureUrlView"
        },
        "customrecord_acws_voucher": {
            "name": "redeemTransactionIdView",
            "custrecord_acws_voucher_reward": "redeemCouponIdView",
            "custrecord_acws_voucher_membership": "redeemTransMemberIdView",
            "custrecord_acws_voucher_pictureurl": "pictureUrlView",
            "custrecord_acws_voucher_rewardtype": "rtRewardTypeView",
            "custrecord_acws_voucher_rewardname": "rewardNameEnView",
            "custrecord_acws_voucher_rewardnametc": "rewardNameTcView",
            "custrecord_acws_voucher_rewardname_2": "rewardNameJpView",
            "custrecord_acws_voucher_rewardname_3": "rewardNameKrView",
            "custrecord_acws_voucher_voucherno": "rtVoucherNoView",
            "created": "createdOnView",
            "custrecord_acws_voucher_expirydate": "expiryDateView",
            "custrecord_acws_voucher_txstatus": "rtTransStatusView",
            "custrecord_acws_voucher_desc_en": "rewardDescriptionEnView",
            "custrecord_acws_voucher_desc_tc": "rewardDescriptionTCView",
            "custrecord_acws_voucher_desc_3": "rewardDescriptionJPView",
            "custrecord_acws_voucher_desc_4": "rewardDescriptionKRView",
            "custrecord_acws_voucher_shortdesc_en": "shortDescriptionEnView",
            "custrecord_acws_voucher_shortdesc_tc": "shortDescriptionJPView",
            "custrecord_acws_voucher_shortdesc_3": "shortDescriptionKRView",
            "custrecord_acws_voucher_shortdesc_4": "couponTypeShowInWebPortalView"
        }
    },
    "optionSetMapping": {
        "contact": {
            "custentity_awcs_contactagegroup": {
                "557130000": 1,
                "805110000": 2,
                "805110001": 3,
                "805110002": 4,
                "805110003": 5,
                "805110004": 6,
                "805110005": 7,
                "557130001": 8
            },
            "custentity_acws_contactgender": {
                "805110000": 3,
                "1": 1,
                "2": 2
            }
        },
        "customrecord_acws_voucher": {
            "custrecord_acws_voucher_txstatus": {
                "557130000": 1,
                "557130001": 2,
                "557130005": 3,
                "557130002": 4,
                "557130003": 5,
                "557130004": 6
            }
        },
        "customrecord_acws_membership": {
            "custrecord_acws_memberstatus": {
                "557130000": 1,
                "557130001": 2
            }
        },
        "customrecord_acws_reward": {
            "custrecord_acws_reward_category": {
                "557130000": 1,
                "557130001": 2,
                "557130002": 3
            },
            "custrecord_acws_publishstatus": {
                "557130000": 1,
                "557130001": 2,
                "557130002": 3
            }
        }
    }
}
```