Chilkat Online Tools

PowerBuilder / Salesforce Platform APIs / Member Profile

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Level_Before_Reset__c
integer li_EscrowPointsBalance
integer li_ExpirablePoints
string ls_LastAccrualProcessedDate
string ls_LastEscrowProcessedDate
string ls_LastExpirationProcessRunDate
string ls_LastPointsAggregationDate
string ls_LastPointsResetDate
string ls_LoyaltyMemberCurrencyName
string ls_LoyaltyProgramCurrencyId
string ls_LoyaltyProgramCurrencyName
string ls_MemberCurrencyId
string ls_NextQualifyingPointsResetDate
integer li_PointsBalance
integer li_QualifyingPointsBalanceBeforeReset
integer li_TotalEscrowPointsAccrued
integer li_TotalEscrowRolloverPoints
integer li_TotalPointsAccrued
integer li_TotalPointsExpired
integer li_TotalPointsRedeemed
integer li_AreTierBenefitsAssigned
string ls_LoyaltyMemberTierId
string ls_LoyaltyMemberTierName
string ls_TierChangeReason
string ls_TierChangeReasonType
string ls_TierEffectiveDate
string ls_TierExpirationDate
string ls_TierGroupId
string ls_TierGroupName
string ls_TierId
integer li_TierSequenceNumber
string ls_AssociatedAccount
string ls_ContactId
string ls_V_Email
string ls_FirstName
string ls_LastName
integer li_CanReceivePartnerPromotions
integer li_CanReceivePromotions
string ls_EnrollmentChannel
string ls_EnrollmentDate
string ls_GroupCreatedByMember
string ls_GroupName
string ls_LastActivityDate
string ls_LoyaltyProgramMemberId
string ls_LoyaltyProgramName
string ls_MemberStatus
string ls_MemberType
string ls_MembershipEndDate
string ls_MembershipLastRenewalDate
string ls_MembershipNumber
string ls_ReferredBy
string ls_RelatedCorporateMembershipNumber
string ls_TransactionJournalStatementFrequency
string ls_TransactionJournalStatementLastGeneratedDate
string ls_TransactionJournalStatementMethod
integer i
integer li_Count_i

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

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_QueryParams = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat.JsonObject")

loo_QueryParams.UpdateString("memberId","")
loo_QueryParams.UpdateString("membershipNumber","")
loo_QueryParams.UpdateString("programCurrencyName","")

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

