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

     1  // Wrapper for Zoho Expense API from https://www.zoho.com/expense/api/v1/
     2  
     3  package expense
     4  
     5  import (
     6  	"math/rand"
     7  
     8  	zoho "github.com/schmorrison/Zoho"
     9  )
    10  
    11  // Change here only if these values changes over time
    12  const (
    13  	ExpenseAPIEndpoint       string = "https://expense.zoho.com/api/v1/"
    14  	ExpenseAPIEndpointHeader string = "X-com-zoho-expense-organizationid"
    15  	OrganizationsModule      string = "organizations"
    16  	ExpenseReportModule      string = "expensereports"
    17  	ExpensesModule           string = "expenses"
    18  	TripsModule              string = "trips"
    19  	ExpenseCategoiesModule   string = "expensecategories"
    20  	UsersModule              string = "users"
    21  	CustomersModule          string = "contacts"
    22  	ProjectsModule           string = "projects"
    23  	CurrenciesModule         string = "settings/currencies"
    24  	TaxesModule              string = "settings/taxes"
    25  )
    26  
    27  // API is used for interacting with the Zoho expense API
    28  // the exposed methods are primarily access to expense modules which provide access to expense Methods
    29  type API struct {
    30  	*zoho.Zoho
    31  	id string
    32  }
    33  
    34  // New returns a *expense.API with the provided zoho.Zoho as an embedded field
    35  func New(z *zoho.Zoho) *API {
    36  	id := func() string {
    37  		var id []byte
    38  		keyspace := "abcdefghijklmnopqrutuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    39  		for i := 0; i < 25; i++ {
    40  			id = append(id, keyspace[rand.Intn(len(keyspace))])
    41  		}
    42  		return string(id)
    43  	}()
    44  	API := &API{
    45  		Zoho: z,
    46  		id:   id,
    47  	}
    48  	return API
    49  }