Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

traQへのリクエストにgo-traqを使う #439

Closed
ras0q opened this issue Jul 24, 2023 · 3 comments · Fixed by #515
Closed

traQへのリクエストにgo-traqを使う #439

ras0q opened this issue Jul 24, 2023 · 3 comments · Fixed by #515
Assignees

Comments

@ras0q
Copy link
Member

ras0q commented Jul 24, 2023

↓みたいなのを全部go-traqに変える

knoQ/infra/traq/user.go

Lines 15 to 29 in cb9fc32

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
}

@ras0q ras0q changed the title traQへのリクエスト traQへのリクエストにgo-traqを使う Jul 24, 2023
@ras0q
Copy link
Member Author

ras0q commented Jul 24, 2023

OAuth2トークンを使ったAPIClientの作成は↓でできる

	traqconf := traq.NewConfiguration()
	traqconf.HTTPClient = conf.Client(c.Request().Context(), tok)
	client := traq.NewAPIClient(traqconf)

https://github.com/ras0q/traq-oauth2/blob/b35ef45bb5d52aab749b863582b4b0a3c4e2dfd7/example/webapp-with-library/main.go#L126-L128

@Nzt3-gh Nzt3-gh self-assigned this Aug 28, 2023
@Nzt3-gh
Copy link
Contributor

Nzt3-gh commented Aug 28, 2023

@ras0q
Copy link
Member Author

ras0q commented Sep 2, 2023

もう少しわかりやすい名前にすれば良かったと思ってるけどwebhookは https://github.com/ras0q/traq-writer とかがあるので記述減らしたい&デバッグ環境でtraQに通知飛ばしたくないときは参考にしてください

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants