go get github.com/aracoool/salesforce_client
Create a client
// Production
client := NewClient(EnvProduction, "44.0")
// Staging
client := NewClient(EnvStaging, "44.0")
Authentication
You have to call the Auth()
method after you created a client
err := client.Auth(Auth{
"Username",
"Password",
"ClientID",
"ClientSecret"
})
Retrieve a specific object
account := &struct{
Id,
Name,
Status
}{}
err := client.Find("Account", "0030x00000N1vJ0AAJ", account)
// account.Id == 0030x00000N1vJ0AAJ
Update a specific object
params := &Params{}
params.AddField("Name", "New name")
err := client.Update("Account", "0030x00000N1vJ0AAJ", params)
Delete a specific object
err := client.Delete("Account", "0030x00000N1vJ0AAJ")
Make a query
builder := &SoqlBuilder{}
builder.Select("Id", "Name")
builder.From("Account")
builder.Where("Name='Test'")
builder.Limit(1)
accounts := &struct{
Records []struct{
Id string,
Name string
} `json:"records"`
}{}
err := client.Query(builder.Build(), accounts)