Documentation ¶
Index ¶
- Constants
- Variables
- type AuthToken
- type BatchResult
- type Client
- func (c *Client) Delete(resource string, data []byte) (response *Response, err error)
- func (c *Client) Get(resource string) (response *Response, err error)
- func (c *Client) GetTokenInfo() TokenInfo
- func (c *Client) Post(resource string, data []byte) (response *Response, err error)
- func (c *Client) RefreshToken() (auth AuthToken, err error)
- type ClientConfig
- type CustomObjectMetadata
- type CustomObjectResult
- type CustomObjects
- func (c *CustomObjects) Describe(ctx context.Context, name string) (*CustomObjectMetadata, error)
- func (c *CustomObjects) Filter(ctx context.Context, name string, opts ...QueryOption) ([]CustomObjectResult, string, error)
- func (c *CustomObjects) List(ctx context.Context) ([]CustomObjectMetadata, error)
- type Error
- type ImportAPI
- func (i *ImportAPI) Create(ctx context.Context, obj ImportObject, file io.Reader) ([]BatchResult, error)
- func (i *ImportAPI) Failures(ctx context.Context, obj ImportObject, id int) ([]LeadImportFailure, error)
- func (i *ImportAPI) Get(ctx context.Context, obj ImportObject, id int) (*BatchResult, error)
- type ImportObject
- type LeadAPI
- type LeadAttribute
- type LeadAttribute2
- type LeadAttributeMap
- type LeadImportFailure
- type LeadResult
- type ObjectField
- type ObjectRelation
- type ObjectState
- type ObjectVersion
- type Query
- type QueryOption
- type Reason
- type RecordResult
- type RelatedObject
- type Response
- type TokenInfo
Constants ¶
const ( BatchComplete = "Complete" BatchQueued = "Queued" BatchImporting = "Importing" BatchFailed = "Failed" )
const (
// DefaultTimeout is http client timeout and 60 seconds
DefaultTimeout = 60
)
const ( // MaximumQueryBatchSize is the largest batch size requestable via Marketo's // list/query API. MaximumQueryBatchSize = 300 )
Variables ¶
var ( ErrBadGateway = Reason{Code: "502"} ErrEmptyAccessToken = Reason{Code: "600"} ErrAccessTokenInvalid = Reason{Code: "601"} ErrAccessTokenExpired = Reason{Code: "602"} ErrAccessDenied = Reason{Code: "603"} ErrRequestTimeOut = Reason{Code: "604"} ErrMethodUnsupported = Reason{Code: "605"} ErrRateLimitExceeded = Reason{Code: "606"} ErrDailyQuotaReached = Reason{Code: "607"} ErrInvalidJSON = Reason{Code: "609"} ErrNotFound = Reason{Code: "610"} ErrSystemError = Reason{Code: "611"} ErrInvalidContentType = Reason{Code: "612"} ErrInvalidMultipart = Reason{Code: "613"} ErrInvalidSubscription = Reason{Code: "614"} ErrConcurrentLimitReached = Reason{Code: "615"} ErrInvalidSubscriptionType = Reason{Code: "616"} ErrCannotBeBlank = Reason{Code: "701"} ErrNoDataFound = Reason{Code: "702"} ErrFeatureNotEnabled = Reason{Code: "703"} ErrInvalidDateFormat = Reason{Code: "704"} ErrBusinessRuleViolation = Reason{Code: "709"} ErrParentFolderNotFound = Reason{Code: "710"} ErrIncompatibleFolderType = Reason{Code: "711"} ErrMergeOperationInvalid = Reason{Code: "712"} ErrTransientError = Reason{Code: "713"} ErrUnableToFindDefaultRecordType = Reason{Code: "714"} ErrExternalSalesPersonIDNotFound = Reason{Code: "718"} ErrTooManyImports = Reason{Code: "1016"} )
var ( Leads = ImportObject{ // contains filtered or unexported fields } )
Functions ¶
This section is empty.
Types ¶
type AuthToken ¶
type AuthToken struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn int `json:"expires_in"` Scope string `json:"scope"` }
AuthToken holds data from Auth request
type BatchResult ¶
type BatchResult struct { BatchID int `json:"batchId"` ImportID string `json:"importId"` Status string `json:"status"` LeadsProcessed int `json:"numOfLeadsProcessed,omitempty"` Failures int `json:"numOfRowsFailed"` Warnings int `json:"numOfRowsWithWarning"` Message string `json:"message"` ObjectsProcessed int `json:"numOfObjectsProcessed,omitempty"` ObjectName string `json:"objectApiName,omitempty"` Processed int `json:"-"` }
BatchResult contains the details of a batch, returned by the Create & Get functions
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client Marketo http Client
func NewClient ¶
func NewClient(config ClientConfig) (*Client, error)
NewClient returns a new Marketo Client
func (*Client) Delete ¶
Delete sends an HTTP DELETE request to specified resource url with given data
func (*Client) GetTokenInfo ¶
GetTokenInfo returns current TokenInfo stored in Client
func (*Client) RefreshToken ¶
RefreshToken refreshes the auth token. This is purely for testing purpose and not intended to be used.
type ClientConfig ¶
type ClientConfig struct { // ID: Marketo client ID ID string // Secret: Marketo client secret Secret string // Endpoint: https://xxx-xxx-xxx.mktorest.com Endpoint string // Timeout, optional: default http timeout is 60 seconds Timeout uint // Debug, optional: a flag to show logging output Debug bool // AuthTransport, optional: the HTTP RoundTripper to use when // making authentication calls to Marketo AuthTransport http.RoundTripper // RESTTransport, optional: the HTTP RoundTripper to use when // making calls to the REST API. RESTTransport http.RoundTripper }
ClientConfig stores client configuration
type CustomObjectMetadata ¶
type CustomObjectMetadata struct { IDField string `json:"idField"` APIName string `json:"name"` Description string `json:"description"` DisplayName string `json:"displayName"` PluralName string `json:"pluralName"` Fields []ObjectField `json:"fields"` SearchableFields [][]string `json:"searchableFields"` DedupeFields []string `json:"dedupeFields"` Relationships []ObjectRelation `json:"relationships"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` State ObjectState `json:"state"` Version ObjectVersion `json:"version"` }
type CustomObjectResult ¶
type CustomObjectResult struct { MarketoGUID string `json:"marketoGUID"` Sequence int `json:"seq"` Fields map[string]interface{} `json:"-" mapstructure:",remain"` }
CustomObjectResult contains a single record returned when filtering custom objects.
type CustomObjects ¶
type CustomObjects struct {
*Client
}
CustomObjects provides access to the Marketo custom objects API
func NewCustomObjectsAPI ¶
func NewCustomObjectsAPI(c *Client) *CustomObjects
NewCustomObjectsAPI returns a new instance of the
func (*CustomObjects) Describe ¶
func (c *CustomObjects) Describe(ctx context.Context, name string) (*CustomObjectMetadata, error)
Describe returns the description for the provided custom object
func (*CustomObjects) Filter ¶
func (c *CustomObjects) Filter(ctx context.Context, name string, opts ...QueryOption) ([]CustomObjectResult, string, error)
Filter queries Marketo for custom objects that match the provided filters.
func (*CustomObjects) List ¶
func (c *CustomObjects) List(ctx context.Context) ([]CustomObjectMetadata, error)
List returns the custom objects supported by the Marketo instance
type Error ¶
Error contains the error state returned from a Marketo operation
func ErrorForReasons ¶
ErrorForReasons returns a new Error wrapping the Reasons provided by the Marketo API
type ImportAPI ¶
type ImportAPI struct {
*Client
}
ImportAPI provides access to the Marketo import API
func NewImportAPI ¶
NewImportAPI returns a new instance of the import API, configured using the provided options
func (*ImportAPI) Create ¶
func (i *ImportAPI) Create(ctx context.Context, obj ImportObject, file io.Reader) ([]BatchResult, error)
Create uploads a new file for importing, returning the new asynchronous import
func (*ImportAPI) Failures ¶
func (i *ImportAPI) Failures(ctx context.Context, obj ImportObject, id int) ([]LeadImportFailure, error)
Failures returns the list of failed recrods for an import
func (*ImportAPI) Get ¶
func (i *ImportAPI) Get(ctx context.Context, obj ImportObject, id int) (*BatchResult, error)
Get retrieves an existing import by its batch ID
type ImportObject ¶
type ImportObject struct {
// contains filtered or unexported fields
}
func ImportObjectForAPIName ¶
func ImportObjectForAPIName(apiName string) ImportObject
ImportObjectForAPIName returns the ImportObject given the API name of a Marketo object
type LeadAPI ¶
type LeadAPI struct {
// contains filtered or unexported fields
}
LeadAPI provides access to the Marketo Lead API
func NewLeadAPI ¶
NewLeadAPI returns a new instance of the lead API, configured with the provided Client.
func (*LeadAPI) DescribeFields ¶
func (l *LeadAPI) DescribeFields(ctx context.Context) ([]LeadAttribute2, error)
DescribeFields fetches the Lead schema from Marketo and returns the set of attributes defined
func (*LeadAPI) Filter ¶
func (l *LeadAPI) Filter(ctx context.Context, opts ...QueryOption) ([]LeadResult, string, error)
Filter queries Marketo for one or more Leads, returning them if present
type LeadAttribute ¶
type LeadAttribute struct { DataType string `json:"dataType"` DisplayName string `json:"displayName"` ID int `json:"id"` Length int `json:"length"` REST LeadAttributeMap `json:"rest"` SOAP LeadAttributeMap `json:"soap"` }
LeadAttribute is returned by the Describe Leads endpoint
type LeadAttribute2 ¶
type LeadAttribute2 struct { Name string `json:"name,omitempty"` DisplayName string `json:"displayName,omitempty"` DataType string `json:"dataType,omitempty"` Length int `json:"length,omitempty"` Updateable bool `json:"updateable,omitempty"` CRMManaged bool `json:"crmManaged,omitempty"` Searchable bool `json:"searchable,omitempty"` }
LeadAttribute2 defines a lead attribute defined by the describe2.json endpoint.
type LeadAttributeMap ¶
LeadAttributeMap defines the name & readonly state of a Lead Attribute
type LeadImportFailure ¶
LeadImportFailure contains a single lead record failure, along with the reason for failure.
type LeadResult ¶
type LeadResult struct { ID int `json:"id" mapstructure:"id"` FirstName string `json:"firstName" mapstructure:"firstName"` LastName string `json:"lastName" mapstructure:"lastName"` Email string `json:"email" mapstructure:"email"` Created string `json:"createdAt" mapstructure:"createdAt"` Updated string `json:"updatedAt" mapstructure:"updatedAt"` Fields map[string]string `json:"-" mapstructure:",remain"` }
LeadResult default result struct
type ObjectField ¶
type ObjectRelation ¶
type ObjectRelation struct { Field string `json:"field"` RelatedTo RelatedObject `json:"relatedTo"` Type string `json:"type"` }
type ObjectState ¶
type ObjectState string
const ( ObjectStateDraft ObjectState = "draft" ObjectStateApproved ObjectState = "approved" ObjectStateApprovedWithDraft ObjectState = "approvedWithDraft" )
type ObjectVersion ¶
type ObjectVersion string
const ( DraftVersion ObjectVersion = "draft" ApprovedVersion ObjectVersion = "approved" )
type Query ¶
type Query struct { FilterField string `json:"filterType,omitempty"` FilterValues []string `json:"filterValues,omitempty"` Fields []string `json:"fields,omitempty"` BatchSize int `json:"batchSize,omitempty"` NextPageToken string `json:"nextPageToken,omitempty"` }
Query contains the possible parameters used when listing Marketo objects
type QueryOption ¶
type QueryOption func(*Query)
QueryOption defines the signature of functional options for Marketo Query APIs.
func FilterField ¶
func FilterField(field string) QueryOption
FilterField sets the field to search Marketo using
func FilterValues ¶
func FilterValues(values []string) QueryOption
FilterValues sets the possible values to match
func GetFields ¶
func GetFields(fields ...string) QueryOption
GetFields sets the fields to retrieve for matching records
type RecordResult ¶
type RecordResult struct { ID int `json:"id"` Status string `json:"status"` Reasons []Reason `json:"reasons,omitempty"` }
RecordResult holds Marketo record-level result
type RelatedObject ¶
type Response ¶
type Response struct { RequestID string `json:"requestId"` Success bool `json:"success"` NextPageToken string `json:"nextPageToken,omitempty"` MoreResult bool `json:"moreResult,omitempty"` Errors []Reason `json:"errors,omitempty"` Result json.RawMessage `json:"result,omitempty"` Warnings []Reason `json:"warning,omitempty"` }
Response is the common Marketo response which covers most of the Marketo response format