Skip to content

Commit

Permalink
Merge 50e6fd1 into f530088
Browse files Browse the repository at this point in the history
  • Loading branch information
Yang-33 committed Nov 22, 2023
2 parents f530088 + 50e6fd1 commit 283d9e2
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ func (client *{{ classname }}) Do(req *http.Request) (*http.Response, error) {
}

func (client *{{ classname }}) Url(endpointPath string) string {
u := client.endpoint
u.Path = path.Join(u.Path, endpointPath)
newPath := path.Join(client.endpoint.Path, endpointPath)
u := *client.endpoint
u.Path = newPath
return u.String()
}

Expand Down
5 changes: 3 additions & 2 deletions linebot/channel_access_token/api_channel_access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ func (client *ChannelAccessTokenAPI) Do(req *http.Request) (*http.Response, erro
}

func (client *ChannelAccessTokenAPI) Url(endpointPath string) string {
u := client.endpoint
u.Path = path.Join(u.Path, endpointPath)
newPath := path.Join(client.endpoint.Path, endpointPath)
u := *client.endpoint
u.Path = newPath
return u.String()
}

Expand Down
5 changes: 3 additions & 2 deletions linebot/insight/api_insight.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ func (client *InsightAPI) Do(req *http.Request) (*http.Response, error) {
}

func (client *InsightAPI) Url(endpointPath string) string {
u := client.endpoint
u.Path = path.Join(u.Path, endpointPath)
newPath := path.Join(client.endpoint.Path, endpointPath)
u := *client.endpoint
u.Path = newPath
return u.String()
}

Expand Down
5 changes: 3 additions & 2 deletions linebot/liff/api_liff.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ func (client *LiffAPI) Do(req *http.Request) (*http.Response, error) {
}

func (client *LiffAPI) Url(endpointPath string) string {
u := client.endpoint
u.Path = path.Join(u.Path, endpointPath)
newPath := path.Join(client.endpoint.Path, endpointPath)
u := *client.endpoint
u.Path = newPath
return u.String()
}

Expand Down
5 changes: 3 additions & 2 deletions linebot/manage_audience/api_manage_audience.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ func (client *ManageAudienceAPI) Do(req *http.Request) (*http.Response, error) {
}

func (client *ManageAudienceAPI) Url(endpointPath string) string {
u := client.endpoint
u.Path = path.Join(u.Path, endpointPath)
newPath := path.Join(client.endpoint.Path, endpointPath)
u := *client.endpoint
u.Path = newPath
return u.String()
}

Expand Down
5 changes: 3 additions & 2 deletions linebot/manage_audience/api_manage_audience_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ func (client *ManageAudienceBlobAPI) Do(req *http.Request) (*http.Response, erro
}

func (client *ManageAudienceBlobAPI) Url(endpointPath string) string {
u := client.endpoint
u.Path = path.Join(u.Path, endpointPath)
newPath := path.Join(client.endpoint.Path, endpointPath)
u := *client.endpoint
u.Path = newPath
return u.String()
}

Expand Down
5 changes: 3 additions & 2 deletions linebot/messaging_api/api_messaging_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ func (client *MessagingApiAPI) Do(req *http.Request) (*http.Response, error) {
}

func (client *MessagingApiAPI) Url(endpointPath string) string {
u := client.endpoint
u.Path = path.Join(u.Path, endpointPath)
newPath := path.Join(client.endpoint.Path, endpointPath)
u := *client.endpoint
u.Path = newPath
return u.String()
}

Expand Down
5 changes: 3 additions & 2 deletions linebot/messaging_api/api_messaging_api_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ func (client *MessagingApiBlobAPI) Do(req *http.Request) (*http.Response, error)
}

func (client *MessagingApiBlobAPI) Url(endpointPath string) string {
u := client.endpoint
u.Path = path.Join(u.Path, endpointPath)
newPath := path.Join(client.endpoint.Path, endpointPath)
u := *client.endpoint
u.Path = newPath
return u.String()
}

Expand Down
50 changes: 50 additions & 0 deletions linebot/messaging_api/tests/handwritten/calling_api_twice_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package tests

import (
"net/http"
"net/http/httptest"
"testing"

"github.com/line/line-bot-sdk-go/v8/linebot/messaging_api"
)

func TestCallingAPITwice(t *testing.T) {
server := httptest.NewServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/v2/bot/message/push" {
t.Errorf("Expected path '/v2/bot/message/push', but got '%s'", r.URL.Path)
}
w.Header().Add("X-Line-Request-Id", "1234567890")
w.Write([]byte(`{}`))
}),
)
client, err := messaging_api.NewMessagingApiAPI(
"channelToken",
messaging_api.WithEndpoint(server.URL),
)
if err != nil {
t.Fatalf("Failed to create client: %v", err)
}
_, err = client.PushMessage(&messaging_api.PushMessageRequest{
Messages: []messaging_api.MessageInterface{
&messaging_api.TextMessage{
Text: "Hello, world",
},
},
}, "")
if err != nil {
t.Fatalf("Failed to get response: %v", err)
}

// call again
_, err = client.PushMessage(&messaging_api.PushMessageRequest{
Messages: []messaging_api.MessageInterface{
&messaging_api.TextMessage{
Text: "Hello, world",
},
},
}, "")
if err != nil {
t.Fatalf("Failed to get response: %v", err)
}
}
5 changes: 3 additions & 2 deletions linebot/module/api_line_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ func (client *LineModuleAPI) Do(req *http.Request) (*http.Response, error) {
}

func (client *LineModuleAPI) Url(endpointPath string) string {
u := client.endpoint
u.Path = path.Join(u.Path, endpointPath)
newPath := path.Join(client.endpoint.Path, endpointPath)
u := *client.endpoint
u.Path = newPath
return u.String()
}

Expand Down
5 changes: 3 additions & 2 deletions linebot/module_attach/api_line_module_attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ func (client *LineModuleAttachAPI) Do(req *http.Request) (*http.Response, error)
}

func (client *LineModuleAttachAPI) Url(endpointPath string) string {
u := client.endpoint
u.Path = path.Join(u.Path, endpointPath)
newPath := path.Join(client.endpoint.Path, endpointPath)
u := *client.endpoint
u.Path = newPath
return u.String()
}

Expand Down
5 changes: 3 additions & 2 deletions linebot/shop/api_shop.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ func (client *ShopAPI) Do(req *http.Request) (*http.Response, error) {
}

func (client *ShopAPI) Url(endpointPath string) string {
u := client.endpoint
u.Path = path.Join(u.Path, endpointPath)
newPath := path.Join(client.endpoint.Path, endpointPath)
u := *client.endpoint
u.Path = newPath
return u.String()
}

Expand Down

0 comments on commit 283d9e2

Please sign in to comment.