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

     1  package subscriptions
     2  
     3  import (
     4  	"math/rand"
     5  
     6  	zoho "github.com/schmorrison/Zoho"
     7  )
     8  
     9  const ZohoSubscriptionsEndpointHeader = "X-com-zoho-subscriptions-organizationid"
    10  
    11  // API is used for interacting with the Zoho Subscriptions API
    12  type API struct {
    13  	*zoho.Zoho
    14  	id             string
    15  	OrganizationID string
    16  }
    17  
    18  // New returns a *subscriptions.API with the provided zoho.Zoho as an embedded field
    19  func New(z *zoho.Zoho, organizationID string) *API {
    20  	id := func() string {
    21  		var id []byte
    22  		keyspace := "abcdefghijklmnopqrutuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    23  		for i := 0; i < 25; i++ {
    24  			id = append(id, keyspace[rand.Intn(len(keyspace))])
    25  		}
    26  		return string(id)
    27  	}()
    28  
    29  	return &API{
    30  		id:             id,
    31  		Zoho:           z,
    32  		OrganizationID: organizationID,
    33  	}
    34  }