forked from theapsgroup/go-freshservice
/
change_note.go
40 lines (34 loc) · 1.54 KB
/
change_note.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package freshservice
import (
"fmt"
"net/http"
)
// GetChangeNote will return a single Note by id
func (s *ChangeService) GetChangeNote(changeId int, changeNoteId int) (*Note, *http.Response, error) {
o := new(noteWrapper)
res, err := s.client.Get(fmt.Sprintf(changeNoteIdUrl, changeId, changeNoteId), &o)
return &o.Details, res, err
}
// ListChangeNotes will return Notes for a specific Change
func (s *ChangeService) ListChangeNotes(changeId int) (*Notes, *http.Response, error) {
o := new(Notes)
res, err := s.client.List(fmt.Sprintf(changeNotesUrl, changeId), nil, &o)
return o, res, err
}
// CreateChangeNote will create and return a new Note based on UpsertNoteModel
func (s *ChangeService) CreateChangeNote(changeId int, note *UpsertNoteModel) (*Note, *http.Response, error) {
o := new(noteWrapper)
res, err := s.client.Post(fmt.Sprintf(changeNotesUrl, changeId), note, &o)
return &o.Details, res, err
}
// UpdateChangeNote will update and return a Note matching id based on UpsertNoteModel
func (s *ChangeService) UpdateChangeNote(changeId int, changeNoteId int, note *UpsertNoteModel) (*Note, *http.Response, error) {
o := new(noteWrapper)
res, err := s.client.Put(fmt.Sprintf(changeNoteIdUrl, changeId, changeNoteId), note, &o)
return &o.Details, res, err
}
// DeleteChangeNote will completely remove a Note from a Change
func (s *ChangeService) DeleteChangeNote(changeId int, changeNoteId int) (bool, *http.Response, error) {
success, res, err := s.client.Delete(fmt.Sprintf(changeNoteIdUrl, changeId, changeNoteId))
return success, res, err
}