contextio

package module
v0.0.0-...-fc76dd0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2013 License: MIT Imports: 6 Imported by: 0

README

go-contextio

Go client for http://context.io

Documentation

Overview

A client-side library for interacting with Context.IO.

Index

Constants

View Source
const (
	API_URL     = "https://api.context.io"
	API_VERSION = "2.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Id              string   `json:"id"`
	Username        string   `json:"username"`
	Created         int      `json:"created"`
	Suspended       int      `json:"suspended"`
	EmailAddresses  []string `json:"email_addresses"`
	FirstName       string   `json:"first_name"`
	LastName        string   `json:"last_name"`
	PasswordExpired int      `json:"password_expired"`
	Sources         []Source `json:"sources"`
	NBMessages      int      `json:"nb_messages"`
	NBFiles         int      `json:"nb_files"`
}

Represents a JSON object representing an account, in context.io.

type AccountEmailAddressBlock

type AccountEmailAddressBlock struct {
	Email     string `json:"email"`
	Validated int    `json:"validated"`
	Primary   int    `json:"primary"`
}

type AddAccountResponse

type AddAccountResponse struct {
	Success           bool   `json:"success"`
	Id                string `json:"id"`
	ResourceUrl       string `json:"resource_url"`
	AccessToken       string `json:"access_token,omitempty"`
	AccessTokenSecret string `json:"access_token_secret,omitempty"`
}

type Address

type Address struct {
	Email string `json:"email"`
	Name  string `json:"name"`
}

type Client

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

func New

func New(key, secret string) *Client

func (*Client) CopyTo

func (c *Client) CopyTo(newclient *Client)

Copies the details of the existing client into a the new one.

func (*Client) Do

func (c *Client) Do(method string, params map[string]string, parts ...string) (resp *http.Response, err error)

Perform a two-legged OAuth 1.0 request against the context.io API.

The supported values for the method are "GET", "POST", "PUT", and "DELETE".

The params string-string map is for any extra parameters you wish to provide to an endpoint, that will be URL-encoded.

The rest of the arguments are the various parts of the API endpoint's URI, done like a print-like function:

var account Account
...
c.Do("GET", nil, "accounts", account.Id, "files")

...this is so that you do not have to constantly re-create the a URI string to pass to this function.

func (*Client) EnableDebugging

func (c *Client) EnableDebugging(debug bool)

Enables debugging of the OAuth consumer when set to true. Providing a value of false disables debugging.

func (*Client) Unmarshal

func (c *Client) Unmarshal(response *http.Response, v interface{}) error

Unmarshals the body of the provided HTTP response, into the provided type.

For example, if you called:

response, err := c.Do("GET", "accounts")

...you would call *c.Unmarshal() like so:

var accounts []contextio.Account
err = c.Unmarshal(response, &accounts)

type ConnectToken

type ConnectToken struct {
	Token       string                   `json:"token"`
	Email       string                   `json:"email"`
	Created     int                      `json:"created"`
	Used        int                      `json:"used"`
	Expires     interface{}              `json:"expires"` // Can be an int, or a boolean
	CallbackUrl string                   `json:"callback_url"`
	FirstName   string                   `json:"first_name"`
	LastName    string                   `json:"last_name"`
	Account     ConnectTokenAccountBlock `json:"account,omitempty"`
}

type ConnectTokenAccountBlock

type ConnectTokenAccountBlock struct {
	Id             string                     `json:"id"`
	Created        int                        `json:"created"`
	Suspended      int                        `json:"suspended"`
	EmailAddresses []AccountEmailAddressBlock `json:"email_addresses"`
	FirstName      string                     `json:"first_name"`
	LastName       string                     `json:"last_name"`
	Sources        []Source                   `json:"sources"`
}

type Contact

type Contact struct {
	Email     string `json:"email"`
	Count     int    `json:"count"`
	Name      string `json:"name"`
	Thumbnail string `json:"thumbnail"`
}

type ContactList

type ContactList struct {
	Query   ContactListQueryBlock `json:"query"`
	Matches []Contact             `json:"matches"`
}

type ContactListQueryBlock

type ContactListQueryBlock struct {
	Limit        int    `json:"limit"`
	Offset       int    `json:"offset"`
	ActiveAfter  int    `json:"active_after"`
	ActiveBefore int    `json:"active_before"`
	Search       string `json:"search"`
}

type CreateAccount

type CreateAccount struct {
	Email     string `json:"email"`
	FirstName string `json:"first_name,omitempty"`
	LastName  string `json:"last_name,omitempty"`
}

type CreateAccountAndSource

type CreateAccountAndSource struct {
	CreateAccount
	CreateSource
}

type CreateSource

type CreateSource struct {
	Email                string `json:"email"`
	Server               string `json:"server"`
	Username             string `json:"username"`
	UseSSL               int    `json:"use_ssl"`
	Port                 int    `json:"port"`
	Type                 string `json:"type"`
	OriginIP             string `json:"origin_ip,omitempty"`
	SyncPeriod           string `json:"sync_period,omitempty"`
	ExpungeOnDeletedFlag int    `json:"expunge_on_deleted_flag,omitempty"`
	SyncFlags            int    `json:"sync_flags,omitempty"`
	SyncAllFolders       int    `json:"sync_all_folders,omitempty"`
	RawFileList          int    `json:"raw_file_list,omitempty"`
	Password             string `json:"password,omitempty"`
	ProviderRefreshToken string `json:"password_refresh_token,omitempty"`
	ProviderToken        string `json:"provider_token,omitempty"`
	ProviderTokenSecret  string `json:"provider_token_secret,omitempty"`
	ProviderConsumerKey  string `json:"provider_consumer_key,omitempty"`
	CallbackUrl          string `json:"callback_url,omitempty"`
}

