salesforce

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete added in v1.2.0

func Delete(ctx context.Context, h *RequestHelper, name, id string) error

Delete sends a delete request to salesforce to delete an object - uses the baseUrl, tokenGetter and http client on RequestHelper

func Patch

func Patch(ctx context.Context, h *RequestHelper, name, id string, record any) (int, error)

Patch sends a patch request to salesforce to update an object - uses the baseUrl, tokenGetter and http client on RequestHelper to query salesforce - returns the status code in the response, as patch requests could result in 200, 201 or 204

func Post added in v1.2.0

func Post(ctx context.Context, h *RequestHelper, name string, record any) (string, error)

Post sends a post request to salesforce to create an object - uses the baseUrl, tokenGetter and http client on RequestHelper - returns the id of the newly created object

Types

type Attributes

type Attributes struct {
	Type string `json:"type"`
	Url  string `json:"url"`
}

Attributes to be added, optionally, to concrete types of E for QueryResponse[E]

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type PostResponse added in v1.2.0

type PostResponse struct {
	Id      string `json:"id"`
	Success bool   `json:"success"`
}

PostResponse is the response from Salesforce for a post/create request

type QueryError

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

func (QueryError) Error

func (q QueryError) Error() string

type QueryResponse

type QueryResponse[E any] struct {
	TotalSize int  `json:"totalSize"`
	Done      bool `json:"done"`
	Records   []E  `json:"records"`
}

QueryResponse see https://ellogroup.atlassian.net/wiki/spaces/EP/pages/13402137/Salesforce+Package#QueryResponse%5BE-any%5D for more detail on below NB. if more models added here please update the above page

func Query

func Query[E any](ctx context.Context, h *RequestHelper, q string) (*QueryResponse[E], error)

Query salesforce in a generic way - uses the baseUrl, tokenGetter and http client on RequestHelper to query salesforce - QueryError returned if status code != 200 with status code of response

type RequestHelper

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

RequestHelper a helper struct for sending requests to salesforce for more on this see https://ellogroup.atlassian.net/wiki/spaces/EP/pages/13402137/Salesforce+Package

func NewRequestHelper

func NewRequestHelper(client HttpClient, tg TokenGetter, baseUrl string, apiVersion int) (*RequestHelper, error)

type TokenCache

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

func NewTokenCache

func NewTokenCache(p TokenParams) (*TokenCache, error)

NewTokenCache creates a default implementation of a salesforce token cache using async type of cache.KeylessRecordCache and storing in memory with driver.NewMemoryCache with a ~1 hour TTL/refresh rate (slightly less to unsure token doesn't expire before cache becomes stale) for more info see: https://ellogroup.atlassian.net/wiki/spaces/EP/pages/13402137/Salesforce+Package#TokenFetcher-and-TokenCache

func NewTokenCacheWithLogger

func NewTokenCacheWithLogger(p TokenParams, log *zap.Logger) (*TokenCache, error)

func (TokenCache) Get

func (tc TokenCache) Get(ctx context.Context) (string, error)

type TokenFetcher

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

func NewTokenFetcher

func NewTokenFetcher(p TokenParams) (*TokenFetcher, error)

func (TokenFetcher) Fetch

func (tf TokenFetcher) Fetch(_ context.Context) (string, error)

type TokenGetter

type TokenGetter interface {
	Get(ctx context.Context) (string, error)
}

type TokenParams

type TokenParams struct {
	HttpClient HttpClient             `validate:"required"`
	SMClient   *secretsmanager.Client `validate:"required"`
	SMKey      string                 `validate:"required"`
	Backoff    backoff.BackOff
}

Jump to

Keyboard shortcuts

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