tourze / wechat-work-external-contact-model
企业微信外部联系人定义
Installs: 460
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/tourze/wechat-work-external-contact-model
Requires
- php: ^8.1
- tourze/enum-extra: 0.1.*
- tourze/wechat-work-contracts: 0.0.*
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-10-31 07:56:32 UTC
README
A PHP library that provides interface definitions and type enumerations for WeChat Work (Enterprise WeChat) external contacts.
Installation
composer require tourze/wechat-work-external-contact-model
Quick Start
Contact Type Enumeration
<?php use Tourze\WechatWorkExternalContactModel\ContactType; // Get contact type label echo ContactType::WECHAT->getLabel(); // 'WeChat User' echo ContactType::WEWORK->getLabel(); // 'WeChat Work User' // Get all contact types for select options $options = ContactType::getSelectOptions();
External Contact Interface
<?php use Tourze\WechatWorkExternalContactModel\ExternalContactInterface; class MyExternalContact implements ExternalContactInterface { public function getExternalUserId(): ?string { // Return the external user ID return $this->externalUserId; } public function getUnionId(): ?string { // Return the union ID return $this->unionId; } public function getNickname(): ?string { // Return the nickname return $this->nickname; } public function getAvatar(): ?string { // Return the avatar URL return $this->avatar; } }
External User Loader Interface
<?php use Tourze\WechatWorkExternalContactModel\ExternalUserLoaderInterface; use Tourze\WechatWorkContracts\CorpInterface; class MyExternalUserLoader implements ExternalUserLoaderInterface { public function loadByUnionIdAndCorp(string $unionId, CorpInterface $corp): ?ExternalContactInterface { // Load external contact by union ID and corporation return $this->findExternalContact($unionId, $corp); } }
Components
ContactType Enum
Defines the type of external contact:
WECHAT(1): WeChat userWEWORK(2): WeChat Work user
ExternalContactInterface
Defines the contract for external contact entities with methods:
getExternalUserId(): Get external user IDgetUnionId(): Get union IDgetNickname(): Get nicknamegetAvatar(): Get avatar URL
ExternalUserLoaderInterface
Defines the contract for loading external contacts:
loadByUnionIdAndCorp(): Load by union ID and corporation
Dependencies
- PHP 8.1+
tourze/enum-extra: Enhanced enum functionalitytourze/wechat-work-contracts: WeChat Work contracts
Reference
License
MIT