github.com/schmorrison/Zoho@v1.1.4/invoice/invoice.go (about) 1 package invoice 2 3 import ( 4 "math/rand" 5 6 zoho "github.com/schmorrison/Zoho" 7 ) 8 9 const ( 10 InvoiceAPIEndpoint string = "https://invoice.zoho.com/api/v3/" 11 InvoiceAPIEndpointHeader string = "X-com-zoho-invoice-organizationid" 12 ContactsModule string = "contacts" 13 ContactsPersonSubModule string = "contactpersons" 14 InvoicesModule string = "invoices" 15 ItemsModule string = "items" 16 RecurringInvoicesModule string = "recurringinvoices" 17 CustomerPaymentsModule string = "customerpayments" 18 ) 19 20 type CustomFieldRequest struct { 21 CustomfieldID string `json:"customfield_id,omitempty"` 22 Label string `json:"label"` 23 Value string `json:"value,omitempty"` 24 } 25 26 // API is used for interacting with the Zoho expense API 27 // the exposed methods are primarily access to expense modules which provide access to expense Methods 28 type API struct { 29 *zoho.Zoho 30 id string 31 } 32 33 // New returns a *invoice.API with the provided zoho.Zoho as an embedded field 34 func New(z *zoho.Zoho) *API { 35 id := func() string { 36 var id []byte 37 keyspace := "abcdefghijklmnopqrutuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" 38 for i := 0; i < 25; i++ { 39 id = append(id, keyspace[rand.Intn(len(keyspace))]) 40 } 41 return string(id) 42 }() 43 44 API := API{ 45 Zoho: z, 46 id: id, 47 } 48 return &API 49 }