Documentation
¶
Index ¶
- Constants
- Variables
- func Bool(b bool) *bool
- func Float32(f float32) *float32
- func Float64(f float64) *float64
- func Int(i int) *int
- func Int64(i int64) *int64
- func Pointer[T any](v T) *T
- func String(s string) *string
- type Accounts
- type Client
- type Common
- type HTTPClient
- type Incoming
- type Mms
- type Outgoing
- func (s *Outgoing) CancelScheduled(ctx context.Context, ids []int64, opts ...operations.Option) (*operations.CancelMessagesResponse, error)
- func (s *Outgoing) GetByIds(ctx context.Context, ids []int64, opts ...operations.Option) (*operations.GetMessagesResponse, error)
- func (s *Outgoing) List(ctx context.Context, page *int64, limit *int64, opts ...operations.Option) (*operations.ListMessagesResponse, error)
- type SDKOption
- func WithClient(client HTTPClient) SDKOption
- func WithRetryConfig(retryConfig retry.Config) SDKOption
- func WithSecurity(bearer string) SDKOption
- func WithSecuritySource(security func(context.Context) (components.Security, error)) SDKOption
- func WithServer(server string) SDKOption
- func WithServerURL(serverURL string) SDKOption
- func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption
- func WithTimeout(timeout time.Duration) SDKOption
- type Senders
- func (s *Senders) Add(ctx context.Context, request components.SenderInput, opts ...operations.Option) (*operations.AddSenderResponse, error)
- func (s *Senders) Delete(ctx context.Context, sender string, opts ...operations.Option) (*operations.DeleteSenderResponse, error)
- func (s *Senders) List(ctx context.Context, opts ...operations.Option) (*operations.ListSendersResponse, error)
- func (s *Senders) SetDefault(ctx context.Context, sender string, opts ...operations.Option) (*operations.SetDefaultSenderResponse, error)
- type Sms
Constants ¶
const ( // Production system ServerProd string = "prod" // Test system (SANDBOX) ServerSandbox string = "sandbox" )
Variables ¶
var ServerList = map[string]string{ ServerProd: "https://api.gsmservice.pl/rest", ServerSandbox: "https://api.gsmservice.pl/rest-sandbox", }
ServerList contains the list of servers available to the SDK
Functions ¶
Types ¶
type Accounts ¶
type Accounts struct {
// contains filtered or unexported fields
}
func (*Accounts) Get ¶
func (s *Accounts) Get(ctx context.Context, opts ...operations.Option) (*operations.GetAccountDetailsResponse, error)
Get account details Get current account balance and other details of your account. You can check also account limit and if account is main one. Main accounts have unlimited privileges and using [User Panel](https://panel.gsmservice.pl) you can create as many subaccounts as you need.
As a successful result a details of current account you are logged in using an API Access Token will be returned.
func (*Accounts) GetSubaccount ¶
func (s *Accounts) GetSubaccount(ctx context.Context, userLogin string, opts ...operations.Option) (*operations.GetSubaccountDetailsResponse, error)
GetSubaccount - Get subaccount details Check account balance and other details such subcredit balance of a subaccount. Subaccounts are additional users who can access your account services and the details. You can restrict access level and setup privileges to subaccounts using [User Panel](https://panel.gsmservice.pl).
This method accepts a `string` type parameter with user login. You should pass there the full subaccount login to access its data.
As a successful result the details of subaccount with provided login will be returned.
type Client ¶
type Client struct { Accounts *Accounts Outgoing *Outgoing Incoming *Incoming Common *Common Senders *Senders // contains filtered or unexported fields }
Client - Messaging Gateway GSMService.pl: This package includes Messaging SDK for GO to send SMS and MMS messages directly from your app via [https://bramka.gsmservice.pl](https://bramka.gsmservice.pl) messaging platform.
To initialize SDK environment please use this syntax:
``` import (
messagingsdkgo "github.com/gsmservice-pl/messaging-sdk-go" "os"
)
s := messagingsdkgo.New(
messagingsdkgo.WithSecurity(os.Getenv("GATEWAY_API_BEARER")),
) ```
If you want to use a Sandbox test system please initialize it as follows:
``` s := messagingsdkgo.New(
messagingsdkgo.WithSecurity(os.Getenv("GATEWAY_API_BEARER")), messagingsdkgo.WithServer(messagingsdkgo.ServerSandbox),
) ```
https://bramka.gsmservice.pl - Bramka GSMService.pl
type Common ¶
type Common struct {
// contains filtered or unexported fields
}
func (*Common) Ping ¶
func (s *Common) Ping(ctx context.Context, opts ...operations.Option) (*operations.PingResponse, error)
Ping - Checks API availability and version Check the API connection and the current API availability status. Also you will get the current API version number.
As a successful result a `PingResponse` object will be returned.
type HTTPClient ¶
HTTPClient provides an interface for suplying the SDK with a custom HTTP client
type Incoming ¶
type Incoming struct {
// contains filtered or unexported fields
}
func (*Incoming) GetByIds ¶
func (s *Incoming) GetByIds(ctx context.Context, ids []int64, opts ...operations.Option) (*operations.GetIncomingMessagesResponse, error)
GetByIds - Get the incoming messages by IDs Get the details of one or more received messages using their `ids`. This method accepts an array of type `[]int64` containing unique incoming message *IDs*, which were given while receiving a messages. The method will accept maximum 50 identifiers in one call.
As a successful result a `GetIncomingMessagesResponse` object will be returned with an `IncomingMessages` property of type `[]IncomingMessage` containing `IncomingMessage` objects, each object per single received message.
`GetIncomingMessagesResponse` object will contain also a `Headers` property where you can find `X-Success-Count` (a count of incoming messages which were found and returned correctly) and `X-Error-Count` (count of incoming messages which were not found) elements.
func (*Incoming) List ¶
func (s *Incoming) List(ctx context.Context, page *int64, limit *int64, opts ...operations.Option) (*operations.ListIncomingMessagesResponse, error)
List the received SMS messages Get the details of all received messages from your account incoming messages box. This method supports pagination so you have to pass `page` (number of page with received messages which you want to access) and a `limit` (max of received messages per page) parameters. Messages are fetched from the latest one. This method will accept maximum **50** as `limit` parameter value.
As a successful result a `ListIncomingMessagesResponse` object will be returned with `IncomingMessages` property of type `[]IncomingMessage` containing `IncomingMessage` objects, each object per single received message.
`ListIncomingMessagesResponse` object will contain also a `Headers` property where you can find `X-Total-Results` (a total count of all received messages which are available in incoming box on your account), `X-Total-Pages` (a total number of all pages with results), `X-Current-Page` (A current page number) and `X-Limit` (messages count per single page) elements.
type Mms ¶ added in v1.2.5
type Mms struct {
// contains filtered or unexported fields
}
func (*Mms) GetPrice ¶ added in v1.2.5
func (s *Mms) GetPrice(ctx context.Context, request operations.GetMmsPriceRequestBody, opts ...operations.Option) (*operations.GetMmsPriceResponse, error)
GetPrice - Check the price of MMS Messages Check the price of single or multiple MMS messages at the same time before sending them. You can pass a single `MmsMessage` object using `operations.CreateGetMmsPriceRequestBodyMmsMessage()` method (for single message) or `[]MmsMessage` array using `operations.CreateGetMmsPriceRequestBodyArrayOfMmsMessage()` method (for multiple messages). Each `MmsMessage` object has several properties, describing message parameters such as recipient phone number, content of the message, attachments, etc. The system will accept maximum **50** messages in one call.
As a successful result a `GetMmsPriceResponse` object will be returned with `Prices` property of type `[]Price` containing a `Price` objects, one object per each single message. You should check the `Error` property of each `Price` object to make sure which messages were priced successfully and which finished with an error. Successfully priced messages will have `null` value of `Error` property.
`GetSmsPriceResponse` object will include also `Headers` property with `X-Success-Count` (a count of messages which were processed successfully) and `X-Error-Count` (count of messages which were rejected) elements.
func (*Mms) Send ¶ added in v1.2.5
func (s *Mms) Send(ctx context.Context, request operations.SendMmsRequestBody, opts ...operations.Option) (*operations.SendMmsResponse, error)
Send MMS Messages Send single or multiple MMS messages at the same time. You can pass a single `MmsMessage` object using `operations.CreateSendMmsRequestBodyMmsMessage()` method (for single message) or `[]MmsMessage` array using `operations.CreateSendMmsRequestBodyArrayOfMmsMessage()` method (for multiple messages). Each `MmsMessage` object has several properties, describing message parameters such recipient phone number, content of the message, attachments or scheduled sending date, etc. This method will accept maximum 50 messages in one call.
As a successful result a `SendMmsResponse` object will be returned with `Messages` property of type `[]Message` containing `Message` objects, one object per each single message. You should check the `StatusCode` property of each `Message` object to make sure which messages were accepted by gateway (queued) and which were rejected. In case of rejection, `StatusDescription` property will include a reason.
`SendMmsResponse` will also include `Headers` property with `X-Success-Count` (a count of messages which were processed successfully), `X-Error-Count` (count of messages which were rejected) and `X-Sandbox` (if a request was made in Sandbox or Production system) elements.
type Outgoing ¶
func (*Outgoing) CancelScheduled ¶
func (s *Outgoing) CancelScheduled(ctx context.Context, ids []int64, opts ...operations.Option) (*operations.CancelMessagesResponse, error)
CancelScheduled - Cancel a scheduled messages Cancel messages using their `ids` which were scheduled to be sent at a specific time. You have to pass an array of type `[]int64` containing the unique message IDs, which were returned after sending a message. This method will accept maximum 50 identifiers in one call. You can cancel only messages with *SCHEDULED* status.
As a successful result a `CancelMessagesResponse` object will be returned, with `CancelledMessages` property of type `[]CancelledMessage` containing `CancelledMessage` objects. The `Status` property of each `CancelledMessage` object will contain a status code of operation - `204` if a particular message was cancelled successfully and other code if an error occured.
`CancelMessagesResponse` object will also contain `Headers` property where you can find `X-Success-Count` (a count of messages which were cancelled successfully), `X-Error-Count` (count of messages which were not cancelled) and `X-Sandbox` (if a request was made in Sandbox or Production system) elements.
func (*Outgoing) GetByIds ¶
func (s *Outgoing) GetByIds(ctx context.Context, ids []int64, opts ...operations.Option) (*operations.GetMessagesResponse, error)
GetByIds - Get the messages details and status by IDs Check the current status and details of one or more messages using their `ids`. You have to pass an array of type `[]int64` containing unique message *IDs* which details you want to fetch. This method will accept maximum 50 identifiers in one call.
As a successful result a `GetMessagesResponse` object will be returned containing `Messages` property of type `[]Message` with `Message` objects, each object per single found message. `GetMessagesResponse` object will also contain `Headers` property where you can find `X-Success-Count` (a count of messages which were found and returned correctly) and `X-Error-Count` (count of messages which were not found) elements.
func (*Outgoing) List ¶
func (s *Outgoing) List(ctx context.Context, page *int64, limit *int64, opts ...operations.Option) (*operations.ListMessagesResponse, error)
List - Lists the history of sent messages Get the details and current status of all of sent messages from your account message history. This method supports pagination so you have to pass a `page` (number of page with messages which you want to access) and a `limit` (max of messages per page) parameters. Messages are fetched from the latest one. This method will accept maximum value of **50** as `limit` parameter value (of type `Int64`).
As a successful result a `ListMessagesResponse` object will be returned containing `Messages` property of type `[]Message` with a `Message` objects, each object per single message. `ListMessagesResponse` will also contain `Headers` property where you can find `X-Total-Results` (a total count of all messages which are available in history on your account), `X-Total-Pages` (a total number of all pages with results), `X-Current-Page` (A current page number) and `X-Limit` (messages count per single page) elements.
type SDKOption ¶
type SDKOption func(*Client)
func WithClient ¶
func WithClient(client HTTPClient) SDKOption
WithClient allows the overriding of the default HTTP client used by the SDK
func WithRetryConfig ¶
func WithSecurity ¶
WithSecurity configures the SDK to use the provided security details
func WithSecuritySource ¶
WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication
func WithServer ¶
WithServer allows the overriding of the default server by name
func WithServerURL ¶
WithServerURL allows the overriding of the default server URL
func WithTemplatedServerURL ¶
WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters
func WithTimeout ¶
WithTimeout Optional request timeout applied to each operation
type Senders ¶
type Senders struct {
// contains filtered or unexported fields
}
func (*Senders) Add ¶
func (s *Senders) Add(ctx context.Context, request components.SenderInput, opts ...operations.Option) (*operations.AddSenderResponse, error)
Add a new sender name Define a new allowed sender on your account. You should pass as parameter a `SenderInput` struct with two fields: `Sender` (defines sender name) and `Description`. Please carefully fill this field with the extensive description of a sender name (what will be its use, what the name mean, etc).
As a successful result a `AddSenderResponse` object will be returned with a `Sender` property containing a `Sender` object with details and status of added sender name.
func (*Senders) Delete ¶
func (s *Senders) Delete(ctx context.Context, sender string, opts ...operations.Option) (*operations.DeleteSenderResponse, error)
Delete a sender name Removes defined sender name from your account. This method accepts a `string` type with a **sender name** you want to remove. Sender name will be deleted immediately.
As a successful response there would be `DeleteSenderResponse` object returned with no Exception thrown.
func (*Senders) List ¶
func (s *Senders) List(ctx context.Context, opts ...operations.Option) (*operations.ListSendersResponse, error)
List allowed senders names Get a list of allowed senders defined in your account.
As a successful result a `ListSendersResponse` object will be returned witch `Senders` property of type `[]Sender` array containing `Sender` objects, each object per single sender.
func (*Senders) SetDefault ¶
func (s *Senders) SetDefault(ctx context.Context, sender string, opts ...operations.Option) (*operations.SetDefaultSenderResponse, error)
SetDefault - Set default sender name Set default sender name to one of the senders names already defined on your account. This method accepts a `string` type containing a **sender name** to be set as default on your account.
As a successful response a `SetDefaultSenderResponse` object will be returned no Exception to be thrown.
type Sms ¶
type Sms struct {
// contains filtered or unexported fields
}
func (*Sms) GetPrice ¶
func (s *Sms) GetPrice(ctx context.Context, request operations.GetSmsPriceRequestBody, opts ...operations.Option) (*operations.GetSmsPriceResponse, error)
GetPrice - Check the price of SMS Messages Check the price of single or multiple SMS messages at the same time before sending them. You can pass a single `SmsMessage` object using `operations.CreateGetSmsPriceRequestBodySmsMessage()` method (for single message) or `[]SmsMessage` array using `operations.CreateGetSmsPriceRequestBodyArrayOfSmsMessage()` method (for multiple messages). Each `SmsMessage` object has several properties, describing message parameters such as recipient phone number, content of the message, type, etc. The method will accept maximum **100** messages in one call.
As a successful result a `GetSmsPriceResponse` object will be returned with `Prices` property of type `[]Price` containing a `Price` objects, one object per each single message. You should check the `Error` property of each `Price` object to make sure which messages were priced successfully and which finished with an error. Successfully priced messages will have `null` value of `Error` property.
`GetSmsPriceResponse` object will include also `Headers` property with `X-Success-Count` (a count of messages which were processed successfully) and `X-Error-Count` (count of messages which were rejected) elements.
func (*Sms) Send ¶
func (s *Sms) Send(ctx context.Context, request operations.SendSmsRequestBody, opts ...operations.Option) (*operations.SendSmsResponse, error)
Send SMS Messages Send single or multiple SMS messages at the same time. You can pass a single `SmsMessage` object using `operations.CreateSendSmsRequestBodySmsMessage()` method (for single message) or `[]SmsMessage` array using `operations.CreateSendSmsRequestBodyArrayOfSmsMessage()` method (for multiple messages). Each `SmsMessage` object has several properties, describing message parameters such recipient phone number, content of the message, type or scheduled sending date, etc. This method will accept maximum 100 messages in one call.
As a successful result a `SendSmsResponse` object will be returned with `Messages` property of type `[]Message` containing `Message` objects, one object per each single message. You should check the `StatusCode` property of each `Message` object to make sure which messages were accepted by gateway (queued) and which were rejected. In case of rejection, `StatusDescription` property will include a reason.
`SendSmsResponse` will also include `Headers` property with `X-Success-Count` (a count of messages which were processed successfully), `X-Error-Count` (count of messages which were rejected) and `X-Sandbox` (if a request was made in Sandbox or Production system) elements.