Giter Club home page Giter Club logo

contextio-go's Introduction

contextio-go

Context.IO API Golang Library

This library is currently in BETA, and as such we make no promises; the use of this library is provided without warranty.

Installation

# For the LITE api
go get github.com/contextio/contextio-go/ciolite

# 2.0 api coming soon...

CIO Lite Usage

package main

import (
	"fmt"
	"log"
	"os"
	"github.com/contextio/contextio-go/ciolite"
)

func main() {
	// Key and Secret
	cioKey := os.Getenv("CONTEXTIO_API_KEY")
	cioSecret := os.Getenv("CONTEXTIO_API_SECRET")

	// Client Instance
	cioLiteClient := ciolite.NewCioLite(cioKey, cioSecret)
	// Can also use with a standard or custom logger:
	// ciolite.NewCioLiteWithLogger(cioKey, cioSecret, logrus.StandardLogger())

	// Discovery Call Parameters
	discoveryParams := ciolite.GetDiscoveryParams{Email: "[email protected]", SourceType: "IMAP"}

	// Actual Discovery Call
	discoveryResp, err := cioLiteClient.GetDiscovery(discoveryParams)
	if err != nil {
		log.Fatal("Error calling ContextIO: " + err.Error())
	}

	// Responses are simple structs, all fields accessible. The following line prints:
	// {Email:[email protected] Type:gmail Documentation:[] Found:true
	// IMAP:{Server:imap.gmail.com Username:[email protected] UseSSL:true OAuth:true Port:993}}
	fmt.Printf("%+v", discoveryResp)

	// Get a slice of users
	users, _ := cioLiteClient.GetUsers(ciolite.GetUsersParams{})

	// Get a slice of emails in the Inbox of the first users's first email account
	fmt.Println(cioLiteClient.GetUserEmailAccountsFolderMessages(
		users[0].ID,
		users[0].EmailAccounts[0].Label,
		"Inbox",
		ciolite.GetUserEmailAccountsFolderMessageParams{},
	))
}

Support

If you want to open an issue or PR for this library - go ahead! We'd love to hear your feedback.

For API support please consult our support site and feel free to drop a line to [email protected].

contextio-go's People

Contributors

dmlyons avatar veqryn avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

suicidegang priom

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.