salesforce

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMultipleExternalIDMatch  = Err("salesforce: external ID exists in more than one record")                      // 300
	ErrRequestContentNotChanged = Err("salesforce: request content has not changed since a specified date and time") // 304
	ErrBadRequest               = Err("salesforce: bad request")
	ErrUnauthorized             = Err("salesforce: unauthorized request")
	ErrForbidden                = Err("salesforce: forbidden")
	ErrMethodNotAllowed         = Err("salesforce: method not allowed")                              // 405
	ErrConflict                 = Err("salesforce: conflict with the current state of the resource") // 409
	ErrInternalError            = Err("salesforce: internal error")
	ErrUnknown                  = Err("salesforce: unexpected error occurred")
)

Error Constants Salesforce documents these as the error responses they will emit. For more detail see their docs: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/errorcodes.htm

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.

func Float64

func Float64(v float64) *float64

Float64 is a helper routine that allocates a new Float64 value to store v and returns a pointer to it.

func Int

func Int(v int) *int

Int is a helper routine that allocates a new int value to store v and returns a pointer to it.

func Int64

func Int64(v int64) *int64

Int64 is a helper routine that allocates a new int64 value to store v and returns a pointer to it.

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

Types

type AccountService

type AccountService struct {
	// contains filtered or unexported fields
}

AccountService represents the Account object

func (*AccountService) Describe

func (s *AccountService) Describe(ctx context.Context) (*DescribeResponse, error)

type BadRequestError

type BadRequestError struct {
	Message   string   `json:"message"`
	ErrorCode string   `json:"errorCode"`
	Fields    []string `json:"fields"`
}

BadRequestError represents the response sent by salesforce for a Bad Request 400 error

type BulkListResponse

type BulkListResponse struct {
	Done           bool      `json:"done"`
	NextRecordsURL string    `json:"nextRecordsUrl"`
	Records        []JobInfo `json:"records"`
}

BulkListResponse is the response from Salesforce listing the jobs

type BulkRequest

type BulkRequest struct {
	Object              string `json:"object,omitempty"`              // e.g. Account
	ContentType         string `json:"contentType,omitempty"`         // e.g. CSV
	Operation           string `json:"operation,omitempty"`           // e.g. insert,upsert,query
	LineEnding          string `json:"lineEnding,omitempty"`          // e.g. CRLF (windows). Default is LF
	ColumnDelimiter     string `json:"columnDelimiter,omitempty"`     // e.g. SEMICOLON. Default is COMMA
	ExternalIDFieldName string `json:"externalIdFieldName,omitempty"` // required only for Upserts
	Query               string `json:"query,omitempty"`               // required only for query operations
}

BulkRequest represents the object required to send when creating a Job Request

type BulkService

type BulkService struct {
	// contains filtered or unexported fields
}

BulkService represents the Bulk Service 2.0 API

func (*BulkService) CancelJob

func (s *BulkService) CancelJob(ctx context.Context, jobType BulkType, id string) (*JobInfo, error)

CancelJob allows you to cancel an existing job request

func (*BulkService) CreateJob

func (s *BulkService) CreateJob(ctx context.Context, br BulkRequest) (*JobInfo, error)

CreateJob allows you to create a new bulk job request

func (*BulkService) GetFailedResults

func (s *BulkService) GetFailedResults(ctx context.Context, jobType BulkType, id string) (string, error)

GetFailedResults will check the specified job id for errors

func (*BulkService) GetJob

func (s *BulkService) GetJob(ctx context.Context, jobType BulkType, id string) (*JobInfo, error)

GetJob allows you to get details for a specific job id

func (*BulkService) GetSuccessfulResults

func (s *BulkService) GetSuccessfulResults(ctx context.Context, jobType BulkType, id string) (string, error)

GetSuccessfulResults will check the specified job id for errors

func (*BulkService) ListJobs

func (s *BulkService) ListJobs(ctx context.Context, jobType BulkType) (*BulkListResponse, error)

ListJobs lists the first 1000 jobs of type BulkType TODO: Add option to list all? https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/get_all_jobs.htm

func (*BulkService) ProcessJob

func (s *BulkService) ProcessJob(ctx context.Context, jobType BulkType, id string) (*JobInfo, error)

ProcessJob marks a job as UploadComplete and begins processing

func (*BulkService) UploadCSV

func (s *BulkService) UploadCSV(ctx context.Context, id string, payload io.Reader) error

UploadCSV will upload CSV data from the provided io.Reader to the provided job id You must remember to begin processing the job and then check it for success/errors. Note that only a single upload/batch is currently supported.

