amocrm/internal/models/createWebHook.go
2024-04-17 15:21:06 +03:00

73 lines
2.5 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package models
type CreateWebHookReq struct {
ClientID string `json:"client_id"` // id интеграции
ClientSecret string `json:"client_secret"` // Секрет интеграции
GrantType string `json:"grant_type"` // Тип авторизационных данных (для кода авторизации authorization_code)
Code string `json:"code"` // Полученный код авторизации
RedirectUrl string `json:"redirect_uri"` // Redirect URI указанный в настройках интеграции. Должен четко совпадать с тем, что указан в настройках
}
type CreateWebHookResp struct {
TokenType string `json:"token_type"` // Тип токена
ExpiresIn int64 `json:"expires_in"` // ttl в секундах
AccessToken string `json:"access_token"` // Access Token в формате JWT
RefreshToken string `json:"refresh_token"`
}
type UpdateWebHookReq struct {
ClientID string `json:"client_id"` // id интеграции
ClientSecret string `json:"client_secret"` // Секрет интеграции
GrantType string `json:"grant_type"` // Тип авторизационных данных (для кода авторизации authorization_code)
RefreshToken string `json:"refresh_token"` // Refresh токен
RedirectUrl string `json:"redirect_uri"` // Redirect URI указанный в настройках интеграции. Должен четко совпадать с тем, что указан в настройках
}
type WebHookRequest interface {
SetClientID(str string)
SetClientSecret(str string)
GetGrantType() string
SetRedirectURL(str string)
GetToken() string
}
func (req *CreateWebHookReq) SetClientID(str string) {
req.ClientID = str
}
func (req *CreateWebHookReq) SetClientSecret(str string) {
req.ClientSecret = str
}
func (req *CreateWebHookReq) GetGrantType() string {
return req.GrantType
}
func (req *CreateWebHookReq) SetRedirectURL(str string) {
req.RedirectUrl = str
}
func (req *CreateWebHookReq) GetToken() string {
return req.Code
}
func (req *UpdateWebHookReq) SetClientID(str string) {
req.ClientID = str
}
func (req *UpdateWebHookReq) SetClientSecret(str string) {
req.ClientSecret = str
}
func (req *UpdateWebHookReq) GetGrantType() string {
return req.GrantType
}
func (req *UpdateWebHookReq) SetRedirectURL(str string) {
req.RedirectUrl = str
}
func (req *UpdateWebHookReq) GetToken() string {
return req.RefreshToken
}