github.com/schmorrison/Zoho@v1.1.4/crm/modules.go (about) 1 package crm 2 3 import ( 4 "fmt" 5 6 zoho "github.com/schmorrison/Zoho" 7 ) 8 9 // GetModules returns the list of modules available in the CRM account 10 // https://www.zoho.com/crm/help/api/v2/#Modules-APIs 11 func (c *API) GetModules() (data ModulesResponse, err error) { 12 endpoint := zoho.Endpoint{ 13 Name: "modules", 14 URL: fmt.Sprintf("https://www.zohoapis.%s/crm/v2/settings/modules", c.ZohoTLD), 15 Method: zoho.HTTPGet, 16 ResponseData: &ModulesResponse{}, 17 } 18 19 err = c.Zoho.HTTPRequest(&endpoint) 20 if err != nil { 21 return ModulesResponse{}, fmt.Errorf("Failed to retrieve modules: %s", err) 22 } 23 24 if v, ok := endpoint.ResponseData.(*ModulesResponse); ok { 25 return *v, nil 26 } 27 28 return ModulesResponse{}, fmt.Errorf("Data retrieved was not 'ModuleResponse'") 29 } 30 31 // ModulesResponse is the data returned by GetModules 32 type ModulesResponse struct { 33 Modules []struct { 34 Convertable bool `json:"convertable,omitempty"` 35 Editable bool `json:"editable,omitempty"` 36 Deletable bool `json:"deletable,omitempty"` 37 WebLink string `json:"web_link,omitempty"` 38 SingularLabel string `json:"singular_label,omitempty"` 39 ModifiedTime Time `json:"modified_time,omitempty"` 40 Viewable bool `json:"viewable,omitempty"` 41 APISupported bool `json:"api_supported,omitempty"` 42 Createable bool `json:"createable,omitempty"` 43 PluralLabel string `json:"plural_label,omitempty"` 44 APIName string `json:"api_name,omitempty"` 45 ModifiedBy string `json:"modified_by,omitempty"` 46 GeneratedType string `json:"generated_type,omitempty"` 47 ID string `json:"id,omitempty"` 48 ModuleName string `json:"module_name,omitempty"` 49 } `json:"modules,omitempty"` 50 }