salesforce

package
v0.0.0-...-1dcf465 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Insert BulkOperationMode = "insert"
	Upsert BulkOperationMode = "upsert"
	Update BulkOperationMode = "update"
	Delete BulkOperationMode = "delete"

	JobStateAborted        = "Aborted"
	JobStateFailed         = "Failed"
	JobStateComplete       = "JobComplete"
	JobStateInProgress     = "InProgress"
	JobStateUploadComplete = "UploadComplete"
)
View Source
const (
	True  string = "true"
	False string = "false"
)

Variables

View Source
var (
	ErrKeyNotFound          = errors.New("key not found")
	ErrUnknownNodeType      = errors.New("unknown node type when parsing JSON")
	ErrInvalidType          = errors.New("invalid type")
	ErrInvalidJobState      = errors.New("invalid job state")
	ErrUnsupportedMode      = errors.New("unsupported mode")
	ErrReadToByteFailed     = errors.New("failed to read data to bytes")
	ErrUnsupportedOperation = errors.New("unsupported operation")
)
View Source
var (
	ErrNotArray           = errors.New("records is not an array")
	ErrNotObject          = errors.New("record isn't an object")
	ErrNoFields           = errors.New("no fields specified")
	ErrNotString          = errors.New("nextRecordsUrl isn't a string")
	ErrNotBool            = errors.New("done isn't a boolean")
	ErrNotNumeric         = errors.New("totalSize isn't numeric")
	ErrMissingWorkspace   = errors.New("missing Salesforce workspace name")
	ErrMissingClient      = errors.New("JSON http client not set")
	ErrCannotReadMetadata = errors.New("cannot read object metadata, it is possible you don't have the correct permissions set") // nolint:lll
)
View Source
var (
	ErrCreateMetadata  = errors.New("error in CreateMetadata")
	ErrCreatingRequest = errors.New("error in creating request")
	ErrBadRequest      = errors.New("bad request")
)

Functions

func APIVersion

func APIVersion() string

func APIVersionSOAP

func APIVersionSOAP() string

func GetRemoteResource

func GetRemoteResource(orgId, channelId string) string

func GetTokenUpdater

func GetTokenUpdater(tok *oauth2.Token) common.OAuthOption

Types

type BoolString

type BoolString string

type BulkOperationMode

type BulkOperationMode string

type BulkOperationParams

type BulkOperationParams struct {
	// The name of the object we are writing, e.g. "Account"
	ObjectName string // required

	// The name of a field on the object which is an External ID. Provided in the case of upserts, not inserts
	ExternalIdField string // required

	// The path to the CSV file we are writing
	CSVData io.Reader // required

	// Salesforce operation mode
	Mode BulkOperationMode
}

BulkOperationParams defines how we are writing data to a SaaS API.

type BulkOperationResult

type BulkOperationResult struct {
	// State is the state of the bulk job process
	State string `json:"state"`
	// JobId is the ID of the bulk job process
	JobId string `json:"jobId"`
}

BulkOperation is what's returned from writing data via the BulkOperation call.

type CalloutOptions

type CalloutOptions struct {
	AllowMergeFieldsInBody      bool `json:"allowMergeFieldsInBody"`
	AllowMergeFieldsInHeader    bool `json:"allowMergeFieldsInHeader"`
	GenerateAuthorizationHeader bool `json:"generateAuthorizationHeader"`
}

type Connector

type Connector struct {
	Domain  string
	BaseURL string
	Client  *common.JSONHTTPClient
}

Connector is a Salesforce connector.

func NewConnector

func NewConnector(opts ...Option) (conn *Connector, outErr error)

NewConnector returns a new Salesforce connector.

func (*Connector) BulkDelete

func (c *Connector) BulkDelete(ctx context.Context, params BulkOperationParams) (*BulkOperationResult, error)

func (*Connector) BulkQuery

func (c *Connector) BulkQuery(
	ctx context.Context,
	query string,
) (*GetJobInfoResult, error)

func (*Connector) BulkWrite

func (c *Connector) BulkWrite(
	ctx context.Context,
	config BulkOperationParams,
) (*BulkOperationResult, error)

func (*Connector) Close

func (c *Connector) Close() error

func (*Connector) CreateMetadata

func (c *Connector) CreateMetadata(
	ctx context.Context,
	metadata *xmldom.Node,
	tok *oauth2.Token,
) (string, error)

func (*Connector) GetBulkQueryInfo

func (c *Connector) GetBulkQueryInfo(
	ctx context.Context,
	jobId string,
) (*GetJobInfoResult, error)

func (*Connector) GetBulkQueryResults

func (c *Connector) GetBulkQueryResults(
	ctx context.Context,
	jobId string,
) (*http.Response, error)

func (*Connector) GetJobInfo

func (c *Connector) GetJobInfo(ctx context.Context, jobId string) (*GetJobInfoResult, error)

func (*Connector) GetJobResults

func (c *Connector) GetJobResults(ctx context.Context, jobId string) (*JobResults, error)

func (*Connector) GetOrganizationId

func (c *Connector) GetOrganizationId(ctx context.Context) (string, error)

func (*Connector) GetSuccessfulJobResults

func (c *Connector) GetSuccessfulJobResults(ctx context.Context, jobId string) (*http.Response, error)

func (*Connector) HTTPClient

func (c *Connector) HTTPClient() *common.HTTPClient

func (*Connector) JSONHTTPClient

func (c *Connector) JSONHTTPClient() *common.JSONHTTPClient

JSONHTTPClient returns the underlying JSON HTTP client.

func (*Connector) ListObjectMetadata

func (c *Connector) ListObjectMetadata(
	ctx context.Context,
	objectNames []string,
) (*common.ListObjectMetadataResult, error)

ListObjectMetadata returns object metadata for each object name provided.

func (*Connector) Provider

func (c *Connector) Provider() providers.Provider

Provider returns the connector provider.

func (*Connector) Read

func (c *Connector) Read(ctx context.Context, config common.ReadParams) (*common.ReadResult, error)

Read reads data from Salesforce. By default it will read all rows (backfill). However, if Since is set, it will read only rows that have been updated since the specified time.

func (*Connector) String

func (c *Connector) String() string

String returns a string representation of the connector, which is useful for logging / debugging.

func (*Connector) Write

func (c *Connector) Write(ctx context.Context, config common.WriteParams) (*common.WriteResult, error)

Write will write data to Salesforce.

type Credential

type Credential interface {
	DestinationResourceName() string
}

type EventChannel

type EventChannel struct {
	Id       string                `json:"Id,omitempty"`
	FullName string                `json:"FullName"`
	Metadata *EventChannelMetadata `json:"Metadata"`
}

nolint:tagliatelle

type EventChannelMember

type EventChannelMember struct {
	Id       string                      `json:"Id,omitempty"`
	FullName string                      `json:"FullName"`
	Metadata *EventChannelMemberMetadata `json:"Metadata"`
}

nolint:tagliatelle

type EventChannelMemberMetadata

type EventChannelMemberMetadata struct {
	EventChannel   string `json:"eventChannel"`
	SelectedEntity string `json:"selectedEntity,omitempty"`
}

type EventChannelMetadata

type EventChannelMetadata struct {
	ChannelType string `json:"channelType"`
	Label       string `json:"label"`
}

type EventRelayConfig

type EventRelayConfig struct {
	Id                      string                    `json:"Id,omitempty"`
	FullName                string                    `json:"FullName,omitempty"`
	Metadata                *EventRelayConfigMetadata `json:"Metadata,omitempty"`
	DeveloperName           string                    `json:"DeveloperName,omitempty"`
	DestinationResourceName string                    `json:"DestinationResourceName,omitempty"`
	EventChannel            string                    `json:"EventChannel,omitempty"`
}

nolint:tagliatelle

type EventRelayConfigMetadata

type EventRelayConfigMetadata struct {
	DestinationResourceName string `json:"destinationResourceName,omitempty"`
	EventChannel            string `json:"eventChannel,omitempty"`
	State                   string `json:"state,omitempty"`
}

type FailInfo

type FailInfo struct {
	FailureType   string              `json:"failureType"`
	FailedUpdates map[string][]string `json:"failedUpdates,omitempty"`
	FailedCreates map[string][]string `json:"failedCreates,omitempty"`
	Reason        string              `json:"reason,omitempty"`
}

type GetJobInfoResult

type GetJobInfoResult struct {
	Id                     string  `json:"id"`
	Object                 string  `json:"object"`
	CreatedById            string  `json:"createdById"`
	ExternalIdFieldName    string  `json:"externalIdFieldName,omitempty"`
	State                  string  `json:"state"`
	Operation              string  `json:"operation"`
	ColumnDelimiter        string  `json:"columnDelimiter"`
	LineEnding             string  `json:"lineEnding"`
	NumberRecordsFailed    float64 `json:"numberRecordsFailed"`
	NumberRecordsProcessed float64 `json:"numberRecordsProcessed"`
	ErrorMessage           string  `json:"errorMessage"`

	ApexProcessingTime      float64 `json:"apexProcessingTime,omitempty"`
	ApiActiveProcessingTime float64 `json:"apiActiveProcessingTime,omitempty"`
	ApiVersion              float64 `json:"apiVersion,omitempty"`
	ConcurrencyMode         string  `json:"concurrencyMode,omitempty"`
	ContentType             string  `json:"contentType,omitempty"`
	CreatedDate             string  `json:"createdDate,omitempty"`
	JobType                 string  `json:"jobType,omitempty"`
	Retries                 float64 `json:"retries,omitempty"`
	SystemModstamp          string  `json:"systemModstamp,omitempty"`
	TotalProcessingTime     float64 `json:"totalProcessingTime,omitempty"`
	IsPkChunkingSupported   bool    `json:"isPkChunkingSupported,omitempty"`
}

type JobResults

type JobResults struct {
	JobId          string            `json:"jobId"`
	State          string            `json:"state"`
	FailureDetails *FailInfo         `json:"failureDetails,omitempty"`
	JobInfo        *GetJobInfoResult `json:"jobInfo,omitempty"`
	Message        string            `json:"message,omitempty"`
}

