Skip to content

Commit

Permalink
update readme to include query example
Browse files Browse the repository at this point in the history
  • Loading branch information
nimajalali committed Feb 27, 2015
1 parent 7ce2ce7 commit 5599e45
Showing 1 changed file with 53 additions and 37 deletions.
90 changes: 53 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,67 @@ Installation

Example
============
```
package main
package main
import (
"fmt"
"log"
import (
"fmt"
"log"

"github.com/nimajalali/go-force/force"
"github.com/nimajalali/go-force/sobjects"
"github.com/nimajalali/go-force/force"
"github.com/nimajalali/go-force/sobjects"
)
type SomeCustomSObject struct {
sobjects.BaseSObject
Active bool `force:"Active__c"`
AccountId string `force:"Account__c"`
}
func (t *SomeCustomSObject) ApiName() string {
return "SomeCustomObject__c"
}
type SomeCustomSObjectQueryResponse struct {
sobjects.BaseQuery
Records []*SomeCustomSObject `force:"records"`
}
func main() {
// Init the force
forceApi, err := force.Create(
"YOUR-API-VERSION",
"YOUR-CLIENT-ID",
"YOUR-CLIENT-SECRET",
"YOUR-USERNAME",
"YOUR-PASSWORD",
"YOUR-SECURITY-TOKEN",
"YOUR-ENVIRONMENT",
)

type SomeCustomSObject struct {
sobjects.BaseSObject
Active bool `force:"Active__c"`
AccountId string `force:"Account__c"`
if err != nil {
log.Fatal(err)
}

func (t *SomeCustomSObject) ApiName() string {
return "SomeCustomObject__c"
// Get somCustomSObject by ID
someCustomSObject := &SomeCustomSObject{}
err = forceApi.GetSObject("Your-Object-ID", someCustomSObject)
if err != nil {
fmt.Println(err)
}
func main() {
// Init the force
forceApi, err := force.Create(
"YOUR-API-VERSION",
"YOUR-CLIENT-ID",
"YOUR-CLIENT-SECRET",
"YOUR-USERNAME",
"YOUR-PASSWORD",
"YOUR-SECURITY-TOKEN",
"YOUR-ENVIRONMENT",
)
if err != nil {
log.Fatal(err)
}

someCustomSObject := &SomeCustomSObject{}
err = forceApi.GetSObject("Your-Object-ID", someCustomSObject)
if err != nil {
fmt.Println(err)
}
fmt.Printf("%#v", someCustomSObject)
fmt.Printf("%#v", someCustomSObject)
// Query
someCustomSObjects := &SomeCustomSObjectQueryResponse{}
err = forceApi.Query("SELECT Id FROM SomeCustomSObject__c LIMIT 10", someCustomSObjects)
if err != nil {
fmt.Println(err)
}
fmt.Printf("%#v", someCustomSObjects)
}
```
Documentation
=======

Expand Down

0 comments on commit 5599e45

Please sign in to comment.