# CRM APIs

# User Summary

# Import User Summary Data

Method: POST Path: /crm/api/projects/{projectId}/import/user-summaries-async
Description: Import User Summary Data

Client Scope: crm.us.bulk-full-async
Authority: -

Request Header:

Param Description Required Example
Authorization The OAuth2 authentication with the O2O System Y Bearer {O2O Access Token}
Content-Type The MIME type of this content Y application/json

Request Body:

Param Description Type Required
mode The mode of import data. PATCH or REPLACE String Y
fieldIndicator The name of field that use for indicator record to update or insert data(required every record to has this field) String Y
records The list of data List Y

Data in records:

Name Description Type
username The unique identifier for that user in the system String
exteranalRef the alternative reference to the user String
mobile the user mobile number List
mobileHash Hashed user mobile number String
currency The currency unit for amount String
totalOrder The summarize number of transaction per user. e.g. mrA buys something 5 times for Feb. mean this value for Feb2021 is 5 Map<String,Number>
totalAmount The summarize number of amount in all transactions per user. e.g. mrA buys something 5 times and all order sum is 200K THB for Feb. mean this value for Feb2021 is 200,000 Map<String,Number>
maxAmount The maximum amount of items in all orders. For example, MrA. purchase iPhone (35k) and Airpod (6K), the value should be 35K Map<String,Number>
minAmount The minimum amount of items in all orders. For example, MrA. purchase iPhone (35k) and Airpod (6K), the value should be 6K Map<String,Number>
registerDate The date that user register to system DateTime (ISO+Zone)
lastPurchaseDate The latest purchaseDate for that user DateTime (ISO+Zone)
status The current status of that user (Active, InActive, Block, etc) This status should be a free text and base on each system information String
groupName Aka category. This field will be use as indicator for separate the data group. For example, you might use this to separate data from each company, BU, ETC String
metadata The dynamic data fields that allow the other application can put their own dynamic fields And searchable Map<String,Object>
personalData The personal data Object

Data in personalData:

Name Description Type
identity the unique identity value of that user. It can be thaiId, passport,SSN etc. This field should be encrypted and allow access only the client that we would like them to get this data String
identityType Type of identity, e.g [thaiId, passport, SSN etc] String
firstName The data of user String
lastName The data of user String
dateOfBirth The data of user String
gender The data of user String
maritalStatus The data of user String
nationality The data of user String

Example Request:

curl -X POST \
  'http://alpha-platform.weomni-test.com/crm/api/projects/5f6467cf723c4100015af031/import/user-summaries-async' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer {O2O Access Token}'\
  -d '{
      "mode": "PATCH",
      "fieldIndicator": "username",
      "records": [
          {
              "username": "Mr. A",
              "totalOrder": {
                  "2021-01-01": 5
              },
              "totalAmount": {
                  "2021-01-01": 200000
              },
              "maxAmount": {
                  "2021-01-01": 2
              },
              "minAmount": {
                  "2021-01-01": 2
              },
              "currency": "THB",
              "registerDate": "2018-07-26T04:53:22.397Z",
              "lastPurchaseDate": "2019-07-26T04:53:22.397Z",
              "status": "ACTIVE",
              "metadata": {
                  "paylaterStatus": "ELIGIBLE",
                  "paylaterApproveBudget": 10000
              },
              "psersonalData": {
                  "identity": "1234567890123",
                  "identityType": "thaiId"
              }
          }
      ]
  }'

Response Example:

HTTP/1.1 202 ACCEPTED

# Search User Summary

Method: GET
Path: /crm/api/projects/{projectId}/_search/user-summaries
Description: Search User Summary

Client Scope: crm.us.search
Authority: -

Request Header:

Param Description Required Example
Authorization The OAuth2 authentication with the O2O System Y Bearer {O2O Access Token}

Request Parameter:

