Documentation
¶
Overview ¶
Package sobjects provides SObject CRUD operations for Salesforce.
Index ¶
- type Attributes
- type ChildRelation
- type CreateResult
- type DeletedRecord
- type DeletedRecords
- type Error
- type FieldMetadata
- type GlobalDescribe
- type HTTPClient
- type Metadata
- type PicklistValue
- type RecordTypeInfo
- type SObject
- func (s *SObject) Attributes() *Attributes
- func (s *SObject) BoolField(key string) bool
- func (s *SObject) FloatField(key string) float64
- func (s *SObject) Get(key string) interface{}
- func (s *SObject) ID() string
- func (s *SObject) IntField(key string) int
- func (s *SObject) MarshalJSON() ([]byte, error)
- func (s *SObject) Related(key string) *SObject
- func (s *SObject) RelatedList(key string) []*SObject
- func (s *SObject) Set(key string, value interface{}) *SObject
- func (s *SObject) StringField(key string) string
- func (s *SObject) TimeField(key string) time.Time
- func (s *SObject) ToCreatePayload() map[string]interface{}
- func (s *SObject) ToMap() map[string]interface{}
- func (s *SObject) Type() string
- func (s *SObject) UnmarshalJSON(data []byte) error
- type Service
- func (s *Service) Create(ctx context.Context, objectType string, data map[string]interface{}) (*CreateResult, error)
- func (s *Service) Delete(ctx context.Context, objectType, id string) error
- func (s *Service) Describe(ctx context.Context, objectType string) (*Metadata, error)
- func (s *Service) DescribeGlobal(ctx context.Context) (*GlobalDescribe, error)
- func (s *Service) Get(ctx context.Context, objectType, id string, fields ...string) (*SObject, error)
- func (s *Service) GetByExternalID(ctx context.Context, objectType, extIDField, extID string) (*SObject, error)
- func (s *Service) GetDeleted(ctx context.Context, objectType string, start, end time.Time) (*DeletedRecords, error)
- func (s *Service) GetUpdated(ctx context.Context, objectType string, start, end time.Time) (*UpdatedRecords, error)
- func (s *Service) Update(ctx context.Context, objectType, id string, data map[string]interface{}) error
- func (s *Service) Upsert(ctx context.Context, objectType, extIDField, extID string, ...) (*CreateResult, error)
- type UpdatedRecords
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attributes ¶
Attributes contains SObject metadata.
type ChildRelation ¶
type ChildRelation struct {
ChildSObject string `json:"childSObject"`
Field string `json:"field"`
RelationshipName string `json:"relationshipName"`
CascadeDelete bool `json:"cascadeDelete"`
RestrictedDelete bool `json:"restrictedDelete"`
DeprecatedAndHidden bool `json:"deprecatedAndHidden"`
}
ChildRelation describes a child relationship.
type CreateResult ¶
type CreateResult struct {
ID string `json:"id"`
Success bool `json:"success"`
Errors []Error `json:"errors,omitempty"`
}
CreateResult contains the result of a create operation.
type DeletedRecord ¶
DeletedRecord represents a deleted record.
type DeletedRecords ¶
type DeletedRecords struct {
DeletedRecords []DeletedRecord `json:"deletedRecords"`
EarliestDateAvailable string `json:"earliestDateAvailable"`
LatestDateCovered string `json:"latestDateCovered"`
}
DeletedRecords contains deleted record information.
type Error ¶
type Error struct {
StatusCode string `json:"statusCode"`
Message string `json:"message"`
Fields []string `json:"fields,omitempty"`
}
Error represents an operation error.
type FieldMetadata ¶
type FieldMetadata struct {
Name string `json:"name"`
Label string `json:"label"`
Type string `json:"type"`
Length int `json:"length"`
Precision int `json:"precision"`
Scale int `json:"scale"`
Createable bool `json:"createable"`
Updateable bool `json:"updateable"`
Nillable bool `json:"nillable"`
Unique bool `json:"unique"`
Custom bool `json:"custom"`
ExternalId bool `json:"externalId"`
AutoNumber bool `json:"autoNumber"`
Calculated bool `json:"calculated"`
NameField bool `json:"nameField"`
IdLookup bool `json:"idLookup"`
DefaultValue interface{} `json:"defaultValue"`
ReferenceTo []string `json:"referenceTo,omitempty"`
RelationshipName string `json:"relationshipName,omitempty"`
PicklistValues []PicklistValue `json:"picklistValues,omitempty"`
}
FieldMetadata describes a field.
type GlobalDescribe ¶
type GlobalDescribe struct {
Encoding string `json:"encoding"`
MaxBatchSize int `json:"maxBatchSize"`
SObjects []Metadata `json:"sobjects"`
}
GlobalDescribe contains all accessible SObjects.
type HTTPClient ¶
type HTTPClient interface {
Get(ctx context.Context, path string) ([]byte, error)
Post(ctx context.Context, path string, body interface{}) ([]byte, error)
Patch(ctx context.Context, path string, body interface{}) ([]byte, error)
Put(ctx context.Context, path string, body interface{}) ([]byte, error)
Delete(ctx context.Context, path string) ([]byte, error)
}
HTTPClient interface for dependency injection.
type Metadata ¶
type Metadata struct {
Name string `json:"name"`
Label string `json:"label"`
LabelPlural string `json:"labelPlural"`
KeyPrefix string `json:"keyPrefix"`
Createable bool `json:"createable"`
Updateable bool `json:"updateable"`
Deletable bool `json:"deletable"`
Queryable bool `json:"queryable"`
Searchable bool `json:"searchable"`
Retrieveable bool `json:"retrieveable"`
Undeletable bool `json:"undeletable"`
Mergeable bool `json:"mergeable"`
Replicateable bool `json:"replicateable"`
Triggerable bool `json:"triggerable"`
FeedEnabled bool `json:"feedEnabled"`
HasSubtypes bool `json:"hasSubtypes"`
IsSubtype bool `json:"isSubtype"`
Custom bool `json:"custom"`
CustomSetting bool `json:"customSetting"`
Fields []FieldMetadata `json:"fields,omitempty"`
ChildRelationships []ChildRelation `json:"childRelationships,omitempty"`
RecordTypeInfos []RecordTypeInfo `json:"recordTypeInfos,omitempty"`
}
Metadata contains SObject describe information.
type PicklistValue ¶
type PicklistValue struct {
Active bool `json:"active"`
DefaultValue bool `json:"defaultValue"`
Label string `json:"label"`
Value string `json:"value"`
}
PicklistValue represents a picklist option.
type RecordTypeInfo ¶
type RecordTypeInfo struct {
Name string `json:"name"`
RecordTypeId string `json:"recordTypeId"`
Available bool `json:"available"`
DefaultRecordTypeMapping bool `json:"defaultRecordTypeMapping"`
Master bool `json:"master"`
}
RecordTypeInfo describes a record type.
type SObject ¶
type SObject struct {
// contains filtered or unexported fields
}
SObject represents a Salesforce SObject record.
func (*SObject) Attributes ¶
func (s *SObject) Attributes() *Attributes
Attributes returns the SObject attributes.
func (*SObject) FloatField ¶
FloatField returns a field as float64.
func (*SObject) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*SObject) RelatedList ¶
RelatedList returns a list of related SObjects.
func (*SObject) StringField ¶
StringField returns a field as string.
func (*SObject) ToCreatePayload ¶
ToCreatePayload returns fields suitable for create/update.
func (*SObject) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides SObject CRUD operations.
func NewService ¶
func NewService(client HTTPClient, apiVersion string) *Service
NewService creates a new SObject service.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, objectType string, data map[string]interface{}) (*CreateResult, error)
Create creates a new SObject record.
func (*Service) DescribeGlobal ¶
func (s *Service) DescribeGlobal(ctx context.Context) (*GlobalDescribe, error)
DescribeGlobal returns all accessible SObject types.
func (*Service) Get ¶
func (s *Service) Get(ctx context.Context, objectType, id string, fields ...string) (*SObject, error)
Get retrieves an SObject by ID.
func (*Service) GetByExternalID ¶
func (s *Service) GetByExternalID(ctx context.Context, objectType, extIDField, extID string) (*SObject, error)
GetByExternalID retrieves an SObject by external ID.
func (*Service) GetDeleted ¶
func (s *Service) GetDeleted(ctx context.Context, objectType string, start, end time.Time) (*DeletedRecords, error)
GetDeleted retrieves deleted records for an SObject type.
func (*Service) GetUpdated ¶
func (s *Service) GetUpdated(ctx context.Context, objectType string, start, end time.Time) (*UpdatedRecords, error)
GetUpdated retrieves updated record IDs for an SObject type.
type UpdatedRecords ¶
type UpdatedRecords struct {
IDs []string `json:"ids"`
LatestDateCovered string `json:"latestDateCovered"`
}
UpdatedRecords contains updated record IDs.