@@ -34,21 +34,6 @@ const (
34
34
httpClientTimeout = 15 * time .Second
35
35
)
36
36
37
- const (
38
- // HLRPath represents the path to the HLR resource.
39
- HLRPath = "hlr"
40
- // MessagePath represents the path to the Message resource.
41
- MessagePath = "messages"
42
- // MMSPath represents the path to the MMS resource.
43
- MMSPath = "mms"
44
- // VoiceMessagePath represents the path to the VoiceMessage resource.
45
- VoiceMessagePath = "voicemessages"
46
- // VerifyPath represents the path to the Verify resource.
47
- VerifyPath = "verify"
48
- // LookupPath represents the path to the Lookup resource.
49
- LookupPath = "lookup"
50
- )
51
-
52
37
var (
53
38
// ErrUnexpectedResponse is used when there was an internal server error and nothing can be done at this point.
54
39
ErrUnexpectedResponse = errors .New ("The MessageBird API is currently unavailable" )
@@ -146,224 +131,3 @@ func (c *Client) Request(v interface{}, method, path string, data interface{}) e
146
131
147
132
return errorResponse
148
133
}
149
-
150
- // Balance returns the balance information for the account that is associated
151
- // with the access key.
152
- func (c * Client ) Balance () (* Balance , error ) {
153
- balance := & Balance {}
154
- if err := c .Request (balance , http .MethodGet , "balance" , nil ); err != nil {
155
- return nil , err
156
- }
157
-
158
- return balance , nil
159
- }
160
-
161
- // HLR looks up an existing HLR object for the specified id that was previously
162
- // created by the NewHLR function.
163
- func (c * Client ) HLR (id string ) (* HLR , error ) {
164
- hlr := & HLR {}
165
- if err := c .Request (hlr , http .MethodGet , HLRPath + "/" + id , nil ); err != nil {
166
- return nil , err
167
- }
168
-
169
- return hlr , nil
170
- }
171
-
172
- // HLRs lists all HLR objects that were previously created by the NewHLR
173
- // function.
174
- func (c * Client ) HLRs () (* HLRList , error ) {
175
- hlrList := & HLRList {}
176
- if err := c .Request (hlrList , http .MethodGet , HLRPath , nil ); err != nil {
177
- return nil , err
178
- }
179
-
180
- return hlrList , nil
181
- }
182
-
183
- // NewHLR retrieves the information of an existing HLR.
184
- func (c * Client ) NewHLR (msisdn string , reference string ) (* HLR , error ) {
185
- requestData , err := requestDataForHLR (msisdn , reference )
186
- if err != nil {
187
- return nil , err
188
- }
189
-
190
- hlr := & HLR {}
191
-
192
- if err := c .Request (hlr , http .MethodPost , HLRPath , requestData ); err != nil {
193
- return nil , err
194
- }
195
-
196
- return hlr , nil
197
- }
198
-
199
- // Message retrieves the information of an existing Message.
200
- func (c * Client ) Message (id string ) (* Message , error ) {
201
- message := & Message {}
202
- if err := c .Request (message , http .MethodGet , MessagePath + "/" + id , nil ); err != nil {
203
- return nil , err
204
- }
205
-
206
- return message , nil
207
- }
208
-
209
- // Messages retrieves all messages of the user represented as a MessageList object.
210
- func (c * Client ) Messages (msgListParams * MessageListParams ) (* MessageList , error ) {
211
- messageList := & MessageList {}
212
- params , err := paramsForMessageList (msgListParams )
213
- if err != nil {
214
- return messageList , err
215
- }
216
-
217
- if err := c .Request (messageList , http .MethodGet , MessagePath + "?" + params .Encode (), nil ); err != nil {
218
- return nil , err
219
- }
220
-
221
- return messageList , nil
222
- }
223
-
224
- // NewMessage creates a new message for one or more recipients.
225
- func (c * Client ) NewMessage (originator string , recipients []string , body string , msgParams * MessageParams ) (* Message , error ) {
226
- requestData , err := requestDataForMessage (originator , recipients , body , msgParams )
227
- if err != nil {
228
- return nil , err
229
- }
230
-
231
- message := & Message {}
232
- if err := c .Request (message , http .MethodPost , MessagePath , requestData ); err != nil {
233
- return nil , err
234
- }
235
-
236
- return message , nil
237
- }
238
-
239
- // MMSMessage retrieves the information of an existing MmsMessage.
240
- func (c * Client ) MMSMessage (id string ) (* MMSMessage , error ) {
241
- mmsMessage := & MMSMessage {}
242
- if err := c .Request (mmsMessage , http .MethodGet , MMSPath + "/" + id , nil ); err != nil {
243
- return nil , err
244
- }
245
-
246
- return mmsMessage , nil
247
- }
248
-
249
- // NewMMSMessage creates a new MMS message for one or more recipients.
250
- func (c * Client ) NewMMSMessage (originator string , recipients []string , msgParams * MMSMessageParams ) (* MMSMessage , error ) {
251
- params , err := paramsForMMSMessage (msgParams )
252
- if err != nil {
253
- return nil , err
254
- }
255
-
256
- params .Set ("originator" , originator )
257
- params .Set ("recipients" , strings .Join (recipients , "," ))
258
-
259
- mmsMessage := & MMSMessage {}
260
- if err := c .Request (mmsMessage , http .MethodPost , MMSPath , params ); err != nil {
261
- return nil , err
262
- }
263
-
264
- return mmsMessage , nil
265
- }
266
-
267
- // VoiceMessage retrieves the information of an existing VoiceMessage.
268
- func (c * Client ) VoiceMessage (id string ) (* VoiceMessage , error ) {
269
- message := & VoiceMessage {}
270
- if err := c .Request (message , http .MethodGet , VoiceMessagePath + "/" + id , nil ); err != nil {
271
- return nil , err
272
- }
273
-
274
- return message , nil
275
- }
276
-
277
- // VoiceMessages retrieves all VoiceMessages of the user.
278
- func (c * Client ) VoiceMessages () (* VoiceMessageList , error ) {
279
- messageList := & VoiceMessageList {}
280
- if err := c .Request (messageList , http .MethodGet , VoiceMessagePath , nil ); err != nil {
281
- return nil , err
282
- }
283
-
284
- return messageList , nil
285
- }
286
-
287
- // NewVoiceMessage creates a new voice message for one or more recipients.
288
- func (c * Client ) NewVoiceMessage (recipients []string , body string , params * VoiceMessageParams ) (* VoiceMessage , error ) {
289
- requestData , err := requestDataForVoiceMessage (recipients , body , params )
290
- if err != nil {
291
- return nil , err
292
- }
293
-
294
- message := & VoiceMessage {}
295
- if err := c .Request (message , http .MethodPost , VoiceMessagePath , requestData ); err != nil {
296
- return nil , err
297
- }
298
-
299
- return message , nil
300
- }
301
-
302
- // NewVerify generates a new One-Time-Password for one recipient.
303
- func (c * Client ) NewVerify (recipient string , params * VerifyParams ) (* Verify , error ) {
304
- requestData , err := requestDataForVerify (recipient , params )
305
- if err != nil {
306
- return nil , err
307
- }
308
-
309
- verify := & Verify {}
310
- if err := c .Request (verify , http .MethodPost , VerifyPath , requestData ); err != nil {
311
- return nil , err
312
- }
313
-
314
- return verify , nil
315
- }
316
-
317
- // VerifyToken performs token value check against MessageBird API.
318
- func (c * Client ) VerifyToken (id , token string ) (* Verify , error ) {
319
- params := & url.Values {}
320
- params .Set ("token" , token )
321
-
322
- path := VerifyPath + "/" + id + "?" + params .Encode ()
323
-
324
- verify := & Verify {}
325
- if err := c .Request (verify , http .MethodGet , path , nil ); err != nil {
326
- return nil , err
327
- }
328
-
329
- return verify , nil
330
- }
331
-
332
- // Lookup performs a new lookup for the specified number.
333
- func (c * Client ) Lookup (phoneNumber string , params * LookupParams ) (* Lookup , error ) {
334
- urlParams := paramsForLookup (params )
335
- path := LookupPath + "/" + phoneNumber + "?" + urlParams .Encode ()
336
-
337
- lookup := & Lookup {}
338
- if err := c .Request (lookup , http .MethodPost , path , nil ); err != nil {
339
- return nil , err
340
- }
341
-
342
- return lookup , nil
343
- }
344
-
345
- // NewLookupHLR creates a new HLR lookup for the specified number.
346
- func (c * Client ) NewLookupHLR (phoneNumber string , params * LookupParams ) (* HLR , error ) {
347
- requestData := requestDataForLookup (params )
348
- path := LookupPath + "/" + phoneNumber + "/" + HLRPath
349
-
350
- hlr := & HLR {}
351
- if err := c .Request (hlr , http .MethodPost , path , requestData ); err != nil {
352
- return nil , err
353
- }
354
-
355
- return hlr , nil
356
- }
357
-
358
- // LookupHLR performs a HLR lookup for the specified number.
359
- func (c * Client ) LookupHLR (phoneNumber string , params * LookupParams ) (* HLR , error ) {
360
- urlParams := paramsForLookup (params )
361
- path := LookupPath + "/" + phoneNumber + "/" + HLRPath + "?" + urlParams .Encode ()
362
-
363
- hlr := & HLR {}
364
- if err := c .Request (hlr , http .MethodGet , path , nil ); err != nil {
365
- return nil , err
366
- }
367
-
368
- return hlr , nil
369
- }
0 commit comments