Coder Social home page Coder Social logo

goketo's Introduction

GoKeto: Marketo REST API Client

GoDoc MIT licensed CircleCI TravisCI Go Report Card Badge Badge

Go package Marketo Logo

About

Unofficial Golang client for the Marketo.com REST API: http://developers.marketo.com/documentation/rest/. Inspired by the VojtechVitek/go-trello implementation

Requires Go 1.5.3

Installation

The recommended way of installing the client is via go get. Simply run the following command to add the package.

go get github.com/FrenchBen/goketo/

Usage

Below is an example of how to use this library

package main

import (
	"io/ioutil"
	"path/filepath"

	"gopkg.in/yaml.v2"

	"github.com/FrenchBen/goketo"
	"github.com/Sirupsen/logrus"
)


func main() {
	// Get config auth
	authFile, _ := filepath.Abs("./auth.yaml")
	data, err := ioutil.ReadFile(authFile)
	if err != nil {
		logrus.Errorf("error reading auth file %q: %v", "auth.yaml", err)
	}
	auth := &marketoAuthConfig{}
	if err = yaml.Unmarshal(data, auth); err != nil {
		logrus.Errorf("Error during Yaml: %v", err)
	}
	// New Marketo Client
	marketo, err := goketo.NewAuthClient(auth.ClientID, auth.ClientSecret, auth.ClientEndpoint)
	if err != nil {
		log.Fatal(err)
	}
	// Get leads
  listID, _ := strconv.Atoi(auth.LeadID)
	leadRequest := &goketo.LeadRequest{ID: listID}
	leads, err := goketo.Leads(marketo, leadRequest)
	if err != nil {
		logrus.Error("Couldn't get leads: ", err)
	}  
  results := []goketo.LeadResult{}
	err = json.Unmarshal(leads.Result, &results)
  logrus.Infof("My leads: %v", results)


  // Get user by lead ID
  leadID, _ := results[0].ID
	leadRequest := &goketo.LeadRequest{ID: leadID}
	lead, err := goketo.Lead(marketo, leadRequest)
	if err != nil {
		logrus.Error("Couldn't get lead: ", err)
	}
  result := []goketo.LeadResult{}
	err = json.Unmarshal(leads.Result, &result)
  logrus.Infof("My lead from ID: %v", result)
}

To view more the token and fields sent with the request, set your log level to debug: logrus.SetLevel(logrus.DebugLevel)

For information on usage, please see the GoDoc.

License

This source is licensed under an MIT License, see the LICENSE file for full details. If you use this code, it would be great to hear from you.

goketo's People

Contributors

bboreham avatar frenchben avatar tomwilkie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

goketo's Issues

Sirupsen -> sirupsen

Hi there

A short while back Sirupsen changed the case of their username to lowercase, this means we can't just plug goketo into our platforms :(

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.