type BulkType

type BulkType int

BulkType represents the type of bulk operation required for bulk operations for example ingest or query

const (
	// BulkTypeIngest represents the ingest bulk type
	BulkTypeIngest BulkType = iota + 1
	// BulkTypeQuery represents the query bulk type
	BulkTypeQuery
)

func (BulkType) EnumIndex

func (b BulkType) EnumIndex() int

EnumIndex provides the index for a given bulk type

func (BulkType) String

func (b BulkType) String() string

type Client

type Client struct {
	// BaseURL for the API.  Set using `salesforce.New()`.
	BaseURL string

	// Version of the API to use.  Default is v53.0. Other versions haven't been tested.
	// Set the Version field after initialising with New.
	Version string

	//HTTP Client to use for making requests, allowing the user to supply their own if required.
	HTTPClient *http.Client

	// BulkService represents the Bulk 2.0 API
	BulkService *BulkService
	// AccountService represents the Account object
	AccountService *AccountService
	// ContactService represents the Contact object
	ContactService *ContactService
	// OpportunityService represents the Opportunity object
	OpportunityService *OpportunityService
	// UserService represents the User object
	UserService *UserService
	// contains filtered or unexported fields
}

Client is the main salesforce client for interacting with the library. It can be created using NewClient

func NewClient

func NewClient(baseURL, username, password, clientID, secret string, client *http.Client) (*Client, error)

NewClient is a helper function that returns an new salesforce client given the required parameters. Optionally you can provide your own http client or use nil to use the default. This is done to ensure you're aware of the decision you're making to not provide your own http client.

func (*Client) Describe

func (c *Client) Describe(ctx context.Context, object string) (*DescribeResponse, error)

type ContactService

type ContactService struct {
	// contains filtered or unexported fields
}

ContactService represents the Contact object

func (*ContactService) Describe

func (s *ContactService) Describe(ctx context.Context) (*DescribeResponse, error)

type DescribeResponse

