digits

package
v0.0.0-...-9878657 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2017 License: MIT Imports: 3 Imported by: 9

Documentation

Overview

Package digits provides a Client for the Digits API.

The digits package provides a Client for accessing Digits API services. Here is an example request for a Digit user's Account.

import (
	"github.com/dghubble/go-digits/digits"
	"github.com/dghubble/oauth1"
)

config := oauth1.NewConfig("consumerKey", "consumerSecret")
token := oauth1.NewToken("accessToken", "accessTokenSecret")
// OAuth1 http.Client will automatically authorize Requests
httpClient := config.Client(token)

// Digits client
client := digits.NewClient(httpClient)
// get current user's Digits Account
account, resp, err := client.Accounts.Account()

The API client accepts any http.Client capable of signing OAuth1 requests to handle authorization.

See the OAuth1 package https://github.com/dghubble/oauth1 for authorization details and examples.

To implement Login with Digits, see https://github.com/dghubble/gologin.

Index

Constants

View Source
const (
	DigitsAPI = "https://api.digits.com"
)

DigitsAPI and version

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Errors []ErrorDetail `json:"errors"`
}

APIError represents a Digits API Error response

func (APIError) Empty

func (e APIError) Empty() bool

Empty returns true if the Errors slice is empty, false otherwise.

func (*APIError) Error

func (e *APIError) Error() string

type AccessToken

type AccessToken struct {
	Token  string `json:"token"`
	Secret string `json:"secret"`
}

AccessToken is a Digits OAuth1 access token and secret.

type Account

type Account struct {
	AccessToken      AccessToken `json:"access_token"`
	CreatedAt        string      `json:"created_at"`
	Email            Email       `json:"email_address"`
	ID               int64       `json:"id"`
	IDStr            string      `json:"id_str"`
	PhoneNumber      string      `json:"phone_number"`
	VerificationType string      `json:"verification_type"`
}

Account is a Digits user account.

type AccountService

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

AccountService provides methods for accessing Digits Accounts.

func NewAccountService

func NewAccountService(sling *sling.Sling) *AccountService

NewAccountService returns a new AccountService.

func (*AccountService) Account

func (s *AccountService) Account() (*Account, *http.Response, error)

Account returns the authenticated user Account.

type Client

type Client struct {

	// Digits API Services
	Accounts *AccountService
	Contacts *ContactService
	// contains filtered or unexported fields
}

Client is a Digits client for making Digits API requests.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Client.

type ContactService

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

ContactService provides methods for accessing Digits contacts.

func NewContactService

func NewContactService(sling *sling.Sling) *ContactService

NewContactService returns a new ContactService.

func (*ContactService) Matches

func (s *ContactService) Matches(params *MatchesParams) (*Contacts, *http.Response, error)

Matches returns Contacts with the cursored Digits Accounts which have logged into the Digits application and are known to the authenticated user Account via address book uploads.

type Contacts

type Contacts struct {
	NextCursor string `json:"next_cursor"`
	// matched contacts are partially hydrated Accounts (i.e. no token, phone)
	Users []Account `json:"users"`
}

Contacts represents a cursored subset of a set of contacts.

type Email

type Email struct {
	Address  string `json:"address"`
	Verified bool   `json:"is_verified"`
}

Email is a Digits user email.

type ErrorDetail

type ErrorDetail struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

ErrorDetail represents an individual error in an APIError.

type MatchesParams

type MatchesParams struct {
	NextCursor string `url:"next_cursor,omitempty"`
	Count      int    `url:"count,omitempty"`
}

MatchesParams are the parameters for ContactService.Matches

Jump to

Keyboard shortcuts

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