batch

package
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: MIT Imports: 7 Imported by: 0

README

Composite Batch API

back

The batch package is an implementation of Salesforce APIs centered on Composite Batch operations. These operations include:

  • Limits Resources
  • SObject Resources
  • Query All
  • Query
  • Search
  • Connect Resources
  • Chatter Resources

As a reference, see Salesforce API documentation

Examples

The following are examples to access the APIs. It is assumed that a sfdc session has been created.

Subrequest
type batchSubrequester struct {
	url             string
	method          string
	richInput       map[string]interface{}
	binaryPartName  string
	binaryPartAlais string
}

func (b *batchSubrequester) URL() string {
	return b.url
}
func (b *batchSubrequester) Method() string {
	return b.method
}
func (b *batchSubrequester) BinaryPartName() string {
	return b.binaryPartName
}
func (b *batchSubrequester) BinaryPartNameAlias() string {
	return b.binaryPartAlais
}
func (b *batchSubrequester) RichInput() map[string]interface{} {
	return b.richInput
}
Composite Batch
	subRequests := []batch.Subrequester{
		&batchSubrequester{
			url:    "v44.0/sobjects/Account/0012E00001qLpKZQA0",
			method: http.MethodPatch,
			richInput: map[string]interface{}{
				"Name": "NewName",
			},
		},
		&batchSubrequester{
			url:    "v44.0/sobjects/Account/0012E00001qLpKZQA0",
			method: http.MethodGet,
		},
	}

	resource, err := batch.NewResource(session)
	if err != nil {
		fmt.Printf("Batch Composite Error %s\n", err.Error())
		return
	}
	value, err := resource.Retrieve(false, subRequests)
	if err != nil {
		fmt.Printf("Batch Composite Error %s\n", err.Error())
		return
	}

	fmt.Printf("%+v\n", value)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resource

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

Resource is the structure that can be just to call composite batch APIs.

func NewResource

func NewResource(session session.ServiceFormatter) (*Resource, error)

NewResource creates a new resourse with the session. If the session is nil an error will be returned.

func (*Resource) Retrieve

func (r *Resource) Retrieve(haltOnError bool, requesters []Subrequester) (Value, error)

Retrieve will retrieve the responses to a composite batch requests. The order of the array is the order in which the subrequests are placed in the composite batch body.

type Subrequester

type Subrequester interface {
	URL() string
	Method() string
	BinaryPartName() string
	BinaryPartNameAlias() string
	RichInput() map[string]interface{}
}

Subrequester provides the composite batch API requests.

type Subvalue

type Subvalue struct {
	Result     interface{} `json:"result"`
	StatusCode int         `json:"statusCode"`
}

Subvalue is the subresponses to the composite batch API.

type Value

type Value struct {
	HasErrors bool       `json:"hasErrors"`
	Results   []Subvalue `json:"results"`
}

Value is the returned structure from the composite batch API response.

Jump to

Keyboard shortcuts

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