Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW queryParams;
HCkHttpResponseW resp;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jResp;
int respStatusCode;
const wchar_t *Level_Before_Reset__c;
int escrowPointsBalance;
int expirablePoints;
const wchar_t *lastAccrualProcessedDate;
const wchar_t *lastEscrowProcessedDate;
const wchar_t *lastExpirationProcessRunDate;
const wchar_t *lastPointsAggregationDate;
const wchar_t *lastPointsResetDate;
const wchar_t *loyaltyMemberCurrencyName;
const wchar_t *loyaltyProgramCurrencyId;
const wchar_t *loyaltyProgramCurrencyName;
const wchar_t *memberCurrencyId;
const wchar_t *nextQualifyingPointsResetDate;
int pointsBalance;
int qualifyingPointsBalanceBeforeReset;
int totalEscrowPointsAccrued;
int totalEscrowRolloverPoints;
int totalPointsAccrued;
int totalPointsExpired;
int totalPointsRedeemed;
BOOL areTierBenefitsAssigned;
const wchar_t *loyaltyMemberTierId;
const wchar_t *loyaltyMemberTierName;
const wchar_t *tierChangeReason;
const wchar_t *tierChangeReasonType;
const wchar_t *tierEffectiveDate;
const wchar_t *tierExpirationDate;
const wchar_t *tierGroupId;
const wchar_t *tierGroupName;
const wchar_t *tierId;
int tierSequenceNumber;
const wchar_t *associatedAccount;
const wchar_t *ContactId;
const wchar_t *v_Email;
const wchar_t *FirstName;
const wchar_t *LastName;
BOOL canReceivePartnerPromotions;
BOOL canReceivePromotions;
const wchar_t *enrollmentChannel;
const wchar_t *enrollmentDate;
const wchar_t *groupCreatedByMember;
const wchar_t *groupName;
const wchar_t *lastActivityDate;
const wchar_t *loyaltyProgramMemberId;
const wchar_t *loyaltyProgramName;
const wchar_t *memberStatus;
const wchar_t *memberType;
const wchar_t *membershipEndDate;
const wchar_t *membershipLastRenewalDate;
const wchar_t *membershipNumber;
const wchar_t *referredBy;
const wchar_t *relatedCorporateMembershipNumber;
const wchar_t *transactionJournalStatementFrequency;
const wchar_t *transactionJournalStatementLastGeneratedDate;
const wchar_t *transactionJournalStatementMethod;
int i;
int count_i;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
queryParams = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(queryParams,L"memberId",L"");
CkJsonObjectW_UpdateString(queryParams,L"membershipNumber",L"");
CkJsonObjectW_UpdateString(queryParams,L"programCurrencyName",L"");
// Adds the "Authorization: Bearer <access_token>" header.
CkHttpW_putAuthToken(http,L"<access_token>");
resp = CkHttpW_QuickRequestParams(http,L"GET",L"https://domain.com/services/data/v{{version}}/loyalty-programs/:loyaltyProgramName/members",queryParams);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(queryParams);
return;
}
sbResponseBody = CkStringBuilderW_Create();
CkHttpResponseW_GetBodySb(resp,sbResponseBody);
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
respStatusCode = CkHttpResponseW_getStatusCode(resp);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpResponseW_header(resp));
wprintf(L"Failed.\n");
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(queryParams);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
return;
}
CkHttpResponseW_Dispose(resp);
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "additionalLoyaltyProgramMemberFields": {},
// "associatedAccount": null,
// "associatedContact": {
// "contactId": "003J8000002Yu0ZIAS",
// "email": "ab@email.com",
// "firstName": "Name1",
// "lastName": "Name2"
// },
// "canReceivePartnerPromotions": true,
// "canReceivePromotions": true,
// "enrollmentChannel": "Email",
// "enrollmentDate": "2021-01-01",
// "groupCreatedByMember": null,
// "groupName": null,
// "lastActivityDate": null,
// "loyaltyProgramMemberId": "0lMJ8000000CaRMMA0",
// "loyaltyProgramName": "NTO Insider",
// "memberCurrencies": [
// {
// "additionalLoyaltyMemberCurrencyFields": {
// "Level_Before_Reset__c": null
// },
// "escrowPointsBalance": 0,
// "expirablePoints": 0,
// "lastAccrualProcessedDate": null,
// "lastEscrowProcessedDate": null,
// "lastExpirationProcessRunDate": null,
// "lastPointsAggregationDate": null,
// "lastPointsResetDate": null,
// "loyaltyMemberCurrencyName": "NTO Qualifying Points",
// "loyaltyProgramCurrencyId": "0lcJ8000000CaR7IAK",
// "loyaltyProgramCurrencyName": null,
// "memberCurrencyId": "0lzJ8000000CaRMIA0",
// "nextQualifyingPointsResetDate": "2024-12-31",
// "pointsBalance": 0,
// "qualifyingPointsBalanceBeforeReset": 0,
// "totalEscrowPointsAccrued": 0,
// "totalEscrowRolloverPoints": 0,
// "totalPointsAccrued": 0,
// "totalPointsExpired": 0,
// "totalPointsRedeemed": 0
// }
// ],
// "memberStatus": "Active",
// "memberTiers": [
// {
// "additionalLoyaltyMemberTierFields": {},
// "areTierBenefitsAssigned": false,
// "loyaltyMemberTierId": "0lyJ8000000CaRMIA0",
// "loyaltyMemberTierName": "Bronze",
// "tierChangeReason": null,
// "tierChangeReasonType": null,
// "tierEffectiveDate": "2021-01-01",
// "tierExpirationDate": null,
// "tierGroupId": "0ltJ8000000CaR8IAK",
// "tierGroupName": null,
// "tierId": "0lgJ80000008OI5IAM",
// "tierSequenceNumber": 10
// }
// ],
// "memberType": "Individual",
// "membershipEndDate": "2022-01-01",
// "membershipLastRenewalDate": null,
// "membershipNumber": "Member1",
// "referredBy": null,
// "relatedCorporateMembershipNumber": null,
// "transactionJournalStatementFrequency": "Monthly",
// "transactionJournalStatementLastGeneratedDate": null,
// "transactionJournalStatementMethod": "Mail"
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
associatedAccount = CkJsonObjectW_stringOf(jResp,L"associatedAccount");
ContactId = CkJsonObjectW_stringOf(jResp,L"associatedContact.contactId");
v_Email = CkJsonObjectW_stringOf(jResp,L"associatedContact.email");
FirstName = CkJsonObjectW_stringOf(jResp,L"associatedContact.firstName");
LastName = CkJsonObjectW_stringOf(jResp,L"associatedContact.lastName");
canReceivePartnerPromotions = CkJsonObjectW_BoolOf(jResp,L"canReceivePartnerPromotions");
canReceivePromotions = CkJsonObjectW_BoolOf(jResp,L"canReceivePromotions");
enrollmentChannel = CkJsonObjectW_stringOf(jResp,L"enrollmentChannel");
enrollmentDate = CkJsonObjectW_stringOf(jResp,L"enrollmentDate");
groupCreatedByMember = CkJsonObjectW_stringOf(jResp,L"groupCreatedByMember");
groupName = CkJsonObjectW_stringOf(jResp,L"groupName");
lastActivityDate = CkJsonObjectW_stringOf(jResp,L"lastActivityDate");
loyaltyProgramMemberId = CkJsonObjectW_stringOf(jResp,L"loyaltyProgramMemberId");
loyaltyProgramName = CkJsonObjectW_stringOf(jResp,L"loyaltyProgramName");
memberStatus = CkJsonObjectW_stringOf(jResp,L"memberStatus");
memberType = CkJsonObjectW_stringOf(jResp,L"memberType");
membershipEndDate = CkJsonObjectW_stringOf(jResp,L"membershipEndDate");
membershipLastRenewalDate = CkJsonObjectW_stringOf(jResp,L"membershipLastRenewalDate");
membershipNumber = CkJsonObjectW_stringOf(jResp,L"membershipNumber");
referredBy = CkJsonObjectW_stringOf(jResp,L"referredBy");
relatedCorporateMembershipNumber = CkJsonObjectW_stringOf(jResp,L"relatedCorporateMembershipNumber");
transactionJournalStatementFrequency = CkJsonObjectW_stringOf(jResp,L"transactionJournalStatementFrequency");
transactionJournalStatementLastGeneratedDate = CkJsonObjectW_stringOf(jResp,L"transactionJournalStatementLastGeneratedDate");
transactionJournalStatementMethod = CkJsonObjectW_stringOf(jResp,L"transactionJournalStatementMethod");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"memberCurrencies");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
Level_Before_Reset__c = CkJsonObjectW_stringOf(jResp,L"memberCurrencies[i].additionalLoyaltyMemberCurrencyFields.Level_Before_Reset__c");
escrowPointsBalance = CkJsonObjectW_IntOf(jResp,L"memberCurrencies[i].escrowPointsBalance");
expirablePoints = CkJsonObjectW_IntOf(jResp,L"memberCurrencies[i].expirablePoints");
lastAccrualProcessedDate = CkJsonObjectW_stringOf(jResp,L"memberCurrencies[i].lastAccrualProcessedDate");
lastEscrowProcessedDate = CkJsonObjectW_stringOf(jResp,L"memberCurrencies[i].lastEscrowProcessedDate");
lastExpirationProcessRunDate = CkJsonObjectW_stringOf(jResp,L"memberCurrencies[i].lastExpirationProcessRunDate");
lastPointsAggregationDate = CkJsonObjectW_stringOf(jResp,L"memberCurrencies[i].lastPointsAggregationDate");
lastPointsResetDate = CkJsonObjectW_stringOf(jResp,L"memberCurrencies[i].lastPointsResetDate");
loyaltyMemberCurrencyName = CkJsonObjectW_stringOf(jResp,L"memberCurrencies[i].loyaltyMemberCurrencyName");
loyaltyProgramCurrencyId = CkJsonObjectW_stringOf(jResp,L"memberCurrencies[i].loyaltyProgramCurrencyId");
loyaltyProgramCurrencyName = CkJsonObjectW_stringOf(jResp,L"memberCurrencies[i].loyaltyProgramCurrencyName");
memberCurrencyId = CkJsonObjectW_stringOf(jResp,L"memberCurrencies[i].memberCurrencyId");
nextQualifyingPointsResetDate = CkJsonObjectW_stringOf(jResp,L"memberCurrencies[i].nextQualifyingPointsResetDate");
pointsBalance = CkJsonObjectW_IntOf(jResp,L"memberCurrencies[i].pointsBalance");
qualifyingPointsBalanceBeforeReset = CkJsonObjectW_IntOf(jResp,L"memberCurrencies[i].qualifyingPointsBalanceBeforeReset");
totalEscrowPointsAccrued = CkJsonObjectW_IntOf(jResp,L"memberCurrencies[i].totalEscrowPointsAccrued");
totalEscrowRolloverPoints = CkJsonObjectW_IntOf(jResp,L"memberCurrencies[i].totalEscrowRolloverPoints");
totalPointsAccrued = CkJsonObjectW_IntOf(jResp,L"memberCurrencies[i].totalPointsAccrued");
totalPointsExpired = CkJsonObjectW_IntOf(jResp,L"memberCurrencies[i].totalPointsExpired");
totalPointsRedeemed = CkJsonObjectW_IntOf(jResp,L"memberCurrencies[i].totalPointsRedeemed");
i = i + 1;
}
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"memberTiers");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
areTierBenefitsAssigned = CkJsonObjectW_BoolOf(jResp,L"memberTiers[i].areTierBenefitsAssigned");
loyaltyMemberTierId = CkJsonObjectW_stringOf(jResp,L"memberTiers[i].loyaltyMemberTierId");
loyaltyMemberTierName = CkJsonObjectW_stringOf(jResp,L"memberTiers[i].loyaltyMemberTierName");
tierChangeReason = CkJsonObjectW_stringOf(jResp,L"memberTiers[i].tierChangeReason");
tierChangeReasonType = CkJsonObjectW_stringOf(jResp,L"memberTiers[i].tierChangeReasonType");
tierEffectiveDate = CkJsonObjectW_stringOf(jResp,L"memberTiers[i].tierEffectiveDate");
tierExpirationDate = CkJsonObjectW_stringOf(jResp,L"memberTiers[i].tierExpirationDate");
tierGroupId = CkJsonObjectW_stringOf(jResp,L"memberTiers[i].tierGroupId");
tierGroupName = CkJsonObjectW_stringOf(jResp,L"memberTiers[i].tierGroupName");
tierId = CkJsonObjectW_stringOf(jResp,L"memberTiers[i].tierId");
tierSequenceNumber = CkJsonObjectW_IntOf(jResp,L"memberTiers[i].tierSequenceNumber");
i = i + 1;
}
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(queryParams);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}
Curl Command
curl -G -d "memberId="
-d "membershipNumber="
-d "programCurrencyName="
-H "Authorization: Bearer <access_token>"
https://domain.com/services/data/v{{version}}/loyalty-programs/:loyaltyProgramName/members
Postman Collection Item JSON
{
"name": "Member Profile",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/loyalty-programs/:loyaltyProgramName/members?memberId=&membershipNumber=&programCurrencyName=",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"loyalty-programs",
":loyaltyProgramName",
"members"
],
"query": [
{
"key": "memberId",
"value": "",
"description": "The ID of the loyalty program member."
},
{
"key": "membershipNumber",
"value": "",
"description": "The membership number of the loyalty program member."
},
{
"key": "programCurrencyName",
"value": "",
"description": "The name of the loyalty program currency associated with the member.\nUse this parameter to get the details of the member’s points-related information for a specific currency."
}
],
"variable": [
{
"key": "loyaltyProgramName",
"value": ""
}
]
},
"description": "Standard Documentation:\n\n[https://developer.salesforce.com/docs/atlas.en-us.loyalty.meta/loyalty/connect_resources_member_profile.htm](https://developer.salesforce.com/docs/atlas.en-us.loyalty.meta/loyalty/connect_resources_member_profile.htm)"
},
"response": [
{
"name": "Member Profile",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{accessToken}}"
}
],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/loyalty-programs/:loyaltyProgramName/members?memberId=0lMJ8000000CaRMMA0&membershipNumber=Member1&programCurrencyName=NTO Qualifying Points",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"loyalty-programs",
":loyaltyProgramName",
"members"
],
"query": [
{
"key": "memberId",
"value": "0lMJ8000000CaRMMA0",
"description": "The ID of the loyalty program member."
},
{
"key": "membershipNumber",
"value": "Member1",
"description": "The membership number of the loyalty program member."
},
{
"key": "programCurrencyName",
"value": "NTO Qualifying Points",
"description": "The name of the loyalty program currency associated with the member.\nUse this parameter to get the details of the member’s points-related information for a specific currency."
}
],
"variable": [
{
"key": "loyaltyProgramName",
"value": "NTO Insider"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Wed, 22 May 2024 16:16:23 GMT"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Robots-Tag",
"value": "none"
},
{
"key": "Cache-Control",
"value": "no-cache,must-revalidate,max-age=0,no-store,private"
},
{
"key": "Content-Type",
"value": "application/json;charset=UTF-8"
},
{
"key": "Vary",
"value": "Accept-Encoding"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
}
],
"cookie": [
],
"body": "{\n \"additionalLoyaltyProgramMemberFields\": {},\n \"associatedAccount\": null,\n \"associatedContact\": {\n \"contactId\": \"003J8000002Yu0ZIAS\",\n \"email\": \"ab@email.com\",\n \"firstName\": \"Name1\",\n \"lastName\": \"Name2\"\n },\n \"canReceivePartnerPromotions\": true,\n \"canReceivePromotions\": true,\n \"enrollmentChannel\": \"Email\",\n \"enrollmentDate\": \"2021-01-01\",\n \"groupCreatedByMember\": null,\n \"groupName\": null,\n \"lastActivityDate\": null,\n \"loyaltyProgramMemberId\": \"0lMJ8000000CaRMMA0\",\n \"loyaltyProgramName\": \"NTO Insider\",\n \"memberCurrencies\": [\n {\n \"additionalLoyaltyMemberCurrencyFields\": {\n \"Level_Before_Reset__c\": null\n },\n \"escrowPointsBalance\": 0,\n \"expirablePoints\": 0,\n \"lastAccrualProcessedDate\": null,\n \"lastEscrowProcessedDate\": null,\n \"lastExpirationProcessRunDate\": null,\n \"lastPointsAggregationDate\": null,\n \"lastPointsResetDate\": null,\n \"loyaltyMemberCurrencyName\": \"NTO Qualifying Points\",\n \"loyaltyProgramCurrencyId\": \"0lcJ8000000CaR7IAK\",\n \"loyaltyProgramCurrencyName\": null,\n \"memberCurrencyId\": \"0lzJ8000000CaRMIA0\",\n \"nextQualifyingPointsResetDate\": \"2024-12-31\",\n \"pointsBalance\": 0,\n \"qualifyingPointsBalanceBeforeReset\": 0,\n \"totalEscrowPointsAccrued\": 0,\n \"totalEscrowRolloverPoints\": 0,\n \"totalPointsAccrued\": 0,\n \"totalPointsExpired\": 0,\n \"totalPointsRedeemed\": 0\n }\n ],\n \"memberStatus\": \"Active\",\n \"memberTiers\": [\n {\n \"additionalLoyaltyMemberTierFields\": {},\n \"areTierBenefitsAssigned\": false,\n \"loyaltyMemberTierId\": \"0lyJ8000000CaRMIA0\",\n \"loyaltyMemberTierName\": \"Bronze\",\n \"tierChangeReason\": null,\n \"tierChangeReasonType\": null,\n \"tierEffectiveDate\": \"2021-01-01\",\n \"tierExpirationDate\": null,\n \"tierGroupId\": \"0ltJ8000000CaR8IAK\",\n \"tierGroupName\": null,\n \"tierId\": \"0lgJ80000008OI5IAM\",\n \"tierSequenceNumber\": 10\n }\n ],\n \"memberType\": \"Individual\",\n \"membershipEndDate\": \"2022-01-01\",\n \"membershipLastRenewalDate\": null,\n \"membershipNumber\": \"Member1\",\n \"referredBy\": null,\n \"relatedCorporateMembershipNumber\": null,\n \"transactionJournalStatementFrequency\": \"Monthly\",\n \"transactionJournalStatementLastGeneratedDate\": null,\n \"transactionJournalStatementMethod\": \"Mail\"\n}"
}
]
}