Skip to content

Commit

Permalink
Merge pull request #15 from green-api/dev
Browse files Browse the repository at this point in the history
Fixed ReceiveNotification
  • Loading branch information
Amele9 authored Dec 21, 2023
2 parents c96e7bc + 4c04d98 commit 87bf9a0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ func (a GreenAPI) Request(method, APIMethod string, data map[string]interface{},
return response.(map[string]interface{}), err
}

func (a GreenAPI) RawRequest(method, APIMethod string, data map[string]interface{}, filePath string) (interface{}, error) {
url := a.getURL(method, APIMethod, data)

return executeRequest(method, url, data, filePath)
}

func (a GreenAPI) ArrayRequest(method, APIMethod string, data map[string]interface{}, filePath string) ([]interface{}, error) {
url := a.getURL(method, APIMethod, data)

Expand Down
1 change: 1 addition & 0 deletions pkg/categories/methods/base_category.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package methods

type GreenAPIInterface interface {
Request(method, APIMethod string, data map[string]interface{}, filePath string) (map[string]interface{}, error)
RawRequest(method, APIMethod string, data map[string]interface{}, filePath string) (interface{}, error)
ArrayRequest(method, APIMethod string, data map[string]interface{}, filePath string) ([]interface{}, error)
}
8 changes: 7 additions & 1 deletion pkg/categories/methods/receiving.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ type ReceivingCategory struct {
// ReceiveNotification is designed to receive a single incoming notification
// from the notification queue.
func (c ReceivingCategory) ReceiveNotification() (map[string]interface{}, error) {
return c.GreenAPI.Request("GET", "receiveNotification", nil, "")
response, err := c.GreenAPI.RawRequest("GET", "receiveNotification", nil, "")

if response != nil {
return response.(map[string]interface{}), err
}

return nil, err
}

// DeleteNotification is designed to remove an incoming notification
Expand Down

0 comments on commit 87bf9a0

Please sign in to comment.