mojo

package module
v0.0.0-...-29b8f99 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2019 License: MIT Imports: 8 Imported by: 0

README

Go client to Mojo API

Run tests

go test

Documentation

Overview

Package mojo is a client to the Mojo API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contact

type Contact struct {
	ID                                string // required
	GroupID                           int    // required
	Name                              string
	Address, City, State, Zip         string
	Email                             string
	MobilePhone, WorkPhone, HomePhone string
	Notes                             []string
}

Contact to be created in Mojo

Either Name must provided OR at least one of Email, MobilePhone, WorkPhone, HomePhone

func (Contact) MarshalJSON

func (c Contact) MarshalJSON() ([]byte, error)

type ErrDuplicate

type ErrDuplicate struct {
	IDs []string
}

ErrDuplicate is returned by AddContact when a contact with same id already exists in Mojo

func (*ErrDuplicate) Error

func (e *ErrDuplicate) Error() string

type ErrForbidden

type ErrForbidden struct {
	Msg string
}

ErrForbidden is returned on status code 403, usually due to invalid access token

func (*ErrForbidden) Error

func (e *ErrForbidden) Error() string

type ErrInvalid

type ErrInvalid struct {
	Msg string
}

ErrInvalid is returned by AddContact when a validation error is detected, like missing a required field

func (*ErrInvalid) Error

func (e *ErrInvalid) Error() string

type Mojo

type Mojo struct {
	// URL for this account, including protocol + host, example:
	// https://posttest.mojosells.com
	//
	// Each mojo client has their own url
	URL string

	// Token is the access token provided by Mojo after the client
	// has logged in using OAuth
	Token string

	HTTP *http.Client // (optional) http client to perform requests
}

Mojo client

func (*Mojo) AddContact

func (mj *Mojo) AddContact(contacts ...Contact) error

AddContact creates a new Contact in Mojo

Contact ID and GroupID must be provided. At least one contact field should be provided

Return ErrDuplicate if a contact with same ID already exists. Return other errors if can't make the request of if Mojo returns an error

func (*Mojo) AddNote

func (mj *Mojo) AddNote(contactID string, note string) error

AddNote adds a note to an existing contact

Return ErrInvalid on validation errors and ErrForbidden if token is invalid

Jump to

Keyboard shortcuts

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