fxiaoke

package module
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2021 License: MIT Imports: 10 Imported by: 0

README

Fxiaoke OpenAPI SDK

Unofficial Go SDK for the fxiaoke.com OpenAPI

Install

go get -u github.com/k8scat/fxiaoke

Quick start

package main

import (
    "fmt"

    "github.com/k8scat/fxiaoke"
)

func main() {
    appID := ""
    appSecret := ""
    permanentCode := ""
    userID := ""
    corpID := ""
    client, err := fxiaoke.NewClient(appID, appSecret, permanentCode, userID, corpID)
    if err != nil {
        panic(err)
    }

    user, err := client.GetUserByOpenID(userID)
    if err != nil {
        panic(err)
    }
    fmt.Printf("%+v", user)
}

Documentation

Index

Constants

View Source
const (
	BaseURL = "https://open.fxiaoke.com"

	EndpointGetToken = "/cgi/corpAccessToken/get/V2"
)
View Source
const (
	ObjTypePackage = "package" // 预设对象
	ObjTypeCustom  = "custom"  // 自定义对象

	FieldAPINameName             = "name"
	FieldAPINameOwner            = "owner"
	FieldAPINameCreateTime       = "create_time"
	FieldAPINameCreatedBy        = "created_by"
	FieldAPINameLastModifiedTime = "last_modified_time"
	FieldAPINameLastModifiedBy   = "last_modified_by"
	FieldAPINameRecordType       = "record_type" // 业务类型
	FieldAPINameLifeStatus       = "life_status" // 生命状态

	FilterOperatorEQ         = "EQ"
	FilterOperatorLT         = "LT"
	FilterOperatorLTE        = "LTE"
	FilterOperatorLike       = "LIKE"
	FilterOperatorIs         = "IS"
	FilterOperatorIn         = "IN"
	FilterOperatorBetween    = "BETWEEN"
	FilterOperatorStartWith  = "STARTWITH"
	FilterOperatorContains   = "CONTAINS"
	FilterOperatorGT         = "GT"
	FilterOperatorGTE        = "GTE"
	FilterOperatorNotEqual   = "N" // Not equal
	FilterOperatorNotLike    = "NLIKE"
	FilterOperatorIsNot      = "ISN"
	FilterOperatorNotIn      = "NIN"
	FilterOperatorNotBetween = "NBETWEEN"
	FilterOperatorEndWith    = "ENDWITH"

	ActionQuery       = "query"
	ActionGet         = "get"
	ActionInvalid     = "invalid"
	ActionChangeOwner = "changeOwner"
	ActionUpdate      = "update"
	ActionCreate      = "create"
	ActionDelete      = "delete"

	ParamTriggerWorkFlow     = "triggerWorkFlow"     // 触发工作流
	ParamTriggerApprovalFlow = "triggerApprovalFlow" // 触发审批流
)

Variables

This section is empty.

Functions

func GetEndpoint added in v0.0.7

func GetEndpoint(objType, action string) (string, error)

Types

type BackOffClient

type BackOffClient struct {
	// contains filtered or unexported fields
}

func (*BackOffClient) Do

func (b *BackOffClient) Do(req *http.Request) (*http.Response, error)

type ChangeOwnerData

type ChangeOwnerData struct {
	OwnerID []string `json:"ownerId"`
	ObjID   string   `json:"objectDataId"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(appID, appSecret, permanentCode, userID, corpID string) (*Client, error)

func (*Client) ChangeOwner

func (c *Client) ChangeOwner(objType, objAPIName string, data []*ChangeOwnerData) error

func (*Client) CreateObj

func (c *Client) CreateObj(objType string, obj interface{}, params map[string]interface{}) (string, error)

func (*Client) DeleteObjs

func (c *Client) DeleteObjs(objType, objAPIName string, idList []string) error

只能删除已作废的对象 该方法不支持 客户对象 中的 删除公海对象接口:https://open.fxiaoke.com/wiki.html#artiId=1258

func (*Client) DescribeObj

func (c *Client) DescribeObj(objAPIName string, includeDetail bool) (string, error)

func (*Client) GetObjByID

func (c *Client) GetObjByID(objType, objApiName, id string) (obj []byte, err error)

func (*Client) GetUserByOpenID

func (c *Client) GetUserByOpenID(openUserID string) (user *User, err error)

func (*Client) InvalidObj

func (c *Client) InvalidObj(objType, objAPIName, id string) error

作废对象

func (*Client) ListAllObjs

func (c *Client) ListAllObjs(objType, objApiName string, searchQueryInfo *SearchQueryInfo) (allObjs []json.RawMessage, err error)

func (*Client) ListObjs

func (c *Client) ListObjs(objType, objApiName string, searchQueryInfo *SearchQueryInfo, params map[string]interface{}) (objs []json.RawMessage, total int, err error)

func (*Client) ListUsersByDepartmentID

func (c *Client) ListUsersByDepartmentID(departmentID int, fetchChild bool) (users []*User, err error)

func (*Client) Post

func (c *Client) Post(endpoint string, data map[string]interface{}, auth bool) (content string, err error)

func (*Client) RawPost added in v0.0.7

func (c *Client) RawPost(endpoint string, data map[string]interface{}, auth bool) (*http.Response, error)

func (*Client) RefreshAccessToken

func (c *Client) RefreshAccessToken() error

func (*Client) UpdateObj

func (c *Client) UpdateObj(objType string, obj map[string]interface{}, params map[string]interface{}) error

type Object

type Object struct {
	APIName     string                 `json:"api_name"`
	DisplayName string                 `json:"display_name"`
	Fields      map[string]interface{} `json:"fields"`
}

type QueryFilter

type QueryFilter struct {
	Operator    string        `json:"operator"`
	FieldName   string        `json:"field_name"`
	FieldValues []interface{} `json:"field_values"`
}

type QueryOrder

type QueryOrder struct {
	FieldName string `json:"fieldName"`
	ASC       bool   `json:"isAsc"`
}

type QueryResult

type QueryResult struct {
	Total    int               `json:"total"`
	Offset   int               `json:"offset"`
	Limit    int               `json:"limit"`
	DataList []json.RawMessage `json:"dataList"`
}

type SearchQueryInfo

type SearchQueryInfo struct {
	Limit           int            `json:"limit"`
	Offset          int            `json:"offset"`
	Filters         []*QueryFilter `json:"filters"`
	FieldProjection []string       `json:"fieldProjection"`
	Orders          []*QueryOrder  `json:"orders"`
}

type User

type User struct {
	OpenUserID    string `json:"openUserId"`
	Name          string `json:"name"`
	NickName      string `json:"nickName"`
	LeaderID      string `json:"leaderId"`
	Position      string `json:"position"`
	Email         string `json:"email"`
	DepartmentIDs []int  `json:"departmentIds"`
	Mobile        string `json:"mobile"`
	CreateTime    int64  `json:"createTime"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL