Skip to content

Bkrm2706/httpsms-go

 
 

Repository files navigation

httpsms-go

Build codecov Scrutinizer Code Quality Go Report Card GitHub contributors GitHub license PkgGoDev

This package provides a generic go client template for the Http SMS Api

Installation

httpsms-go is compatible with modern Go releases in module mode, with Go installed:

go get github.com/NdoleStudio/httpsms-go

Alternatively the same can be achieved if you use import in a package:

import "github.com/NdoleStudio/httpsms-go"

Implemented

  • Messages
    • POST /v1/messages/send: Send a new SMS Message

Usage

Initializing the Client

An instance of the client can be created using httpsms.New().

package main

import (
    "github.com/NdoleStudio/httpsms-go"
)

func main()  {
    client := htpsms.New(htpsms.WithDelay(200))
}

Error handling

All API calls return an error as the last return object. All successful calls will return a nil error.

_, response, err := client.Messages.Send(context.Background())
if err != nil {
    //handle error
}

Messages

POST /v1/messages/send: Send a new SMS Message

message, response, err := client.Messages.Send(context.Background(), &MessageSendParams{
    Content: "This is a sample text message",
    From:    "+18005550199",
    To:      "+18005550100",
})

if err != nil {
    log.Fatal(err)
}

log.Println(message.Code) // 202

Testing

You can run the unit tests for this client from the root directory using the command below:

go test -v

License

This project is licensed under the MIT License - see the LICENSE file for details

About

Go Client for the Http Sms API https://api.httpsms.com

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 100.0%