custom

package
v0.0.0-...-fa26777 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2025 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomClient

type CustomClient struct {
	Config      *config.CustomSMSProviderConfig
	SMSDenoHook SMSDenoHook
	SMSWebHook  SMSWebHook
}

func (*CustomClient) Send

func (c *CustomClient) Send(ctx context.Context, opts smsapi.SendOptions) error

type DenoHook

type DenoHook interface {
	RunSync(ctx context.Context, client hook.DenoClient, u *url.URL, input interface{}) (out interface{}, err error)
	SupportURL(u *url.URL) bool
}

type HookDenoClient

type HookDenoClient interface {
	Run(ctx context.Context, script string, input interface{}) (out interface{}, err error)
}

func NewHookDenoClient

func NewHookDenoClient(endpoint config.DenoEndpoint, logger hook.Logger, timeout SMSHookTimeout) HookDenoClient

type HookDenoClientImpl

type HookDenoClientImpl struct {
	hook.DenoClient
}

type HookHTTPClient

type HookHTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

func NewHookHTTPClient

func NewHookHTTPClient(timeout SMSHookTimeout) HookHTTPClient

type HookHTTPClientImpl

type HookHTTPClientImpl struct {
	*http.Client
}

type ResponseBody

type ResponseBody struct {
	Code              string `json:"code"`
	ProviderName      string `json:"provider_name,omitempty"`
	ProviderErrorCode string `json:"provider_error_code,omitempty"`
	GoError           string `json:"go_error,omitempty"`
	DumpedResponse    []byte `json:"dumped_response,omitempty"`
}

See https://github.com/authgear/authgear-sms-gateway/blob/main/pkg/handler/api.go

func ParseResponseBody

func ParseResponseBody(jsonData []byte) (*ResponseBody, error)

type SMSDenoHook

type SMSDenoHook struct {
	DenoHook
	Client HookDenoClient
}

func NewSMSDenoHookForTest

func NewSMSDenoHookForTest(lf *log.Factory, denoEndpoint config.DenoEndpoint, smsCfg *config.CustomSMSProviderConfig) *SMSDenoHook

func (*SMSDenoHook) Call

func (d *SMSDenoHook) Call(ctx context.Context, u *url.URL, payload SendOptions) error

func (*SMSDenoHook) Test

func (d *SMSDenoHook) Test(ctx context.Context, script string, payload SendOptions) error

type SMSHookTimeout

type SMSHookTimeout struct {
	Timeout time.Duration
}

func NewSMSHookTimeout

func NewSMSHookTimeout(smsCfg *config.CustomSMSProviderConfig) SMSHookTimeout

type SMSWebHook

type SMSWebHook struct {
	hook.WebHook
	Client HookHTTPClient
}

func NewSMSWebHook

func NewSMSWebHook(hook hook.WebHook, smsCfg *config.CustomSMSProviderConfig) *SMSWebHook

func (*SMSWebHook) Call

func (w *SMSWebHook) Call(ctx context.Context, u *url.URL, payload SendOptions) error

type SendOptions

type SendOptions struct {
	To                string                    `json:"to"`
	Body              string                    `json:"body"`
	AppID             string                    `json:"app_id"`
	TemplateName      string                    `json:"template_name"`
	LanguageTag       string                    `json:"language_tag"`
	TemplateVariables *smsapi.TemplateVariables `json:"template_variables"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL