tourze/wechat-work-contracts

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

Installs: 1 077

Dependents: 16

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/tourze/wechat-work-contracts

0.0.5 2025-06-03 13:07 UTC

This package is auto-updated.

Last update: 2025-10-31 07:56:22 UTC


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