Chilkat Online Tools

Foxpro / Salesforce Platform APIs / Member Profile

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loQueryParams
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcLevel_Before_Reset__c
LOCAL lnEscrowPointsBalance
LOCAL lnExpirablePoints
LOCAL lcLastAccrualProcessedDate
LOCAL lcLastEscrowProcessedDate
LOCAL lcLastExpirationProcessRunDate
LOCAL lcLastPointsAggregationDate
LOCAL lcLastPointsResetDate
LOCAL lcLoyaltyMemberCurrencyName
LOCAL lcLoyaltyProgramCurrencyId
LOCAL lcLoyaltyProgramCurrencyName
LOCAL lcMemberCurrencyId
LOCAL lcNextQualifyingPointsResetDate
LOCAL lnPointsBalance
LOCAL lnQualifyingPointsBalanceBeforeReset
LOCAL lnTotalEscrowPointsAccrued
LOCAL lnTotalEscrowRolloverPoints
LOCAL lnTotalPointsAccrued
LOCAL lnTotalPointsExpired
LOCAL lnTotalPointsRedeemed
LOCAL lnAreTierBenefitsAssigned
LOCAL lcLoyaltyMemberTierId
LOCAL lcLoyaltyMemberTierName
LOCAL lcTierChangeReason
LOCAL lcTierChangeReasonType
LOCAL lcTierEffectiveDate
LOCAL lcTierExpirationDate
LOCAL lcTierGroupId
LOCAL lcTierGroupName
LOCAL lcTierId
LOCAL lnTierSequenceNumber
LOCAL lcAssociatedAccount
LOCAL lcContactId
LOCAL lcV_Email
LOCAL lcFirstName
LOCAL lcLastName
LOCAL lnCanReceivePartnerPromotions
LOCAL lnCanReceivePromotions
LOCAL lcEnrollmentChannel
LOCAL lcEnrollmentDate
LOCAL lcGroupCreatedByMember
LOCAL lcGroupName
LOCAL lcLastActivityDate
LOCAL lcLoyaltyProgramMemberId
LOCAL lcLoyaltyProgramName
LOCAL lcMemberStatus
LOCAL lcMemberType
LOCAL lcMembershipEndDate
LOCAL lcMembershipLastRenewalDate
LOCAL lcMembershipNumber
LOCAL lcReferredBy
LOCAL lcRelatedCorporateMembershipNumber
LOCAL lcTransactionJournalStatementFrequency
LOCAL lcTransactionJournalStatementLastGeneratedDate
LOCAL lcTransactionJournalStatementMethod
LOCAL i
LOCAL lnCount_i

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

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loQueryParams = CreateObject('Chilkat.JsonObject')
loQueryParams.UpdateString("memberId","")
loQueryParams.UpdateString("membershipNumber","")
loQueryParams.UpdateString("programCurrencyName","")

* Adds the "Authorization: Bearer <access_token>" header.
loHttp.AuthToken = "<access_token>"

loResp = loHttp.QuickRequestParams("GET","https://domain.com/services/data/v{{version}}/loyalty-programs/:loyaltyProgramName/members",loQueryParams)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loQueryParams
    CANCEL
ENDIF

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
loResp.GetBodySb(loSbResponseBody)

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loQueryParams
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

RELEASE loResp

* 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

