-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Init user api * Add first method * Add ClientTokenSource interface as an abstract layer of api token provider * Add request interface * Fix readme * fix token url * fix oauth * fix interface * fix tokensource
- Loading branch information
Showing
12 changed files
with
258 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package contact | ||
|
||
const ( | ||
DepartmentIdTypeDepartmentId = "department_id" | ||
DepartmentIdTypeOpenDepartmentId = "open_department_id" | ||
) | ||
|
||
type DepartmentI18nName struct { | ||
ZhCn string `json:"zh_cn"` | ||
EnUs string `json:"en_us"` | ||
JaJp string `json:"ja_jp"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,45 @@ | ||
package contact | ||
|
||
type UserIdType string | ||
import ( | ||
"github.com/creasty/defaults" | ||
"github.com/joyqi/go-feishu/api" | ||
"github.com/joyqi/go-feishu/httptool" | ||
"net/http" | ||
) | ||
|
||
const ( | ||
UserIdTypeUserId UserIdType = "user_id" | ||
UserIdTypeOpenId = "open_id" | ||
UserIdTypeUnionId = "union_id" | ||
UserCreateURL = "https://open.feishu.cn/open-apis/contact/v3/users" | ||
) | ||
|
||
const ( | ||
UserIdTypeUserId = "user_id" | ||
UserIdTypeOpenId = "open_id" | ||
UserIdTypeUnionId = "union_id" | ||
) | ||
|
||
type UserCreateParams struct { | ||
UserIdType string `url:"user_id_type" default:"open_id"` | ||
DepartmentIdType string `url:"department_id_type" default:"department_id"` | ||
ClientToken string `url:"client_token"` | ||
} | ||
|
||
type UserCreateBody struct { | ||
Name string `json:"name"` | ||
I18nName DepartmentI18nName `json:"i18n_name"` | ||
} | ||
|
||
type UserCreateData struct { | ||
} | ||
|
||
type User api.Api | ||
|
||
// Create creates a user by given UserCreateParams and UserCreateBody. | ||
// See https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/user/create for more details. | ||
func (u *User) Create(params *UserCreateParams, body *UserCreateBody) (*UserCreateData, error) { | ||
if err := defaults.Set(¶ms); err != nil { | ||
return nil, err | ||
} | ||
|
||
url := httptool.MakeStructureURL(UserCreateURL, params) | ||
return api.MakeApi[UserCreateData](u.Client, http.MethodPost, url, body) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.