Documentation ¶
Index ¶
- Constants
- Variables
- type HTTPClient
- type LoginResponse
- type LoginResponseUser
- type LoginResponseUserExpiresTime
- type OnPremisesClient
- type ResolvedSendAuthenticationOTPOptions
- type SendAuthenticationOTPOptions
- type SendTemplateError
- type SendTemplateErrorResponse
- 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, NewHTTPClient, 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 HTTPClient ¶
func NewHTTPClient ¶
func NewHTTPClient() HTTPClient
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 HTTPClient Endpoint *url.URL Credentials *config.WhatsappOnPremisesCredentials TokenStore *TokenStore }
func NewWhatsappOnPremisesClient ¶
func NewWhatsappOnPremisesClient( cfg *config.WhatsappConfig, credentials *config.WhatsappOnPremisesCredentials, tokenStore *TokenStore, httpClient HTTPClient, ) *OnPremisesClient
func (*OnPremisesClient) GetOTPTemplate ¶
func (c *OnPremisesClient) GetOTPTemplate() *config.WhatsappTemplateConfig
func (*OnPremisesClient) SendTemplate ¶
func (c *OnPremisesClient) SendTemplate( ctx context.Context, to string, templateName string, templateLanguage string, templateComponents []TemplateComponent, namespace string) error
type SendTemplateError ¶
type SendTemplateErrorResponse ¶
type SendTemplateErrorResponse struct {
Errors *[]SendTemplateError `json:"errors,omitempty"`
}
type SendTemplateRequest ¶
type Service ¶
type Service struct { Logger ServiceLogger WhatsappConfig *config.WhatsappConfig LocalizationConfig *config.LocalizationConfig OnPremisesClient *OnPremisesClient }
func (*Service) ResolveSendAuthenticationOTPOptions ¶
func (s *Service) ResolveSendAuthenticationOTPOptions(ctx context.Context, opts *SendAuthenticationOTPOptions) (*ResolvedSendAuthenticationOTPOptions, error)
func (*Service) SendAuthenticationOTP ¶
func (s *Service) SendAuthenticationOTP(ctx context.Context, opts *ResolvedSendAuthenticationOTPOptions) 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 ¶
Click to show internal directories.
Click to hide internal directories.