Skip to content

Commit 540e1f5

Browse files
committed
change client interface and implementation names
1 parent 698c51d commit 540e1f5

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

client.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ type Client interface {
4646
Request(v interface{}, method, path string, data interface{}) error
4747
}
4848

49-
// BasicClient is used to access API with a given key.
49+
// DefaultClient is used to access API with a given key.
5050
// Uses standard lib HTTP client internally, so should be reused instead of created as needed and it is safe for concurrent use.
51-
type BasicClient struct {
51+
type DefaultClient struct {
5252
AccessKey string // The API access key.
5353
HTTPClient *http.Client // The HTTP client to send requests on.
5454
DebugLog *log.Logger // Optional logger for debugging purposes.
@@ -73,8 +73,8 @@ func SetErrorReader(r errorReader) {
7373
}
7474

7575
// New creates a new MessageBird client object.
76-
func New(accessKey string) *BasicClient {
77-
return &BasicClient{
76+
func New(accessKey string) *DefaultClient {
77+
return &DefaultClient{
7878
AccessKey: accessKey,
7979
HTTPClient: &http.Client{
8080
Timeout: httpClientTimeout,
@@ -83,7 +83,7 @@ func New(accessKey string) *BasicClient {
8383
}
8484

8585
// Request is for internal use only and unstable.
86-
func (c *BasicClient) Request(v interface{}, method, path string, data interface{}) error {
86+
func (c *DefaultClient) Request(v interface{}, method, path string, data interface{}) error {
8787
if !strings.HasPrefix(path, "https://") && !strings.HasPrefix(path, "http://") {
8888
path = fmt.Sprintf("%s/%s", Endpoint, path)
8989
}

conversation/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const (
3131
webhooksPath = "webhooks"
3232
)
3333

34-
// request does the exact same thing as BasicClient.Request. It does, however,
34+
// request does the exact same thing as DefaultClient.Request. It does, however,
3535
// prefix the path with the Conversation API's root. This ensures the client
3636
// doesn't "handle" this for us: by default, it uses the REST API.
3737
func request(c messagebird.Client, v interface{}, method, path string, data interface{}) error {

internal/mbtest/test_client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ func MockClient() messagebird.Client {
3232
}
3333

3434
// Client initializes a new MessageBird client that uses the
35-
func Client(t *testing.T) *messagebird.BasicClient {
35+
func Client(t *testing.T) *messagebird.DefaultClient {
3636
return newClient(t, "")
3737
}
3838

39-
func newClient(t *testing.T, accessKey string) *messagebird.BasicClient {
39+
func newClient(t *testing.T, accessKey string) *messagebird.DefaultClient {
4040
transport := &http.Transport{
4141
DialTLS: func(network, _ string) (net.Conn, error) {
4242
addr := server.Listener.Addr().String()

number/number.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ func paramsForArrays(field string, values []string, urlParams *url.Values) {
311311
}
312312
}
313313

314-
// request does the exact same thing as BasicClient.Request. It does, however,
314+
// request does the exact same thing as DefaultClient.Request. It does, however,
315315
// prefix the path with the Numbers API's root. This ensures the client
316316
// doesn't "handle" this for us: by default, it uses the REST API.
317317
func request(c messagebird.Client, v interface{}, method, path string, data interface{}) error {

voice/main_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
messagebird "github.com/messagebird/go-rest-api/v9"
1313
)
1414

15-
func testRequest(status int, body []byte) (*messagebird.BasicClient, func()) {
15+
func testRequest(status int, body []byte) (*messagebird.DefaultClient, func()) {
1616
mbServer := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1717
w.Header().Set("Content-Type", "application/json")
1818
w.WriteHeader(status)
@@ -33,12 +33,12 @@ func testRequest(status int, body []byte) (*messagebird.BasicClient, func()) {
3333
return mbClient, func() { mbServer.Close() }
3434
}
3535

36-
func testClient(t *testing.T) (*messagebird.BasicClient, bool) {
36+
func testClient(t *testing.T) (*messagebird.DefaultClient, bool) {
3737
key, ok := os.LookupEnv("MB_TEST_KEY")
3838
if !ok {
3939
return nil, false
4040
}
41-
client := &messagebird.BasicClient{
41+
client := &messagebird.DefaultClient{
4242
AccessKey: key,
4343
HTTPClient: &http.Client{},
4444
DebugLog: log.New(testWriter{T: t}, "", 0),

voice/recording.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func Delete(client messagebird.Client, callID, legID, recordingID string) error
115115
}
116116

117117
// DownloadFile streams the recorded WAV file.
118-
func (rec *Recording) DownloadFile(client *messagebird.BasicClient) (io.ReadCloser, error) {
118+
func (rec *Recording) DownloadFile(client *messagebird.DefaultClient) (io.ReadCloser, error) {
119119
req, err := http.NewRequest(http.MethodGet, apiRoot+rec.Links["file"], nil)
120120
if err != nil {
121121
return nil, err

voice/transcription.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (trans *Transcription) UnmarshalJSON(data []byte) error {
7070
// Contents gets the transcription file.
7171
//
7272
// This is a plain text file.
73-
func (trans *Transcription) Contents(client *messagebird.BasicClient) (string, error) {
73+
func (trans *Transcription) Contents(client *messagebird.DefaultClient) (string, error) {
7474
req, err := http.NewRequest(http.MethodGet, apiRoot+trans.links["file"], nil)
7575
if err != nil {
7676
return "", err

0 commit comments

Comments
 (0)