-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I888ea1515b9767e1beb49512e66c996f3bd2715e
- Loading branch information
tianfengyuan
committed
Nov 12, 2020
1 parent
fe2ba0b
commit f5da8f1
Showing
7 changed files
with
2,097 additions
and
0 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,61 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/larksuite/oapi-sdk-go/api/core/response" | ||
"github.com/larksuite/oapi-sdk-go/core" | ||
"github.com/larksuite/oapi-sdk-go/core/tools" | ||
contact "github.com/larksuite/oapi-sdk-go/service/contact/v3" | ||
) | ||
|
||
var contactService = contact.NewService(conf) | ||
|
||
func main() { | ||
testUserServiceList() | ||
testDepartmentServiceUpdate() | ||
} | ||
func testUserServiceList() { | ||
|
||
coreCtx := core.WarpContext(context.Background()) | ||
reqCall := contactService.Users.List(coreCtx) | ||
reqCall.SetDepartmentIdType("open_id") | ||
reqCall.SetPageSize(20) | ||
reqCall.SetDepartmentIdType("open_department_id") | ||
reqCall.SetDepartmentId("od_XXXXXXXXX") | ||
reqCall.SetUserIdType("open_id") | ||
result, err := reqCall.Do() | ||
fmt.Printf("request_id:%s", coreCtx.GetRequestID()) | ||
fmt.Printf("http status code:%d", coreCtx.GetHTTPStatusCode()) | ||
if err != nil { | ||
e := err.(*response.Error) | ||
fmt.Printf(tools.Prettify(e)) | ||
return | ||
} | ||
fmt.Printf("reault:%s", tools.Prettify(result)) | ||
} | ||
|
||
func testDepartmentServiceUpdate() { | ||
coreCtx := core.WarpContext(context.Background()) | ||
updateBody := &contact.Department{ | ||
Name: "xxxxx", | ||
ParentDepartmentId: "od_xxxxxx", | ||
LeaderUserId: "ou-xxxxxxx", | ||
Order: 666, | ||
CreateGroupChat: false, | ||
} | ||
reqCall := contactService.Departments.Create(coreCtx, updateBody) | ||
reqCall.SetDepartmentIdType("open_department_id") | ||
reqCall.SetUserIdType("open_id") | ||
reqCall.SetClientToken("xxxxxxx") | ||
result, err := reqCall.Do() | ||
fmt.Printf("request_id:%s", coreCtx.GetRequestID()) | ||
fmt.Printf("http status code:%d", coreCtx.GetHTTPStatusCode()) | ||
if err != nil { | ||
e := err.(*response.Error) | ||
fmt.Printf(tools.Prettify(e)) | ||
return | ||
} | ||
fmt.Printf("reault:%s", tools.Prettify(result)) | ||
} |
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,43 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"path" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/larksuite/oapi-sdk-go/core" | ||
"github.com/larksuite/oapi-sdk-go/core/test" | ||
"github.com/larksuite/oapi-sdk-go/core/tools" | ||
eventginserver "github.com/larksuite/oapi-sdk-go/event/http/gin" | ||
contact "github.com/larksuite/oapi-sdk-go/service/contact/v3" | ||
) | ||
|
||
func main() { | ||
|
||
conf := test.GetInternalConf("staging") | ||
|
||
contact.SetDepartmentCreatedEventHandler(conf, func(ctx *core.Context, event *contact.DepartmentCreatedEvent) error { | ||
fmt.Println(ctx.GetRequestID()) | ||
fmt.Println(tools.Prettify(event)) | ||
return nil | ||
}) | ||
|
||
contact.SetUserCreateEventHandler(conf, func(ctx *core.Context, event *contact.UserCreateEvent) error { | ||
fmt.Println(ctx.GetRequestID()) | ||
fmt.Println(tools.Prettify(event)) | ||
return nil | ||
}) | ||
contact.SetDepartmentDeletedEventHandler(conf, func(ctx *core.Context, event *contact.DepartmentDeletedEvent) error { | ||
fmt.Println(ctx.GetRequestID()) | ||
fmt.Println(tools.Prettify(event)) | ||
return nil | ||
}) | ||
|
||
g := gin.Default() | ||
eventginserver.Register(path.Join("/", conf.GetAppSettings().AppID, "webhook/event"), conf, g) | ||
err := g.Run(":8089") | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
} |
Oops, something went wrong.