tourze/wechat-work-external-contact-model 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tourze/wechat-work-external-contact-model

最新稳定版本:0.1.0

Composer 安装命令:

composer require tourze/wechat-work-external-contact-model

包简介

企业微信外部联系人定义

README 文档

README

English | 中文

Latest Version Total Downloads License [PHP Version] Build Status Code Coverage

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 user
  • WEWORK (2): WeChat Work user

ExternalContactInterface

Defines the contract for external contact entities with methods:

  • getExternalUserId(): Get external user ID
  • getUnionId(): Get union ID
  • getNickname(): Get nickname
  • getAvatar(): 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 functionality
  • tourze/wechat-work-contracts: WeChat Work contracts

Reference

License

MIT

统计信息

  • 总下载量: 482
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-17