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

     1  package crm
     2  
     3  import (
     4  	"math/rand"
     5  	"time"
     6  
     7  	zoho "github.com/schmorrison/Zoho"
     8  )
     9  
    10  type Module string
    11  
    12  // Proper names for CRM modules
    13  const (
    14  	AccountsModule       Module = "Accounts"
    15  	CallsModule          Module = "Calls"
    16  	CampaignsModule      Module = "Campaigns"
    17  	CasesModule          Module = "Cases"
    18  	ContactsModule       Module = "Contacts"
    19  	CustomModule         Module = "Custom"
    20  	DealsModule          Module = "Deals"
    21  	EventsModule         Module = "Events"
    22  	InvoicesModule       Module = "Invoices"
    23  	LeadsModule          Module = "Leads"
    24  	PotentialsModule     Module = "Potentials"
    25  	PriceBooksModule     Module = "PriceBooks"
    26  	ProductsModule       Module = "Products"
    27  	PurchaseOrdersModule Module = "PurchaseOrders"
    28  	QuotesModule         Module = "Quotes"
    29  	SalesOrdersModule    Module = "SalesOrders"
    30  	SolutionsModule      Module = "Solutions"
    31  	TasksModule          Module = "Tasks"
    32  	VendorsModule        Module = "Vendors"
    33  )
    34  
    35  // API is used for interacting with the Zoho CRM API
    36  // the exposed methods are primarily access to CRM modules which provide access to CRM Methods
    37  type API struct {
    38  	*zoho.Zoho
    39  	id string
    40  }
    41  
    42  // New returns a *crm.API with the provided zoho.Zoho as an embedded field
    43  func New(z *zoho.Zoho) *API {
    44  	id := func() string {
    45  		var id []byte
    46  		keyspace := "abcdefghijklmnopqrutuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    47  		for i := 0; i < 25; i++ {
    48  			source := rand.NewSource(time.Now().UnixNano())
    49  			rnd := rand.New(source)
    50  			id = append(id, keyspace[rnd.Intn(len(keyspace))])
    51  		}
    52  		return string(id)
    53  	}()
    54  
    55  	return &API{
    56  		Zoho: z,
    57  		id:   id,
    58  	}
    59  }