Param Description Required Example
query condition for filtering return result Y query = username:John
fields selected fields in return result N fields = username,lastPurchaseDate
page page no of result starting from 0 N page = 0
size maximum no of return records( default 20) N size = 15
sort sorting by fields and direction asc(default) or desc N sort=totalAmount.2020-01-01,username

Response Body:

Name Description Type
username The unique identifier for that user in the system String
exteranalRef the alternative reference to the user String
mobile the user mobile number List
mobileHash Hashed user mobile number String
currency The currency unit for amount String
totalOrder The summarize number of transaction per user. e.g. mrA buys something 5 times for Feb. mean this value for Feb2021 is 5 Map<String,Number>
totalAmount The summarize number of amount in all transactions per user. e.g. mrA buys something 5 times and all order sum is 200K THB for Feb. mean this value for Feb2021 is 200,000 Map<String,Number>
maxAmount The maximum amount of items in all orders. For example, MrA. purchase iPhone (35k) and Airpod (6K), the value should be 35K Map<String,Number>
minAmount The minimum amount of items in all orders. For example, MrA. purchase iPhone (35k) and Airpod (6K), the value should be 6K Map<String,Number>
registerDate The date that user register to system DateTime (ISO+Zone)
lastPurchaseDate The latest purchaseDate for that user DateTime (ISO+Zone)
status The current status of that user (Active, InActive, Block, etc) This status should be a free text and base on each system information String
groupName Aka category. This field will be use as indicator for separate the data group. For example, you might use this to separate data from each company, BU, ETC String
metadata The dynamic data fields that allow the other application can put their own dynamic fields And searchable Map<String,Object>
personalData The personal data Object

Data in personalData:

Name Description Type
identity the unique identity value of that user. It can be thaiId, passport,SSN etc. This field should be encrypted and allow access only the client that we would like them to get this data String
identityType Type of identity, e.g [thaiId, passport, SSN etc] String
firstName The data of user String
lastName The data of user String
dateOfBirth The data of user String
gender The data of user String
maritalStatus The data of user String
nationality The data of user String

Example Request:

curl -X POST \
  'http://alpha-platform.weomni-test.com/crm/api/projects/5f6467cf723c4100015af031/_search/user-summaries?query=username:wemall001 AND metadata.paylaterStatus: APPROVE' \
  -H 'Authorization: Bearer {O2O Access Token}'\

Response Example:

HTTP/1.1 200 OK
Content-Type: application/json
[
    {
        "createdBy": "webhook",
        "createdDate": "2021-03-19T08:20:58.740070Z",
        "lastModifiedBy": "webhook",
        "lastModifiedDate": "2021-03-20T18:30:58.740070Z",
        "id": "001",
        "username": "wemall001",
        "projectId": "wemall",
        "currency": "THB",
        "status": "ACTIVE",
        "groupName": "TrueOnlineStoreShop",
        "registerDate": "2021-01-01T12:30:00Z",
        "lastPurchaseDate": "2021-03-20T12:30:00Z",
        "mobile":"081234567",
        "mobileHash":"99987627hslg7298",
        "externalRef": "xxxwemall001",
        "totalOrder": {
            "2021-01-01": 5
        },
        "totalAmount": {
            "2021-01-01": 200000.0,
            "2021-02-01": 300000.0
        },
        "maxAmount": {
            "2021-01-01": 2.0,
            "2021-02-01": 2.0
        },
        "minAmount": {
            "2021-01-01": 2.0,
            "2021-02-01": 2.0
        },
        "personalData": {
            "identity":"77798654457",
            "identityType":"SSN",
            "firstName": "First",
            "lastName": "Mylastname",
            "gender": "MALE",
            "nationality": "THAI",
            "dateOfBirth": "2000-02-01T00:00:00Z",
            "maritalStatus": "SINGLE"
        },
        "metadata": {
            "consentA": true,
            "consentB": true,
            "paylaterStatus": "APPROVE",
            "paylaterApproveAmount": 10000
        }
    }
]
Last Updated: 3/23/2021, 2:53:49 AM