type DescribeResponse struct {
	Fields []struct {
		Aggregatable             bool        `json:"aggregatable"`
		AiPredictionField        bool        `json:"aiPredictionField"`
		AutoNumber               bool        `json:"autoNumber"`
		ByteLength               int         `json:"byteLength"`
		Calculated               bool        `json:"calculated"`
		CalculatedFormula        string      `json:"calculatedFormula"`
		CascadeDelete            bool        `json:"cascadeDelete"`
		CaseSensitive            bool        `json:"caseSensitive"`
		CompoundFieldName        string      `json:"compoundFieldName"`
		ControllerName           string      `json:"controllerName"`
		Createable               bool        `json:"createable"`
		Custom                   bool        `json:"custom"`
		DefaultValue             interface{} `json:"defaultValue"`
		DefaultValueFormula      string      `json:"defaultValueFormula"`
		DefaultedOnCreate        bool        `json:"defaultedOnCreate"`
		DependentPicklist        bool        `json:"dependentPicklist"`
		DeprecatedAndHidden      bool        `json:"deprecatedAndHidden"`
		Digits                   int         `json:"digits"`
		DisplayLocationInDecimal bool        `json:"displayLocationInDecimal"`
		Encrypted                bool        `json:"encrypted"`
		ExternalID               bool        `json:"externalId"`
		ExtraTypeInfo            string      `json:"extraTypeInfo"`
		Filterable               bool        `json:"filterable"`
		// FilteredLookupInfo           interface{} `json:"filteredLookupInfo"`
		FormulaTreatNullNumberAsZero bool   `json:"formulaTreatNullNumberAsZero"`
		Groupable                    bool   `json:"groupable"`
		HighScaleNumber              bool   `json:"highScaleNumber"`
		HTMLFormatted                bool   `json:"htmlFormatted"`
		IDLookup                     bool   `json:"idLookup"`
		InlineHelpText               string `json:"inlineHelpText"`
		Label                        string `json:"label"`
		Length                       int    `json:"length"`
		// Mask                         interface{} `json:"mask"`
		// MaskType                     interface{} `json:"maskType"`
		Name           string `json:"name"`
		NameField      bool   `json:"nameField"`
		NamePointing   bool   `json:"namePointing"`
		Nillable       bool   `json:"nillable"`
		Permissionable bool   `json:"permissionable"`
		PicklistValues []struct {
			Active       bool   `json:"active"`
			DefaultValue bool   `json:"defaultValue"`
			Label        string `json:"label"`
			ValidFor     string `json:"validFor"`
			Value        string `json:"value"`
		} `json:"picklistValues"`
		PolymorphicForeignKey bool `json:"polymorphicForeignKey"`
		Precision             int  `json:"precision"`
		QueryByDistance       bool `json:"queryByDistance"`
		// ReferenceTargetField    interface{}   `json:"referenceTargetField"`
		ReferenceTo      []string `json:"referenceTo"`
		RelationshipName string   `json:"relationshipName"`
		// RelationshipOrder       interface{} `json:"relationshipOrder"`
		RestrictedDelete        bool   `json:"restrictedDelete"`
		RestrictedPicklist      bool   `json:"restrictedPicklist"`
		Scale                   int    `json:"scale"`
		SearchPrefilterable     bool   `json:"searchPrefilterable"`
		SoapType                string `json:"soapType"`
		Sortable                bool   `json:"sortable"`
		Type                    string `json:"type"`
		Unique                  bool   `json:"unique"`
		Updateable              bool   `json:"updateable"`
		WriteRequiresMasterRead bool   `json:"writeRequiresMasterRead"`
	} `json:"fields"`
	IsSubtype       bool   `json:"isSubtype"`
	KeyPrefix       string `json:"keyPrefix"`
	Label           string `json:"label"`
	LabelPlural     string `json:"labelPlural"`
	Name            string `json:"name"`
	Queryable       bool   `json:"queryable"`
	RecordTypeInfos []struct {
		Active                   bool   `json:"active"`
		Available                bool   `json:"available"`
		DefaultRecordTypeMapping bool   `json:"defaultRecordTypeMapping"`
		DeveloperName            string `json:"developerName"`
		Master                   bool   `json:"master"`
		Name                     string `json:"name"`
		RecordTypeID             string `json:"recordTypeId"`
		Urls                     struct {
			Layout string `json:"layout"`
		} `json:"urls"`
	} `json:"recordTypeInfos"`
	Replicateable         bool   `json:"replicateable"`
	Retrieveable          bool   `json:"retrieveable"`
	SearchLayoutable      bool   `json:"searchLayoutable"`
	Searchable            bool   `json:"searchable"`
	SobjectDescribeOption string `json:"sobjectDescribeOption"`
	SupportedScopes       []struct {
		Label string `json:"label"`
		Name  string `json:"name"`
	} `json:"supportedScopes"`
	Triggerable bool `json:"triggerable"`
	Undeletable bool `json:"undeletable"`
	Updateable  bool `json:"updateable"`
	Urls        struct {
		CompactLayouts   string `json:"compactLayouts"`
		RowTemplate      string `json:"rowTemplate"`
		ApprovalLayouts  string `json:"approvalLayouts"`
		UIDetailTemplate string `json:"uiDetailTemplate"`
		UIEditTemplate   string `json:"uiEditTemplate"`
		Listviews        string `json:"listviews"`
		Describe         string `json:"describe"`
		UINewRecord      string `json:"uiNewRecord"`
		QuickActions     string `json:"quickActions"`
		Layouts          string `json:"layouts"`
		Sobject          string `json:"sobject"`
	} `json:"urls"`
}

DescribeResponse represents the fields for describing an object. Note that not all fields are provided here. Feel free to add extra fields if you need them.

type Err

type Err string

Err implements the error interface so we can have constant errors.

func (Err) Error

func (e Err) Error() string

type JobInfo

type JobInfo struct {
	ID                     string  `json:"id"`
	Operation              string  `json:"operation"`
	Object                 string  `json:"object"`
	CreatedByID            string  `json:"createdById"`
	CreatedDate            string  `json:"createdDate"`
	SystemModstamp         string  `json:"systemModstamp"`
	State                  string  `json:"state"`
	ConcurrencyMode        string  `json:"concurrencyMode"`
	ContentType            string  `json:"contentType"`
	APIVersion             float64 `json:"apiVersion"`
	JobType                string  `json:"jobType"`
	LineEnding             string  `json:"lineEnding"`
	ColumnDelimiter        string  `json:"columnDelimiter"`
	NumberRecordsProcessed int     `json:"numberRecordsProcessed"`
	NumberRecordsFailed    int     `json:"numberRecordsFailed"`
	Retries                int     `json:"retries"`
}

JobInfo represents a specific Job

type OpportunityService

type OpportunityService struct {
	// contains filtered or unexported fields
}

OpportunityService represents the Opportunity object

func (*OpportunityService) Describe

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

UserService represents the User object

func (*UserService) Describe

func (s *UserService) Describe(ctx context.Context) (*DescribeResponse, error)

Jump to

Keyboard shortcuts

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