type NamedCredential

type NamedCredential struct {
	FullName string                   `json:"FullName"`
	Metadata *NamedCredentialMetadata `json:"Metadata"`

	// below exist in response, but not in request
	Id string `json:"Id,omitempty"`
}

nolint:tagliatelle

func (*NamedCredential) DestinationResourceName

func (n *NamedCredential) DestinationResourceName() string

type NamedCredentialMetadata

type NamedCredentialMetadata struct {
	AllowMergeFieldsInBody      bool                        `json:"allowMergeFieldsInBody,omitempty"`
	AllowMergeFieldsInHeader    bool                        `json:"allowMergeFieldsInHeader,omitempty"`
	GenerateAuthorizationHeader bool                        `json:"generateAuthorizationHeader,omitempty"`
	FullName                    string                      `json:"fullName,omitempty"                    validate:"required"`
	Label                       string                      `json:"label,omitempty"`
	NamedCredentialParameters   []*NamedCredentialParameter `json:"namedCredentialParameters,omitempty"`
	NamedCredentialType         string                      `json:"namedCredentialType,omitempty"`

	// Below are deprecated fields, but still in use in SF
	AuthProvider             string `json:"authProvider,omitempty"`
	AuthTokenEndpointUrl     string `json:"authTokenEndpointUrl,omitempty"` // nolint: revive
	AwsAccessKey             string `json:"awsAccessKey,omitempty"`
	AwsAccessSecret          string `json:"awsAccessSecret,omitempty"`
	AwsRegion                string `json:"awsRegion,omitempty"`
	AwsService               string `json:"awsService,omitempty"`
	Certificate              string `json:"certificate,omitempty"`
	Endpoint                 string `json:"endpoint,omitempty"`
	JwtAudience              string `json:"jwtAudience,omitempty"`
	JwtFormulaSubject        string `json:"jwtFormulaSubject,omitempty"`
	JwtIssuer                string `json:"jwtIssuer,omitempty"`
	JwtSigningCertificate    string `json:"jwtSigningCertificate,omitempty"`
	JwtTextSubject           string `json:"jwtTextSubject,omitempty"`
	JwtValidityPeriodSeconds int    `json:"jwtValidityPeriodSeconds,omitempty"`
	OauthRefreshToken        string `json:"oauthRefreshToken,omitempty"`
	OauthScope               string `json:"oauthScope,omitempty"`
	OauthToken               string `json:"oauthToken,omitempty"`
	Password                 string `json:"password,omitempty"`
	PrincipalType            string `json:"principalType,omitempty"`
	Protocol                 string `json:"protocol,omitempty"`
	Username                 string `json:"username,omitempty"`
}

nolint: lll

type NamedCredentialParameter

type NamedCredentialParameter struct {
	Certificate               string `json:"certificate"`
	Description               string `json:"description"`
	ExternalCredential        string `json:"externalCredential"`
	OutboundNetworkConnection string `json:"outboundNetworkConnection"`
	ParameterName             string `json:"parameterName"`
	ParameterType             string `json:"parameterType"`
	ParameterValue            string `json:"parameterValue"`
	SequenceNumber            int    `json:"sequenceNumber"`
}

type NamedCredentialParameterType

type NamedCredentialParameterType string
const (
	AllowedManagedPackageNamespaces NamedCredentialParameterType = "AllowedManagedPackageNamespaces"
	ClientCertificate               NamedCredentialParameterType = "ClientCertificate"
	HttpHeader                      NamedCredentialParameterType = "HttpHeader"
	OutboundNetworkConnection       NamedCredentialParameterType = "OutboundNetworkConnection"
	Url                             NamedCredentialParameterType = "Url"
)

nolint: revive

type Option

type Option func(params *sfParams)

Option is a function which mutates the salesforce connector configuration.

func WithAuthenticatedClient

func WithAuthenticatedClient(client common.AuthenticatedHTTPClient) Option

WithAuthenticatedClient sets the http client to use for the connector. Its usage is optional.

func WithClient

func WithClient(ctx context.Context, client *http.Client, config *oauth2.Config, token *oauth2.Token,
	opts ...common.OAuthOption,
) Option

WithClient sets the http client to use for the connector. Saves some boilerplate.

func WithWorkspace

func WithWorkspace(workspaceRef string) Option

WithWorkspace sets the salesforce workspace to use for the connector. It's required.

type SFAPIResponseBody

type SFAPIResponseBody struct {
	Id       string        `json:"id"`
	Success  bool          `json:"success"`
	Errors   []interface{} `json:"errors"`
	Infos    []interface{} `json:"infos"`
	Warnings []interface{} `json:"warnings"`
}

type ToolingApiBaseParams

type ToolingApiBaseParams struct {
	DeveloperName   string `json:"DeveloperName,omitempty"`
	Language        string `json:"Language,omitempty"`
	ManageableState string `json:"ManageableState,omitempty"`
	MasterLabel     string `json:"MasterLabel,omitempty"`
	NamespacePrefix string `json:"NamespacePrefix,omitempty"`
}

nolint: tagliatelle

Jump to

Keyboard shortcuts

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