Documentation
¶
Overview ¶
Methods that handle methods through the Bulk API.
Methods that consume object _and_ SOQL methods, or that handle data processing.
Methods that handle objects.
Methods that query SOQL.
Index ¶
- Constants
- Variables
- func MarshalCSV(base any, customFields ...map[string]any) (string, error)
- func MarshalCSVSlice(base any) (string, error)
- func SOQL() *soql
- type Account
- type Address
- type Attributes
- type Auth
- func (auth *Auth) CacheNewToken(token *Token) (err error)
- func (auth *Auth) GetAccessToken() (token string, err error)
- func (auth *Auth) GetNewToken() (*Token, error)
- func (auth *Auth) IntrospectToken(token string) (*TokenIntrospection, error)
- func (auth *Auth) SetAccessToken(token *Token) (err error)
- type AuthErrorResponse
- type BaseObject
- type BulkClient
- func (bc *BulkClient) Insert(bulkJob *BulkJob, data any, cf ...map[string]any) (*BulkJobCompleteResponse, error)
- func (bc *BulkClient) InsertMultiple(bulkJob *BulkJob, data any) (*BulkJobCompleteResponse, error)
- func (bc *BulkClient) InsertRaw(bulkJob *BulkJob, data string) (*BulkJobCompleteResponse, error)
- func (bc *BulkClient) JobIsAborted(id string) (bool, error)
- func (bc *BulkClient) JobIsComplete(id string) (bool, error)
- func (bc *BulkClient) JobIsFailed(id string) (bool, error)
- func (bc *BulkClient) JobIsInProgress(id string) (bool, error)
- func (bc *BulkClient) JobIsOpen(id string) (bool, error)
- func (bc *BulkClient) JobStatus(id string) (*BulkJobStatus, error)
- func (bc *BulkClient) NewInsertJob(object string) *BulkJob
- func (bc *BulkClient) NewUpsertJob(object string, extIDField string) *BulkJob
- func (bc *BulkClient) Upsert(bulkJob *BulkJob, data any, cf ...map[string]any) (*BulkJobCompleteResponse, error)
- func (bc *BulkClient) UpsertMultiple(bulkJob *BulkJob, data any) (*BulkJobCompleteResponse, error)
- func (bc *BulkClient) UpsertRaw(bulkJob *BulkJob, data string) (*BulkJobCompleteResponse, error)
- type BulkJob
- type BulkJobComplete
- type BulkJobCompleteResponse
- type BulkJobResponse
- type BulkJobStatus
- type CachedTokenCallback
- type Case
- type CaseCreate
- type CaseUpdate
- type Client
- func (client *Client) Account(id string) (account *Account, err error)
- func (client *Client) AccountIDFromName(name string) (id string, err error)
- func (client *Client) Bulk() *BulkClient
- func (client *Client) Case(id string) (_case *Case, err error)
- func (client *Client) CaseByNumber(caseNumber string) (result *Case, err error)
- func (client *Client) CloseCase(caseID string) (err error)
- func (client *Client) Contact(id string) (contact *Contact, err error)
- func (client *Client) CreateCase(data *CaseCreate, customFields ...map[string]any) (result *RecordCreatedResponse, err error)
- func (client *Client) CreateFeedItem(data *FeedItemOptions) (*RecordCreatedResponse, error)
- func (client *Client) Customers() (accounts []Customer, err error)
- func (client *Client) DeleteObject(path string) error
- func (client *Client) Do(doer func(u string) (*resty.Response, error), url string) (*resty.Response, error)
- func (client *Client) FeedItem(id string) (result *FeedItem, err error)
- func (client *Client) GetObject(path string) (*ObjectResponse, error)
- func (client *Client) Group(id string) (group *Group, err error)
- func (client *Client) GroupName(id string) (name string, err error)
- func (client *Client) OpenCases() (cases []OpenCase, err error)
- func (client *Client) PatchObject(path string, data map[string]any) error
- func (client *Client) PostObject(path string, data map[string]any) (*RecordCreatedResponse, error)
- func (client *Client) PostToCase(caseID string, content string, feedOptions *FeedItemOptions) (result *RecordCreatedResponse, err error)
- func (client *Client) SendCaseUpdate(id string, data *Case, cf ...map[string]any) (*BulkJobCompleteResponse, error)
- func (client *Client) SendCloseCase(id string) error
- func (client *Client) SendFeedItem(item *FeedItemOptions) (*BulkJobCompleteResponse, error)
- func (client *Client) ServiceContract(id string) (contract *ServiceContract, err error)
- func (client *Client) UpdateAccount(id string, data any, customFields ...map[string]any) (err error)
- func (client *Client) UpdateCase(id string, data *CaseUpdate, customFields ...map[string]any) (err error)
- func (client *Client) User(id string) (user *User, err error)
- func (client *Client) UserByEmail(email string) (user *User, err error)
- func (client *Client) UserName(id string) (name string, err error)
- func (client *Client) WithRetry(timeout time.Duration) *Client
- type Contact
- type CustomFields
- type Customer
- type Date
- type FeedItem
- type FeedItemOptions
- type GenericResponse
- type Group
- type JWTClaim
- type JWTHeader
- type ObjectID
- type ObjectResponse
- func (obj *ObjectResponse) GetBool(key string) bool
- func (obj *ObjectResponse) GetFloat32(key string) float32
- func (obj *ObjectResponse) GetFloat64(key string) float64
- func (obj *ObjectResponse) GetInt(key string) int
- func (obj *ObjectResponse) GetMap(key string) map[string]any
- func (obj *ObjectResponse) GetSlice(key string) []any
- func (obj *ObjectResponse) GetString(key string) string
- type ObjectSummary
- type OpenCase
- type RecordCreatedResponse
- type RecordResponse
- type SOQLClient
- type SOQLOperator
- type SalesforceError
- type SalesforceErrorResponse
- type ServiceContract
- type SetTokenCallback
- type Time
- type Token
- type TokenIntrospection
- type User
Examples ¶
Constants ¶
const API_VERSION string = "v58.0"
const DefaultRetryDuration time.Duration = time.Second * 10
const PATH_ACCOUNT string = "/services/data/%s/sobjects/Account"
const PATH_BULK_INGEST string = "/services/data/%s/jobs/ingest"
const PATH_BULK_INGEST_COMPLETE string = "/services/data/%s/jobs/ingest/%s"
const PATH_CASE string = "/services/data/%s/sobjects/Case"
const PATH_CONTACT string = "/services/data/%s/sobjects/Contact"
const PATH_FEED_ITEM string = "/services/data/%s/sobjects/FeedItem"
const PATH_GROUP string = "/services/data/%s/sobjects/Group"
const PATH_PRICEBOOK_ENTRY string = "/services/data/%s/sobjects/PricebookEntry"
const PATH_SERVICE_CONTRACT string = "/services/data/%s/sobjects/ServiceContract"
const PATH_SOQL string = "/services/data/%s/query"
const PATH_USER string = "/services/data/%s/sobjects/User"
Variables ¶
var BulkJobCompleteData = BulkJobComplete{State: "UploadComplete"}
Functions ¶
func MarshalCSV ¶ added in v0.4.2
func MarshalCSVSlice ¶ added in v0.4.5
Types ¶
type Account ¶ added in v0.2.0
type Account struct { BaseObject AccountSource string `json:"AccountSource,omitempty"` BillingAddress *Address `json:"BillingAddress,omitempty"` BillingCity string `json:"BillingCity,omitempty"` BillingCountry string `json:"BillingCountry,omitempty"` BillingGeocodeAccuracy string `json:"BillingGeocodeAccuracy,omitempty"` BillingLatitude int `json:"BillingLatitude,omitempty"` BillingLongitude int `json:"BillingLongitude,omitempty"` BillingPostalCode string `json:"BillingPostalCode,omitempty"` BillingState string `json:"BillingState,omitempty"` BillingStreet string `json:"BillingStreet,omitempty"` ConnectionReceivedID string `json:"ConnectionReceivedId,omitempty"` Description string `json:"Description,omitempty"` Industry string `json:"Industry,omitempty"` IsCustomerPortal bool `json:"IsCustomerPortal"` IsDeleted bool `json:"IsDeleted,omitempty"` Jigsaw string `json:"Jigsaw,omitempty"` JigsawCompanyID string `json:"JigsawCompanyId,omitempty"` LastReferencedDate string `json:"LastReferencedDate,omitempty"` LastViewedDate string `json:"LastViewedDate,omitempty"` MasterRecordID string `json:"MasterRecordId,omitempty"` Name string `json:"Name"` NumberOfEmployees int `json:"NumberOfEmployees,omitempty"` ParentID string `json:"ParentId,omitempty"` Phone string `json:"Phone,omitempty"` PhotoUrl string `json:"PhotoUrl,omitempty"` ShippingAddress *Address `json:"ShippingAddress,omitempty"` ShippingCity string `json:"ShippingCity,omitempty"` ShippingCountry string `json:"ShippingCountry,omitempty"` ShippingGeocodeAccuracy string `json:"ShippingGeocodeAccuracy,omitempty"` ShippingLatitude int `json:"ShippingLatitude,omitempty"` ShippingLongitude int `json:"ShippingLongitude,omitempty"` ShippingPostalCode string `json:"ShippingPostalCode,omitempty"` ShippingState string `json:"ShippingState,omitempty"` ShippingStreet string `json:"ShippingStreet,omitempty"` SicDesc string `json:"SicDesc,omitempty"` Type string `json:"Type,omitempty"` Website string `json:"Website,omitempty"` CustomFields CustomFields `json:"-"` }
type Address ¶ added in v0.2.0
type Address struct { City string `json:"city,omitempty"` Country string `json:"country,omitempty"` GeocodeAccuracy string `json:"geocodeAccuracy,omitempty"` Latitude int `json:"latitude,omitempty"` Longitude int `json:"longitude,omitempty"` State string `json:"state,omitempty"` Street string `json:"street,omitempty"` }
type Attributes ¶ added in v0.2.0
type Auth ¶ added in v0.2.0
func NewAuth ¶ added in v0.2.0
func NewAuth( clientID, clientSecret, authURL string, encryption *string, getAccessTokenCallback CachedTokenCallback, setAccessTokenCallback SetTokenCallback, ) (auth *Auth, err error)
func (*Auth) CacheNewToken ¶ added in v0.2.0
func (*Auth) GetAccessToken ¶ added in v0.2.0
func (*Auth) GetNewToken ¶ added in v0.2.0
func (*Auth) IntrospectToken ¶ added in v0.4.0
func (auth *Auth) IntrospectToken(token string) (*TokenIntrospection, error)
func (*Auth) SetAccessToken ¶ added in v0.2.0
type AuthErrorResponse ¶ added in v0.2.0
type AuthErrorResponse struct { Error string `json:"error"` ErrorDescription string `json:"error_description"` }
func (*AuthErrorResponse) GetError ¶ added in v0.2.0
func (a *AuthErrorResponse) GetError() error
func (*AuthErrorResponse) GetErrorString ¶ added in v0.2.0
func (a *AuthErrorResponse) GetErrorString() string
type BaseObject ¶ added in v0.2.0
type BaseObject struct { Attributes *Attributes `json:"attributes,omitempty"` CreatedByID string `json:"CreatedById,omitempty"` CreatedDate string `json:"CreatedDate,omitempty"` ID string `json:"Id,omitempty"` LastModifiedByID string `json:"LastModifiedById,omitempty"` LastModifiedDate string `json:"LastModifiedDate,omitempty"` OwnerID string `json:"OwnerId,omitempty"` SystemModStamp string `json:"SystemModstamp,omitempty"` }
type BulkClient ¶ added in v0.4.2
type BulkClient struct {
// contains filtered or unexported fields
}
func NewBulkClient ¶ added in v0.4.2
func NewBulkClient(client *Client) *BulkClient
func (*BulkClient) Insert ¶ added in v0.4.2
func (bc *BulkClient) Insert(bulkJob *BulkJob, data any, cf ...map[string]any) (*BulkJobCompleteResponse, error)
func (*BulkClient) InsertMultiple ¶ added in v0.4.5
func (bc *BulkClient) InsertMultiple(bulkJob *BulkJob, data any) (*BulkJobCompleteResponse, error)
func (*BulkClient) InsertRaw ¶ added in v0.4.3
func (bc *BulkClient) InsertRaw(bulkJob *BulkJob, data string) (*BulkJobCompleteResponse, error)
func (*BulkClient) JobIsAborted ¶ added in v0.4.4
func (bc *BulkClient) JobIsAborted(id string) (bool, error)
func (*BulkClient) JobIsComplete ¶ added in v0.4.4
func (bc *BulkClient) JobIsComplete(id string) (bool, error)
func (*BulkClient) JobIsFailed ¶ added in v0.4.4
func (bc *BulkClient) JobIsFailed(id string) (bool, error)
func (*BulkClient) JobIsInProgress ¶ added in v0.4.4
func (bc *BulkClient) JobIsInProgress(id string) (bool, error)
func (*BulkClient) JobIsOpen ¶ added in v0.4.4
func (bc *BulkClient) JobIsOpen(id string) (bool, error)
func (*BulkClient) JobStatus ¶ added in v0.4.4
func (bc *BulkClient) JobStatus(id string) (*BulkJobStatus, error)
func (*BulkClient) NewInsertJob ¶ added in v0.4.4
func (bc *BulkClient) NewInsertJob(object string) *BulkJob
func (*BulkClient) NewUpsertJob ¶ added in v0.4.4
func (bc *BulkClient) NewUpsertJob(object string, extIDField string) *BulkJob
func (*BulkClient) Upsert ¶ added in v0.4.4
func (bc *BulkClient) Upsert(bulkJob *BulkJob, data any, cf ...map[string]any) (*BulkJobCompleteResponse, error)
func (*BulkClient) UpsertMultiple ¶ added in v0.4.5
func (bc *BulkClient) UpsertMultiple(bulkJob *BulkJob, data any) (*BulkJobCompleteResponse, error)
func (*BulkClient) UpsertRaw ¶ added in v0.4.4
func (bc *BulkClient) UpsertRaw(bulkJob *BulkJob, data string) (*BulkJobCompleteResponse, error)
type BulkJobComplete ¶ added in v0.4.2
type BulkJobComplete struct {
State string `json:"state"`
}
type BulkJobCompleteResponse ¶ added in v0.4.2
type BulkJobCompleteResponse 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"` }
type BulkJobResponse ¶ added in v0.4.2
type BulkJobResponse 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"` ContentURL string `json:"contentUrl"` LineEnding string `json:"lineEnding"` ColumnDelimiter string `json:"columnDelimiter"` }
type BulkJobStatus ¶ added in v0.4.2
type BulkJobStatus 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"` TotalProcessingTime int `json:"totalProcessingTime"` APIActiveProcessingTime int `json:"apiActiveProcessingTime"` ApexProcessingTime int `json:"apexProcessingTime"` }
type CachedTokenCallback ¶ added in v0.2.0
type Case ¶ added in v0.2.0
type Case struct { BaseObject AccountId string `json:"AccountId,omitempty"` CaseNumber string `json:"CaseNumber,omitempty"` ClosedDate string `json:"ClosedDate,omitempty"` Comments string `json:"Comments,omitempty"` ContactEmail string `json:"ContactEmail,omitempty"` ContactFax string `json:"ContactFax,omitempty"` ContactID string `json:"ContactId,omitempty"` ContactMobile string `json:"ContactMobile,omitempty"` ContactPhone string `json:"ContactPhone,omitempty"` Description string `json:"Description,omitempty"` EntitlementID string `json:"EntitlementId,omitempty"` IsClosed bool `json:"IsClosed,omitempty"` IsDeleted bool `json:"IsDeleted,omitempty"` IsEscalated bool `json:"IsEscalated,omitempty"` IsStopped bool `json:"IsStopped,omitempty"` Language string `json:"Language,omitempty"` LastReferencedDate string `json:"LastReferencedDate,omitempty"` LastViewedDate string `json:"LastViewedDate,omitempty"` MasterRecordID string `json:"MasterRecordId,omitempty"` MilestoneStatus string `json:"MilestoneStatus,omitempty"` Origin string `json:"Origin,omitempty"` OwnerID string `json:"OwnerId,omitempty"` ParentID string `json:"ParentId,omitempty"` Reason string `json:"Reason,omitempty"` Status string `json:"Status,omitempty"` StopStartDate string `json:"StopStartDate,omitempty"` Subject string `json:"Subject,omitempty"` SuppliedCompany string `json:"SuppliedCompany,omitempty"` SuppliedEmail string `json:"SuppliedEmail,omitempty"` SuppliedName string `json:"SuppliedName,omitempty"` SuppliedPhone string `json:"SuppliedPhone,omitempty"` Type string `json:"Type,omitempty"` CustomFields CustomFields `json:"-"` }
type CaseCreate ¶ added in v0.2.0
type CaseCreate struct { AccountID string `json:"AccountId,omitempty"` Comments string `json:"Comments,omitempty"` ContactID string `json:"ContactId,omitempty"` Description string `json:"Description,omitempty"` Origin string `json:"Origin,omitempty"` Status string `json:"Status,omitempty"` Subject string `json:"Subject,omitempty"` CustomFields CustomFields `json:"-"` }
type CaseUpdate ¶ added in v0.2.0
type CaseUpdate struct { // Options SkipAutoAssign bool `json:"-"` // Fields Comments string `json:"Comments,omitempty"` ContactEmail string `json:"ContactEmail,omitempty"` ContactFax string `json:"ContactFax,omitempty"` ContactID string `json:"ContactId,omitempty"` ContactMobile string `json:"ContactMobile,omitempty"` ContactPhone string `json:"ContactPhone,omitempty"` Description string `json:"Description,omitempty"` EntitlementID string `json:"EntitlementId,omitempty"` IsEscalated bool `json:"IsEscalated,omitempty"` IsStopped bool `json:"IsStopped,omitempty"` Language string `json:"Language,omitempty"` MasterRecordID string `json:"MasterRecordId,omitempty"` MilestoneStatus string `json:"MilestoneStatus,omitempty"` Origin string `json:"Origin,omitempty"` OwnerID string `json:"OwnerId,omitempty"` ParentId string `json:"ParentId,omitempty"` Reason string `json:"Reason,omitempty"` Status string `json:"Status,omitempty"` StopStartDate string `json:"StopStartDate,omitempty"` Subject string `json:"Subject,omitempty"` SuppliedCompany string `json:"SuppliedCompany,omitempty"` SuppliedEmail string `json:"SuppliedEmail,omitempty"` SuppliedName string `json:"SuppliedName,omitempty"` SuppliedPhone string `json:"SuppliedPhone,omitempty"` Type string `json:"Type,omitempty"` }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Salesforce Client
func New ¶ added in v0.2.0
func New( clientID, clientSecret, authURL string, encryption *string, getToken CachedTokenCallback, setToken SetTokenCallback, ) (*Client, error)
Create a go-sfdc client and performs initial authentication.
Example ¶
In this example, the cache2go caching backend is used, but any caching backend can be used.
cache := cache2go.Cache("go-sfdc") cache.Flush() // Define a callback function to retrieve the Salesforce OAuth2 access token from the cache. getAccessToken := func() (string, error) { res, err := cache.Value("access-token") if err != nil { return "", nil } token := res.Data().(string) return token, nil } // Define a callback function to add the Salesforce OAuth2 access token from the cache. setAccessToken := func(token string, expiresIn time.Duration) error { cache.Add("access-token", expiresIn, token) return nil } // Salesforce Connected App OAuth2 Client ID. clientID := "abcdef1234567890" // Salesforce Connected App OAuth2 Client Secret. clientSecret := "0987654321fedcba" // If set, the encryption passphrase is used to encrypt all values written to the cache // using AES-256-GCM encryption. var encryptionPassphrase *string passphrase := "xY2jK9a8s6d5fE7H" encryptionPassphrase = &passphrase // If you do not wish to encrypt cached values, pass nil. encryptionPassphrase = nil // Salesforce authentication URL. // See: https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_jwt_flow.htm authURL := "https://login.salesforce.com" client, err := sfdc.New( clientID, clientSecret, authURL, encryptionPassphrase, getAccessToken, setAccessToken, ) if err != nil { // handle error } client.Account("001G00000789QPONML")
Output:
func (*Client) Account ¶
Retrieve an Account.
Example ¶
account, err := client.Account("006G00000678LKJIHE") if err != nil { // handle error } fmt.Println(account.ID) // Example Output: 006G00000678LKJIHE
Output:
func (*Client) AccountIDFromName ¶
Find an account's ID based on the account's name.
Example ¶
id, err := client.AccountIDFromName("Acme Corp") if err != nil { // handle error } fmt.Println(id) // Example Output: 001G00000456MNOPQR
Output:
func (*Client) Bulk ¶ added in v0.4.2
func (client *Client) Bulk() *BulkClient
Bulk performs a bulk operation using BulkClient.
func (*Client) Case ¶
Retrieve a Case.
Example ¶
_case, err := client.Case("001G00000987KJIHGF") if err != nil { // handle error } fmt.Println(_case.ID) // Example Output: 001G00000987KJIHGF
Output:
func (*Client) CaseByNumber ¶ added in v0.0.3
Retrieve a case by its case number.
func (*Client) Contact ¶
Retrieve a Contact.
Example ¶
contact, err := client.Contact("003G00000123ZYXWVU") if err != nil { // handle error } fmt.Println(contact.ID) // Example Output: 003G00000123ZYXWVU
Output:
func (*Client) CreateCase ¶ added in v0.0.2
func (client *Client) CreateCase(data *CaseCreate, customFields ...map[string]any) (result *RecordCreatedResponse, err error)
Create a new case.
func (*Client) CreateFeedItem ¶ added in v0.2.9
func (client *Client) CreateFeedItem(data *FeedItemOptions) (*RecordCreatedResponse, error)
func (*Client) Customers ¶
Retrieve a summary of all accounts where the 'Type' field is 'Customer'.
Example ¶
customers, err := client.Customers() if err != nil { // handle error } for _, customer := range customers { fmt.Printf("Id=%s, Name=%s, Type=%s", customer.ID, customer.Name, customer.Type) // Example Output: Id=00QG00000567DCBAZY, Name=Acme Corp, Type=Customer // ... }
Output:
func (*Client) DeleteObject ¶ added in v0.4.1
DeleteObject deletes an existing object.
func (*Client) Do ¶ added in v0.4.0
func (client *Client) Do(doer func(u string) (*resty.Response, error), url string) (*resty.Response, error)
Do executes a given resty request method such as Get/Post. If a timeout/backoff is specified, the request will be executed and retried within that timeout period.
func (*Client) GetObject ¶ added in v0.4.1
func (client *Client) GetObject(path string) (*ObjectResponse, error)
GetObject retrieves an object and provides an interface to access its data.
func (*Client) Group ¶
Retrieve a Group.
Example ¶
group, err := client.Account("00QG00000890ZYXWVU") if err != nil { // handle error } fmt.Println(group.ID) // Example Output: 00QG00000890ZYXWVU
Output:
func (*Client) GroupName ¶
Retrieve the name of a group based on the group's ID.
Example ¶
name, err := client.GroupName("006G00000345LKJIHG") if err != nil { // handle error } fmt.Println(name) // Example Output: Help Desk
Output:
func (*Client) OpenCases ¶
Retrieve a summary of all open cases.
Example ¶
openCases, err := client.OpenCases() if err != nil { // handle error } for _, openCase := range openCases { fmt.Printf("Id=%s, Subject=%s, OwnerId=%s", openCase.ID, openCase.Subject, openCase.OwnerID) } // Example Output: // Id=003G000002z8VBQIA2, Subject=Case Subject, OwnerId=00QG00000234ZYXWVU
Output:
func (*Client) PatchObject ¶ added in v0.4.1
PatchObject updates an existing object.
func (*Client) PostObject ¶ added in v0.4.1
PostObject creates a new object.
func (*Client) PostToCase ¶ added in v0.0.3
func (client *Client) PostToCase(caseID string, content string, feedOptions *FeedItemOptions) (result *RecordCreatedResponse, err error)
Post a comment to a case.
func (*Client) SendCaseUpdate ¶ added in v0.4.4
func (*Client) SendCloseCase ¶ added in v0.4.4
func (*Client) SendFeedItem ¶ added in v0.4.4
func (client *Client) SendFeedItem(item *FeedItemOptions) (*BulkJobCompleteResponse, error)
func (*Client) ServiceContract ¶ added in v0.2.7
func (client *Client) ServiceContract(id string) (contract *ServiceContract, err error)
Retrieve a Service Contract.
func (*Client) UpdateAccount ¶ added in v0.0.2
func (client *Client) UpdateAccount(id string, data any, customFields ...map[string]any) (err error)
Update an account's fields.
func (*Client) UpdateCase ¶ added in v0.0.2
func (client *Client) UpdateCase(id string, data *CaseUpdate, customFields ...map[string]any) (err error)
Update a case's fields.
func (*Client) User ¶
Retrieve a User.
Example ¶
user, err := client.Account("003G00000789VUTSRQ") if err != nil { // handle error } fmt.Println(user.ID) // Example Output: 003G00000789VUTSRQ
Output:
func (*Client) UserByEmail ¶ added in v0.2.2
Retrieve a user by its email address.
type Contact ¶ added in v0.2.0
type Contact struct { BaseObject AccountID string `json:"AccountId,omitempty"` IsDeleted bool `json:"IsDeleted,omitempty"` MasterRecordID string `json:"MasterRecordId,omitempty"` LastName string `json:"LastName,omitempty"` FirstName string `json:"FirstName,omitempty"` MiddleName string `json:"MiddleName,omitempty"` Suffix string `json:"Suffix,omitempty"` Name string `json:"Name,omitempty"` Salutation string `json:"Salutation,omitempty"` MailingStreet string `json:"MailingStreet,omitempty"` MailingCity string `json:"MailingCity,omitempty"` MailingState string `json:"MailingState,omitempty"` MailingPostalCode string `json:"MailingPostalCode,omitempty"` MailingCountry string `json:"MailingCountry,omitempty"` MailingLatitude int `json:"MailingLatitude,omitempty"` MailingLongitude int `json:"MailingLongitude,omitempty"` MailingGeocodeAccuracy string `json:"MailingGeocodeAccuracy,omitempty"` MailingAddress *Address `json:"MailingAddress,omitempty"` Phone string `json:"Phone,omitempty"` Fax string `json:"Fax,omitempty"` MobilePhone string `json:"MobilePhone,omitempty"` ReportsToId string `json:"ReportsToId,omitempty"` Email string `json:"Email,omitempty"` Title string `json:"Title,omitempty"` Department string `json:"Department,omitempty"` LastActivityDate string `json:"LastActivityDate,omitempty"` CustomFields CustomFields `json:"-"` }
type CustomFields ¶ added in v0.2.0
type Date ¶ added in v0.2.7
func (*Date) UnmarshalJSON ¶ added in v0.2.7
type FeedItem ¶ added in v0.2.0
type FeedItem struct { Attributes *Attributes `json:"attributes,omitempty"` ID string `json:"Id,omitempty"` ParentID string `json:"ParentId,omitempty"` Type string `json:"Type,omitempty"` CreatedByID string `json:"CreatedById,omitempty"` CreatedDate string `json:"CreatedDate,omitempty"` IsDeleted bool `json:"IsDeleted,omitempty"` LastModifiedDate string `json:"LastModifiedDate,omitempty"` SystemModstamp string `json:"SystemModstamp,omitempty"` Revision int `json:"Revision,omitempty"` LastEditByID string `json:"LastEditById,omitempty"` LastEditDate string `json:"LastEditDate,omitempty"` ConnectionID string `json:"ConnectionId,omitempty"` CommentCount int `json:"CommentCount,omitempty"` LikeCount int `json:"LikeCount,omitempty"` Title string `json:"Title,omitempty"` Body string `json:"Body,omitempty"` LinkURL string `json:"LinkUrl,omitempty"` IsRichText bool `json:"IsRichText,omitempty"` RelatedRecordID string `json:"RelatedRecordId,omitempty"` InsertedByID string `json:"InsertedById,omitempty"` NetworkScope string `json:"NetworkScope,omitempty"` Visibility string `json:"Visibility,omitempty"` BestCommentID string `json:"BestCommentId,omitempty"` HasContent bool `json:"HasContent,omitempty"` HasLink bool `json:"HasLink,omitempty"` HasFeedEntity bool `json:"HasFeedEntity,omitempty"` HasVerifiedComment bool `json:"HasVerifiedComment,omitempty"` IsClosed bool `json:"IsClosed,omitempty"` Status string `json:"Status,omitempty"` }
type FeedItemOptions ¶ added in v0.2.0
type FeedItemOptions struct { // ID of the user that posts the feed item. CreatedByID string `json:"CreatedById,omitempty"` // ID of whatever this is attached to (most likely, the case ID). ParentID string `json:"ParentId,omitempty"` // Title of the feed item. Title string `json:"Title,omitempty"` // Body - required if Type is TextPost. Body string `json:"Body,omitempty"` // Temporarily only supporting "TextPost". Type string `json:"Type,omitempty"` /* If true, these HTML tags are supported: <p/> <a/> <b/> <code/> <i/> <u/> <s/> <ul/> <ol/> <li/> <img/> */ IsRichText bool `json:"IsRichText,omitempty"` /* Specifies whether this feed item is available to all users or internal users only. "AllUsers": The feed item is available to all users who have permission to see the feed item. "InternalUsers": The feed item is available to internal users only. For record posts, Visibility is set to InternalUsers for all internal users by default. External users can set Visibility only to AllUsers. Visibility can be updated on record posts. The Update property is supported only for feed items posted on records. */ Visibility string `json:"Visibility,omitempty"` }
type GenericResponse ¶ added in v0.2.0
type Group ¶ added in v0.2.0
type Group struct { BaseObject Name string `json:"Name"` Developer_Name string `json:"Developer_Name,omitempty"` RelatedID string `json:"RelatedId,omitempty"` QueueRoutingConfigID string `json:"QueueRoutingConfigId,omitempty"` DoesSendEmailToMembers bool `json:"DoesSendEmailToMembers,omitempty"` DoesIncludeBosses bool `json:"DoesIncludeBosses,omitempty"` Email string `json:"Email,omitempty"` Type string `json:"Type,omitempty"` CustomFields CustomFields `json:"-"` }
type ObjectResponse ¶ added in v0.4.1
type ObjectResponse struct {
// contains filtered or unexported fields
}
func NewObjectResponse ¶ added in v0.4.1
func NewObjectResponse(data []byte) (*ObjectResponse, error)
func (*ObjectResponse) GetBool ¶ added in v0.4.1
func (obj *ObjectResponse) GetBool(key string) bool
func (*ObjectResponse) GetFloat32 ¶ added in v0.4.1
func (obj *ObjectResponse) GetFloat32(key string) float32
func (*ObjectResponse) GetFloat64 ¶ added in v0.4.1
func (obj *ObjectResponse) GetFloat64(key string) float64
func (*ObjectResponse) GetInt ¶ added in v0.4.1
func (obj *ObjectResponse) GetInt(key string) int
func (*ObjectResponse) GetMap ¶ added in v0.4.1
func (obj *ObjectResponse) GetMap(key string) map[string]any
func (*ObjectResponse) GetSlice ¶ added in v0.4.1
func (obj *ObjectResponse) GetSlice(key string) []any
func (*ObjectResponse) GetString ¶ added in v0.4.1
func (obj *ObjectResponse) GetString(key string) string
type ObjectSummary ¶ added in v0.2.0
type RecordCreatedResponse ¶ added in v0.2.0
type RecordResponse ¶ added in v0.2.0
type SOQLClient ¶ added in v0.0.5
func NewSOQL ¶ added in v0.2.0
func NewSOQL[T any](client *Client) (sc *SOQLClient[T])
func (*SOQLClient[T]) Query ¶ added in v0.0.5
func (soqlClient *SOQLClient[T]) Query(soqlQuery *soql) (results RecordResponse[T], err error)
Query the Salesforce SOQL API with the created SOQL query.
type SOQLOperator ¶ added in v0.2.1
type SOQLOperator string
const CONTAINS SOQLOperator = "CONTAINS"
const ENDS_WITH SOQLOperator = "ENDS WITH"
const EQUALS SOQLOperator = "="
const EXCLUDES SOQLOperator = "EXCLUDES"
const GEQUAL SOQLOperator = ">="
const GREATER_THAN SOQLOperator = ">"
const IN SOQLOperator = "IN"
const INCLUDES SOQLOperator = "INCLUDES"
const LEQUAL SOQLOperator = "<="
const LESS_THAN SOQLOperator = "<"
const LIKE SOQLOperator = "LIKE"
const NOT_EQUALS SOQLOperator = "!="
const NOT_IN SOQLOperator = "NOT IN"
const STARTS_WITH SOQLOperator = "STARTS WITH"
type SalesforceError ¶ added in v0.2.0
type SalesforceErrorResponse ¶ added in v0.2.0
type SalesforceErrorResponse []*SalesforceError
func (*SalesforceErrorResponse) GetError ¶ added in v0.2.0
func (er *SalesforceErrorResponse) GetError() error
func (*SalesforceErrorResponse) GetErrorString ¶ added in v0.2.0
func (er *SalesforceErrorResponse) GetErrorString() string
type ServiceContract ¶ added in v0.2.7
type ServiceContract struct { BaseObject AccountID string `json:"AccountId,omitempty"` ActivationDate string `json:"ActivationDate,omitempty"` ApprovalStatus string `json:"ApprovalStatus,omitempty"` BillingAddress *Address `json:"BillingAddress,omitempty"` BillingCity string `json:"BillingCity,omitempty"` BillingCountry string `json:"BillingCountry,omitempty"` BillingGeocodeAccuracy string `json:"BillingGeocodeAccuracy,omitempty"` BillingLatitude int `json:"BillingLatitude,omitempty"` BillingLongitude int `json:"BillingLongitude,omitempty"` BillingPostalCode string `json:"BillingPostalCode,omitempty"` BillingState string `json:"BillingState,omitempty"` BillingStreet string `json:"BillingStreet,omitempty"` ContactID string `json:"ContactId,omitempty"` ContractNumber string `json:"ContractNumber,omitempty"` Description string `json:"Description,omitempty"` Discount float64 `json:"Discount,omitempty"` EndDate string `json:"EndDate,omitempty"` GrandTotal float64 `json:"GrandTotal,omitempty"` IsDeleted bool `json:"IsDeleted,omitempty"` LastReferencedDate string `json:"LastReferencedDate,omitempty"` LastViewedDate string `json:"LastViewedDate,omitempty"` LineItemCount int `json:"LineItemCount,omitempty"` Name string `json:"Name,omitempty"` ParentServiceContractID string `json:"ParentServiceContractId,omitempty"` Pricebook2ID string `json:"Pricebook2Id,omitempty"` RecordTypeID string `json:"RecordTypeId,omitempty"` RootServiceContractID string `json:"RootServiceContractId,omitempty"` ShippingAddress *Address `json:"ShippingAddress,omitempty"` ShippingCity string `json:"ShippingCity,omitempty"` ShippingCountry string `json:"ShippingCountry,omitempty"` ShippingGeocodeAccuracy string `json:"ShippingGeocodeAccuracy,omitempty"` ShippingLatitude int `json:"ShippingLatitude,omitempty"` ShippingLongitude int `json:"ShippingLongitude,omitempty"` ShippingPostalCode string `json:"ShippingPostalCode,omitempty"` ShippingState string `json:"ShippingState,omitempty"` ShippingStreet string `json:"ShippingStreet,omitempty"` ShippingHandling float64 `json:"ShippingHandling,omitempty"` SpecialTerms string `json:"SpecialTerms,omitempty"` StartDate string `json:"StartDate,omitempty"` Status string `json:"Status,omitempty"` Subtotal float64 `json:"Subtotal,omitempty"` SystemModstamp string `json:"SystemModstamp,omitempty"` Tax float64 `json:"Tax,omitempty"` Term int `json:"Term,omitempty"` TotalPrice float64 `json:"TotalPrice,omitempty"` }
type SetTokenCallback ¶ added in v0.2.0
type Time ¶ added in v0.2.7
func (*Time) UnmarshalJSON ¶ added in v0.2.7
type Token ¶ added in v0.2.0
type Token struct { ID string `json:"id"` Scope string `json:"scope"` TokenType string `json:"token_type"` AccessToken string `json:"access_token"` InstanceURL string `json:"instance_url"` IssuedAt string `json:"issued_at"` Signature string `json:"signature"` // contains filtered or unexported fields }
type TokenIntrospection ¶ added in v0.4.0
type User ¶ added in v0.2.0
type User struct { BaseObject Username string `json:"Username"` LastName string `json:"LastName,omitempty"` FirstName string `json:"FirstName,omitempty"` MiddleName string `json:"MiddleName,omitempty"` Suffix string `json:"Suffix,omitempty"` Name string `json:"Name,omitempty"` CompanyName string `json:"CompanyName,omitempty"` Division string `json:"Division,omitempty"` Department string `json:"Department,omitempty"` Title string `json:"Title,omitempty"` Street string `json:"Street,omitempty"` City string `json:"City,omitempty"` State string `json:"State,omitempty"` PostalCode string `json:"PostalCode,omitempty"` Country string `json:"Country,omitempty"` Latitude int `json:"Latitude,omitempty"` Longitude int `json:"Longitude,omitempty"` GeocodeAccuracy string `json:"GeocodeAccuracy,omitempty"` Address *Address `json:"Address,omitempty"` Email string `json:"Email,omitempty"` Phone string `json:"Phone,omitempty"` Alias string `json:"Alias,omitempty"` CommunityNickname string `json:"CommunityNickname,omitempty"` IsActive bool `json:"IsActive,omitempty"` TimeZoneSidKey string `json:"TimeZoneSidKey,omitempty"` UserRoleID string `json:"UserRoleId,omitempty"` ManagerID string `json:"ManagerId,omitempty"` UserType string `json:"UserType,omitempty"` ProfileID string `json:"ProfileId,omitempty"` ContactID string `json:"ContactId,omitempty"` AccountID string `json:"AccountId,omitempty"` CustomFields CustomFields `json:"-"` }