kickbox

package module
Version: v1.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2016 License: MIT Imports: 7 Imported by: 0

README

Build Status GoDoc

kickbox

An easy-to-use Go library using Kickbox.io for email address validation

##Example Install a tagged version with: go get github.com/domodwyer/kickbox

// Create a new client with your API key
kickbox := kickbox.NewClient("KICKBOX_TEST")

// Verify an email address
result, err := kickbox.Verify("dom@itsallbroken.com")
if err != nil {
	panic("something went wrong :( ")
}

// Interact with the response!
if(result.IsDeliverable()) {
	log.Print("Send some stuff to ", result.Email)
}

##Usage The Verify() method returns an instance of Kickbox.Result and is mapped onto the Kickbox API response:

type Result struct {
	Success    bool    `json:"success"`
	Result     string  `json:"result"`
	Reason     string  `json:"reason"`
	Disposable bool    `json:"disposable"`
	Role       bool    `json:"role"`
	Free       bool    `json:"free"`
	AcceptAll  bool    `json:"accept_all"`
	Suggested  string  `json:"did_you_mean"`
	Sendex     float32 `json:"sendex"`
	Email      string  `json:"email"`
	User       string  `json:"user"`
	Domain     string  `json:"domain"`
	Message    string  `json:"message"`
}

For convenience Kickbox.Result also recieves several helper methods:

func (r Result) IsDeliverable() bool {
	return (r.Result == "deliverable")
}

func (r Result) IsUndeliverable() bool {
	return (r.Result == "undeliverable")
}

func (r Result) IsRisky() bool {
	return (r.Result == "risky")
}

func (r Result) IsUnknown() bool {
	return (r.Result == "unknown")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client holds the HTTP client for interacting with the API, and the associated API key

func NewClient

func NewClient(apiKey string) *Client

NewClient returns an instance of a Kickbox API Client

func (*Client) SetTimeout

func (c *Client) SetTimeout(time time.Duration)

SetTimeout configures the request timeout value (includes connecting, waiting for a response, and reading the response)

func (Client) Verify

func (c Client) Verify(address string) (*Result, error)

Verify the given email address using Kickbox.io

type KickboxResultBuilder

type KickboxResultBuilder struct{}

KickboxResultBuilder implements our ResultBuilder interface and creates the actual Result struct (the response from Kickbox)

func (KickboxResultBuilder) NewResult

func (b KickboxResultBuilder) NewResult(response []byte) (*Result, error)

NewResult creates a new Result object from an JSON API response

type Result

type Result struct {
	Success    bool    `json:"success"`
	Result     string  `json:"result"`
	Reason     string  `json:"reason"`
	Disposable bool    `json:"disposable"`
	Role       bool    `json:"role"`
	Free       bool    `json:"free"`
	AcceptAll  bool    `json:"accept_all"`
	Suggested  string  `json:"did_you_mean"`
	Sendex     float32 `json:"sendex"`
	Email      string  `json:"email"`
	User       string  `json:"user"`
	Domain     string  `json:"domain"`
	Message    string  `json:"message"`
}

Result struct we store the API response in

func (Result) IsDeliverable

func (r Result) IsDeliverable() bool

IsDeliverable returns true if the API returns "result: deliverable"

func (Result) IsRisky

func (r Result) IsRisky() bool

IsRisky returns true if the API returns "result: risky"

func (Result) IsUndeliverable

func (r Result) IsUndeliverable() bool

IsUndeliverable returns true if the API returns "result: undeliverable"

func (Result) IsUnknown

func (r Result) IsUnknown() bool

IsUnknown returns true if the API returns "result: unknown"

type ResultBuilder

type ResultBuilder interface {
	NewResult(response []byte) (*Result, error)
}

ResultBuilder defines our interface for creating Result objects

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL