Skip to content

Commit

Permalink
WhatsApp bot
Browse files Browse the repository at this point in the history
  • Loading branch information
dimuska139 committed Jul 22, 2021
1 parent b73950a commit e4341fc
Show file tree
Hide file tree
Showing 9 changed files with 1,749 additions and 9 deletions.
2 changes: 1 addition & 1 deletion sendpulse/bots_fb_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ type FbBotSendTextParams struct {
Text string `json:"text"`
}

func (service *BotsFbService) SendTextToContact(params FbBotSendTextParams) error {
func (service *BotsFbService) SendTextByContact(params FbBotSendTextParams) error {
path := "/messenger/contacts/sendText"

var respData struct {
Expand Down
4 changes: 2 additions & 2 deletions sendpulse/bots_fb_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (suite *SendpulseTestSuite) TestBotsFbService_GetContactsByVariable() {
suite.Equal("1234", contacts[0].ID)
}

func (suite *SendpulseTestSuite) TestBotsFbService_SendTextToContact() {
func (suite *SendpulseTestSuite) TestBotsFbService_SendTextByContact() {
suite.mux.HandleFunc("/messenger/contacts/sendText", func(w http.ResponseWriter, r *http.Request) {
suite.Equal(http.MethodPost, r.Method)

Expand All @@ -195,7 +195,7 @@ func (suite *SendpulseTestSuite) TestBotsFbService_SendTextToContact() {
}`)
})

err := suite.client.Bots.Fb.SendTextToContact(FbBotSendTextParams{
err := suite.client.Bots.Fb.SendTextByContact(FbBotSendTextParams{
ContactID: "qwe12345",
MessageType: "RESPONSE",
MessageTag: "ACCOUNT_UPDATE",
Expand Down
2 changes: 2 additions & 0 deletions sendpulse/bots_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type BotsService struct {
Fb *BotsFbService
Vk *BotsVkService
Telegram *BotsTelegramService
WhatsApp *BotsWhatsAppService
}

func newBotsService(cl *Client) *BotsService {
Expand All @@ -13,5 +14,6 @@ func newBotsService(cl *Client) *BotsService {
Fb: newBotsFbService(cl),
Vk: newBotsVkService(cl),
Telegram: newBotsTelegramService(cl),
WhatsApp: newBotsWhatsAppService(cl),
}
}
2 changes: 1 addition & 1 deletion sendpulse/bots_telegram_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (service *BotsTelegramService) GetContactsByVariable(params BotContactsByVa
return respData.Data, err
}

func (service *BotsTelegramService) SendTextToContact(contactID string, text string) error {
func (service *BotsTelegramService) SendTextByContact(contactID string, text string) error {
path := "/telegram/contacts/sendText"

type bodyFormat struct {
Expand Down
4 changes: 2 additions & 2 deletions sendpulse/bots_telegram_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (suite *SendpulseTestSuite) TestBotsTelegramService_GetContactsByVariable()
suite.Equal("1234", contacts[0].ID)
}

func (suite *SendpulseTestSuite) TestBotsTelegramService_SendTextToContact() {
func (suite *SendpulseTestSuite) TestBotsTelegramService_SendTextByContact() {
suite.mux.HandleFunc("/telegram/contacts/sendText", func(w http.ResponseWriter, r *http.Request) {
suite.Equal(http.MethodPost, r.Method)

Expand All @@ -198,7 +198,7 @@ func (suite *SendpulseTestSuite) TestBotsTelegramService_SendTextToContact() {
}`)
})

err := suite.client.Bots.Telegram.SendTextToContact("qwe12345", "hello")
err := suite.client.Bots.Telegram.SendTextByContact("qwe12345", "hello")
suite.NoError(err)
}

Expand Down
2 changes: 1 addition & 1 deletion sendpulse/bots_vk_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (service *BotsVkService) GetContactsByVariable(params BotContactsByVariable
return respData.Data, err
}

func (service *BotsVkService) SendTextToContact(contactID string, text string) error {
func (service *BotsVkService) SendTextByContact(contactID string, text string) error {
path := "/vk/contacts/sendText"

type bodyFormat struct {
Expand Down
4 changes: 2 additions & 2 deletions sendpulse/bots_vk_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (suite *SendpulseTestSuite) TestBotsVkService_GetContactsByVariable() {
suite.Equal("1234", contacts[0].ID)
}

func (suite *SendpulseTestSuite) TestBotsVkService_SendTextToContact() {
func (suite *SendpulseTestSuite) TestBotsVkService_SendTextByContact() {
suite.mux.HandleFunc("/vk/contacts/sendText", func(w http.ResponseWriter, r *http.Request) {
suite.Equal(http.MethodPost, r.Method)

Expand All @@ -186,7 +186,7 @@ func (suite *SendpulseTestSuite) TestBotsVkService_SendTextToContact() {
}`)
})

err := suite.client.Bots.Vk.SendTextToContact("qwe12345", "hello")
err := suite.client.Bots.Vk.SendTextByContact("qwe12345", "hello")
suite.NoError(err)
}

Expand Down
Loading

0 comments on commit e4341fc

Please sign in to comment.