desk

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2015 License: MIT Imports: 1 Imported by: 3

README

GoDoc Build Status

Desk.com APIv2 client implementation in Go (http://dev.desk.com/API)

Most major endpoints have been implemented, leaving the more isoteric ones still to do. Those likely won't be worked on unless there's a demand for it. See the project issues section for up-to-date information on what's on the roadmap.

Examples

There's two ways to create request bodies.

Using the builder pattern:

message:=resource.MessageBuilder.
	SetString("Direction","in").
	SetString("Status","received").
	SetString("To","someone@desk.com").
	SetString("From","someone-else@desk.com").
	SetString("Subject","Case created by API via desk-go").
	SetString("Body","Please assist me with this case").
	BuildMessage()

Using a constructor:

message:=resource.NewMessage()
message.Direction=types.String("in")
message.Status=types.String("received")
message.To=types.String("someone@desk.com")
message.From=types.String("someone-else@desk.com")
message.Subject=types.String("Case created by API via desk-go")
message.Body=types.String("Please assist me with this case")

Struct literal composition is not supported, as the constructor performs some additional initialization(s).

For additional examples of the desk API usage, look at the tests in the integration directory.

Create a new case

func main() {

  //create http client
	siteUrl := "mysite.desk.com"
	userEmail := "mysite@somewhere.com"
	userPassword := "mysite.desk.com pass"
	client := service.NewClient(nil,siteUrl,userEmail,userPassword)

  //create a new case
	message:=resource.MessageBuilder.
		SetString("Direction","in").
		SetString("Status","received").
		SetString("To","someone@desk.com").
		SetString("From","someone-else@desk.com").
		SetString("Subject","Case created by API via desk-go").
		SetString("Body","Please assist me with this case").
		BuildMessage()
	caze:=resource.CaseBuilder.
		SetString("Type","email").
		SetString("Subject","Case created by API via desk-go").
		SetInt("Priority",4).
		SetString("Status","received").
		SetMessage(message).
		AddHrefLink("customer",fmt.Sprintf("/api/v2/customers/%d",192220782)).
		BuildCase()
	newCase,_,err := client.Case.Create(caze)
	if err != nil {
		fmt.Printf("error: %v\n\n", err)
	} else {
		fmt.Printf("%v\n\n",newCase.String())
	}
}

Other Libraries

Libraries in other languages are also available:

Documentation

Index

Constants

View Source
const (
	DeskLibVersion = "0.1"
	DeskApiVersion = "v2"
	DeskHost       = "desk.com"
	DeskUserAgent  = "go-desk/" + DeskLibVersion
)

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
Godeps
_workspace/src/github.com/gedex/inflector
Package inflector pluralizes and singularizes English nouns.
Package inflector pluralizes and singularizes English nouns.
_workspace/src/github.com/jacobsa/oglematchers
Package oglematchers provides a set of matchers useful in a testing or mocking framework.
Package oglematchers provides a set of matchers useful in a testing or mocking framework.
_workspace/src/github.com/joho/godotenv
Package godotenv is a go port of the ruby dotenv library (https://github.com/bkeepers/dotenv) Examples/readme can be found on the github page at https://github.com/joho/godotenv The TL;DR is that you make a .env file that looks something like SOME_ENV_VAR=somevalue and then in your go code you can call godotenv.Load() and all the env vars declared in .env will be avaiable through os.Getenv("SOME_ENV_VAR")
Package godotenv is a go port of the ruby dotenv library (https://github.com/bkeepers/dotenv) Examples/readme can be found on the github page at https://github.com/joho/godotenv The TL;DR is that you make a .env file that looks something like SOME_ENV_VAR=somevalue and then in your go code you can call godotenv.Load() and all the env vars declared in .env will be avaiable through os.Getenv("SOME_ENV_VAR")
_workspace/src/github.com/lann/builder
Package builder provides a method for writing fluent immutable builders.
Package builder provides a method for writing fluent immutable builders.
_workspace/src/github.com/mndrix/ps
Fully persistent data structures.
Fully persistent data structures.
_workspace/src/github.com/smartystreets/goconvey/convey
Oh the stack trace scanning! The density of comments in this file is evidence that the code doesn't exactly explain itself.
Oh the stack trace scanning! The density of comments in this file is evidence that the code doesn't exactly explain itself.
_workspace/src/github.com/smartystreets/goconvey/convey/assertions
Package assertions contains the implementations for all assertions which are referenced in the convey package for use with the So(...) method.
Package assertions contains the implementations for all assertions which are referenced in the convey package for use with the So(...) method.
_workspace/src/github.com/smartystreets/goconvey/convey/gotest
Package gotest contains internal functionality.
Package gotest contains internal functionality.
_workspace/src/github.com/smartystreets/goconvey/convey/reporting
Package reporting contains internal functionality related to console reporting and output.
Package reporting contains internal functionality related to console reporting and output.

Jump to

Keyboard shortcuts

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