Documentation ¶
Index ¶
- Constants
- Variables
- type LoginResponse
- type LoginResponseUser
- type LoginResponseUserExpiresTime
- type OnPremisesClient
- type PreparedOTPTemplate
- type SendTemplateError
- type SendTemplateErrorResponse
- type SendTemplateOptions
- type SendTemplateRequest
- type Service
- type ServiceLogger
- type Template
- type TemplateComponent
- type TemplateComponentParameter
- type TemplateComponentParameterType
- type TemplateComponentSubType
- type TemplateComponentType
- type TemplateLanguage
- type TokenStore
- type UserToken
Constants ¶
View Source
const (
LoginResponseUserExpiresTimeLayout = "2006-01-02 15:04:05-07:00"
)
Variables ¶
View Source
var DependencySet = wire.NewSet( NewServiceLogger, NewWhatsappOnPremisesClient, wire.Struct(new(TokenStore), "*"), wire.Struct(new(Service), "*"), )
View Source
var ErrBadRequest = errors.New("whatsapp: bad request")
View Source
var ErrInvalidUser = errors.New("whatsapp: invalid user")
View Source
var ErrNoAvailableClient = errors.New("whatsapp: no available client")
View Source
var ErrUnexpectedLoginResponse = errors.New("whatsapp: unexpected login response body")
Functions ¶
This section is empty.
Types ¶
type LoginResponse ¶
type LoginResponse struct {
Users []LoginResponseUser `json:"users"`
}
type LoginResponseUser ¶
type LoginResponseUser struct { Token string `json:"token"` ExpiresAfter LoginResponseUserExpiresTime `json:"expires_after"` }
type LoginResponseUserExpiresTime ¶
func (LoginResponseUserExpiresTime) MarshalText ¶
func (j LoginResponseUserExpiresTime) MarshalText() ([]byte, error)
func (*LoginResponseUserExpiresTime) UnmarshalText ¶
func (j *LoginResponseUserExpiresTime) UnmarshalText(textb []byte) error
Implement Marshaler and Unmarshaler interface
type OnPremisesClient ¶
type OnPremisesClient struct { HTTPClient *http.Client Endpoint *url.URL Credentials *config.WhatsappOnPremisesCredentials TokenStore *TokenStore }
func NewWhatsappOnPremisesClient ¶
func NewWhatsappOnPremisesClient( cfg *config.WhatsappConfig, credentials *config.WhatsappOnPremisesCredentials, tokenStore *TokenStore) *OnPremisesClient
func (*OnPremisesClient) GetOTPTemplate ¶
func (c *OnPremisesClient) GetOTPTemplate() *config.WhatsappTemplateConfig
func (*OnPremisesClient) SendTemplate ¶
func (c *OnPremisesClient) SendTemplate( to string, templateName string, templateLanguage string, templateComponents []TemplateComponent, namespace string) error
type PreparedOTPTemplate ¶
type PreparedOTPTemplate struct { TemplateName string TemplateType string Language string Components []TemplateComponent Namespace string }
type SendTemplateError ¶
type SendTemplateErrorResponse ¶
type SendTemplateErrorResponse struct {
Errors *[]SendTemplateError `json:"errors,omitempty"`
}
type SendTemplateOptions ¶
type SendTemplateRequest ¶
type Service ¶
type Service struct { Context context.Context Logger ServiceLogger DevMode config.DevMode FeatureTestModeWhatsappSuppressed config.FeatureTestModeWhatsappSuppressed TestModeWhatsappConfig *config.TestModeWhatsappConfig WhatsappConfig *config.WhatsappConfig LocalizationConfig *config.LocalizationConfig OnPremisesClient *OnPremisesClient TokenStore *TokenStore }
func (*Service) PrepareOTPTemplate ¶
func (*Service) ResolveOTPTemplateLanguage ¶
func (*Service) SendTemplate ¶
func (s *Service) SendTemplate(opts *SendTemplateOptions) error
type ServiceLogger ¶
func NewServiceLogger ¶
func NewServiceLogger(lf *log.Factory) ServiceLogger
type Template ¶
type Template struct { Name string `json:"name"` Language *TemplateLanguage `json:"language"` Components []TemplateComponent `json:"components"` Namespace *string `json:"namespace,omitempty"` }
type TemplateComponent ¶
type TemplateComponent struct { Type TemplateComponentType `json:"type"` SubType *TemplateComponentSubType `json:"sub_type,omitempty"` Index *int `json:"index,omitempty"` Parameters []TemplateComponentParameter `json:"parameters"` }
func NewTemplateButtonComponent ¶
func NewTemplateButtonComponent(subtyp TemplateComponentSubType, index int) *TemplateComponent
func NewTemplateComponent ¶
func NewTemplateComponent(typ TemplateComponentType) *TemplateComponent
type TemplateComponentParameter ¶
type TemplateComponentParameter struct { Type TemplateComponentParameterType `json:"type"` Text string `json:"text"` }
func NewTemplateComponentTextParameter ¶
func NewTemplateComponentTextParameter(text string) *TemplateComponentParameter
type TemplateComponentParameterType ¶
type TemplateComponentParameterType string
const (
TemplateComponentParameterTypeText TemplateComponentParameterType = "text"
)
type TemplateComponentSubType ¶
type TemplateComponentSubType string
const (
TemplateComponentSubTypeURL TemplateComponentSubType = "url"
)
type TemplateComponentType ¶
type TemplateComponentType string
const ( TemplateComponentTypeHeader TemplateComponentType = "header" TemplateComponentTypeBody TemplateComponentType = "body" TemplateComponentTypeButton TemplateComponentType = "button" )
type TemplateLanguage ¶
type TokenStore ¶
func (*TokenStore) Get ¶
func (s *TokenStore) Get(endpoint string, username string) (*UserToken, error)
func (*TokenStore) Set ¶
func (s *TokenStore) Set(token *UserToken) error
Click to show internal directories.
Click to hide internal directories.