Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 1 month 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 (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-30T13:55:57.000Z (over 1 year ago)
- Last Synced: 2024-06-20T05:16:34.745Z (7 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
[![Build](https://github.com/NdoleStudio/smsto-go/actions/workflows/main.yml/badge.svg)](https://github.com/NdoleStudio/smsto-go/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/NdoleStudio/smsto-go/branch/main/graph/badge.svg)](https://codecov.io/gh/NdoleStudio/smsto-go)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/NdoleStudio/smsto-go/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/NdoleStudio/smsto-go/?branch=main)
[![Go Report Card](https://goreportcard.com/badge/github.com/NdoleStudio/smsto-go)](https://goreportcard.com/report/github.com/NdoleStudio/smsto-go)
[![GitHub contributors](https://img.shields.io/github/contributors/NdoleStudio/smsto-go)](https://github.com/NdoleStudio/smsto-go/graphs/contributors)
[![GitHub license](https://img.shields.io/github/license/NdoleStudio/smsto-go?color=brightgreen)](https://github.com/NdoleStudio/smsto-go/blob/master/LICENSE)
[![PkgGoDev](https://pkg.go.dev/badge/github.com/NdoleStudio/smsto-go)](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