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

Version 0.3.0 #15

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.8

require (
github.com/essentialkaos/check v1.4.1
github.com/essentialkaos/ek/v13 v13.10.0
github.com/essentialkaos/ek/v13 v13.11.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/essentialkaos/check v1.4.1 h1:SuxXzrbokPGTPWxGRnzy0hXvtb44mtVrdNxgPa1s4c8=
github.com/essentialkaos/check v1.4.1/go.mod h1:xQOYwFvnxfVZyt5Qvjoa1SxcRqu5VyP77pgALr3iu+M=
github.com/essentialkaos/ek/v13 v13.10.0 h1:uoLNjiDRJ/bOPAciq8Ff92r+XHgTm+rBI4ItOtZje9k=
github.com/essentialkaos/ek/v13 v13.10.0/go.mod h1:6G9EPJ/k4N0mugTLqPuWS/fb7K5JwoEqZSkNSfBCsgg=
github.com/essentialkaos/ek/v13 v13.11.0 h1:vpIk6wiycQGzLcC/zZrxWP2CguJxeoNj9fjuGiYAmJ8=
github.com/essentialkaos/ek/v13 v13.11.0/go.mod h1:GAoS44v5gtd3Yc1qqfgXsaJNoC0dMw1ueW5Fc9TTHUg=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand Down
46 changes: 46 additions & 0 deletions pachca.go
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,52 @@ func (c *Client) ExcludeChatTag(chatID, tagID uint64) error {
return nil
}

// ArchiveChat sends chat to archive
//
// https://crm.pachca.com/dev/chats/archive/
func (c *Client) ArchiveChat(chatID uint64) error {
switch {
case c == nil || c.engine == nil:
return ErrNilClient
case chatID == 0:
return ErrInvalidChatID
}

err := c.sendRequest(
req.PUT, getURL("/chats/%d/archive", chatID),
nil, nil, nil,
)

if err != nil {
return fmt.Errorf("Can't archive chat %d: %w", chatID, err)
}

return nil
}

// UnarchiveChat restores chat from archive
//
// https://crm.pachca.com/dev/chats/unarchive/
func (c *Client) UnarchiveChat(chatID uint64) error {
switch {
case c == nil || c.engine == nil:
return ErrNilClient
case chatID == 0:
return ErrInvalidChatID
}

err := c.sendRequest(
req.PUT, getURL("/chats/%d/unarchive", chatID),
nil, nil, nil,
)

if err != nil {
return fmt.Errorf("Can't unarchive chat %d: %w", chatID, err)
}

return nil
}

// MESSAGES ///////////////////////////////////////////////////////////////////////// //

// GetMessage returns info about message
Expand Down