Chilkat Online Tools

Node.js / Salesforce Platform APIs / Member Profile

Back to Collection Items

var os = require('os');
if (os.platform() == 'win32') {  
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node21-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node21-win64'); 
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node21-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node21-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node21-linux64');
    }
} else if (os.platform() == 'darwin') {
    if (os.arch() == 'arm64') {
        var chilkat = require('@chilkat/ck-node21-mac-m1');
    } else {
        var chilkat = require('@chilkat/ck-node21-macosx');
    }
}


function chilkatExample() {

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    var http = new chilkat.Http();
    var success;

    var queryParams = new chilkat.JsonObject();
    queryParams.UpdateString("memberId","");
    queryParams.UpdateString("membershipNumber","");
    queryParams.UpdateString("programCurrencyName","");

    // Adds the "Authorization: Bearer <access_token>" header.
    http.AuthToken = "<access_token>";

    // resp: HttpResponse
    var resp = http.QuickRequestParams("GET","https://domain.com/services/data/v{{version}}/loyalty-programs/:loyaltyProgramName/members",queryParams);
    if (http.LastMethodSuccess == false) {
        console.log(http.LastErrorText);
        return;
    }

    var sbResponseBody = new chilkat.StringBuilder();
    resp.GetBodySb(sbResponseBody);

    var jResp = new chilkat.JsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.EmitCompact = false;

    console.log("Response Body:");
    console.log(jResp.Emit());

    var respStatusCode = resp.StatusCode;
    console.log("Response Status Code = " + respStatusCode);
    if (respStatusCode >= 400) {
        console.log("Response Header:");
        console.log(resp.Header);
        console.log("Failed.");

        return;
    }

    // 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

    var Level_Before_Reset__c;
    var escrowPointsBalance;
    var expirablePoints;
    var lastAccrualProcessedDate;
    var lastEscrowProcessedDate;
    var lastExpirationProcessRunDate;
    var lastPointsAggregationDate;
    var lastPointsResetDate;
    var loyaltyMemberCurrencyName;
    var loyaltyProgramCurrencyId;
    var loyaltyProgramCurrencyName;
    var memberCurrencyId;
    var nextQualifyingPointsResetDate;
    var pointsBalance;
    var qualifyingPointsBalanceBeforeReset;
    var totalEscrowPointsAccrued;
    var totalEscrowRolloverPoints;
    var totalPointsAccrued;
    var totalPointsExpired;
    var totalPointsRedeemed;
    var areTierBenefitsAssigned;
    var loyaltyMemberTierId;
    var loyaltyMemberTierName;
    var tierChangeReason;
    var tierChangeReasonType;
    var tierEffectiveDate;
    var tierExpirationDate;
    var tierGroupId;
    var tierGroupName;
    var tierId;
    var tierSequenceNumber;

    var associatedAccount = jResp.StringOf("associatedAccount");
    var ContactId = jResp.StringOf("associatedContact.contactId");
    var v_Email = jResp.StringOf("associatedContact.email");
    var FirstName = jResp.StringOf("associatedContact.firstName");
    var LastName = jResp.StringOf("associatedContact.lastName");
    var canReceivePartnerPromotions = jResp.BoolOf("canReceivePartnerPromotions");
    var canReceivePromotions = jResp.BoolOf("canReceivePromotions");
    var enrollmentChannel = jResp.StringOf("enrollmentChannel");
    var enrollmentDate = jResp.StringOf("enrollmentDate");
    var groupCreatedByMember = jResp.StringOf("groupCreatedByMember");
    var groupName = jResp.StringOf("groupName");
    var lastActivityDate = jResp.StringOf("lastActivityDate");
    var loyaltyProgramMemberId = jResp.StringOf("loyaltyProgramMemberId");
    var loyaltyProgramName = jResp.StringOf("loyaltyProgramName");
    var memberStatus = jResp.StringOf("memberStatus");
    var memberType = jResp.StringOf("memberType");
    var membershipEndDate = jResp.StringOf("membershipEndDate");
    var membershipLastRenewalDate = jResp.StringOf("membershipLastRenewalDate");
    var membershipNumber = jResp.StringOf("membershipNumber");
    var referredBy = jResp.StringOf("referredBy");
    var relatedCorporateMembershipNumber = jResp.StringOf("relatedCorporateMembershipNumber");
    var transactionJournalStatementFrequency = jResp.StringOf("transactionJournalStatementFrequency");
    var transactionJournalStatementLastGeneratedDate = jResp.StringOf("transactionJournalStatementLastGeneratedDate");
    var transactionJournalStatementMethod = jResp.StringOf("transactionJournalStatementMethod");
    var i = 0;
    var count_i = jResp.SizeOfArray("memberCurrencies");
    while (i < count_i) {
        jResp.I = i;
        Level_Before_Reset__c = jResp.StringOf("memberCurrencies[i].additionalLoyaltyMemberCurrencyFields.Level_Before_Reset__c");
        escrowPointsBalance = jResp.IntOf("memberCurrencies[i].escrowPointsBalance");
        expirablePoints = jResp.IntOf("memberCurrencies[i].expirablePoints");
        lastAccrualProcessedDate = jResp.StringOf("memberCurrencies[i].lastAccrualProcessedDate");
        lastEscrowProcessedDate = jResp.StringOf("memberCurrencies[i].lastEscrowProcessedDate");
        lastExpirationProcessRunDate = jResp.StringOf("memberCurrencies[i].lastExpirationProcessRunDate");
        lastPointsAggregationDate = jResp.StringOf("memberCurrencies[i].lastPointsAggregationDate");
        lastPointsResetDate = jResp.StringOf("memberCurrencies[i].lastPointsResetDate");
        loyaltyMemberCurrencyName = jResp.StringOf("memberCurrencies[i].loyaltyMemberCurrencyName");
        loyaltyProgramCurrencyId = jResp.StringOf("memberCurrencies[i].loyaltyProgramCurrencyId");
        loyaltyProgramCurrencyName = jResp.StringOf("memberCurrencies[i].loyaltyProgramCurrencyName");
        memberCurrencyId = jResp.StringOf("memberCurrencies[i].memberCurrencyId");
        nextQualifyingPointsResetDate = jResp.StringOf("memberCurrencies[i].nextQualifyingPointsResetDate");
        pointsBalance = jResp.IntOf("memberCurrencies[i].pointsBalance");
        qualifyingPointsBalanceBeforeReset = jResp.IntOf("memberCurrencies[i].qualifyingPointsBalanceBeforeReset");
        totalEscrowPointsAccrued = jResp.IntOf("memberCurrencies[i].totalEscrowPointsAccrued");
        totalEscrowRolloverPoints = jResp.IntOf("memberCurrencies[i].totalEscrowRolloverPoints");
        totalPointsAccrued = jResp.IntOf("memberCurrencies[i].totalPointsAccrued");
        totalPointsExpired = jResp.IntOf("memberCurrencies[i].totalPointsExpired");
        totalPointsRedeemed = jResp.IntOf("memberCurrencies[i].totalPointsRedeemed");
        i = i+1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("memberTiers");
    while (i < count_i) {
        jResp.I = i;
        areTierBenefitsAssigned = jResp.BoolOf("memberTiers[i].areTierBenefitsAssigned");
        loyaltyMemberTierId = jResp.StringOf("memberTiers[i].loyaltyMemberTierId");
        loyaltyMemberTierName = jResp.StringOf("memberTiers[i].loyaltyMemberTierName");
        tierChangeReason = jResp.StringOf("memberTiers[i].tierChangeReason");
        tierChangeReasonType = jResp.StringOf("memberTiers[i].tierChangeReasonType");
        tierEffectiveDate = jResp.StringOf("memberTiers[i].tierEffectiveDate");
        tierExpirationDate = jResp.StringOf("memberTiers[i].tierExpirationDate");
        tierGroupId = jResp.StringOf("memberTiers[i].tierGroupId");
        tierGroupName = jResp.StringOf("memberTiers[i].tierGroupName");
        tierId = jResp.StringOf("memberTiers[i].tierId");
        tierSequenceNumber = jResp.IntOf("memberTiers[i].tierSequenceNumber");
        i = i+1;
    }


}

chilkatExample();

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}"
    }
  ]
}