Repository: mr-linch/go-tg
Pull request #59 (2022-07-09 14:26:29)

refactor: fix names

codecov[bot]: # [Codecov](https://codecov.io/gh/mr-linch/go-tg/pull/59?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sasha+Savchuk) Report
> Merging [#59](https://codecov.io/gh/mr-linch/go-tg/pull/59?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sasha+Savchuk) (4da5047) into [main](https://codecov.io/gh/mr-linch/go-tg/commit/40ef538ac48c97f3f6b2be27df5279d2ae218936?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sasha+Savchuk) (40ef538) will **not change** coverage.
> The diff coverage is `20.00%`.

```diff
@@           Coverage Diff           @@
##             main      #59   +/-   ##
=======================================
  Coverage   90.06%   90.06%           
=======================================
  Files          17       17           
  Lines        1711     1711           
=======================================
  Hits         1541     1541           
  Misses        140      140           
  Partials       30       30           
```


| [Impacted Files](https://codecov.io/gh/mr-linch/go-tg/pull/59?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sasha+Savchuk) | Coverage Δ | |
|---|---|---|
| [call.go](https://codecov.io/gh/mr-linch/go-tg/pull/59/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sasha+Savchuk#diff-Y2FsbC5nbw==) | `0.00% <0.00%> (ø)` | |
| [client.go](https://codecov.io/gh/mr-linch/go-tg/pull/59/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sasha+Savchuk#diff-Y2xpZW50Lmdv) | `60.54% <50.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/mr-linch/go-tg/pull/59?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sasha+Savchuk).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sasha+Savchuk)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/mr-linch/go-tg/pull/59?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sasha+Savchuk). Last update [40ef538...4da5047](https://codecov.io/gh/mr-linch/go-tg/pull/59?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sasha+Savchuk). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sasha+Savchuk).


Patch:
diff --git a/call.go b/call.go
index 8e5cc4e..4735713 100644
--- a/call.go
+++ b/call.go
@@ -31,7 +31,7 @@ func (call *Call[T]) Bind(client *Client) {
 }
 
 func (call *Call[T]) Do(ctx context.Context) (result T, err error) {
-	if err := call.client.Invoke(ctx, call.request, &result); err != nil {
+	if err := call.client.Do(ctx, call.request, &result); err != nil {
 		return result, err
 	}
 
@@ -39,7 +39,7 @@ func (call *Call[T]) Do(ctx context.Context) (result T, err error) {
 }
 
 func (call *Call[T]) DoVoid(ctx context.Context) (err error) {
-	return call.client.Invoke(ctx, call.request, nil)
+	return call.client.Do(ctx, call.request, nil)
 }
 
 func callWithClient[B interface {
@@ -73,5 +73,5 @@ func (call *CallNoResult) Bind(client *Client) {
 }
 
 func (call *CallNoResult) DoVoid(ctx context.Context) (err error) {
-	return call.client.Invoke(ctx, call.request, nil)
+	return call.client.Do(ctx, call.request, nil)
 }
diff --git a/client.go b/client.go
index a30edd7..26c3895 100644
--- a/client.go
+++ b/client.go
@@ -35,8 +35,8 @@ type Client struct {
 // ClientOption is a function that sets some option for Client.
 type ClientOption func(*Client)
 
-// WithClient sets custom server url for Client.
-func WithClient(server string) ClientOption {
+// WithClientServerURL sets custom server url for Client.
+func WithClientServerURL(server string) ClientOption {
 	return func(c *Client) {
 		c.server = server
 	}
@@ -224,7 +224,7 @@ func (client *Client) executeStreaming(
 	}
 }
 
-func (client *Client) Invoke(ctx context.Context, req *Request, dst interface{}) error {
+func (client *Client) Do(ctx context.Context, req *Request, dst interface{}) error {
 	res, err := client.execute(ctx, req)
 	if err != nil {
 		return fmt.Errorf("execute: %w", err)
diff --git a/examples/echo-bot/main.go b/examples/echo-bot/main.go
index 8da9c5c..7a59938 100644
--- a/examples/echo-bot/main.go
+++ b/examples/echo-bot/main.go
@@ -53,7 +53,7 @@ func run(ctx context.Context) error {
 	}
 
 	client := tg.New(flagToken,
-		tg.WithClient(flagServer),
+		tg.WithClientServerURL(flagServer),
 	)
 
 	me, err := client.Me(ctx)


Test patch:
diff --git a/client_test.go b/client_test.go
index 6bc1092..e34648c 100644
--- a/client_test.go
+++ b/client_test.go
@@ -15,7 +15,7 @@ func TestNewClient(t *testing.T) {
 	doer := &http.Client{}
 
 	client := New("token",
-		WithClient("http://example.com"),
+		WithClientServerURL("http://example.com"),
 		WithClientDoer(doer),
 	)
 
@@ -34,7 +34,7 @@ func TestClientExecute(t *testing.T) {
 
 		defer ts.Close()
 
-		client := New("1234:secret", WithClientDoer(ts.Client()), WithClient(ts.URL))
+		client := New("1234:secret", WithClientDoer(ts.Client()), WithClientServerURL(ts.URL))
 		ctx := context.Background()
 
 		res, err := client.execute(ctx, NewRequest("getMe"))
@@ -59,7 +59,7 @@ func TestClientExecute(t *testing.T) {
 
 		defer ts.Close()
 
-		client := New("1234:secret", WithClientDoer(ts.Client()), WithClient(ts.URL))
+		client := New("1234:secret", WithClientDoer(ts.Client()), WithClientServerURL(ts.URL))
 		ctx := context.Background()
 
 		file := NewInputFileBytes("types.go", []byte("package tg"))
@@ -91,7 +91,7 @@ func TestClientExecute(t *testing.T) {
 
 		defer ts.Close()
 
-		client := New("1234:secret", WithClientDoer(ts.Client()), WithClient(ts.URL))
+		client := New("1234:secret", WithClientDoer(ts.Client()), WithClientServerURL(ts.URL))
 		ctx := context.Background()
 
 		file := NewInputFileBytes("types.go", []byte("package tg"))
diff --git a/tgb/filter_test.go b/tgb/filter_test.go
index 47a6bfa..cdfb998 100644
--- a/tgb/filter_test.go
+++ b/tgb/filter_test.go
@@ -23,7 +23,7 @@ func testWithClientLocal(
 	defer server.Close()
 
 	client := tg.New("12345:secret",
-		tg.WithClient(server.URL),
+		tg.WithClientServerURL(server.URL),
 		tg.WithClientDoer(http.DefaultClient),
 	)
 
diff --git a/tgb/polling_test.go b/tgb/polling_test.go
index a38345f..92857ee 100644
--- a/tgb/polling_test.go
+++ b/tgb/polling_test.go
@@ -66,7 +66,7 @@ func TestPoller(t *testing.T) {
 				cancel()
 				return nil
 			}),
-			tg.New("1234:secret", tg.WithClient(server.URL), tg.WithClientDoer(server.Client())),
+			tg.New("1234:secret", tg.WithClientServerURL(server.URL), tg.WithClientDoer(server.Client())),
 		).Run(ctx)
 
 		assert.NoError(t, err)
@@ -122,7 +122,7 @@ func TestPoller(t *testing.T) {
 				cancel()
 				return nil
 			}),
-			tg.New("1234:secret", tg.WithClient(server.URL), tg.WithClientDoer(server.Client())),
+			tg.New("1234:secret", tg.WithClientServerURL(server.URL), tg.WithClientDoer(server.Client())),
 			WithPollerRetryAfter(time.Millisecond),
 			WithPollerHandlerTimeout(time.Millisecond),
 			WithPollerAllowedUpdates([]string{"callback_query"}),
diff --git a/tgb/webhook_test.go b/tgb/webhook_test.go
index fdfda11..c4c2680 100644
--- a/tgb/webhook_test.go
+++ b/tgb/webhook_test.go
@@ -260,7 +260,7 @@ func TestWebhook_Setup(t *testing.T) {
 
 		webhook := NewWebhook(
 			HandlerFunc(func(ctx context.Context, update *Update) error { return nil }),
-			tg.New("1234:secret", tg.WithClient(server.URL), tg.WithClientDoer(server.Client())),
+			tg.New("1234:secret", tg.WithClientServerURL(server.URL), tg.WithClientDoer(server.Client())),
 			"https://google.com",
 		)
 
@@ -300,7 +300,7 @@ func TestWebhook_Setup(t *testing.T) {
 
 		webhook := NewWebhook(
 			HandlerFunc(func(ctx context.Context, update *Update) error { return nil }),
-			tg.New("1234:secret", tg.WithClient(server.URL), tg.WithClientDoer(server.Client())),
+			tg.New("1234:secret", tg.WithClientServerURL(server.URL), tg.WithClientDoer(server.Client())),
 			"https://google.com",
 			WithDropPendingUpdates(true),
 			WithWebhookIP("1.1.1.1"),
@@ -342,7 +342,7 @@ func TestWebhook_Setup(t *testing.T) {
 
 		webhook := NewWebhook(
 			HandlerFunc(func(ctx context.Context, update *Update) error { return nil }),
-			tg.New("1234:secret", tg.WithClient(server.URL), tg.WithClientDoer(server.Client())),
+			tg.New("1234:secret", tg.WithClientServerURL(server.URL), tg.WithClientDoer(server.Client())),
 			"https://google.com",
 			WithWebhookAllowedUpdates("message"),
 			WithWebhookIP("1.1.1.1"),