Skip to content

Commit f88742b

Browse files
committed
rename ClientInterface -> MessageBirdClient
1 parent ec91cd8 commit f88742b

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const (
5151
FeatureConversationsAPIWhatsAppSandbox Feature = iota
5252
)
5353

54-
type ClientInterface interface {
54+
type MessageBirdClient interface {
5555
EnableFeatures(feature Feature)
5656
DisableFeatures(feature Feature)
5757
IsFeatureEnabled(feature Feature) bool

conversation/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (lro *PaginationRequest) QueryParams() string {
5959
// request does the exact same thing as Client.Request. It does, however,
6060
// prefix the path with the Conversation API's root. This ensures the client
6161
// doesn't "handle" this for us: by default, it uses the REST API.
62-
func request(c messagebird.ClientInterface, v interface{}, method, path string, data interface{}) error {
62+
func request(c messagebird.MessageBirdClient, v interface{}, method, path string, data interface{}) error {
6363
var root string
6464
if c.IsFeatureEnabled(messagebird.FeatureConversationsAPIWhatsAppSandbox) {
6565
root = whatsappSandboxAPIRoot

conversation/conversation.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (lr *ListByContactRequest) QueryParams() string {
159159
}
160160

161161
// List gets a collection of Conversations. Pagination can be set in options.
162-
func List(c messagebird.ClientInterface, options *ListRequest) (*ConversationList, error) {
162+
func List(c messagebird.MessageBirdClient, options *ListRequest) (*ConversationList, error) {
163163
convList := &ConversationList{}
164164
if err := request(c, convList, http.MethodGet, fmt.Sprintf("%s?%s", path, options.QueryParams()), nil); err != nil {
165165
return nil, err
@@ -169,7 +169,7 @@ func List(c messagebird.ClientInterface, options *ListRequest) (*ConversationLis
169169
}
170170

171171
// ListByContact fetches a collection of Conversations of a specific MessageBird contact ID.
172-
func ListByContact(c messagebird.ClientInterface, contactId string, options *PaginationRequest) (*ConversationByContactList, error) {
172+
func ListByContact(c messagebird.MessageBirdClient, contactId string, options *PaginationRequest) (*ConversationByContactList, error) {
173173
reqPath := fmt.Sprintf("%s/%s/%s?%s", path, contactPath, contactId, options.QueryParams())
174174

175175
conv := &ConversationByContactList{}
@@ -181,7 +181,7 @@ func ListByContact(c messagebird.ClientInterface, contactId string, options *Pag
181181
}
182182

183183
// Read fetches a single Conversation based on its ID.
184-
func Read(c messagebird.ClientInterface, id string) (*Conversation, error) {
184+
func Read(c messagebird.MessageBirdClient, id string) (*Conversation, error) {
185185
conv := &Conversation{}
186186
if err := request(c, conv, http.MethodGet, path+"/"+id, nil); err != nil {
187187
return nil, err
@@ -192,7 +192,7 @@ func Read(c messagebird.ClientInterface, id string) (*Conversation, error) {
192192

193193
// Start creates a conversation by sending an initial message. If an active
194194
// conversation exists for the recipient, it is resumed.
195-
func Start(c messagebird.ClientInterface, req *StartRequest) (*Conversation, error) {
195+
func Start(c messagebird.MessageBirdClient, req *StartRequest) (*Conversation, error) {
196196
conv := &Conversation{}
197197
if err := request(c, conv, http.MethodPost, path+"/"+startConversationPath, req); err != nil {
198198
return nil, err
@@ -202,7 +202,7 @@ func Start(c messagebird.ClientInterface, req *StartRequest) (*Conversation, err
202202
}
203203

204204
// Reply Send a new message to an existing conversation. In case the conversation is archived, a new conversation is created.
205-
func Reply(c messagebird.ClientInterface, conversationID string, req *ReplyRequest) (*Message, error) {
205+
func Reply(c messagebird.MessageBirdClient, conversationID string, req *ReplyRequest) (*Message, error) {
206206
uri := fmt.Sprintf("%s/%s/%s", path, conversationID, messagesPath)
207207

208208
message := &Message{}
@@ -215,7 +215,7 @@ func Reply(c messagebird.ClientInterface, conversationID string, req *ReplyReque
215215

216216
// Update changes the conversation's status, so this can be used to (un)archive
217217
// conversations.
218-
func Update(c messagebird.ClientInterface, id string, req *UpdateRequest) (*Conversation, error) {
218+
func Update(c messagebird.MessageBirdClient, id string, req *UpdateRequest) (*Conversation, error) {
219219
conv := &Conversation{}
220220
if err := request(c, conv, http.MethodPatch, path+"/"+id, req); err != nil {
221221
return nil, err

conversation/message.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func (lr *ListMessagesRequest) QueryParams() string {
212212
// SendMessage send a message to a specific recipient in a specific platform.
213213
// If an active conversation already exists for the recipient, the conversation will be resumed.
214214
// In case there's no active conversation a new one is created.
215-
func SendMessage(c messagebird.ClientInterface, options *SendMessageRequest) (*Message, error) {
215+
func SendMessage(c messagebird.MessageBirdClient, options *SendMessageRequest) (*Message, error) {
216216
message := &Message{}
217217
if err := request(c, message, http.MethodPost, sendMessagePath, options); err != nil {
218218
return nil, err
@@ -223,7 +223,7 @@ func SendMessage(c messagebird.ClientInterface, options *SendMessageRequest) (*M
223223

224224
// ListConversationMessages gets a collection of messages from a conversation.
225225
// Pagination can be set in the options.
226-
func ListConversationMessages(c messagebird.ClientInterface, conversationID string, options *ListConversationMessagesRequest) (*MessageList, error) {
226+
func ListConversationMessages(c messagebird.MessageBirdClient, conversationID string, options *ListConversationMessagesRequest) (*MessageList, error) {
227227
uri := fmt.Sprintf("%s/%s/%s?%s", path, conversationID, messagesPath, options.QueryParams())
228228

229229
messageList := &MessageList{}
@@ -236,7 +236,7 @@ func ListConversationMessages(c messagebird.ClientInterface, conversationID stri
236236

237237
// ListMessages gets a collection of messages from a conversation.
238238
// Pagination can be set in the options.
239-
func ListMessages(c messagebird.ClientInterface, options *ListMessagesRequest) (*MessageList, error) {
239+
func ListMessages(c messagebird.MessageBirdClient, options *ListMessagesRequest) (*MessageList, error) {
240240
uri := fmt.Sprintf("%s?%s", messagesPath, options.QueryParams())
241241

242242
messageList := &MessageList{}
@@ -248,7 +248,7 @@ func ListMessages(c messagebird.ClientInterface, options *ListMessagesRequest) (
248248
}
249249

250250
// ReadMessage gets a single message based on its ID.
251-
func ReadMessage(c messagebird.ClientInterface, messageID string) (*Message, error) {
251+
func ReadMessage(c messagebird.MessageBirdClient, messageID string) (*Message, error) {
252252
message := &Message{}
253253
if err := request(c, message, http.MethodGet, messagesPath+"/"+messageID, nil); err != nil {
254254
return nil, err

conversation/webhook.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const (
6969

7070
// CreateWebhook registers a webhook that is invoked when something interesting
7171
// happens.
72-
func CreateWebhook(c messagebird.ClientInterface, req *WebhookCreateRequest) (*Webhook, error) {
72+
func CreateWebhook(c messagebird.MessageBirdClient, req *WebhookCreateRequest) (*Webhook, error) {
7373
webhook := &Webhook{}
7474
if err := request(c, webhook, http.MethodPost, webhooksPath, req); err != nil {
7575
return nil, err
@@ -80,12 +80,12 @@ func CreateWebhook(c messagebird.ClientInterface, req *WebhookCreateRequest) (*W
8080

8181
// DeleteWebhook ensures an existing webhook is deleted and no longer
8282
// triggered. If the error is nil, the deletion was successful.
83-
func DeleteWebhook(c messagebird.ClientInterface, id string) error {
83+
func DeleteWebhook(c messagebird.MessageBirdClient, id string) error {
8484
return request(c, nil, http.MethodDelete, webhooksPath+"/"+id, nil)
8585
}
8686

8787
// ListWebhooks gets a collection of webhooks. Pagination can be set in options.
88-
func ListWebhooks(c messagebird.ClientInterface, options *PaginationRequest) (*WebhookList, error) {
88+
func ListWebhooks(c messagebird.MessageBirdClient, options *PaginationRequest) (*WebhookList, error) {
8989
webhookList := &WebhookList{}
9090
if err := request(c, webhookList, http.MethodGet, webhooksPath+"?"+options.QueryParams(), nil); err != nil {
9191
return nil, err
@@ -95,7 +95,7 @@ func ListWebhooks(c messagebird.ClientInterface, options *PaginationRequest) (*W
9595
}
9696

9797
// ReadWebhook gets a single webhook based on its ID.
98-
func ReadWebhook(c messagebird.ClientInterface, id string) (*Webhook, error) {
98+
func ReadWebhook(c messagebird.MessageBirdClient, id string) (*Webhook, error) {
9999
webhook := &Webhook{}
100100
if err := request(c, webhook, http.MethodGet, webhooksPath+"/"+id, nil); err != nil {
101101
return nil, err
@@ -106,7 +106,7 @@ func ReadWebhook(c messagebird.ClientInterface, id string) (*Webhook, error) {
106106

107107
// UpdateWebhook updates a single webhook based on its ID with any values set in WebhookUpdateRequest.
108108
// Do not set any values that should not be updated.
109-
func UpdateWebhook(c messagebird.ClientInterface, id string, req *WebhookUpdateRequest) (*Webhook, error) {
109+
func UpdateWebhook(c messagebird.MessageBirdClient, id string, req *WebhookUpdateRequest) (*Webhook, error) {
110110
webhook := &Webhook{}
111111
if err := request(c, webhook, http.MethodPatch, webhooksPath+"/"+id, req); err != nil {
112112
return nil, err

internal/mbtest/test_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (c *ClientMock) Request(v interface{}, method, path string, data interface{
2727
}
2828

2929
// MockClient initializes a new mock of MessageBird client
30-
func MockClient() messagebird.ClientInterface {
30+
func MockClient() messagebird.MessageBirdClient {
3131
return &ClientMock{}
3232
}
3333

0 commit comments

Comments
 (0)