Member Management SDK

Last Updated on : 2024-10-11 02:16:04download

The @ray-js/wechat-ms-member SDK integrates capabilities that enable users to create, query, update, delete, and bind unlocking methods.

Installation

yarn add @ray-js/wechat-ms-member

// or

npm install @ray-js/wechat-ms-member

Get the list of members using mobile phones

getListUsers

Request parameters

Parameter Type Description Required
device_id string The device ID. true
page_no number The page number. The default value is 1. false
page_size number The number of records to return per page. The default value is 200. false
target_standard_dp_codes string The data point (DP) code of a standard unlocking method. Valid values:
  • unlock_fingerprint: unlock with fingerprint
  • unlock_password: unlock with password
  • unlock_card: unlock with card
  • unlock_finger_vein: unlock with finger vein
  • unlock_face: unlock with face recognition
  • unlock_hand: unlock with palm print
  • unlock_eye: unlock with iris recognition
false

Response parameters

Parameter Type Description
has_more bool Indicates whether the next page exists.
total number The total number of records.
total_pages number The total number of pages.
records GetListUserItem[] The details of all users in the list.

Description of GetListUserItem

Parameter Type Description
user_id string The ID of the user of a home.
lock_user_id number The ID of the user of a lock.
user_contact string The contact information.
avatar_url string The avatar URL.
nick_name string The nickname.
user_type number The user type. Valid values:
  • 10: administrator
  • 20: common member
  • 30: anonymous member
  • 50: home owner
back_home_notify_attr number Indicates whether to send notifications when family members arrive home. Valid values:
  • 0: no
  • 1: yes
effective_flag number Indicates whether the unlocking method is valid. Valid values:
  • 0: invalid
  • 1: valid
  • 2: to be valid later
time_schedule_info ITimeScheduleInfo The schedule information for when the unlocking method becomes valid.
unlock_detail IUnlockDetail[] The details of the unlocking method.

Description of ITimeScheduleInfo

Parameter Type Description
permanent bool Indicates whether the unlocking method is valid permanently.
effective_time number The effective time.
expired_time number The expiration time.
operate string The operation type. Valid values: ADD, MODIFY, and DELETE. Currently, only MODIFY is available.
delivery_status string The response of the device to the operation. Valid values:
  • ONGOING: ongoing
  • SUCCESS: succeeded
  • FAILED: failed

Description of IScheduleDetails

Parameter Type Description
all_day bool Indicates whether the unlocking method is valid all day.
effective_time number The effective time.
invalid_time number The expiration time.
working_day string The day of the week the unlocking method is valid.

Description of IUnlockDetail

Parameter Type Description
dp_code number The DP code of the unlocking method.
count number The number of the current unlocking methods.
unlock_list IUnlockList The list of the unlocking methods.

Description of IUnlockList

Parameter Type Description
unlock_sn string The SN of the unlocking method.
dp_code string The DP code of the unlocking method. Valid values:
  • unlock_fingerprint: unlock with fingerprint
  • unlock_password: unlock with password
  • unlock_card: unlock with card
  • unlock_finger_vein: unlock with finger vein
  • unlock_face: unlock with face recognition
  • unlock_hand: unlock with palm print
  • unlock_eye: unlock with iris recognition
unlock_name string The name of the unlocking method.
unlock_attr number The attribute of the unlocking method. Valid values:
  • 1: special
  • 0: non-special