type Error

type Error struct {
	Type  string `json:"type"`
	Code  int    `json:"code"`
	Value string `json:"value"`
}

type File

type File struct {
	Size               int                    `json:"size"`
	Type               string                 `json:"type"`
	Subject            string                 `json:"subject"`
	Date               int                    `json:"date"`
	DateIndexed        int                    `json:"date_indexed"`
	Addresses          MessageAddressesBlock  `json:"addresses"`
	PersonInfo         MessagePersonInfoBlock `json:"person_info"`
	FileName           string                 `json:"file_name"`
	FileNameStructure  map[string][]string    `json:"file_name_structure"`
	BodySection        int                    `json:"body_section"`
	FileId             string                 `json:"file_id"`
	SupportsPreview    bool                   `json:"supports_preview"`
	IsEmbedded         bool                   `json:"is_embedded"`
	ContentDisposition string                 `json:"content_disposition"`
	ContentId          string                 `json:"content_id"`
	MessageId          string                 `json:"message_id"`
	EmailMessageId     string                 `json:"email_message_id"`
	GmailMessageId     string                 `json:"gmail_message_id"`
	GmailThreadId      string                 `json:"gmail_thread_id"`
}

type Message

type Message struct {
	Date           int                    `json:"date,omitempty"`
	DateIndexed    int                    `json:"date_indexed,omitempty"`
	DateReceived   int                    `json:"date_received,omitempty"`
	Addresses      MessageAddressesBlock  `json:"addresses,omitempty"`
	PersonInfo     MessagePersonInfoBlock `json:"person_info,omitempty"`
	EmailMessageId string                 `json:"email_message_id,omitempty"`
	MessageId      string                 `json:"message_id,omitempty"`
	GmailMessageId string                 `json:"gmail_message_id,omitempty"`
	GmailThreadId  string                 `json:"gmail_thread_id,omitempty"`
	Files          []MessageFilesBlock    `json:"files,omitempty,omitempty"`
	Subject        string                 `json:"subject,omitempty"`
	Folders        []string               `json:"folders,omitempty"`
	Sources        []MessageSourcesBlock  `json:"sources,omitempty"`
	ResourceURL    string                 `json:"resource_url,omitempty"`
}

type MessageAddressesBlock

type MessageAddressesBlock struct {
	From Address   `json:"from"`
	To   []Address `json:"to"`
	CC   []Address `json:"cc"`
}

type MessageBody

type MessageBody struct {
	Type        string `json:"type"`
	Charset     string `json:"charset"`
	Content     string `json:"content"`
	BodySection string `json:"body_section"`
}

type MessageFilesBlock

type MessageFilesBlock struct {
	Size               int        `json:"size,omitempty"`
	Type               string     `json:"type"`
	FileName           string     `json:"file_name"`
	FileNameStructure  [][]string `json:"file_name_structure"`
	BodySection        string     `json:"body_section,omitempty"`
	FileId             string     `json:"file_id"`
	IsEmbedded         bool       `json:"is_embedded"`
	ContentDisposition string     `json:"content_disposition"`
	ContentId          string     `json:"content_id"`
}

type MessagePersonInfoBlock

type MessagePersonInfoBlock map[string]ThumbnailBlock

type MessageSourcesBlock

type MessageSourcesBlock struct {
	Label       string `json:"label"`
	ResourceURL string `json:"resource_url"`
}

type Source

type Source struct {
	Server             string `json:"server"`
	Label              string `json:"label"`
	Username           string `json:"username"`
	Port               int    `json:"port"`
	AuthenticationType string `json:"authentication_type"`
	Status             string `json:"status"`
	ServiceLevel       string `json:"service_level"`
	SyncPeriod         string `json:"sync_period"`
	UseSSL             bool   `json:"use_ssl"`
	Type               string `json:"type"`
	ResourceURL        string `json:"resource_url"`
}

type SyncMailboxBlock

type SyncMailboxBlock struct {
	InitialImportFinished bool `json:"initial_import_finished"`
	LastExpunge           int  `json:"last_expunge"`
	LastSyncStart         int  `json:"last_sync_start"`
	LastSyncStop          int  `json:"last_sync_stop"`
}

type SyncResponse

type SyncResponse map[string]map[string]SyncMailboxBlock

type Thread

type Thread struct {
	GmailThreadId   string                 `json:"gmail_thread_id"`
	EmailMessagesId []string               `json:"email_messages_id"`
	PersonInfo      MessagePersonInfoBlock `json:"person_info"`
	Messages        []Message              `json:"messages"`
}

type ThreadList

type ThreadList []string

type ThumbnailBlock

type ThumbnailBlock struct {
	Thumbnail string `json:"thumbnail"`
}

Jump to

Keyboard shortcuts

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