Salesforce SOAP API Client for golang
go get github.com/tzmfreedom/go-soapforce
import package and initialize client
import "github.com/tzmfreedom/go-soapforce"
client := soapforce.NewClient()
for sandbox
client.SetLoginUrl("test.salesforce.com")
set api version
client.SetApiVersion("44.0")
debug request/response
client.SetDebug(true)
Login
res, err := client.Login("username", "password")
Logout
res, err := client.Logout()
DescribeSObject
res, err := client.DescribeSObject("Account")
DescribeGlobal
res, err := client.DescribeGlobal()
DescribeLayout
recordTypeIds := []string{}
res, err := client.DescribeLayout("Account", "layout_name", recordTypeIds)
Create
sobjects := []*soapforce.SObject{
{
Type: "Account",
Fields: map[string]string{
"Name": "Foo",
},
},
}
res, err := client.Create(sobjects)
Update
sobjects := []*soapforce.SObject{
{
Id: "001xxxxxxxxxxxxxxx",
Type: "Account",
Fields: map[string]string{
"Name": "Updated Name",
},
},
}
sResult, err := client.Update(sobjects)
Upsert
sobjects := []*soapforce.SObject{
{
Id: "001xxxxxxxxxxxxxxx",
Type: "Account",
Fields: map[string]string{
"Name": "Upserted Name",
},
},
}
sResult, err := client.Upsert(sobjects, "Id")
Delete
ids := []string{
"001xxxxxxxxxxxxxxx",
}
sResult, err := client.Delete(ids)
Undelete
ids := []string{
"001xxxxxxxxxxxxxxx",
}
sResult, err := client.Undelete(ids)
Query
res, err := client.Query("SELECT id, Name FROM Account")
Set BatchSize
client.SetBatchSize(200)
QueryMore
res, err := client.Query("SELECT id FROM Account")
res, err = client.QueryMore(res.ql)
Retrieve
ids := []string{ "001A000001WTqy6" }
res, err := client.Retrieve("Account", ids, "Name, BillingAddress")
GetUserInfo
res, err := client.GetUserInfo()
Just send pull request if needed or fill an issue!
The MIT License See LICENSE file.