lcAssociatedAccount = loJResp.StringOf("associatedAccount")
lcContactId = loJResp.StringOf("associatedContact.contactId")
lcV_Email = loJResp.StringOf("associatedContact.email")
lcFirstName = loJResp.StringOf("associatedContact.firstName")
lcLastName = loJResp.StringOf("associatedContact.lastName")
lnCanReceivePartnerPromotions = loJResp.BoolOf("canReceivePartnerPromotions")
lnCanReceivePromotions = loJResp.BoolOf("canReceivePromotions")
lcEnrollmentChannel = loJResp.StringOf("enrollmentChannel")
lcEnrollmentDate = loJResp.StringOf("enrollmentDate")
lcGroupCreatedByMember = loJResp.StringOf("groupCreatedByMember")
lcGroupName = loJResp.StringOf("groupName")
lcLastActivityDate = loJResp.StringOf("lastActivityDate")
lcLoyaltyProgramMemberId = loJResp.StringOf("loyaltyProgramMemberId")
lcLoyaltyProgramName = loJResp.StringOf("loyaltyProgramName")
lcMemberStatus = loJResp.StringOf("memberStatus")
lcMemberType = loJResp.StringOf("memberType")
lcMembershipEndDate = loJResp.StringOf("membershipEndDate")
lcMembershipLastRenewalDate = loJResp.StringOf("membershipLastRenewalDate")
lcMembershipNumber = loJResp.StringOf("membershipNumber")
lcReferredBy = loJResp.StringOf("referredBy")
lcRelatedCorporateMembershipNumber = loJResp.StringOf("relatedCorporateMembershipNumber")
lcTransactionJournalStatementFrequency = loJResp.StringOf("transactionJournalStatementFrequency")
lcTransactionJournalStatementLastGeneratedDate = loJResp.StringOf("transactionJournalStatementLastGeneratedDate")
lcTransactionJournalStatementMethod = loJResp.StringOf("transactionJournalStatementMethod")
i = 0
lnCount_i = loJResp.SizeOfArray("memberCurrencies")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcLevel_Before_Reset__c = loJResp.StringOf("memberCurrencies[i].additionalLoyaltyMemberCurrencyFields.Level_Before_Reset__c")
    lnEscrowPointsBalance = loJResp.IntOf("memberCurrencies[i].escrowPointsBalance")
    lnExpirablePoints = loJResp.IntOf("memberCurrencies[i].expirablePoints")
    lcLastAccrualProcessedDate = loJResp.StringOf("memberCurrencies[i].lastAccrualProcessedDate")
    lcLastEscrowProcessedDate = loJResp.StringOf("memberCurrencies[i].lastEscrowProcessedDate")
    lcLastExpirationProcessRunDate = loJResp.StringOf("memberCurrencies[i].lastExpirationProcessRunDate")
    lcLastPointsAggregationDate = loJResp.StringOf("memberCurrencies[i].lastPointsAggregationDate")
    lcLastPointsResetDate = loJResp.StringOf("memberCurrencies[i].lastPointsResetDate")
    lcLoyaltyMemberCurrencyName = loJResp.StringOf("memberCurrencies[i].loyaltyMemberCurrencyName")
    lcLoyaltyProgramCurrencyId = loJResp.StringOf("memberCurrencies[i].loyaltyProgramCurrencyId")
    lcLoyaltyProgramCurrencyName = loJResp.StringOf("memberCurrencies[i].loyaltyProgramCurrencyName")
    lcMemberCurrencyId = loJResp.StringOf("memberCurrencies[i].memberCurrencyId")
    lcNextQualifyingPointsResetDate = loJResp.StringOf("memberCurrencies[i].nextQualifyingPointsResetDate")
    lnPointsBalance = loJResp.IntOf("memberCurrencies[i].pointsBalance")
    lnQualifyingPointsBalanceBeforeReset = loJResp.IntOf("memberCurrencies[i].qualifyingPointsBalanceBeforeReset")
    lnTotalEscrowPointsAccrued = loJResp.IntOf("memberCurrencies[i].totalEscrowPointsAccrued")
    lnTotalEscrowRolloverPoints = loJResp.IntOf("memberCurrencies[i].totalEscrowRolloverPoints")
    lnTotalPointsAccrued = loJResp.IntOf("memberCurrencies[i].totalPointsAccrued")
    lnTotalPointsExpired = loJResp.IntOf("memberCurrencies[i].totalPointsExpired")
    lnTotalPointsRedeemed = loJResp.IntOf("memberCurrencies[i].totalPointsRedeemed")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("memberTiers")
DO WHILE i < lnCount_i
    loJResp.I = i
    lnAreTierBenefitsAssigned = loJResp.BoolOf("memberTiers[i].areTierBenefitsAssigned")
    lcLoyaltyMemberTierId = loJResp.StringOf("memberTiers[i].loyaltyMemberTierId")
    lcLoyaltyMemberTierName = loJResp.StringOf("memberTiers[i].loyaltyMemberTierName")
    lcTierChangeReason = loJResp.StringOf("memberTiers[i].tierChangeReason")
    lcTierChangeReasonType = loJResp.StringOf("memberTiers[i].tierChangeReasonType")
    lcTierEffectiveDate = loJResp.StringOf("memberTiers[i].tierEffectiveDate")
    lcTierExpirationDate = loJResp.StringOf("memberTiers[i].tierExpirationDate")
    lcTierGroupId = loJResp.StringOf("memberTiers[i].tierGroupId")
    lcTierGroupName = loJResp.StringOf("memberTiers[i].tierGroupName")
    lcTierId = loJResp.StringOf("memberTiers[i].tierId")
    lnTierSequenceNumber = loJResp.IntOf("memberTiers[i].tierSequenceNumber")
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loQueryParams
RELEASE loSbResponseBody
RELEASE loJResp

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