allocate_flag number Indicates whether an unallocated unlocking method is allocated to the user. Valid values:
  • 1: yes. If so, the unlocking method can be unbound.
  • 0: no

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.getListUsers({
  device_id: 'vdevo172164201350692',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

{
  has_more: false,
  records: [
    {
      avatar_url: "https://images.tuyacn.com/xxxxxx.png",
      back_home_notify_attr: 0,
      effective_flag: 1,
      lock_user_id: 1,
      nick_name: "Alice",
      user_contact: "*******@tuya.com",
      user_id: "5958862",
      user_type: 50,
      uid: "xxxxxxxx",
      time_schedule_info: {
      permanent: true,
      user_time_set: "386cd30072bc9b7f000000000000000000",
    },
    unlock_detail:[
      {
        count: 0,
        dp_code: "unlock_fingerprint",
    unlock_list: []
  }]
}],
  total: 1,
  total_pages: 1
}

Get the list of members not using mobile phones

getListPanelUsers

Request parameters

Parameter Type Description Required
device_id string The device ID. true
page_no number The page number. The default value is 1. false
page_size number The number of records to return per page. The default value is 200. false
dp_codes string The DP code of a standard unlocking method. Valid values:
  • unlock_fingerprint: unlock with fingerprint
  • unlock_password: unlock with password
  • unlock_card: unlock with card
  • unlock_finger_vein: unlock with finger vein
  • unlock_face: unlock with face recognition
  • unlock_hand: unlock with palm print
  • unlock_eye: unlock with iris recognition
false

Response parameters

Parameter Type Description
has_more bool Indicates whether the next page exists.
total number The total number of records.
total_pages number The total number of pages.
records GetListUserItem[] The details of all users in the list.

Description of GetListUserItem

Parameter Type Description
user_id string The ID of the user of a home.
lock_user_id number The ID of the user of a lock.
user_contact string The contact information.
avatar_url string The avatar URL.
nick_name string The nickname.
user_type number The user type. Valid values:
  • 10: administrator
  • 20: common member
  • 30: anonymous member
  • 50: home owner
back_home_notify_attr number Indicates whether to send notifications when family members arrive home. Valid values:
  • 0: no
  • 1: yes
effective_flag number Indicates whether the unlocking method is valid. Valid values:
  • 0: invalid
  • 1: valid
  • 2: to be valid later
time_schedule_info ITimeScheduleInfo The schedule information for when the unlocking method becomes valid.
unlock_detail IUnlockDetail[] The details of the unlocking method.

Description of ITimeScheduleInfo

Parameter Type Description
permanent bool Indicates whether the unlocking method is valid permanently.
effective_time number The effective time.
expired_time number The expiration time.
operate string The operation type. Valid values: ADD, MODIFY, and DELETE. Currently, only MODIFY is available.
delivery_status string The response of the device to the operation. Valid values:
  • ONGOING: ongoing
  • SUCCESS: succeeded
  • FAILED: failed

Description of IScheduleDetails

Parameter Type Description
all_day bool Indicates whether the unlocking method is valid all day.
effective_time number The effective time.
invalid_time number The expiration time.
working_day string The day of the week the unlocking method is valid.

Description of IUnlockDetail

Parameter Type Description
dp_code number The DP code of the unlocking method.
count number The number of the current unlocking methods.
unlock_list IUnlockList The list of the unlocking methods.

Description of IUnlockList

Parameter Type Description
unlock_sn string The SN of the unlocking method.
dp_code string The DP code of the unlocking method. Valid values:
  • unlock_fingerprint: unlock with fingerprint
  • unlock_password: unlock with password
  • unlock_card: unlock with card
  • unlock_finger_vein: unlock with finger vein
  • unlock_face: unlock with face recognition
  • unlock_hand: unlock with palm print
  • unlock_eye: unlock with iris recognition
unlock_name string The name of the unlocking method.
unlock_attr number The attribute of the unlocking method. Valid values:
  • 1: special
  • 0: non-special
allocate_flag number Indicates whether an unallocated unlocking method is allocated to the user. Valid values:
  • 1: yes. If so, the unlocking method can be unbound.
  • 0: no

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.getListPanelUsers({
  device_id: 'vdevo172164201350692',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

{
  has_more: false,
  records: [],
  total: 0,
  total_pages: 0,
}

Add a user not using a mobile phone

addPanelUsers

Request parameters

Parameter Type Description Required
device_id string The device ID. true
nick_name string The nickname. true

Response parameters

Parameter Type Description
result string The user ID.

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.addPanelUsers({
  device_id: 'vdevo172164201350692',
  nick_name: 'Ming',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

'7wmqnc';

Delete a user not using a mobile phone

deletePanelUsers

Request parameters

Parameter Type Description Required
device_id string The device ID. true
user_id string The user ID. true

Response parameters

Return a boolean value to indicate whether the user is deleted.

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.deletePanelUsers({
  device_id: 'vdevo172164201350692',
  user_id: '7wmqnc',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

true;

Get the list of unbound unlocking methods

Get the list of unbound unlocking methods, or determine whether any unlocking method is not bound.

listUnallocatedOpModes

Request parameters

Parameter Type Description Required
device_id string The device ID. true
page_no number The page number. The default value is 1. false
page_size number The number of records to return per page. The default value is 200. false

Response parameters

Parameter Type Description
has_more bool Indicates whether the next page exists.
total number The total number of records in the list.
total_pages number The total number of pages in the list.
records IUnAllocatedItem[] The details of all users in the list.

Description of IUnAllocatedItem

Parameter Type Description
standard_dp string The DP code of the unlocking method. Valid values:
  • unlock_fingerprint: unlock with fingerprint
  • unlock_password: unlock with password
  • unlock_card: unlock with card
  • unlock_finger_vein: unlock with finger vein
  • unlock_face: unlock with face recognition
  • unlock_hand: unlock with palm print
  • unlock_eye: unlock with iris recognition
unlock_info IUnlockInfo The details of the unlocking method.

Description of IUnlockInfo

Parameter Type Description
dp_code string The DP code of the unlocking method. Valid values:
  • unlock_fingerprint: unlock with fingerprint
  • unlock_password: unlock with password
  • unlock_card: unlock with card
  • unlock_finger_vein: unlock with finger vein
  • unlock_face: unlock with face recognition
  • unlock_hand: unlock with palm print
  • unlock_eye: unlock with iris recognition
opmode_id number The ID of the unlocking method.
unlock_name string The name of the unlocking method.
unlock_sn number The SN of the unlocking method.

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.listUnallocatedOpModes({
  device_id: 'vdevo172164201350692',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

{
  has_more: false,
  records: [
    {
      standard_dp: 'unlock_fingerprint',
      unlock_info: [
        {
          dp_code: 'unlock_fingerprint',
          opmode_id: '4065562',
          unlock_name: 'fingerprint',
          unlock_sn: 2
        }
      ]
    }
  ],
  total: 1,
  total_pages: 1,
}

Get the list of the unlocking methods of members

listUserOpModes

Request parameters

Parameter Type Description Required
device_id string The device ID. true
user_id string The user ID. true
target_unlock_standard_dp_codes string The DP code of the unlocking method. Valid values:
  • unlock_fingerprint: unlock with fingerprint
  • unlock_password: unlock with password
  • unlock_card: unlock with card
  • unlock_finger_vein: unlock with finger vein
  • unlock_face: unlock with face recognition
  • unlock_hand: unlock with palm print
  • unlock_eye: unlock with iris recognition
false
page_no number The page number. The default value is 1. false
page_size number The number of records to return per page. The default value is 200. false

Response parameters

Parameter Type Description
has_more bool Indicates whether the next page exists.
total number The total number of records in the list.
total_pages number The total number of pages in the list.
records listUserOpmodeItem[] The details of all users in the list.

Description of listUserOpmodeItem

Parameter Type Description
unlock_sn string The SN of the unlocking method.
dp_code string The DP code of the unlocking method. Valid values:
  • unlock_fingerprint: unlock with fingerprint
  • unlock_password: unlock with password
  • unlock_card: unlock with card
  • unlock_finger_vein: unlock with finger vein
  • unlock_face: unlock with face recognition
  • unlock_hand: unlock with palm print
  • unlock_eye: unlock with iris recognition
unlock_name string The name of the unlocking method.
unlock_attr number The attribute of the unlocking method. 1 represents duress unlocking.
allocate_flag number Indicates whether an unallocated unlocking method is allocated to the user. Valid values:
  • 1: yes. If so, the unlocking method can be unbound.
  • 0: no
lock_user_id number The ID of the user of a lock.
phase number The phase. Valid values:
  • 1: confirmed and normal
  • 2: to be confirmed and updated
  • 3: frozen
  • 4: to be frozen
  • 5: to be unfrozen
  • 6: to be reset
  • 7: creation failed
  • 8: deleted
  • 9: to be deleted
  • 10: to be created
user_name string The nickname of the user.
user_id string The ID of the user of a home.
user_type number The user type. Valid values:
  • 10: administrator
  • 20: common member
  • 30: anonymous member
  • 50: home owner
photo_unlock number Indicates whether photo-based duress alert is enabled. Valid values:
  • 0: disabled
  • 1: enabled

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.listUserOpModes({
  device_id: 'vdevo172164201350692',
  user_id: '7wmqnc',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

{
  has_more: false,
  records: [
    {
      allocate_flag: 1,
      channel_id: -1,
      dp_code: 'unlock_password',
      lock_user_id: 8,
      phase: 1,
      photo_unlock: 0,
      unlock_attr: 1,
      unlock_name: 'password',
      unlock_sn: 5,
      user_id: '5958862',
      user_name: 'Ling',
      user_type: 10,
      voice_attr: 0
    }
  ],
  total: 1,
  total_pages: 1,
}

Delete an unlocking method of a member

deleteOpMode

Request parameters

Parameter Type Description Required
device_id string The device ID. true
dp_code string The DP code of the unlocking method. Valid values:
  • unlock_fingerprint: unlock with fingerprint
  • unlock_password: unlock with password
  • unlock_card: unlock with card
  • unlock_finger_vein: unlock with finger vein
  • unlock_face: unlock with face recognition
  • unlock_hand: unlock with palm print
  • unlock_eye: unlock with iris recognition
true
unlock_sn string or number The SN of the unlocking method. true

Response parameters

Return a boolean value to indicate whether the unlocking method is deleted.

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.deleteOpMode({
  device_id: 'vdevo172164201350***',
  dp_code: 'unlock_fingerprint',
  unlock_sn: 10,
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

true;

Add an unlocking method for a member

createOpMode

Request parameters

Parameter Type Description Required
device_id string The device ID. true
user_id string The user ID. true
standard_dp_code string The DP code of the unlocking method. Valid values:
  • unlock_fingerprint: unlock with fingerprint
  • unlock_password: unlock with password
  • unlock_card: unlock with card
  • unlock_finger_vein: unlock with finger vein
  • unlock_face: unlock with face recognition
  • unlock_hand: unlock with palm print
  • unlock_eye: unlock with iris recognition
true
unlock_no number or string The SN of the unlocking DP. true
unlock_attr number The attribute of the unlocking method. Valid values:
  • 1: special
  • 0: non-special
true
unlock_name string The name of the unlocking method. false
notify_info number Specifies whether to enable the app to send notifications (app_send). Valid values:
  • 0: disable
  • 1: enable
false

Response parameters

Return a boolean value to indicate whether the unlocking method is added.

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.createOpMode({
  device_id: 'vdevo172164201350692',
  standard_dp_code: 'unlock_fingerprint',
  unlock_no: 10,
  user_id: '5958862',
  unlock_attr: 0,
  unlock_name: '',
  notify_info: { app_send: 1 },
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

true;

Update an unlocking method

updateOpMode

Request parameters

Parameter Type Description Required
device_id string The device ID. true
dp_code string The DP code of the unlocking method. Valid values:
  • unlock_fingerprint: unlock with fingerprint
  • unlock_password: unlock with password
  • unlock_card: unlock with card
  • unlock_finger_vein: unlock with finger vein
  • unlock_face: unlock with face recognition
  • unlock_hand: unlock with palm print
  • unlock_eye: unlock with iris recognition
true
unlock_sn string The SN of the unlocking method. true
unlock_attr 0 or 1 The attribute of the unlocking method. Valid values:
  • 0: non-duress unlocking
  • 1: duress unlocking
true
unlock_name string The name of the unlocking method. It is empty by default. false
photo_unlock number Specifies whether to enable photo-based duress alert. Valid values:
  • 0: disable
  • 1: enable
false
notify_info number Specifies whether to enable the app to send notifications (app_send). Valid values:
  • 0: disable
  • 1: enable
false

Response parameters

Return a boolean value to indicate whether the unlocking method is updated.

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.updateOpMode({
  device_id: 'vdevo172164201350692',
  photo_unlock: 0,
  dp_code: 'unlock_fingerprint',
  unlock_attr: 0,
  unlock_name: 'fingerprint',
  unlock_sn: 10,
  notify_info: {
    app_send: 1,
  },
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

true;

Bind unlocking methods

Multiple unlocking methods can be bound at once.

allocateOpMode

Request parameters

Parameter Type Description Required
device_id string The device ID. true
user_id string The user ID. true
unlock_list UnlockListItem[] The list of unlocking methods to bind. true

Description of UnlockListItem

Parameter Type Description Required
dp_code string The DP code of the unlocking method. Valid values:
  • unlock_fingerprint: unlock with fingerprint
  • unlock_password: unlock with password
  • unlock_card: unlock with card
  • unlock_finger_vein: unlock with finger vein
  • unlock_face: unlock with face recognition
  • unlock_hand: unlock with palm print
  • unlock_eye: unlock with iris recognition
true
unlock_sn string The SN of the unlocking method. true

Response parameters

Return a boolean value to indicate whether the unlocking methods are bound.

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.allocateOpMode({
  device_id: 'vdevo172164201350692',
  user_id: '5958862',
  unlock_list: [
    {
      dp_code: 'unlock_fingerprint',
      unlock_sn: 2,
    },
  ],
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

true;

Get the SN used for creating an unlocking method

getSn

Request parameters

Parameter Type Description Required
device_id string The device ID. true
dp_id string The DP ID. true

Response parameters

Return a number, which is the SN used for creating an unlocking method.

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.getSn({
  device_id: 'vdevo172164201350692',
  dp_id: '63',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

1;

Get the settings used for creating a password

Get the developer platform settings used for creating a password, including base, length range, and whether to hide zeros.

getPwdInfo

Request parameters

Parameter Type Description Required
device_id string The device ID. true

Response parameters

Parameter Type Description
digit number The base.
hasZero bool Indicates whether passwords can contain zeros.
pwdLenMax number The maximum length of passwords created through the member management SDK.
pwdLenMin number The minimum length of passwords created through the member management SDK.
tempPwdLenMax number The maximum length of passwords created through the temporary password management SDK.
tempPwdLenMin number The minimum length of passwords created through the temporary password management SDK.

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.getPwdInfo({
  device_id: 'vdevo172164201350692',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

{
  digit: 10,
  hasZero: true,
  pwdLenMax: 10,
  pwdLenMin: 10,
  tempPwdLenMax: 7,
  tempPwdLenMax: 7,
}

Unbind an unlocking method from a member

dealLocateOpMode

Request parameters

Parameter Type Description Required
device_id string The device ID. true
user_id string The user ID. true
dp_code string The DP code of the unlocking method. Valid values:
  • unlock_fingerprint: unlock with fingerprint
  • unlock_password: unlock with password
  • unlock_card: unlock with card
  • unlock_finger_vein: unlock with finger vein
  • unlock_face: unlock with face recognition
  • unlock_hand: unlock with palm print
  • unlock_eye: unlock with iris recognition
true
unlock_sn string The SN of the unlocking method. true

Response parameters

Return a boolean value to indicate whether the unlocking method is unbound from the member.

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.dealLocateOpMode({
  device_id: 'vdevo172164201350692',
  user_id: '5958862',
  unlock_sn: 2,
  dp_code: 'unlock_fingerprint',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

true;

Enable duress alerts

setHijack

Request parameters

Parameter Type Description Required
device_id string The device ID. true
unlock_type string The DP code of the unlocking method. Valid values:
  • fingerprint: unlock with fingerprint
  • password: unlock with password
  • card: unlock with card
  • finger_vein: unlock with finger vein
  • hand: unlock with palm print
true
unlock_sn string The SN of the unlocking method. true

Response parameters

Return a boolean value to indicate whether duress alerts are enabled.

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.setHijack({
  device_id: 'vdevo172164201350692',
  unlock_no: 10,
  unlock_type: 'fingerprint',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

true;

Disable duress alerts

removeHijack

Request parameters

Parameter Type Description Required
device_id string The device ID. true
unlock_type string The DP code of the unlocking method. Valid values:
  • unlock_fingerprint: unlock with fingerprint
  • unlock_password: unlock with password
  • unlock_card: unlock with card
  • unlock_finger_vein: unlock with finger vein
  • unlock_face: unlock with face recognition
  • unlock_hand: unlock with palm print
  • unlock_eye: unlock with iris recognition
true
unlock_sn string The SN of the unlocking method. true

Response parameters

Return a boolean value to indicate whether duress alerts are disabled.

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.removeHijack({
  device_id: 'vdevo172164201350692',
  unlock_no: 10,
  unlock_type: 'unlock_fingerprint',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

true;

Get the synchronizable unlocking methods of members

getSyncableOpModeTypes

Request parameters

Parameter Type Description Required
device_id string The device ID. true

Response parameters

Parameter Type Description
dp_id number The DP ID.
distributed bool Indicates whether unlocking methods are allowed to be sent from the cloud.
ins string The content to be sent.

Sample request

import MsMemberApi from '@ray-js/wechat-ms-member';

MsMemberApi.getSyncableOpModeTypes({
  device_id: 'vdevo172164201350692',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

{
  distributed: true,
  dp_id: 54,
  ins: "04f0080506030102"
}