https://github.com/ndolestudio/smsto-go
Go client for the sms.to API
https://github.com/ndolestudio/smsto-go
sms-api sms-gateway smsto
Last synced: 3 months ago
JSON representation
Go client for the sms.to API
- Host: GitHub
- URL: https://github.com/ndolestudio/smsto-go
- Owner: NdoleStudio
- License: mit
- Created: 2022-03-28T14:05:00.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-30T13:55:57.000Z (almost 2 years ago)
- Last Synced: 2025-02-02T15:54:25.409Z (5 months ago)
- Topics: sms-api, sms-gateway, smsto
- Language: Go
- Homepage: https://developers.sms.to
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# smsto-go
[](https://github.com/NdoleStudio/smsto-go/actions/workflows/main.yml)
[](https://codecov.io/gh/NdoleStudio/smsto-go)
[](https://scrutinizer-ci.com/g/NdoleStudio/smsto-go/?branch=main)
[](https://goreportcard.com/report/github.com/NdoleStudio/smsto-go)
[](https://github.com/NdoleStudio/smsto-go/graphs/contributors)
[](https://github.com/NdoleStudio/smsto-go/blob/master/LICENSE)
[](https://pkg.go.dev/github.com/NdoleStudio/smsto-go)This package provides a `go` client for the SMS.to HTTP API https://developers.sms.to
## Installation
`smsto-go` is compatible with modern Go releases in module mode, with Go installed:
```bash
go get github.com/NdoleStudio/smsto-go
```Alternatively the same can be achieved if you use `import` in a package:
```go
import "github.com/NdoleStudio/smsto-go"
```## Implemented
- [SMS](#sms)
- `POST /sms/send`: Send single message to a number
- `GET /last/message`: Get the last message that you have sent## Usage
### Initializing the Client
An instance of the client can be created using `New()`.
```go
package mainimport (
"github.com/NdoleStudio/smsto-go"
)func main() {
client := smsto.New(smsto.WithAPIKey(/* API KEY */))
}
```### Error handling
All API calls return an `error` as the last return object. All successful calls will return a `nil` error.
```go
result, response, err := client.SMS.SendSingle(context.Background(), &smsto.SmsSendSingleRequest{})
if err != nil {
//handle error
}
```### SMS
#### `POST /sms/send`: Send single message to a number
```go
result, response, err := client.SMS.SendSingle(context.Background(), &SmsSendSingleRequest{
Message: "This is test and \n this is a new line",
To: "+35799999999999",
})if err != nil {
log.Fatal(err)
}log.Println(result.Success) // true
```#### `GET /last/message`: Get the last message that you have sent
```go
message, response, err := client.SMS.LastMessage(context.Background())if err != nil {
log.Fatal(err)
}log.Println(message.Id) // 302050741
```## Testing
You can run the unit tests for this client from the root directory using the command below:
```bash
go test -v
```## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details