Update README.md to reflect new error handling
This commit is contained in:
parent
9cef8aeaa2
commit
ae4c27d491
34
README.md
34
README.md
@ -13,20 +13,34 @@ go get deadbeef.codes/steven/go-cw
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"deadbeef.codes/steven/go-cw/3.0/connectwise"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"deadbeef.codes/steven/go-cw/3.0/connectwise"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
var cw *connectwise.ConnectwiseSite
|
||||||
cwSite = "https://yourconnectwisesite.com/v4_6_release/apis/3.0"
|
|
||||||
cwAPIKeyPrivate = "ASDLFK4ah89ad" //Put in either your private API key or account password if using user impersonation
|
func init() {
|
||||||
cwAPIKey = "ASLDFKJ2342kl" //Put in either your public API key or account username if using user impersonation
|
publicKey := os.Getenv("gocwpublickey")
|
||||||
cwCompany = "yourcompanyname" //The connectwise company name
|
privateKey := os.Getenv("gocwprivatekey")
|
||||||
)
|
site := os.Getenv("gocwsite")
|
||||||
|
company := os.Getenv("gocwcompany")
|
||||||
|
|
||||||
|
cw = connectwise.NewSite(site, publicKey, privateKey, company)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cw := connectwise.NewSite(cwSite, cwAPIKey, cwAPIKeyPrivate, cwCompany)
|
|
||||||
companyDataByID := cw.GetCompanyByID(2) //Retrieves company ID 2 from CW and returns type pointer a Company
|
co, err := cw.GetCompanyByID(2)
|
||||||
fmt.Println(*companyDataByID.Name)
|
if err != nil {
|
||||||
|
log.Fatal("could not get company 2: %g", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Refer to the Connectwise API documentation to see what fields are available
|
||||||
|
fmt.Println(co.Name)
|
||||||
|
fmt.Println(co.DefaultContact.Name)
|
||||||
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user