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

     1  // Wrapper for Zoho Bookings API from https://www.zohoapis.com/bookings/v1/json/
     2  
     3  package bookings
     4  
     5  import (
     6  	"math/rand"
     7  
     8  	zoho "github.com/schmorrison/Zoho"
     9  )
    10  
    11  type BookingsModule = string
    12  
    13  const (
    14  	GetAppointmentModule        BookingsModule = "getappointment"
    15  	GetAvailabilityModule       BookingsModule = "availableslots"
    16  	FetchWorkspacesModule       BookingsModule = "workspaces"
    17  	FetchServicesModule         BookingsModule = "services"
    18  	FetchStaffModule            BookingsModule = "staffs"
    19  	FetchResourceModule         BookingsModule = "resources"
    20  	BookAppointmentModule       BookingsModule = "appointment"
    21  	RescheduleAppointmentModule BookingsModule = "rescheduleappointment"
    22  	UpdateAppointmentModule     BookingsModule = "updateappointment"
    23  )
    24  
    25  // API is used for interacting with the Zoho expense API
    26  // the exposed methods are primarily access to expense modules which provide access to expense Methods
    27  type API struct {
    28  	*zoho.Zoho
    29  	id string
    30  }
    31  
    32  // New returns a *expense.API with the provided zoho.Zoho as an embedded field
    33  func New(z *zoho.Zoho) *API {
    34  	id := func() string {
    35  		var id []byte
    36  		keyspace := "abcdefghijklmnopqrutuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    37  		for i := 0; i < 25; i++ {
    38  			id = append(id, keyspace[rand.Intn(len(keyspace))])
    39  		}
    40  		return string(id)
    41  	}()
    42  	API := &API{
    43  		Zoho: z,
    44  		id:   id,
    45  	}
    46  	return API
    47  }