https://github.com/iaintshine/basecrm-go
Go client for the BaseCRM API v2
https://github.com/iaintshine/basecrm-go
Last synced: 2 months ago
JSON representation
Go client for the BaseCRM API v2
- Host: GitHub
- URL: https://github.com/iaintshine/basecrm-go
- Owner: iaintshine
- License: mit
- Created: 2015-02-09T23:57:45.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-09T23:22:22.000Z (over 10 years ago)
- Last Synced: 2025-02-04T14:48:27.365Z (4 months ago)
- Language: Go
- Size: 215 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# basecrm-go
basecrm-go is a Go client library for accessing the BaseCRM API v2 beta.
You can view BaseCRM API docs here: [https://developers.getbase.com/](https://developers.getbase.com/)
## Usage
```go
import "github.com/iaintshine/basecrm-go/basecrm"
```Create a new BaseCRM client
```go
client := basecrm.NewClient(httpClient)
```Now use the exposed services to access different parts of the BaseCRM API.
## Authentication
The basecrm-go library does not handle authentication. Instead, you pass an instance of `http.Client`
that is able to handle authentication to resource servers using Bearer authentication schema.
The recommended way to do this is to use [goauth2](https://code.google.com/p/goauth2/), newer
[golang.org/x/oauth2](https://godoc.org/golang.org/x/oauth2) or any other library that can provide
an instance of `http.Client`. The easiest way to interact with BaseCRM is to use Personal Access Tokens
(PATs), which can be generated in the Accounts Settings page.Assuming you have set `BASECRM_TOKEN` environment variable to a Personal Access Token.
```go
t := oauth.Transport{
Token: &oauth.Token{
AccessToken: os.Getenv("BASECRM_TOKEN"),
},
}client := basecrm.NewClient(t.Client())
me, _, _ := client.Users.Self()
```Full running examples can be found under [examples](https://github.com/iaintshine/basecrm-go/tree/master/examples/) directory.
## Examples
To create a new Contact:
```go
createRequest := &Contact{
IsOrganization: false,
FirstName: "Mark",
LastName: "Johnson",
}newContact, _, err := client.Contacts.Create(createRequest)
if err != nil {
fmt.Printf("Something bad happened during the request to the contacts service %v", err)
return
}// do something with the new contact
```