Skip to content
Bitzsoft.Integrationsbitzsoft.integrations

Reference

Moka HR

Bitzsoft.Integrations.HumanResources.Moka 包参考——HTTP Basic Auth 鉴权、IHumanResourcesService 配置与使用示例。

Last updated

Moka 基于 Moka HR 开放平台 API,实现 IHumanResourcesService 统一接口。

包信息

NuGet 包Bitzsoft.Integrations.HumanResources.Moka
实现接口IHumanResourcesService
Provider IDmoka
鉴权方式HTTP Basic Auth(API Key + Secret)
默认 ApiBaseUrlhttps://api.mokahr.com/api
区域Global

凭据(API Key + Secret)在 Moka 开放平台后台创建应用后获取。

配置字段

字段类型必填默认值说明
ApiBaseUrlstringhttps://api.mokahr.com/apiMoka 开放平台基地址
ApiKeystringAPI Key(Basic Auth 用户名)
ApiSecretstringAPI Secret(Basic Auth 密码)
HttpClientNamestringHumanResourcesMoka业务 HttpClient 命名

配置 JSON 示例

{
"HumanResources": {
"Moka": {
"ApiBaseUrl": "https://api.mokahr.com/api",
"ApiKey": "xxxxxxxxxxxx",
"ApiSecret": "xxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}

DI 注册

// 从配置节注册(默认节名 HumanResources:Moka)
services.AddMokaHumanResources(configuration);
// 或用回调单独配置
services.AddMokaHumanResources(options =>
{
options.ApiKey = "xxxxxxxxxxxx";
options.ApiSecret = "xxxxxxxxxxxxxxxxxxxxxxxx";
});

使用示例

public class EmployeeService
{
private readonly IHumanResourcesService _hr;
public EmployeeService(IHumanResourcesService hr) => _hr = hr;
public Task<HrEmployee> OnboardAsync(string name, string email, string departmentId)
=> _hr.CreateEmployeeAsync(new CreateEmployeeRequest
{
Name = name,
Email = email,
DepartmentId = departmentId
});
public Task<HrResult> OffboardAsync(string employeeId)
=> _hr.DeactivateEmployeeAsync(employeeId);
}

依赖

说明
Bitzsoft.Integrations.HumanResources人力资源服务抽象层
Bitzsoft.Integrations.Core公共基座

已知限制

  • Basic Auth 凭据为长期凭据,请妥善保管。

100%

滚轮或按钮缩放 · 放大后拖动画面 · 双击切换 100% / 200%