tourze/wechat-work-contracts 问题修复 & 功能扩展

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

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

tourze/wechat-work-contracts

最新稳定版本:1.0.2

Composer 安装命令:

composer require tourze/wechat-work-contracts

包简介

企业微信 API 接口定义和数据契约

README 文档

README

English | 中文

Latest Version PHP Version License Quality Score Code Coverage Total Downloads

WeChat Work (Enterprise WeChat) contracts and interfaces definitions for PHP applications.

Features

  • 🏢 Enterprise Management - Standard interfaces for WeChat Work enterprise information
  • 👥 User Management - Contracts for user/employee data handling
  • 🏗️ Department Management - Interfaces for organizational structure
  • 🤖 Agent Management - Application agent configuration contracts
  • 🔄 User Operations - User loading and creation interface definitions
  • 📋 Type Safe - Full PHP 8.1+ type hints and nullable return types
  • 🎯 Focused - Minimal, focused contracts without implementation details

Installation

composer require tourze/wechat-work-contracts

Quick Start

<?php

use Tourze\WechatWorkContracts\UserInterface;
use Tourze\WechatWorkContracts\CorpInterface;
use Tourze\WechatWorkContracts\AgentInterface;
use Tourze\WechatWorkContracts\UserLoaderInterface;

// Implement the interfaces in your application
class MyWechatUser implements UserInterface
{
    public function getUserId(): ?string
    {
        return $this->userId;
    }

    public function getName(): ?string
    {
        return $this->name;
    }
}

class MyUserLoader implements UserLoaderInterface
{
    public function loadUserByUserIdAndCorp(string $userId, CorpInterface $corp): ?UserInterface
    {
        // Your implementation to load user from WeChat Work API
        return new MyWechatUser($userId);
    }

    public function createUser(CorpInterface $corp, AgentInterface $agent, string $userId, string $name): UserInterface
    {
        // Your implementation to create user
        return new MyWechatUser($userId, $name);
    }
}

Overview

This package provides common contracts and interfaces for WeChat Work (Enterprise WeChat) integration. It defines standard interfaces for:

  • AgentInterface - Application agent management
  • CorpInterface - Enterprise/Corporation information
  • DepartmentInterface - Department management
  • UserInterface - User/Employee information
  • UserLoaderInterface - User loading and creation operations

Interfaces

AgentInterface

Defines methods for WeChat Work application agents:

interface AgentInterface
{
    public function getAgentId(): ?string;
    public function getWelcomeText(): ?string;
}

CorpInterface

Defines methods for enterprise information:

interface CorpInterface
{
    public function getCorpId(): ?string;
}

DepartmentInterface

Defines methods for department management:

interface DepartmentInterface
{
    public function getId(): ?int;
    public function getName(): string;
}

UserInterface

Defines methods for user/employee information:

interface UserInterface
{
    public function getUserId(): ?string;
    public function getName(): ?string;
}

UserLoaderInterface

Defines methods for user loading and creation:

interface UserLoaderInterface
{
    public function loadUserByUserIdAndCorp(string $userId, CorpInterface $corp): ?UserInterface;
    public function createUser(CorpInterface $corp, AgentInterface $agent, string $userId, string $name): UserInterface;
}

Usage

These interfaces are meant to be implemented by concrete classes in your WeChat Work integration packages. They provide a standardized way to work with WeChat Work entities across different implementations.

Requirements

  • PHP 8.1 or higher

License

MIT License

Reference Documentation

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-03