Documentation ¶
Index ¶
- Variables
- type API
- func (a *API) AuthorizeCode(code string) (ou *OAuth2UserInfo, err error)
- func (a *API) CorpID() string
- func (a *API) GetTaskStatus(taskID string) (res []DeptRespItem, err error)
- func (a *API) GetUser(uid string, at CType) (*User, error)
- func (a *API) GetsDepartments(ids []string) (data Departments, err error)
- func (a *API) ListContactScope() (ContactScoper, error)
- func (a *API) ListDepartment(recursive bool, id string) (data Departments, err error)
- func (a *API) ListUser(lr ListReq) (res ListResult, err error)
- func (a *API) SyncDepartment(data []DepartmentUp) (res []DeptRespItem, err error)
- func (a *API) SyncUser(user UserUp) error
- type AuthContactResponse
- type CType
- type CallbackReq
- type CallbackResp
- type ContactScoper
- type Decrypter
- type Department
- type DepartmentUp
- type Departments
- type DeptRespItem
- type EType
- type EncryptEntry
- type Error
- type Event
- type EventCallback
- type EventCallbackForDepartment
- type EventCallbackForUser
- type EventCallbackForUserStatus
- type IClient
- type ListReq
- type ListResult
- type OAuth2UserInfo
- type OAuth2UserResp
- type Status
- type User
- type UserUp
- type Users
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API ...
func (*API) AuthorizeCode ¶
func (a *API) AuthorizeCode(code string) (ou *OAuth2UserInfo, err error)
AuthorizeCode ...
func (*API) GetTaskStatus ¶
func (a *API) GetTaskStatus(taskID string) (res []DeptRespItem, err error)
GetTaskStatus ...
func (*API) GetsDepartments ¶
func (a *API) GetsDepartments(ids []string) (data Departments, err error)
GetsDepartments ...
func (*API) ListContactScope ¶
func (a *API) ListContactScope() (ContactScoper, error)
func (*API) ListDepartment ¶
func (a *API) ListDepartment(recursive bool, id string) (data Departments, err error)
ListDepartment child Department ...
func (*API) SyncDepartment ¶
func (a *API) SyncDepartment(data []DepartmentUp) (res []DeptRespItem, err error)
SyncDepartment ...
type AuthContactResponse ¶
type AuthContactResponse struct { client.Error Data struct { AuthedDepartments []string `json:"authed_departments"` AuthedEmployeeIDs []string `json:"authed_employee_ids"` AuthedOpenIDs []string `json:"authed_open_ids"` } `json:"data"` }
func (*AuthContactResponse) GetDepartments ¶
func (acr *AuthContactResponse) GetDepartments() []string
func (*AuthContactResponse) GetEmployeeIDs ¶
func (acr *AuthContactResponse) GetEmployeeIDs() []string
func (*AuthContactResponse) GetOpenIDs ¶
func (acr *AuthContactResponse) GetOpenIDs() []string
type CallbackReq ¶
type CallbackReq struct { Challenge string `json:"challenge"` Token string `json:"token"` Type string `json:"type"` }
CallbackReq ...
{ "challenge": "ajls384kdjx98XX", // 应用需要原样返回的值 "token": "xxxxxx", // 约定的校验Token "type": "url_verification" // 表示这是一个验证请求 }
func UnmarsalCallback ¶
func UnmarsalCallback(s string) (cr *CallbackReq, err error)
UnmarsalCallback ...
type CallbackResp ¶
type CallbackResp struct {
Challenge string `json:"challenge"`
}
CallbackResp ...
type ContactScoper ¶
type ContactScoper interface { GetDepartments() []string GetEmployeeIDs() []string GetOpenIDs() []string }
ContactScoper ...
type Department ¶
type Department struct { ID string `json:"id"` ParentID string `json:"parent_id"` Name string `json:"name"` NameEN string `json:"name_en,omitempty"` ChatID string `json:"chat_id"` LeaderEmployeeID string `json:"leader_employee_id,omitempty"` LeaderOpenID string `json:"leader_open_id,omitempty"` Status int `json:"status,omitempty"` MemberCount int `json:"member_count,omitempty"` }
Department 部门
"department_info": { "id":"od-c042a4980ba8e1466050e3e8da2378fe", "leader_employee_id":"612a67ef", "leader_open_id":"ou_05065996251935ada9c2b0ecc50be91e", "chat_id": "oc_405333f8fc89c3262865b014ccbbb274", "member_count": 79, "name": "市场部", "parent_id": "0", "status": 1 }
type DepartmentUp ¶
type Departments ¶
type Departments []Department
func (Departments) WithID ¶
func (z Departments) WithID(id string) *Department
type DeptRespItem ¶
type DeptRespItem struct {
TaskID []string `json:"task_id"`
}
type EncryptEntry ¶
type EncryptEntry struct {
EncryptedBody string `json:"encrypt"`
}
EncryptEntry ...
type Event ¶
type Event struct { Type string `json:"type"` APPID string `json:"app_id,omitempty"` TenantKey string `json:"tenant_key,omitempty"` }
Event ...
type EventCallback ¶
type EventCallback struct { UUID string `json:"uuid"` Token string `json:"token"` Stamp int64 `json:"ts"` Type string `json:"type"` Event json.RawMessage `json:"event"` }
EventCallback ...
{ "uuid":"c4ca4238a0b923820dcc509a6f75849b", "token": "41a9425ea7df4536a7623e38fa321bae", //校验Token "ts": "1502199207.7171419", //时间戳 "type": "event_callback", //事件回调此处固定为event_callback "event": json }
type EventCallbackForDepartment ¶
type EventCallbackForDepartment struct { Type string `json:"type"` APPID string `json:"app_id"` TenantKey string `json:"tenant_key"` OpenDepartmentID string `json:"open_department_id"` }
EventCallbackForDepartment 通讯录部门相关变更 { "type": "dept_add", //事件类型,包括 dept_add,dept_update,dept_delete "app_id": "cli_xxx", "tenant_key": "xxx", //企业标识 "open_department_id":"od-xxx" //部门的Id }
type EventCallbackForUser ¶
type EventCallbackForUser struct { Type string `json:"type"` APPID string `json:"app_id"` TenantKey string `json:"tenant_key"` OpenID string `json:"open_id"` EmployeeID string `json:"employee_id"` }
EventCallbackForUser 通讯录用户相关变更 { "type": "user_add", //事件类型,包括user_add,user_update,user_leave "app_id": "cli_xxx", "tenant_key": "xxx", //企业标识 "open_id":"xxx" , "employee_id":"xxx" //企业自建应用返回 }
type EventCallbackForUserStatus ¶
type EventCallbackForUserStatus struct { EventCallbackForUser BeforeStatus struct { IsActive bool `json:"is_active"` IsFrozen bool `json:"is_frozen"` IsLeaved bool `json:"is_resigned"` } `json:"before_status"` ChangedStatus struct { IsActive bool `json:"is_active"` IsFrozen bool `json:"is_frozen"` IsLeaved bool `json:"is_resigned"` } `json:"current_status"` ChangeTime string `json:"change_time"` }
EventCallbackForUserStatus 用户状态变更 { "app_id": "cli_9c8609450f78d102", "before_status": { "is_active": false, // 账号是否已激活 "is_frozen": false, // 账号是否冻结 "is_resigned": false // 是否离职 }, "change_time": "2020-02-21 16:28:48", "current_status": { "is_active": true, "is_frozen": false, "is_resigned": false }, "employee_id": "ca51d83b", "open_id": "ou_2d2c0399b53d06fd195bb393cd1e38f2", "tenant_key": "xxx", "type": "user_status_change" }
type IClient ¶
type IClient interface { ListDepartment(recursive bool, id string) (data Departments, err error) ListUser(r ListReq) (res ListResult, err error) ListContactScope() (ContactScoper, error) SyncDepartment(data []DepartmentUp) (res []DeptRespItem, err error) SyncUser(user UserUp) error }
IClient ... interface of API client
type ListReq ¶
type ListReq struct { DeptID string `json:"deptID,omitempty"` Limit int `json:"limit"` PageToken string `json:"pageToken,omitempty"` IncChild bool `json:"incChild"` OpenIDs []string `json:"openIDs"` IsSimple bool `json:"isSimple,omitempty"` }
ListReq ...
type ListResult ¶
ListResult ...
type OAuth2UserInfo ¶
type OAuth2UserInfo struct { AccessToken string `json:"access_token,omitempty"` AvatarURI string `json:"avatar_url,omitempty"` ExpiresIn int64 `json:"expires_in,omitempty"` Name string `json:"name,omitempty"` NameEn string `json:"en_name,omitempty"` OpenID string `json:"open_id,omitempty"` TenantKey string `json:"tenant_key,omitempty"` RefreshExpiresIn int64 `json:"refresh_expires_in,omitempty"` RefreshToken string `json:"refresh_token,omitempty"` TokenType string `json:"token_type,omitempty"` }
OAuth2UserInfo 为用户 OAuth2 验证登录后的简单信息
type OAuth2UserResp ¶
type OAuth2UserResp struct { client.Error User *OAuth2UserInfo `json:"data,omitempty"` }
OAuth2UserResp ...
type User ¶
type User struct { Name string `json:"name"` // 用户名 NameEN string `json:"en_name,omitempty"` // 英文名 NamePY string `json:"name_py,omitempty"` // 用户名拼音 EmployeeID string `json:"employee_id"` // 用户的 employee_id,申请了"获取用户 user_id"权限后返回 EmployeeNo string `json:"employee_no,omitempty"` // 工号 EmployeeType EType `json:"employee_type,omitempty"` // 员工类型。1:正式员工;2:实习生;3:外包;4:劳务;5:顾问 AvatarURI string `json:"avatar_url,omitempty"` // 头像,原始大小 OpenID string `json:"open_id,omitempty"` // 用户的 open_id UnionID string `json:"union_id,omitempty"` // 用户的 union_id,申请了"获取用户统一ID"权限后返回 Mobile string `json:"mobile,omitempty"` // required Email string `json:"email,omitempty"` // required Gender gender.Gender `json:"gender,omitempty"` // 性别 Status Status `json:"userStatus,omitempty"` // 用户状态,bit0(最低位): 1冻结,0未冻结;bit1:1离职,0在职;bit2:1未激活,0已激活 Description string `json:"description,emitempty"` // 用户个人签名 Country string `json:"country,omitempty"` // 用户所在国家 City string `json:"city,omitempty"` // 用户所在城市 WorkStation string `json:"work_station,omitempty"` // 工位 JoinedStamp int64 `json:"join_time,omitempty"` // 入职时间 UpdatedStamp int64 `json:"update_time,omitempty"` // 更新时间 LeaderEmployeeID string `json:"leader_employee_id,omitempty"` LeaderOpenID string `json:"leader_open_id,omitempty"` Departments []string `json:"departments,omitempty"` // 所在部门,用户可能同时存在于多个部门 CustomAttrs map[string]interface{} `json:"custom_attrs,omitempty"` }
User 用户 "name":"zhang san", "name_py":"zhang san", "en_name":"John", "employee_id":"a0615a67", "employee_no":"235634", "open_id":"ou_e03053f0541cecc3269d7a9dc34a0b21", "status":2, "employee_type": 1, "avatar_72": "https://sf3-ttcdn-tos.pstatp.com/img/avatar/62db96e8-c5b6-4077-bb9d-2697d65a29eb~72x72.png", "avatar_240": "https://sf3-ttcdn-tos.pstatp.com/img/avatar/62db96e8-c5b6-4077-bb9d-2697d65a29eb~240x240.png", "avatar_640": "https://sf3-ttcdn-tos.pstatp.com/img/avatar/62db96e8-c5b6-4077-bb9d-2697d65a29eb~640x640.png", "avatar_url": "https://sf3-ttcdn-tos.pstatp.com/img/avatar/62db96e8-c5b6-4077-bb9d-2697d65a29eb~noop.png", "gender":1, "email":"zhangsan@gmail.com", "mobile":"+8615343215730", "description": "", "country": "CN", "city":"Beijing", "work_station":"Poly, F6-123", "is_tenant_manager":false, "join_time":1562342314, "update_time":1569140032, "leader_employee_id":"a0615a67", "leader_open_id":"ou_e03053f0541cecc3269d7a9dc34a0b21", "departments":[
"od-8c6c97ab9a34c1a649001d7ad36b97a7"
],
"custom_attrs": { "C-6702376000044400907": { "value": "value1" }, "C-6702376000048595214": { "value": "value2" } }