Skip to content

Commit

Permalink
disable debag code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nzt3-gh committed Oct 26, 2023
1 parent 8c0016b commit a071658
Showing 1 changed file with 7 additions and 63 deletions.
70 changes: 7 additions & 63 deletions infra/traq/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
//"context"
"context"
// "encoding/json"
"fmt"
// "fmt"
// "net/http"
// "net/url"
// "strconv"
Expand All @@ -17,93 +17,38 @@ import (


func (repo *TraQRepository) GetUser(token *oauth2.Token, userID uuid.UUID) (*traq.User, error) {
// URL := fmt.Sprintf("%s/users/%s", repo.URL, userID)
// req, err := http.NewRequest(http.MethodGet, URL, nil)
// if err != nil {
// return nil, err
// }
// data, err := repo.doRequest(token, req)
// if err != nil {
// return nil, err
// }

// user := new(traq.User)
// err = json.Unmarshal(data, &user)

// return user, err

// ここから go-traq 書き換え

traqconf := traq.NewConfiguration()
conf := TraQDefaultConfig
traqconf.HTTPClient = conf.Client(context.Background(),token)
apiClient := traq.NewAPIClient(traqconf)
userDtail,_,err := apiClient.UserApi.GetUser(context.Background(),userID.String()).Execute()
if err!=nil{
fmt.Println("GetUserError")
// fmt.Println("GetUserError")
return nil,err
}
user := convertUserdetailToUser(userDtail)
fmt.Println("GetUserDetailSuccess")
// fmt.Println("GetUserDetailSuccess")
return user, err

// ここまで go-traq 書き換え
}

func (repo *TraQRepository) GetUsers(token *oauth2.Token, includeSuspended bool) ([]*traq.User, error) {
// URL, err := url.Parse(fmt.Sprintf("%s/users", repo.URL))
// if err != nil {
// return nil, err
// }
// q := URL.Query()
// q.Set("include-suspended", strconv.FormatBool(includeSuspended))
// URL.RawQuery = q.Encode()
// req, err := http.NewRequest(http.MethodGet, URL.String(), nil)
// if err != nil {
// return nil, err
// }
// data, err := repo.doRequest(token, req)
// if err != nil {
// return nil, err
// }

// users := make([]*traq.User, 0)
// err = json.Unmarshal(data, &users)

// return users, err

traqconf := traq.NewConfiguration()
conf := TraQDefaultConfig
traqconf.HTTPClient = conf.Client(context.Background(),token)
apiClient := traq.NewAPIClient(traqconf)
users,_,err := apiClient.UserApi.GetUsers(context.Background()).IncludeSuspended(includeSuspended).Execute()
if err!=nil{
fmt.Println("GetUsersError")
// fmt.Println("GetUsersError")
return nil,err
}
res_users := convertUsersToUsers(users)
fmt.Println("GetUsersSuccess")
fmt.Println(res_users)
// fmt.Println("GetUsersSuccess")
// fmt.Println(res_users)
return res_users, err
}


func (repo *TraQRepository) GetUserMe(token *oauth2.Token) (*traq.User, error) {
// URL := fmt.Sprintf("%s/users/me", repo.URL)
// req, err := http.NewRequest(http.MethodGet, URL, nil)
// if err != nil {
// return nil, err
// }
// data, err := repo.doRequest(token, req)
// if err != nil {
// return nil, err
// }

// user := new(traq.User)
// err = json.Unmarshal(data, &user)
// return user, err

// ここから go-traq 書き換え
traqconf := traq.NewConfiguration()
conf :=TraQDefaultConfig
traqconf.HTTPClient=conf.Client(context.Background(),token)
Expand All @@ -114,9 +59,8 @@ func (repo *TraQRepository) GetUserMe(token *oauth2.Token) (*traq.User, error) {
return nil,err
}
user := convertMyUserdetailToUser(data)
fmt.Println("GetUserMeSuccess")
// fmt.Println("GetUserMeSuccess")
return user, err
// ここまで go-traq 書き換え
}

func convertMyUserdetailToUser (userdetail *traq.MyUserDetail) *traq.User{
Expand Down

0 comments on commit a071658

Please sign in to comment.