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

     1  package recruit
     2  
     3  import (
     4  	"fmt"
     5  
     6  	zoho "github.com/schmorrison/Zoho"
     7  )
     8  
     9  // GetNotes returns a list of all notes
    10  // https://www.zoho.com/recruit/developer-guide/apiv2/get-notes.html
    11  // https://recruit.zoho.%s/recruit/v2/Notes
    12  func (c *API) GetNotes(params map[string]zoho.Parameter) (data NotesResponse, err error) {
    13  	endpoint := zoho.Endpoint{
    14  		Name:         "GetNotes",
    15  		URL:          fmt.Sprintf("https://recruit.zoho.%s/recruit/v2/Notes", c.ZohoTLD),
    16  		Method:       zoho.HTTPGet,
    17  		ResponseData: &NotesResponse{},
    18  		URLParameters: map[string]zoho.Parameter{
    19  			"page":     "",
    20  			"per_page": "",
    21  		},
    22  	}
    23  
    24  	if len(params) > 0 {
    25  		for k, v := range params {
    26  			endpoint.URLParameters[k] = v
    27  		}
    28  	}
    29  
    30  	err = c.Zoho.HTTPRequest(&endpoint)
    31  	if err != nil {
    32  		return NotesResponse{}, fmt.Errorf("failed to retrieve notes: %s", err)
    33  	}
    34  
    35  	if v, ok := endpoint.ResponseData.(*NotesResponse); ok {
    36  		return *v, nil
    37  	}
    38  
    39  	return NotesResponse{}, fmt.Errorf("data returned was not 'NotesResponse'")
    40  }
    41  
    42  // NotesResponse is the data returned by GetNotes
    43  type NotesResponse struct {
    44  	Data []struct {
    45  		IsStatusSplitDone bool   `json:"isStatusSplitDone,omitempty"`
    46  		Modified_Time     Time   `json:"Modified_Time,omitempty"`
    47  		Attachments       string `json:"$attachments,omitempty"`
    48  		Created_Time      Time   `json:"Created_Time,omitempty"`
    49  		ParentID          struct {
    50  			Name string `json:"name,omitempty"`
    51  			ID   string `json:"id,omitempty"`
    52  		} `json:"Parent_Id,omitempty"`
    53  		Editable  bool   `json:"$editable,omitempty"`
    54  		SeModule  string `json:"$se_module,omitempty"`
    55  		NoteOwner struct {
    56  			Name string `json:"name,omitempty"`
    57  			ID   string `json:"id,omitempty"`
    58  		} `json:"Note_Owner,omitempty"`
    59  		ModifiedBy struct {
    60  			Name string `json:"name,omitempty"`
    61  			ID   string `json:"id,omitempty"`
    62  		} `json:"Modified_By,omitempty"`
    63  		Size      string `json:"$size,omitempty"`
    64  		VoiceNote bool   `json:"$voice_note,omitempty"`
    65  		ID        string `json:"id,omitempty"`
    66  		CreatedBy struct {
    67  			Name string `json:"name,omitempty"`
    68  			ID   string `json:"id,omitempty"`
    69  		} `json:"Created_By,omitempty"`
    70  		NoteTitle      string `json:"Note_Title,omitempty"`
    71  		NoteContent    string `json:"Note_Content,omitempty"`
    72  		IsSystemAction bool   `json:"is_system_action,omitempty"`
    73  	} `json:"data,omitempty"`
    74  	Info PageInfo `json:"info,omitempty"`
    75  }