github.com/schmorrison/Zoho@v1.1.4/crm/README.md (about)

     1  [![](https://godoc.org/github.com/schmorrison/Zoho/crm?status.svg)](http://godoc.org/github.com/schmorrison/Zoho/crm)
     2  # Zoho CRM V2 API
     3  
     4  NOTE: Not finished and probably unstable. PRs welcome.
     5  
     6  This API wrapper should provide access to Zoho CRM. Because some fields exist only in add-ons for CRM, or are custom fields, which cannot be easily differentiated, all fields that are recieved in a record which have no direct corresponding field in the defined struct will be available in a `map[string]interface{}` field. This may extend to all fields being accessible in a field called "RAW" or some-such, which can then be manually type-asserted against.
     7  
     8  Brainstorm: CRM defines many special types for their internal fields (SingleLine, MultiLine, Picklist, MultiSelect, Date, Time, etc.) that must be parsed from the JSON, and provided in a type safe way to this library and back to Zoho. If the records struct fields are made up of mainly these specialized field types (types.go), and each field type has a MarshalJSON/UnmarshalJSON function then parsing may be a little more staight forward. These MarshalJSON/UnmarshalJSON field types will need to handle 'null' cases in the JSON.
     9  
    10  Additional Brainstorm: Because of the custom field problem, I believe we can define the definite fields that CRM will return in structs. Then when users that are using this client library need to have custom fields parsed, they can embed the parent struct we defined, into a struct of their own making which defines the custom fields they need.
    11  
    12  ## Usage
    13      import (
    14          "log"
    15          "fmt"
    16          "github.com/schmorrison/Zoho"
    17      )
    18  
    19      func main() {
    20          // get access/refresh tokens
    21          z := zoho.New()
    22          scopes := []zoho.ScopeString{
    23              zoho.BuildScope(zoho.Crm, zoho.ModulesScope, zoho.AllMethod, zoho.NoOp),
    24          }
    25          if err := z.AuthorizationCodeRequest("yourClientID", "yourClientSecret", scopes, "http://localhost:8080/oauthredirect"); err != nil {
    26              log.Fatal(err)
    27          }
    28  
    29          // Create a new CRM object and provide the Zoho struct
    30          c := crm.New(z)
    31  
    32          // While untested, getting data should work like so
    33          notes, err := c.GetNotes(nil)
    34          if err != nil {
    35              log.Fatal(err)
    36          }
    37  
    38          fmt.Println(notes)
    39  
    40          // The API for getting module records is bound to change once the returned data types can be defined.
    41          // The returned JSON values are subject to change given that custom fields are an instrinsic part of zoho. (see brainstorm above)
    42          data := crm.Account{}
    43          _, err := c.ListRecords(&data, crm.AccountsModule, nil)
    44          if err != nil {
    45              log.Fatal(err)
    46          }
    47  
    48          fmt.Println(data)
    49      }
    50  
    51  ## TODO
    52  
    53  - [ ] Write a TODO list
    54  - [ ] Comment code with full details
    55  - [ ] Add page context values to returned data, or methods to interact with it via module
    56  - [ ]