From 220bd855a9861ed0fdaf9632144fce4492d0008d Mon Sep 17 00:00:00 2001 From: dephea Date: Tue, 12 Mar 2024 11:29:41 +0300 Subject: [PATCH 1/7] added partner methods --- examples/createInstance/main.go | 26 ++++++++++++++++++++++++ examples/deleteInstanceAccount/main.go | 23 +++++++++++++++++++++ examples/getInstances/main.go | 21 +++++++++++++++++++ pkg/api/api.go | 27 +++++++++++++++++++++++++ pkg/categories/categories.go | 4 ++++ pkg/categories/methods/base_category.go | 1 + pkg/categories/methods/partner.go | 22 ++++++++++++++++++++ 7 files changed, 124 insertions(+) create mode 100644 examples/createInstance/main.go create mode 100644 examples/deleteInstanceAccount/main.go create mode 100644 examples/getInstances/main.go create mode 100644 pkg/categories/methods/partner.go diff --git a/examples/createInstance/main.go b/examples/createInstance/main.go new file mode 100644 index 0000000..4de7d43 --- /dev/null +++ b/examples/createInstance/main.go @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + + "github.com/green-api/whatsapp-api-client-golang/pkg/api" +) + +func main() { + Partner := api.GreenAPI{ + IDInstance: "", + APITokenInstance: "Partner-Token", // Partner token + } + + response, err := Partner.Methods().Partner().CreateInstance(map[string]interface{}{ + "stateWebhook": "yes", + "incomingWebhook": "yes", + }) + if err != nil { + fmt.Println(err) + } + + for key, value := range response { + fmt.Printf("%s: %v\n", key, value) + } +} diff --git a/examples/deleteInstanceAccount/main.go b/examples/deleteInstanceAccount/main.go new file mode 100644 index 0000000..c4381f9 --- /dev/null +++ b/examples/deleteInstanceAccount/main.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + + "github.com/green-api/whatsapp-api-client-golang/pkg/api" +) + +func main() { + Partner := api.GreenAPI{ + IDInstance: "", + APITokenInstance: "Partner-Token", // Partner token + } + + response, err := Partner.Methods().Partner().DeleteInstanceAccout(1101915618) + if err != nil { + fmt.Println(err) + } + + for key, value := range response { + fmt.Printf("%s: %v\n", key, value) + } +} diff --git a/examples/getInstances/main.go b/examples/getInstances/main.go new file mode 100644 index 0000000..1a09a87 --- /dev/null +++ b/examples/getInstances/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + + "github.com/green-api/whatsapp-api-client-golang/pkg/api" +) + +func main() { + Partner := api.GreenAPI{ + IDInstance: "", + APITokenInstance: "Partner-Token", // Partner token + } + + response, err := Partner.Methods().Partner().GetInstances() + if err != nil { + fmt.Println(err) + } + + fmt.Println(response) +} diff --git a/pkg/api/api.go b/pkg/api/api.go index 48a9d5e..4002617 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -33,6 +33,14 @@ func (a GreenAPI) Request(method, APIMethod string, data map[string]interface{}, return response.(map[string]interface{}), err } +func (a GreenAPI) PartnerRequest(method, APIMethod string, data map[string]interface{}, filePath string) (map[string]interface{}, error) { + url := a.GetPartnerURL(method, APIMethod, data) + + response, err := executeRequest(method, url, data, filePath) + + 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) @@ -75,3 +83,22 @@ func (a GreenAPI) getURL(method, APIMethod string, data map[string]interface{}) return url.String() } + +func (a GreenAPI) GetPartnerURL(method, APIMethod string, data map[string]interface{}) string { + if a.URL != "" { + return a.URL + } + + var url strings.Builder + + url.WriteString("https://api.green-api.com") + + url.WriteString("/") + url.WriteString("partner") + url.WriteString("/") + url.WriteString(APIMethod) + url.WriteString("/") + url.WriteString(a.APITokenInstance) + + return url.String() +} diff --git a/pkg/categories/categories.go b/pkg/categories/categories.go index 3bc0679..c703451 100644 --- a/pkg/categories/categories.go +++ b/pkg/categories/categories.go @@ -41,3 +41,7 @@ func (c GreenAPICategories) Sending() methods.SendingCategory { func (c GreenAPICategories) Service() methods.ServiceCategory { return methods.ServiceCategory{GreenAPI: c.GreenAPI} } + +func (c GreenAPICategories) Partner() methods.PartnerCategory { + return methods.PartnerCategory{GreenAPI: c.GreenAPI} +} diff --git a/pkg/categories/methods/base_category.go b/pkg/categories/methods/base_category.go index 63e687b..247ab3f 100644 --- a/pkg/categories/methods/base_category.go +++ b/pkg/categories/methods/base_category.go @@ -4,4 +4,5 @@ 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) + PartnerRequest(method, APIMethod string, data map[string]interface{}, filePath string) (map[string]interface{}, error) } diff --git a/pkg/categories/methods/partner.go b/pkg/categories/methods/partner.go new file mode 100644 index 0000000..3b89f55 --- /dev/null +++ b/pkg/categories/methods/partner.go @@ -0,0 +1,22 @@ +package methods + +type PartnerCategory struct { + GreenAPI GreenAPIInterface +} + +func (c PartnerCategory) CreateInstance(parameters map[string]interface{}) (map[string]interface{}, error) { + + return c.GreenAPI.PartnerRequest("POST", "createInstance", parameters, "") +} + +func (c PartnerCategory) DeleteInstanceAccout(idInstance int) (map[string]interface{}, error) { + + return c.GreenAPI.PartnerRequest("POST", "deleteInstanceAccount", map[string]interface{}{ + "idInstance": idInstance, + }, "") +} + +func (c PartnerCategory) GetInstances() (map[string]interface{}, error) { + + return c.GreenAPI.PartnerRequest("GET", "getInstances", nil, "") +} From a19fbe1dab136a499e29ef7d049cbd6cec7c103a Mon Sep 17 00:00:00 2001 From: dephea Date: Tue, 12 Mar 2024 12:21:55 +0300 Subject: [PATCH 2/7] fix createInstance method --- examples/createInstance/main.go | 2 +- examples/deleteInstanceAccount/main.go | 2 +- examples/getInstances/main.go | 6 ++++-- pkg/api/api.go | 12 ++++++++++-- pkg/categories/methods/base_category.go | 1 + pkg/categories/methods/partner.go | 4 ++-- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/examples/createInstance/main.go b/examples/createInstance/main.go index 4de7d43..843014e 100644 --- a/examples/createInstance/main.go +++ b/examples/createInstance/main.go @@ -9,7 +9,7 @@ import ( func main() { Partner := api.GreenAPI{ IDInstance: "", - APITokenInstance: "Partner-Token", // Partner token + APITokenInstance: "PARTNERTOKEN", // Partner token } response, err := Partner.Methods().Partner().CreateInstance(map[string]interface{}{ diff --git a/examples/deleteInstanceAccount/main.go b/examples/deleteInstanceAccount/main.go index c4381f9..0b9372e 100644 --- a/examples/deleteInstanceAccount/main.go +++ b/examples/deleteInstanceAccount/main.go @@ -9,7 +9,7 @@ import ( func main() { Partner := api.GreenAPI{ IDInstance: "", - APITokenInstance: "Partner-Token", // Partner token + APITokenInstance: "PARTNERTOKEN", // Partner token } response, err := Partner.Methods().Partner().DeleteInstanceAccout(1101915618) diff --git a/examples/getInstances/main.go b/examples/getInstances/main.go index 1a09a87..a0cc33c 100644 --- a/examples/getInstances/main.go +++ b/examples/getInstances/main.go @@ -9,7 +9,7 @@ import ( func main() { Partner := api.GreenAPI{ IDInstance: "", - APITokenInstance: "Partner-Token", // Partner token + APITokenInstance: "PARTNERTOKEN", // Partner token } response, err := Partner.Methods().Partner().GetInstances() @@ -17,5 +17,7 @@ func main() { fmt.Println(err) } - fmt.Println(response) + for key, value := range response { + fmt.Printf("%v: %v\n", key, value) + } } diff --git a/pkg/api/api.go b/pkg/api/api.go index 4002617..360c4f7 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -34,13 +34,21 @@ func (a GreenAPI) Request(method, APIMethod string, data map[string]interface{}, } func (a GreenAPI) PartnerRequest(method, APIMethod string, data map[string]interface{}, filePath string) (map[string]interface{}, error) { - url := a.GetPartnerURL(method, APIMethod, data) + url := a.getPartnerURL(method, APIMethod, data) response, err := executeRequest(method, url, data, filePath) return response.(map[string]interface{}), err } +func (a GreenAPI) ArrayPartnerRequest(method, APIMethod string, data map[string]interface{}, filePath string) ([]interface{}, error) { + url := a.getPartnerURL(method, APIMethod, data) + + response, err := executeRequest(method, url, data, filePath) + + return response.([]interface{}), err +} + func (a GreenAPI) RawRequest(method, APIMethod string, data map[string]interface{}, filePath string) (interface{}, error) { url := a.getURL(method, APIMethod, data) @@ -84,7 +92,7 @@ func (a GreenAPI) getURL(method, APIMethod string, data map[string]interface{}) return url.String() } -func (a GreenAPI) GetPartnerURL(method, APIMethod string, data map[string]interface{}) string { +func (a GreenAPI) getPartnerURL(method, APIMethod string, data map[string]interface{}) string { if a.URL != "" { return a.URL } diff --git a/pkg/categories/methods/base_category.go b/pkg/categories/methods/base_category.go index 247ab3f..668da9d 100644 --- a/pkg/categories/methods/base_category.go +++ b/pkg/categories/methods/base_category.go @@ -5,4 +5,5 @@ type GreenAPIInterface interface { RawRequest(method, APIMethod string, data map[string]interface{}, filePath string) (interface{}, error) ArrayRequest(method, APIMethod string, data map[string]interface{}, filePath string) ([]interface{}, error) PartnerRequest(method, APIMethod string, data map[string]interface{}, filePath string) (map[string]interface{}, error) + ArrayPartnerRequest(method, APIMethod string, data map[string]interface{}, filePath string) ([]interface{}, error) } diff --git a/pkg/categories/methods/partner.go b/pkg/categories/methods/partner.go index 3b89f55..e49c778 100644 --- a/pkg/categories/methods/partner.go +++ b/pkg/categories/methods/partner.go @@ -16,7 +16,7 @@ func (c PartnerCategory) DeleteInstanceAccout(idInstance int) (map[string]interf }, "") } -func (c PartnerCategory) GetInstances() (map[string]interface{}, error) { +func (c PartnerCategory) GetInstances() ([]interface{}, error) { - return c.GreenAPI.PartnerRequest("GET", "getInstances", nil, "") + return c.GreenAPI.ArrayPartnerRequest("GET", "getInstances", nil, "") } From 21ceb41baf44542d6dbc436b483ff6638fdaf0c7 Mon Sep 17 00:00:00 2001 From: dephea Date: Wed, 13 Mar 2024 08:58:53 +0300 Subject: [PATCH 3/7] Documentation for partner methods --- examples/createInstance/main.go | 2 +- examples/deleteInstanceAccount/main.go | 23 ----------------------- examples/getInstances/main.go | 23 ----------------------- pkg/categories/methods/partner.go | 7 ++++++- 4 files changed, 7 insertions(+), 48 deletions(-) delete mode 100644 examples/deleteInstanceAccount/main.go delete mode 100644 examples/getInstances/main.go diff --git a/examples/createInstance/main.go b/examples/createInstance/main.go index 843014e..4de7d43 100644 --- a/examples/createInstance/main.go +++ b/examples/createInstance/main.go @@ -9,7 +9,7 @@ import ( func main() { Partner := api.GreenAPI{ IDInstance: "", - APITokenInstance: "PARTNERTOKEN", // Partner token + APITokenInstance: "Partner-Token", // Partner token } response, err := Partner.Methods().Partner().CreateInstance(map[string]interface{}{ diff --git a/examples/deleteInstanceAccount/main.go b/examples/deleteInstanceAccount/main.go deleted file mode 100644 index 0b9372e..0000000 --- a/examples/deleteInstanceAccount/main.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/green-api/whatsapp-api-client-golang/pkg/api" -) - -func main() { - Partner := api.GreenAPI{ - IDInstance: "", - APITokenInstance: "PARTNERTOKEN", // Partner token - } - - response, err := Partner.Methods().Partner().DeleteInstanceAccout(1101915618) - if err != nil { - fmt.Println(err) - } - - for key, value := range response { - fmt.Printf("%s: %v\n", key, value) - } -} diff --git a/examples/getInstances/main.go b/examples/getInstances/main.go deleted file mode 100644 index a0cc33c..0000000 --- a/examples/getInstances/main.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/green-api/whatsapp-api-client-golang/pkg/api" -) - -func main() { - Partner := api.GreenAPI{ - IDInstance: "", - APITokenInstance: "PARTNERTOKEN", // Partner token - } - - response, err := Partner.Methods().Partner().GetInstances() - if err != nil { - fmt.Println(err) - } - - for key, value := range response { - fmt.Printf("%v: %v\n", key, value) - } -} diff --git a/pkg/categories/methods/partner.go b/pkg/categories/methods/partner.go index e49c778..ef63b1f 100644 --- a/pkg/categories/methods/partner.go +++ b/pkg/categories/methods/partner.go @@ -4,11 +4,14 @@ type PartnerCategory struct { GreenAPI GreenAPIInterface } +// This method is aimed to create an instace using partner account. +// https://green-api.com/en/docs/partners/createInstance/ func (c PartnerCategory) CreateInstance(parameters map[string]interface{}) (map[string]interface{}, error) { - return c.GreenAPI.PartnerRequest("POST", "createInstance", parameters, "") } +// This method is aimed to delete an instance using partner account. +// https://green-api.com/en/docs/partners/deleteInstanceAccount/ func (c PartnerCategory) DeleteInstanceAccout(idInstance int) (map[string]interface{}, error) { return c.GreenAPI.PartnerRequest("POST", "deleteInstanceAccount", map[string]interface{}{ @@ -16,6 +19,8 @@ func (c PartnerCategory) DeleteInstanceAccout(idInstance int) (map[string]interf }, "") } +// This method is aimed to get all instances on a partner account. +// https://green-api.com/en/docs/partners/getInstances/ func (c PartnerCategory) GetInstances() ([]interface{}, error) { return c.GreenAPI.ArrayPartnerRequest("GET", "getInstances", nil, "") From 29c2e652cd1ac2c333e0f0b509da34c5cca33ee5 Mon Sep 17 00:00:00 2001 From: dephea Date: Wed, 13 Mar 2024 10:00:35 +0300 Subject: [PATCH 4/7] Added links within the methods to their respective documentation --- pkg/categories/categories.go | 25 +++++++++++++++++++++++++ pkg/categories/methods/account.go | 10 ++++++++++ pkg/categories/methods/groups.go | 9 +++++++++ pkg/categories/methods/journals.go | 4 ++++ pkg/categories/methods/queues.go | 2 ++ pkg/categories/methods/read_mark.go | 1 + pkg/categories/methods/receiving.go | 3 +++ pkg/categories/methods/sending.go | 14 ++++++++++++-- pkg/categories/methods/service.go | 8 ++++++++ 9 files changed, 74 insertions(+), 2 deletions(-) diff --git a/pkg/categories/categories.go b/pkg/categories/categories.go index c703451..15991e4 100644 --- a/pkg/categories/categories.go +++ b/pkg/categories/categories.go @@ -6,6 +6,8 @@ type GreenAPICategories struct { GreenAPI methods.GreenAPIInterface } +// This section presents methods for working with the Account. +// https://green-api.com/en/docs/api/account/ func (c GreenAPICategories) Account() methods.AccountCategory { return methods.AccountCategory{GreenAPI: c.GreenAPI} } @@ -14,34 +16,57 @@ func (c GreenAPICategories) Device() methods.DeviceCategory { return methods.DeviceCategory{GreenAPI: c.GreenAPI} } +// This section presents methods for working with group chats. +// https://green-api.com/en/docs/api/groups/ func (c GreenAPICategories) Groups() methods.GroupsCategory { return methods.GroupsCategory{GreenAPI: c.GreenAPI} } +// This section presents methods for working with incoming and outgoing messages journals. +// https://green-api.com/en/docs/api/journals/ func (c GreenAPICategories) Journals() methods.JournalsCategory { return methods.JournalsCategory{GreenAPI: c.GreenAPI} } +// This section presents methods for working with a messages queue. +// https://green-api.com/en/docs/api/queues/ func (c GreenAPICategories) Queues() methods.QueuesCategory { return methods.QueuesCategory{GreenAPI: c.GreenAPI} } +// This section presents methods for working with chat read mark. +// https://green-api.com/en/docs/api/marks/ func (c GreenAPICategories) ReadMark() methods.ReadMarkCategory { return methods.ReadMarkCategory{GreenAPI: c.GreenAPI} } +// This section presents methods for working with receiving events. +// https://green-api.com/en/docs/api/receiving/ func (c GreenAPICategories) Receiving() methods.ReceivingCategory { return methods.ReceivingCategory{GreenAPI: c.GreenAPI} } +// This section presents methods for sending text messages, video, audio, images, documents, locations, contacts and links. +// https://green-api.com/en/docs/api/sending/ func (c GreenAPICategories) Sending() methods.SendingCategory { return methods.SendingCategory{GreenAPI: c.GreenAPI} } +// This section presents different service methods. +// https://green-api.com/en/docs/api/service/ func (c GreenAPICategories) Service() methods.ServiceCategory { return methods.ServiceCategory{GreenAPI: c.GreenAPI} } +// This section presents exclusive methods for partners. +// The partnership scheme involves deeper integration with the service and working with a larger number of instances on your side: + +// * Instance management via API +// * Postpaid billing system (starting from the second month of operation) +// * Daily billing (for created and not deleted instances) +// * Dedicated support line +// For questions regarding connection to the partnership scheme and additional conditions, please contact us via email at support@green-api.com or via chat on the website. +// https://green-api.com/en/docs/partners/ func (c GreenAPICategories) Partner() methods.PartnerCategory { return methods.PartnerCategory{GreenAPI: c.GreenAPI} } diff --git a/pkg/categories/methods/account.go b/pkg/categories/methods/account.go index b5b054d..f6232d1 100644 --- a/pkg/categories/methods/account.go +++ b/pkg/categories/methods/account.go @@ -5,16 +5,19 @@ type AccountCategory struct { } // GetSettings is designed to get the current settings of the account. +// https://green-api.com/en/docs/api/account/GetSettings/ func (c AccountCategory) GetSettings() (map[string]interface{}, error) { return c.GreenAPI.Request("GET", "getSettings", nil, "") } // GetWaSettings is designed to get information about the WhatsApp account. +// https://green-api.com/en/docs/api/account/GetWaSettings/ func (c AccountCategory) GetWaSettings() (map[string]interface{}, error) { return c.GreenAPI.Request("GET", "getWaSettings", nil, "") } // SetSettings is for setting the account settings. +// https://green-api.com/en/docs/api/account/SetSettings/ func (c AccountCategory) SetSettings(parameters map[string]interface{}) (map[string]interface{}, error) { method := "GET" if parameters != nil { @@ -25,37 +28,44 @@ func (c AccountCategory) SetSettings(parameters map[string]interface{}) (map[str } // GetStateInstance is designed to get the state of the account. +// https://green-api.com/en/docs/api/account/GetStateInstance/ func (c AccountCategory) GetStateInstance() (map[string]interface{}, error) { return c.GreenAPI.Request("GET", "getStateInstance", nil, "") } // GetStatusInstance is designed to get the socket connection state // of the account instance with WhatsApp. +// https://green-api.com/en/docs/api/account/GetStatusInstance/ func (c AccountCategory) GetStatusInstance() (map[string]interface{}, error) { return c.GreenAPI.Request("GET", "getStatusInstance", nil, "") } // Reboot is designed to restart the account. +// https://green-api.com/en/docs/api/account/Reboot/ func (c AccountCategory) Reboot() (map[string]interface{}, error) { return c.GreenAPI.Request("GET", "reboot", nil, "") } // Logout is designed to unlogin the account. +// https://green-api.com/en/docs/api/account/Logout/ func (c AccountCategory) Logout() (map[string]interface{}, error) { return c.GreenAPI.Request("GET", "logout", nil, "") } // QR is designed to get a QR code. +// https://green-api.com/en/docs/api/account/QR/ func (c AccountCategory) QR() (map[string]interface{}, error) { return c.GreenAPI.Request("GET", "qr", nil, "") } // SetProfilePicture is designed to set the avatar of the account. +// https://green-api.com/en/docs/api/account/SetProfilePicture/ func (c AccountCategory) SetProfilePicture(filePath string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "setProfilePicture", nil, filePath) } // GetAuthorizationCode is designed to authorize an instance by phone number. +// https://green-api.com/en/docs/api/account/GetAuthorizationCode/ func (c AccountCategory) GetAuthorizationCode(phoneNumber int) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "getAuthorizationCode", map[string]interface{}{ "phoneNumber": phoneNumber, diff --git a/pkg/categories/methods/groups.go b/pkg/categories/methods/groups.go index 1046724..b2fb03b 100644 --- a/pkg/categories/methods/groups.go +++ b/pkg/categories/methods/groups.go @@ -5,6 +5,7 @@ type GroupsCategory struct { } // CreateGroup is designed to create a group chat. +// https://green-api.com/en/docs/api/groups/CreateGroup/ func (c GroupsCategory) CreateGroup(groupName string, chatIds []string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "createGroup", map[string]interface{}{ "groupName": groupName, @@ -13,6 +14,7 @@ func (c GroupsCategory) CreateGroup(groupName string, chatIds []string) (map[str } // UpdateGroupName changes the name of the group chat. +// https://green-api.com/en/docs/api/groups/UpdateGroupName/ func (c GroupsCategory) UpdateGroupName(groupId, groupName string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "updateGroupName", map[string]interface{}{ "groupId": groupId, @@ -21,6 +23,7 @@ func (c GroupsCategory) UpdateGroupName(groupId, groupName string) (map[string]i } // GetGroupData gets group chat data. +// https://green-api.com/en/docs/api/groups/GetGroupData/ func (c GroupsCategory) GetGroupData(groupId string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "getGroupData", map[string]interface{}{ "groupId": groupId, @@ -28,6 +31,7 @@ func (c GroupsCategory) GetGroupData(groupId string) (map[string]interface{}, er } // AddGroupParticipant adds a participant to the group chat. +// https://green-api.com/en/docs/api/groups/AddGroupParticipant/ func (c GroupsCategory) AddGroupParticipant(groupId, participantChatId string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "addGroupParticipant", map[string]interface{}{ "groupId": groupId, @@ -36,6 +40,7 @@ func (c GroupsCategory) AddGroupParticipant(groupId, participantChatId string) ( } // RemoveGroupParticipant removes the participant from the group chat. +// https://green-api.com/en/docs/api/groups/RemoveGroupParticipant/ func (c GroupsCategory) RemoveGroupParticipant(groupId, participantChatId string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "removeGroupParticipant", map[string]interface{}{ "groupId": groupId, @@ -44,6 +49,7 @@ func (c GroupsCategory) RemoveGroupParticipant(groupId, participantChatId string } // SetGroupAdmin designates a member of a group chat as an administrator. +// https://green-api.com/en/docs/api/groups/SetGroupAdmin/ func (c GroupsCategory) SetGroupAdmin(groupId, participantChatId string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "setGroupAdmin", map[string]interface{}{ "groupId": groupId, @@ -52,6 +58,7 @@ func (c GroupsCategory) SetGroupAdmin(groupId, participantChatId string) (map[st } // RemoveAdmin deprives the participant of group chat administration rights. +// https://green-api.com/en/docs/api/groups/RemoveAdmin/ func (c GroupsCategory) RemoveAdmin(groupId, participantChatId string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "removeAdmin", map[string]interface{}{ "groupId": groupId, @@ -60,6 +67,7 @@ func (c GroupsCategory) RemoveAdmin(groupId, participantChatId string) (map[stri } // SetGroupPicture sets the avatar of the group. +// https://green-api.com/en/docs/api/groups/SetGroupPicture/ func (c GroupsCategory) SetGroupPicture(filePath, groupId string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "setGroupPicture", map[string]interface{}{ "groupId": groupId, @@ -67,6 +75,7 @@ func (c GroupsCategory) SetGroupPicture(filePath, groupId string) (map[string]in } // LeaveGroup logs the user of the current account out of the group chat. +// https://green-api.com/en/docs/api/groups/LeaveGroup/ func (c GroupsCategory) LeaveGroup(groupId string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "leaveGroup", map[string]interface{}{ "groupId": groupId, diff --git a/pkg/categories/methods/journals.go b/pkg/categories/methods/journals.go index 9cffa3d..691b216 100644 --- a/pkg/categories/methods/journals.go +++ b/pkg/categories/methods/journals.go @@ -5,11 +5,13 @@ type JournalsCategory struct { } // GetChatHistory returns the chat message history. +// https://green-api.com/en/docs/api/journals/GetChatHistory/ func (c JournalsCategory) GetChatHistory(parameters map[string]interface{}) ([]interface{}, error) { return c.GreenAPI.ArrayRequest("POST", "getChatHistory", parameters, "") } // GetMessage returns a chat message. +// https://green-api.com/en/docs/api/journals/GetMessage/ func (c JournalsCategory) GetMessage(chatId, idMessage string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "getMessage", map[string]interface{}{ "chatId": chatId, @@ -19,11 +21,13 @@ func (c JournalsCategory) GetMessage(chatId, idMessage string) (map[string]inter // LastIncomingMessages returns the most recent incoming messages // of the account. +// https://green-api.com/en/docs/api/journals/LastIncomingMessages/ func (c JournalsCategory) LastIncomingMessages(parameters map[string]interface{}) ([]interface{}, error) { return c.GreenAPI.ArrayRequest("GET", "lastIncomingMessages", parameters, "") } // LastOutgoingMessages returns the last sent messages of the account. +// https://green-api.com/en/docs/api/journals/LastOutgoingMessages/ func (c JournalsCategory) LastOutgoingMessages(parameters map[string]interface{}) ([]interface{}, error) { return c.GreenAPI.ArrayRequest("GET", "lastOutgoingMessages", parameters, "") } diff --git a/pkg/categories/methods/queues.go b/pkg/categories/methods/queues.go index 1808c45..586db99 100644 --- a/pkg/categories/methods/queues.go +++ b/pkg/categories/methods/queues.go @@ -6,11 +6,13 @@ type QueuesCategory struct { // ShowMessagesQueue is designed to get the list of messages // that are in the queue to be sent. +// https://green-api.com/en/docs/api/queues/ShowMessagesQueue/ func (c QueuesCategory) ShowMessagesQueue() ([]interface{}, error) { return c.GreenAPI.ArrayRequest("GET", "showMessagesQueue", nil, "") } // ClearMessagesQueue is designed to clear the queue of messages to be sent. +// https://green-api.com/en/docs/api/queues/ClearMessagesQueue/ func (c QueuesCategory) ClearMessagesQueue() (map[string]interface{}, error) { return c.GreenAPI.Request("GET", "clearMessagesQueue", nil, "") } diff --git a/pkg/categories/methods/read_mark.go b/pkg/categories/methods/read_mark.go index a8763dc..f82cb58 100644 --- a/pkg/categories/methods/read_mark.go +++ b/pkg/categories/methods/read_mark.go @@ -5,6 +5,7 @@ type ReadMarkCategory struct { } // ReadChat is designed to mark chat messages as read. +// https://green-api.com/en/docs/api/marks/ReadChat/ func (c ReadMarkCategory) ReadChat(parameters map[string]interface{}) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "readChat", parameters, "") } diff --git a/pkg/categories/methods/receiving.go b/pkg/categories/methods/receiving.go index 2cc050d..c68c32c 100644 --- a/pkg/categories/methods/receiving.go +++ b/pkg/categories/methods/receiving.go @@ -6,6 +6,7 @@ type ReceivingCategory struct { // ReceiveNotification is designed to receive a single incoming notification // from the notification queue. +// https://green-api.com/en/docs/api/receiving/technology-http-api/ReceiveNotification/ func (c ReceivingCategory) ReceiveNotification() (map[string]interface{}, error) { response, err := c.GreenAPI.RawRequest("GET", "receiveNotification", nil, "") @@ -18,6 +19,7 @@ func (c ReceivingCategory) ReceiveNotification() (map[string]interface{}, error) // DeleteNotification is designed to remove an incoming notification // from the notification queue. +// https://green-api.com/en/docs/api/receiving/technology-http-api/DeleteNotification/ func (c ReceivingCategory) DeleteNotification(receiptId int) (map[string]interface{}, error) { return c.GreenAPI.Request("DELETE", "deleteNotification", map[string]interface{}{ "receiptId": receiptId, @@ -25,6 +27,7 @@ func (c ReceivingCategory) DeleteNotification(receiptId int) (map[string]interfa } // DownloadFile is for downloading received and sent files. +// https://green-api.com/en/docs/api/receiving/files/DownloadFile/ func (c ReceivingCategory) DownloadFile(chatId, idMessage string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "downloadFile", map[string]interface{}{ "chatId": chatId, diff --git a/pkg/categories/methods/sending.go b/pkg/categories/methods/sending.go index 03059b8..3439596 100644 --- a/pkg/categories/methods/sending.go +++ b/pkg/categories/methods/sending.go @@ -5,56 +5,64 @@ type SendingCategory struct { } // SendMessage is designed to send a text message to a personal or group chat. +// https://green-api.com/en/docs/api/sending/SendMessage/ func (c SendingCategory) SendMessage(parameters map[string]interface{}) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "sendMessage", parameters, "") } // SendButtons is designed to send a message with buttons // to a personal or group chat. +// https://green-api.com/en/docs/api/sending/SendButtons/ func (c SendingCategory) SendButtons(parameters map[string]interface{}) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "sendButtons", parameters, "") } // SendTemplateButtons is designed to send a message with interactive buttons // from the list of templates in a personal or group chat. +// https://green-api.com/en/docs/api/sending/SendTemplateButtons/ func (c SendingCategory) SendTemplateButtons(parameters map[string]interface{}) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "sendTemplateButtons", parameters, "") } // SendListMessage is designed to send a message with a selection button // from a list of values to a personal or group chat. +// https://green-api.com/en/docs/api/sending/SendListMessage/ func (c SendingCategory) SendListMessage(parameters map[string]interface{}) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "sendListMessage", parameters, "") } // SendFileByUpload is designed to send a file loaded through a form (form-data). +// https://green-api.com/en/docs/api/sending/SendFileByUpload/ func (c SendingCategory) SendFileByUpload(filePath string, parameters map[string]interface{}) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "sendFileByUpload", parameters, filePath) } // SendFileByUrl is designed to send a file downloaded via a link. +// https://green-api.com/en/docs/api/sending/SendFileByUrl/ func (c SendingCategory) SendFileByUrl(parameters map[string]interface{}) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "sendFileByUrl", parameters, "") } // SendLocation is designed to send a geolocation message. +// https://green-api.com/en/docs/api/sending/SendLocation/ func (c SendingCategory) SendLocation(parameters map[string]interface{}) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "sendLocation", parameters, "") } // SendContact is for sending a message with a contact. +// https://green-api.com/en/docs/api/sending/SendContact/ func (c SendingCategory) SendContact(parameters map[string]interface{}) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "sendContact", parameters, "") } -// SendLink is designed to send a message with a link -// that will add an image preview, title and description. +// The method is deprecated. Please use sendMessage. func (c SendingCategory) SendLink(parameters map[string]interface{}) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "sendLink", parameters, "") } // ForwardMessages is designed for forwarding messages // to a personal or group chat. +// https://green-api.com/en/docs/api/sending/ForwardMessages/ func (c SendingCategory) ForwardMessages(chatId, chatIdFrom string, messages []string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "forwardMessages", map[string]interface{}{ "chatId": chatId, @@ -65,12 +73,14 @@ func (c SendingCategory) ForwardMessages(chatId, chatIdFrom string, messages []s // UploadFile allows you to upload a file from the local file system, // which can later be sent using the SendFileByUrl method. +// https://green-api.com/en/docs/api/sending/UploadFile/ func (c SendingCategory) UploadFile(filePath string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "uploadFile", nil, filePath) } // SendPoll is designed for sending messages with a poll // to a private or group chat. +// https://green-api.com/en/docs/api/sending/SendPoll/ func (c SendingCategory) SendPoll(parameters map[string]interface{}) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "sendPoll", parameters, "") } diff --git a/pkg/categories/methods/service.go b/pkg/categories/methods/service.go index 853580c..632bb0e 100644 --- a/pkg/categories/methods/service.go +++ b/pkg/categories/methods/service.go @@ -5,6 +5,7 @@ type ServiceCategory struct { } // CheckWhatsapp checks if there is a WhatsApp account on the phone number. +// https://green-api.com/en/docs/api/service/CheckWhatsapp/ func (c ServiceCategory) CheckWhatsapp(phoneNumber int) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "checkWhatsapp", map[string]interface{}{ "phoneNumber": phoneNumber, @@ -12,6 +13,7 @@ func (c ServiceCategory) CheckWhatsapp(phoneNumber int) (map[string]interface{}, } // GetAvatar returns the avatar of the correspondent or group chat. +// https://green-api.com/en/docs/api/service/GetAvatar/ func (c ServiceCategory) GetAvatar(chatId string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "getAvatar", map[string]interface{}{ "chatId": chatId, @@ -19,11 +21,13 @@ func (c ServiceCategory) GetAvatar(chatId string) (map[string]interface{}, error } // GetContacts is designed to get a list of contacts of the current account. +// https://green-api.com/en/docs/api/service/GetContacts/ func (c ServiceCategory) GetContacts() ([]interface{}, error) { return c.GreenAPI.ArrayRequest("GET", "getContacts", nil, "") } // GetContactInfo is designed to obtain information about the contact. +// https://green-api.com/en/docs/api/service/GetContactInfo/ func (c ServiceCategory) GetContactInfo(chatId string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "getContactInfo", map[string]interface{}{ "chatId": chatId, @@ -31,6 +35,7 @@ func (c ServiceCategory) GetContactInfo(chatId string) (map[string]interface{}, } // DeleteMessage deletes the message from chat. +// https://green-api.com/en/docs/api/service/deleteMessage/ func (c ServiceCategory) DeleteMessage(chatId, idMessage string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "deleteMessage", map[string]interface{}{ "chatId": chatId, @@ -39,6 +44,7 @@ func (c ServiceCategory) DeleteMessage(chatId, idMessage string) (map[string]int } // ArchiveChat archives the chat. +// https://green-api.com/en/docs/api/service/archiveChat/ func (c ServiceCategory) ArchiveChat(chatId string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "archiveChat", map[string]interface{}{ "chatId": chatId, @@ -46,6 +52,7 @@ func (c ServiceCategory) ArchiveChat(chatId string) (map[string]interface{}, err } // UnarchiveChat unarchives the chat. +// https://green-api.com/en/docs/api/service/unarchiveChat/ func (c ServiceCategory) UnarchiveChat(chatId string) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "unarchiveChat", map[string]interface{}{ "chatId": chatId, @@ -54,6 +61,7 @@ func (c ServiceCategory) UnarchiveChat(chatId string) (map[string]interface{}, e // SetDisappearingChat is designed to change the settings // of disappearing messages in chats. +// https://green-api.com/en/docs/api/service/SetDisappearingChat/ func (c ServiceCategory) SetDisappearingChat(parameters map[string]interface{}) (map[string]interface{}, error) { method := "GET" if parameters != nil { From f5239326ffeed918cc8062e8d22b48fd93d3e822 Mon Sep 17 00:00:00 2001 From: dephea Date: Fri, 15 Mar 2024 10:14:25 +0300 Subject: [PATCH 5/7] methods and documentation small fixes --- examples/createInstance/main.go | 7 ++----- pkg/api/api.go | 22 +++++++++++++++------- pkg/categories/categories.go | 17 +++++++++++------ pkg/categories/methods/device.go | 1 + pkg/categories/methods/partner.go | 14 +++++--------- pkg/categories/methods/sending.go | 4 ++-- 6 files changed, 36 insertions(+), 29 deletions(-) diff --git a/examples/createInstance/main.go b/examples/createInstance/main.go index 4de7d43..9602d05 100644 --- a/examples/createInstance/main.go +++ b/examples/createInstance/main.go @@ -8,8 +8,7 @@ import ( func main() { Partner := api.GreenAPI{ - IDInstance: "", - APITokenInstance: "Partner-Token", // Partner token + PartnerToken: "gac.37ea41ed00d74bc7a0899215312fed55bfd9bcd03a1e48", } response, err := Partner.Methods().Partner().CreateInstance(map[string]interface{}{ @@ -20,7 +19,5 @@ func main() { fmt.Println(err) } - for key, value := range response { - fmt.Printf("%s: %v\n", key, value) - } + fmt.Println(response) } diff --git a/pkg/api/api.go b/pkg/api/api.go index 360c4f7..c1c9825 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -1,6 +1,7 @@ package api import ( + "fmt" "strconv" "strings" @@ -11,6 +12,7 @@ type GreenAPI struct { URL string IDInstance string APITokenInstance string + PartnerToken string } func (a GreenAPI) Methods() categories.GreenAPICategories { @@ -34,7 +36,10 @@ func (a GreenAPI) Request(method, APIMethod string, data map[string]interface{}, } func (a GreenAPI) PartnerRequest(method, APIMethod string, data map[string]interface{}, filePath string) (map[string]interface{}, error) { - url := a.getPartnerURL(method, APIMethod, data) + url, err := a.getPartnerURL(APIMethod) + if err != nil { + return nil, err + } response, err := executeRequest(method, url, data, filePath) @@ -42,7 +47,10 @@ func (a GreenAPI) PartnerRequest(method, APIMethod string, data map[string]inter } func (a GreenAPI) ArrayPartnerRequest(method, APIMethod string, data map[string]interface{}, filePath string) ([]interface{}, error) { - url := a.getPartnerURL(method, APIMethod, data) + url, err := a.getPartnerURL(APIMethod) + if err != nil { + return nil, err + } response, err := executeRequest(method, url, data, filePath) @@ -92,9 +100,9 @@ func (a GreenAPI) getURL(method, APIMethod string, data map[string]interface{}) return url.String() } -func (a GreenAPI) getPartnerURL(method, APIMethod string, data map[string]interface{}) string { - if a.URL != "" { - return a.URL +func (a GreenAPI) getPartnerURL(APIMethod string) (string, error) { + if a.PartnerToken == "" { + return "", fmt.Errorf("error while generating URL: PartnerToken is empty") } var url strings.Builder @@ -106,7 +114,7 @@ func (a GreenAPI) getPartnerURL(method, APIMethod string, data map[string]interf url.WriteString("/") url.WriteString(APIMethod) url.WriteString("/") - url.WriteString(a.APITokenInstance) + url.WriteString(a.PartnerToken) - return url.String() + return url.String(), nil } diff --git a/pkg/categories/categories.go b/pkg/categories/categories.go index 15991e4..0779c24 100644 --- a/pkg/categories/categories.go +++ b/pkg/categories/categories.go @@ -6,12 +6,14 @@ type GreenAPICategories struct { GreenAPI methods.GreenAPIInterface } -// This section presents methods for working with the Account. +// This section presents methods for working with the account. // https://green-api.com/en/docs/api/account/ func (c GreenAPICategories) Account() methods.AccountCategory { return methods.AccountCategory{GreenAPI: c.GreenAPI} } +// This section presents methods for working with the device (phone). +// https://green-api.com/en/docs/api/phone/ func (c GreenAPICategories) Device() methods.DeviceCategory { return methods.DeviceCategory{GreenAPI: c.GreenAPI} } @@ -22,7 +24,7 @@ func (c GreenAPICategories) Groups() methods.GroupsCategory { return methods.GroupsCategory{GreenAPI: c.GreenAPI} } -// This section presents methods for working with incoming and outgoing messages journals. +// This section presents methods for working with incoming and outgoing messages. // https://green-api.com/en/docs/api/journals/ func (c GreenAPICategories) Journals() methods.JournalsCategory { return methods.JournalsCategory{GreenAPI: c.GreenAPI} @@ -46,7 +48,7 @@ func (c GreenAPICategories) Receiving() methods.ReceivingCategory { return methods.ReceivingCategory{GreenAPI: c.GreenAPI} } -// This section presents methods for sending text messages, video, audio, images, documents, locations, contacts and links. +// This section presents methods for sending different messages. // https://green-api.com/en/docs/api/sending/ func (c GreenAPICategories) Sending() methods.SendingCategory { return methods.SendingCategory{GreenAPI: c.GreenAPI} @@ -59,13 +61,16 @@ func (c GreenAPICategories) Service() methods.ServiceCategory { } // This section presents exclusive methods for partners. -// The partnership scheme involves deeper integration with the service and working with a larger number of instances on your side: - +// The partnership scheme involves deeper integration with the service +// and working with a larger number of instances on your side: +// // * Instance management via API // * Postpaid billing system (starting from the second month of operation) // * Daily billing (for created and not deleted instances) // * Dedicated support line -// For questions regarding connection to the partnership scheme and additional conditions, please contact us via email at support@green-api.com or via chat on the website. +// For questions regarding connection to the partnership scheme +// and additional conditions, please contact us via email +// at support@green-api.com or via chat on the website. // https://green-api.com/en/docs/partners/ func (c GreenAPICategories) Partner() methods.PartnerCategory { return methods.PartnerCategory{GreenAPI: c.GreenAPI} diff --git a/pkg/categories/methods/device.go b/pkg/categories/methods/device.go index 8a00511..60d0a70 100644 --- a/pkg/categories/methods/device.go +++ b/pkg/categories/methods/device.go @@ -6,6 +6,7 @@ type DeviceCategory struct { // GetDeviceInfo is designed to get information about the device (phone) // on which the WhatsApp Business application is running. +// https://green-api.com/en/docs/api/phone/ func (c DeviceCategory) GetDeviceInfo() (map[string]interface{}, error) { return c.GreenAPI.Request("GET", "getDeviceInfo", nil, "") } diff --git a/pkg/categories/methods/partner.go b/pkg/categories/methods/partner.go index ef63b1f..6f9d786 100644 --- a/pkg/categories/methods/partner.go +++ b/pkg/categories/methods/partner.go @@ -4,24 +4,20 @@ type PartnerCategory struct { GreenAPI GreenAPIInterface } -// This method is aimed to create an instace using partner account. +// CreateInstance is aimed to create an instace using partner account. // https://green-api.com/en/docs/partners/createInstance/ func (c PartnerCategory) CreateInstance(parameters map[string]interface{}) (map[string]interface{}, error) { return c.GreenAPI.PartnerRequest("POST", "createInstance", parameters, "") } -// This method is aimed to delete an instance using partner account. +// DeleteInstanceAccount is aimed to delete an instance using partner account. // https://green-api.com/en/docs/partners/deleteInstanceAccount/ -func (c PartnerCategory) DeleteInstanceAccout(idInstance int) (map[string]interface{}, error) { - - return c.GreenAPI.PartnerRequest("POST", "deleteInstanceAccount", map[string]interface{}{ - "idInstance": idInstance, - }, "") +func (c PartnerCategory) DeleteInstanceAccount(idInstance int) (map[string]interface{}, error) { + return c.GreenAPI.PartnerRequest("POST", "deleteInstanceAccount", map[string]interface{}{"idInstance": idInstance}, "") } -// This method is aimed to get all instances on a partner account. +// GetInstances is aimed to get all instances on a partner account. // https://green-api.com/en/docs/partners/getInstances/ func (c PartnerCategory) GetInstances() ([]interface{}, error) { - return c.GreenAPI.ArrayPartnerRequest("GET", "getInstances", nil, "") } diff --git a/pkg/categories/methods/sending.go b/pkg/categories/methods/sending.go index 3439596..df26587 100644 --- a/pkg/categories/methods/sending.go +++ b/pkg/categories/methods/sending.go @@ -31,7 +31,7 @@ func (c SendingCategory) SendListMessage(parameters map[string]interface{}) (map return c.GreenAPI.Request("POST", "sendListMessage", parameters, "") } -// SendFileByUpload is designed to send a file loaded through a form (form-data). +// SendFileByUpload is designed to send a file loaded through a form-data. // https://green-api.com/en/docs/api/sending/SendFileByUpload/ func (c SendingCategory) SendFileByUpload(filePath string, parameters map[string]interface{}) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "sendFileByUpload", parameters, filePath) @@ -55,7 +55,7 @@ func (c SendingCategory) SendContact(parameters map[string]interface{}) (map[str return c.GreenAPI.Request("POST", "sendContact", parameters, "") } -// The method is deprecated. Please use sendMessage. +// The method is deprecated. Please use SendMessage. func (c SendingCategory) SendLink(parameters map[string]interface{}) (map[string]interface{}, error) { return c.GreenAPI.Request("POST", "sendLink", parameters, "") } From 58a42e4df290ee6bfec02d7bd831805746767d0e Mon Sep 17 00:00:00 2001 From: dephea Date: Wed, 20 Mar 2024 08:52:41 +0300 Subject: [PATCH 6/7] small documentation fix --- pkg/categories/categories.go | 20 ++++++++++---------- pkg/categories/methods/device.go | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/categories/categories.go b/pkg/categories/categories.go index 0779c24..0ba2be7 100644 --- a/pkg/categories/categories.go +++ b/pkg/categories/categories.go @@ -6,61 +6,61 @@ type GreenAPICategories struct { GreenAPI methods.GreenAPIInterface } -// This section presents methods for working with the account. +// Account category presents methods for working with the account. // https://green-api.com/en/docs/api/account/ func (c GreenAPICategories) Account() methods.AccountCategory { return methods.AccountCategory{GreenAPI: c.GreenAPI} } -// This section presents methods for working with the device (phone). +// Device category presents methods for working with the device (phone). // https://green-api.com/en/docs/api/phone/ func (c GreenAPICategories) Device() methods.DeviceCategory { return methods.DeviceCategory{GreenAPI: c.GreenAPI} } -// This section presents methods for working with group chats. +// Groups category presents methods for working with group chats. // https://green-api.com/en/docs/api/groups/ func (c GreenAPICategories) Groups() methods.GroupsCategory { return methods.GroupsCategory{GreenAPI: c.GreenAPI} } -// This section presents methods for working with incoming and outgoing messages. +// Journals present methods for working with incoming and outgoing messages. // https://green-api.com/en/docs/api/journals/ func (c GreenAPICategories) Journals() methods.JournalsCategory { return methods.JournalsCategory{GreenAPI: c.GreenAPI} } -// This section presents methods for working with a messages queue. +// Queues category presents methods for working with a messages queue. // https://green-api.com/en/docs/api/queues/ func (c GreenAPICategories) Queues() methods.QueuesCategory { return methods.QueuesCategory{GreenAPI: c.GreenAPI} } -// This section presents methods for working with chat read mark. +// ReadMark category presents methods for working with chat read mark. // https://green-api.com/en/docs/api/marks/ func (c GreenAPICategories) ReadMark() methods.ReadMarkCategory { return methods.ReadMarkCategory{GreenAPI: c.GreenAPI} } -// This section presents methods for working with receiving events. +// Receiving category presents methods for working with receiving events. // https://green-api.com/en/docs/api/receiving/ func (c GreenAPICategories) Receiving() methods.ReceivingCategory { return methods.ReceivingCategory{GreenAPI: c.GreenAPI} } -// This section presents methods for sending different messages. +// Sending category presents methods for sending different messages. // https://green-api.com/en/docs/api/sending/ func (c GreenAPICategories) Sending() methods.SendingCategory { return methods.SendingCategory{GreenAPI: c.GreenAPI} } -// This section presents different service methods. +// Service category presents different service methods. // https://green-api.com/en/docs/api/service/ func (c GreenAPICategories) Service() methods.ServiceCategory { return methods.ServiceCategory{GreenAPI: c.GreenAPI} } -// This section presents exclusive methods for partners. +// Partner category presents exclusive methods for partners. // The partnership scheme involves deeper integration with the service // and working with a larger number of instances on your side: // diff --git a/pkg/categories/methods/device.go b/pkg/categories/methods/device.go index 60d0a70..ab8db34 100644 --- a/pkg/categories/methods/device.go +++ b/pkg/categories/methods/device.go @@ -6,7 +6,7 @@ type DeviceCategory struct { // GetDeviceInfo is designed to get information about the device (phone) // on which the WhatsApp Business application is running. -// https://green-api.com/en/docs/api/phone/ +// https://green-api.com/en/docs/api/phone/GetDeviceInfo/ func (c DeviceCategory) GetDeviceInfo() (map[string]interface{}, error) { return c.GreenAPI.Request("GET", "getDeviceInfo", nil, "") } From dcd7b8853e9059cdbf4ff63f4c84cc2d01a6b995 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 02:01:17 +0000 Subject: [PATCH 7/7] Bump golang.org/x/net from 0.22.0 to 0.23.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.22.0 to 0.23.0. - [Commits](https://github.com/golang/net/compare/v0.22.0...v0.23.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 281c533..2973a9e 100644 --- a/go.mod +++ b/go.mod @@ -4,4 +4,4 @@ go 1.19 require github.com/gabriel-vasile/mimetype v1.4.3 -require golang.org/x/net v0.22.0 // indirect +require golang.org/x/net v0.23.0 // indirect diff --git a/go.sum b/go.sum index 68766e6..af2399b 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,4 @@ github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=