Documentation
¶
Index ¶
- Variables
- type APIErrorResponse
- type APIResponse
- type AuthServerImpl
- type BulkSMSResponse
- type CommsLib
- func (l CommsLib) ActivateSubscription(ctx context.Context, offer string, msisdn string, activate bool) (bool, error)
- func (l CommsLib) GetSubscriptions(ctx context.Context, queryParams map[string]string) ([]*Subscription, error)
- func (l CommsLib) SendBulkSMS(ctx context.Context, message string, recipients []string, senderID string) (*BulkSMSResponse, error)
- func (l CommsLib) SendPremiumSMS(ctx context.Context, message, msisdn, subscription string) (*PremiumSMSResponse, error)
- type ErrorMessage
- type ErrorResponse
- type PremiumSMSResponse
- type ResultsResponse
- type Status
- type Subscription
- type TokenResponse
Constants ¶
This section is empty.
Variables ¶
var ( // BaseURL represents the SIL-Comms base URL BaseURL = serverutils.MustGetEnvVar("SIL_COMMS_BASE_URL") )
Functions ¶
This section is empty.
Types ¶
type APIErrorResponse ¶ added in v0.0.6
type APIErrorResponse struct {
Status string `json:"status"`
Message string `json:"message"`
Data map[string]interface{} `json:"data"`
}
APIErrorResponse is the representation of an error response
type APIResponse ¶
type APIResponse struct {
Status Status `json:"status"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
APIResponse is the base response from sil communications API
type AuthServerImpl ¶ added in v0.0.7
type AuthServerImpl interface {
LoginUser(ctx context.Context, input *authutils.LoginUserPayload) (*authutils.OAUTHResponse, error)
RefreshToken(ctx context.Context, refreshToken string) (*authutils.OAUTHResponse, error)
}
AuthServerImpl defines the methods provided by the auth server library
type BulkSMSResponse ¶
type BulkSMSResponse struct {
GUID string `json:"guid"`
Sender string `json:"sender"`
Message string `json:"message"`
Recipients []string `json:"recipients"`
State string `json:"state"`
SMS []string `json:"sms"`
Created string `json:"created"`
Updated string `json:"updated"`
}
BulkSMSResponse is the data in the API response that is returned after making a request to send bulk sms
type CommsLib ¶
type CommsLib struct {
// contains filtered or unexported fields
}
CommsLib is the SDK implementation for interacting with the sil communications API
func MustNewSILCommsLib ¶ added in v0.0.3
func MustNewSILCommsLib(authServer AuthServerImpl) *CommsLib
MustNewSILCommsLib initializes a new implementation of the SIL Comms SDK
func NewSILCommsLib ¶
func NewSILCommsLib(authServer AuthServerImpl) (*CommsLib, error)
NewSILCommsLib initializes a new implementation of the SIL Comms SDK
func (CommsLib) ActivateSubscription ¶ added in v0.0.5
func (l CommsLib) ActivateSubscription(ctx context.Context, offer string, msisdn string, activate bool) (bool, error)
ActivateSubscription is used activate a subscription to an offer on SILCOMMS. msisdn - phone number to be to activate a subscription to an offer. offer - offercode used to create a subscription. activate - boolean value to determine whether activation should happen on SDP
func (CommsLib) GetSubscriptions ¶ added in v0.0.5
func (l CommsLib) GetSubscriptions(ctx context.Context, queryParams map[string]string) ([]*Subscription, error)
GetSubscriptions fetches subscriptions from SILCOMMs based on provided query params params - query params used to get a subscription to an offer.
func (CommsLib) SendBulkSMS ¶
func (l CommsLib) SendBulkSMS(ctx context.Context, message string, recipients []string, senderID string) (*BulkSMSResponse, error)
SendBulkSMS returns a 202 Accepted synchronous response while the API attempts to send the SMS in the background. An asynchronous call is made to the app's sms_callback URL with a notification that shows the Bulk SMS status. An asynchronous call is made to the app's sms_callback individually for each of the recipients with the SMS status. message - message to be sent via the Bulk SMS recipients - phone number(s) to receive the Bulk SMS
func (CommsLib) SendPremiumSMS ¶ added in v0.0.4
func (l CommsLib) SendPremiumSMS(ctx context.Context, message, msisdn, subscription string) (*PremiumSMSResponse, error)
SendPremiumSMS is used to send a premium SMS using SILCOMMS gateway. message - message to be sent via the premium SMS. msisdn - phone number to receive the premium SMS. subscription - subscription/offer associated with the premium SMS.
type ErrorMessage ¶
type ErrorMessage struct {
Message string `json:"message,omitempty"`
}
ErrorMessage is the message in the ErrorResponse
type ErrorResponse ¶
type ErrorResponse struct {
Detail string `json:"detail,omitempty"`
Code string `json:"code,omitempty"`
Message []ErrorMessage `json:"message,omitempty"`
}
ErrorResponse is the data in the API response when an error is encountered
type PremiumSMSResponse ¶ added in v0.0.4
type PremiumSMSResponse struct {
GUID string `json:"guid"`
Body string `json:"body"`
Msisdn string `json:"msisdn"`
SMSType string `json:"sms_type"`
Gateway string `json:"gateway"`
Carrier string `json:"carrier"`
Subscription string `json:"subscription"`
Direction string `json:"direction"`
State string `json:"state"`
}
PremiumSMSResponse is the response returned after making a request to SILCOMMS to send a premium SMS
type ResultsResponse ¶ added in v0.0.3
type ResultsResponse struct {
Count int `json:"count"`
Next *string `json:"next"`
Previous *string `json:"previous"`
Results []interface{} `json:"results"`
}
ResultsResponse is the base response from a paginated list of results
type Subscription ¶ added in v0.0.5
type Subscription struct {
GUID string `json:"guid"`
Gateway string `json:"gateway"`
Offer string `json:"offer"`
Msisdn string `json:"msisdn"`
LinkID string `json:"link_id"`
ActivationDate string `json:"activation_date"`
DeactivationDate any `json:"deactivation_date"`
DeactivationType string `json:"deactivation_type"`
Sms []any `json:"sms"`
Created string `json:"created"`
Updated string `json:"updated"`
}
Subscription represents the response that is returned when activating a subscription to an offer
type TokenResponse ¶
TokenResponse is the data in the API response when logging in The access token is used as the X-bearer token when making API requests The refresh token is used to obtain a new access token when it expires