loo_Resp = loo_Http.QuickRequestParams("GET","https://domain.com/services/data/v{{version}}/loyalty-programs/:loyaltyProgramName/members",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_QueryParams
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_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

ls_AssociatedAccount = loo_JResp.StringOf("associatedAccount")
ls_ContactId = loo_JResp.StringOf("associatedContact.contactId")
ls_V_Email = loo_JResp.StringOf("associatedContact.email")
ls_FirstName = loo_JResp.StringOf("associatedContact.firstName")
ls_LastName = loo_JResp.StringOf("associatedContact.lastName")
li_CanReceivePartnerPromotions = loo_JResp.BoolOf("canReceivePartnerPromotions")
li_CanReceivePromotions = loo_JResp.BoolOf("canReceivePromotions")
ls_EnrollmentChannel = loo_JResp.StringOf("enrollmentChannel")
ls_EnrollmentDate = loo_JResp.StringOf("enrollmentDate")
ls_GroupCreatedByMember = loo_JResp.StringOf("groupCreatedByMember")
ls_GroupName = loo_JResp.StringOf("groupName")
ls_LastActivityDate = loo_JResp.StringOf("lastActivityDate")
ls_LoyaltyProgramMemberId = loo_JResp.StringOf("loyaltyProgramMemberId")
ls_LoyaltyProgramName = loo_JResp.StringOf("loyaltyProgramName")
ls_MemberStatus = loo_JResp.StringOf("memberStatus")
ls_MemberType = loo_JResp.StringOf("memberType")
ls_MembershipEndDate = loo_JResp.StringOf("membershipEndDate")
ls_MembershipLastRenewalDate = loo_JResp.StringOf("membershipLastRenewalDate")
ls_MembershipNumber = loo_JResp.StringOf("membershipNumber")
ls_ReferredBy = loo_JResp.StringOf("referredBy")
ls_RelatedCorporateMembershipNumber = loo_JResp.StringOf("relatedCorporateMembershipNumber")
ls_TransactionJournalStatementFrequency = loo_JResp.StringOf("transactionJournalStatementFrequency")
ls_TransactionJournalStatementLastGeneratedDate = loo_JResp.StringOf("transactionJournalStatementLastGeneratedDate")
ls_TransactionJournalStatementMethod = loo_JResp.StringOf("transactionJournalStatementMethod")
i = 0
li_Count_i = loo_JResp.SizeOfArray("memberCurrencies")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Level_Before_Reset__c = loo_JResp.StringOf("memberCurrencies[i].additionalLoyaltyMemberCurrencyFields.Level_Before_Reset__c")
    li_EscrowPointsBalance = loo_JResp.IntOf("memberCurrencies[i].escrowPointsBalance")
    li_ExpirablePoints = loo_JResp.IntOf("memberCurrencies[i].expirablePoints")
    ls_LastAccrualProcessedDate = loo_JResp.StringOf("memberCurrencies[i].lastAccrualProcessedDate")
    ls_LastEscrowProcessedDate = loo_JResp.StringOf("memberCurrencies[i].lastEscrowProcessedDate")
    ls_LastExpirationProcessRunDate = loo_JResp.StringOf("memberCurrencies[i].lastExpirationProcessRunDate")
    ls_LastPointsAggregationDate = loo_JResp.StringOf("memberCurrencies[i].lastPointsAggregationDate")
    ls_LastPointsResetDate = loo_JResp.StringOf("memberCurrencies[i].lastPointsResetDate")
    ls_LoyaltyMemberCurrencyName = loo_JResp.StringOf("memberCurrencies[i].loyaltyMemberCurrencyName")
    ls_LoyaltyProgramCurrencyId = loo_JResp.StringOf("memberCurrencies[i].loyaltyProgramCurrencyId")
    ls_LoyaltyProgramCurrencyName = loo_JResp.StringOf("memberCurrencies[i].loyaltyProgramCurrencyName")
    ls_MemberCurrencyId = loo_JResp.StringOf("memberCurrencies[i].memberCurrencyId")
    ls_NextQualifyingPointsResetDate = loo_JResp.StringOf("memberCurrencies[i].nextQualifyingPointsResetDate")
    li_PointsBalance = loo_JResp.IntOf("memberCurrencies[i].pointsBalance")
    li_QualifyingPointsBalanceBeforeReset = loo_JResp.IntOf("memberCurrencies[i].qualifyingPointsBalanceBeforeReset")
    li_TotalEscrowPointsAccrued = loo_JResp.IntOf("memberCurrencies[i].totalEscrowPointsAccrued")
    li_TotalEscrowRolloverPoints = loo_JResp.IntOf("memberCurrencies[i].totalEscrowRolloverPoints")
    li_TotalPointsAccrued = loo_JResp.IntOf("memberCurrencies[i].totalPointsAccrued")
    li_TotalPointsExpired = loo_JResp.IntOf("memberCurrencies[i].totalPointsExpired")
    li_TotalPointsRedeemed = loo_JResp.IntOf("memberCurrencies[i].totalPointsRedeemed")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("memberTiers")
do while i < li_Count_i
    loo_JResp.I = i
    li_AreTierBenefitsAssigned = loo_JResp.BoolOf("memberTiers[i].areTierBenefitsAssigned")
    ls_LoyaltyMemberTierId = loo_JResp.StringOf("memberTiers[i].loyaltyMemberTierId")
    ls_LoyaltyMemberTierName = loo_JResp.StringOf("memberTiers[i].loyaltyMemberTierName")
    ls_TierChangeReason = loo_JResp.StringOf("memberTiers[i].tierChangeReason")
    ls_TierChangeReasonType = loo_JResp.StringOf("memberTiers[i].tierChangeReasonType")
    ls_TierEffectiveDate = loo_JResp.StringOf("memberTiers[i].tierEffectiveDate")
    ls_TierExpirationDate = loo_JResp.StringOf("memberTiers[i].tierExpirationDate")
    ls_TierGroupId = loo_JResp.StringOf("memberTiers[i].tierGroupId")
    ls_TierGroupName = loo_JResp.StringOf("memberTiers[i].tierGroupName")
    ls_TierId = loo_JResp.StringOf("memberTiers[i].tierId")
    li_TierSequenceNumber = loo_JResp.IntOf("memberTiers[i].tierSequenceNumber")
    i = i + 1
loop


destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_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}"
    }
  ]
}