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

     1  package recruit
     2  
     3  import (
     4  	"math/rand"
     5  	"time"
     6  
     7  	zoho "github.com/schmorrison/Zoho"
     8  )
     9  
    10  type Module string
    11  
    12  const (
    13  	CandidatesModule   Module = "Candidates"
    14  	ClientsModule      Module = "Clients"
    15  	ContactsModule     Module = "Contacts"
    16  	CustomModule1      Module = "CustomModule1"
    17  	CustomModule2      Module = "CustomModule2"
    18  	CustomModule3      Module = "CustomModule3"
    19  	CustomModule4      Module = "CustomModule4"
    20  	CustomModule5      Module = "CustomModule5"
    21  	InterviewsModule   Module = "Interviews"
    22  	JobOpeningsModule  Module = "JobOpenings"  // this is used mostly
    23  	Job_OpeningsModule Module = "Job_Openings" // inconsistency in Zoho API
    24  )
    25  
    26  type RelatedRecord string
    27  
    28  const (
    29  	Activities          RelatedRecord = "Activities"
    30  	Activity_History    RelatedRecord = "Activity_History"
    31  	Attachments         RelatedRecord = "Attachments"
    32  	Campaigns           RelatedRecord = "Campaigns"
    33  	Contacts            RelatedRecord = "Contacts"
    34  	Custom_Related_List RelatedRecord = "Custom_Related_List"
    35  	Interviews          RelatedRecord = "Interviews"
    36  	Invited_Events      RelatedRecord = "Invited_Events"
    37  	Notes               RelatedRecord = "Notes"
    38  	Offers              RelatedRecord = "Offers"
    39  )
    40  
    41  type AttachmentCategory string
    42  
    43  const (
    44  	Contracts        AttachmentCategory = "Contracts"
    45  	Cover_Letter     AttachmentCategory = "Cover_Letter"
    46  	Formatted_Resume AttachmentCategory = "Formatted_Resume"
    47  	Offer            AttachmentCategory = "Offer"
    48  	Others           AttachmentCategory = "Others"
    49  	Resume           AttachmentCategory = "Resume"
    50  )
    51  
    52  // API is used for interacting with the Zoho recruit API
    53  // the exposed methods are primarily access to recruit modules which provide access to recruit Methods
    54  type API struct {
    55  	*zoho.Zoho
    56  	id string
    57  }
    58  
    59  // New returns a *recruit.API with the provided zoho.Zoho as an embedded field
    60  func New(z *zoho.Zoho) *API {
    61  	id := func() string {
    62  		var id []byte
    63  		keyspace := "abcdefghijklmnopqrutuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    64  		for i := 0; i < 25; i++ {
    65  			source := rand.NewSource(time.Now().UnixNano())
    66  			rnd := rand.New(source)
    67  			id = append(id, keyspace[rnd.Intn(len(keyspace))])
    68  		}
    69  		return string(id)
    70  	}()
    71  
    72  	return &API{
    73  		Zoho: z,
    74  		id:   id,
    75  	}
    76  }