Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Member Tags API calls #46

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions members.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const (

member_notes_path = single_member_path + "/notes"
single_member_note_path = member_notes_path + "/%s"

member_tags_path = single_member_path + "/tags"
)

type ListOfMembers struct {
Expand Down Expand Up @@ -116,8 +118,9 @@ type MemberNoteShort struct {
}

type MemberTag struct {
ID int `json:"id"`
Name string `json:"name"`
ID int `json:"id"`
Name string `json:"name"`
DateAdded string `json:"date_added"`
}

func (list ListResponse) GetMembers(params *InterestCategoriesQueryParams) (*ListOfMembers, error) {
Expand Down Expand Up @@ -344,3 +347,44 @@ func (mem Member) DeleteNote(id string) (bool, error) {
endpoint := fmt.Sprintf(single_member_note_path, mem.ListID, mem.ID, id)
return mem.api.RequestOk("DELETE", endpoint)
}

// ------------------------------------------------------------------------------------------------
// Tags
// ------------------------------------------------------------------------------------------------

type ListOfMemberTags struct {
baseList

Tags []MemberTag `json:"tags"`
}

type ListOfTagsRequest struct {
Tags []TagsRequest `json:"tags"`
IsSyncing bool `json:"is_syncing"`
}

type TagsRequest struct {
Name string `json:"name"`
Status string `json:"status"`
}

func (mem Member) GetTags(params *BasicQueryParams) (*ListOfMemberTags, error) {
if err := mem.CanMakeRequest(); err != nil {
return nil, err
}

endpoint := fmt.Sprintf(member_tags_path, mem.ListID, mem.ID)
response := new(ListOfMemberTags)

return response, mem.api.Request("GET", endpoint, params, nil, response)
}

func (mem Member) CreateTags(body *ListOfTagsRequest) error {
if err := mem.CanMakeRequest(); err != nil {
return err
}

endpoint := fmt.Sprintf(member_tags_path, mem.ListID, mem.ID)

return mem.api.Request("POST", endpoint, nil, body, nil)
}