forked from ubogdan/peerless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.go
463 lines (414 loc) · 14.8 KB
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
// Package peerless provides a SOAP HTTP client.
package peerless
import (
"context"
"fmt"
"net/http"
"go.uber.org/zap"
)
const (
// Namespace
namespace = "http://publicapi.api.s2.peerless.com/"
// ProductionEndpoint endpoint used in production
ProductionEndpoint = "https://animate.peerlessnetwork.com:8181/animateapi/axis/APIService"
// StagingEndpoint endpoint used for development
StagingEndpoint = "https://aniweb02.peerlessnetwork.com:8181/animateapi/axis/APIService"
)
// APIService was auto-generated from WSDL
// and defines interface for the remote service. Useful for testing.
type APIService interface {
// ActivateSOA The numbers for the given orderId(s) would be npac activated. Only the numbers which are peerless
// and offnet numbers would have npac activation skipped.
ActivateSOA(ctx context.Context, orderID []string) (bool, error)
// AddNotes add notes to an Order
AddNotes(ctx context.Context, orderID, note string) (bool, error)
// CreateException An Exception Request should be used in the event that your search results do not return the desired
// number availability. This request will generate an email notification to a designated Peerless
// representative to further investigate. Please include as many details of your desired request in the
// body of the email.
CreateException(ctx context.Context, ExceptionNote *ExceptionNote) (bool, error)
// DisconnectOrder If order is soft disconnect with or without features then available date will not be
// displayed. And if it is hard disconnect then available date will be shown.
DisconnectOrder(ctx context.Context, DisconnectOrderRequest DisconnectOrderRequest) (string, error)
// Download This method can be used to upload required attachments to an order
Download(ctx context.Context, orderID string) ([]Attachment, error)
// GetHierarchicalView Enables a user to identify the full coverage area in Peerless Network’s entire inventory by
// State, LATA, Rate Center, NPAs and NXXs.
GetHierarchicalView(ctx context.Context) (*HiearchicalView, error)
// GetNewNumberSearchFilters With this operation users can request a list of all possible additional filter options
// for a given filter.
GetNewNumberSearchFilters(ctx context.Context, filters *NumberSearchParameters) (*NumberSearchParameters, error)
// GetOrderStatus This operation returns Order Status
GetOrderStatus(ctx context.Context, orderID string) (string, error)
// GetOrdersByPONSearch This is used to get the orders based on the PON entered in the request.
GetOrdersByPONSearch(ctx context.Context, pon string) ([]ResultPONOrderDetails, error)
// GetPortInRelatedOrders godoc
GetPortInRelatedOrders(ctx context.Context, orderID int64) ([]ResultOrderDetails, error)
// GetStatusByNumberSearch This is to get the status of the number given in the request. The number should belong
// to the entity in question.
GetStatusByNumberSearch(ctx context.Context, telephoneNumber []string) ([]string, error)
// GetTnInventoryReport godoc
GetTnInventoryReport(ctx context.Context, searchParams *TnInventoryForApiSearchParams) ([]TnInventory, error)
// PlaceOrder was Placing your order will begin the activation process of your selected numbers. This request
// includes features and destination instructions to provision your selected numbers.
PlaceOrder(ctx context.Context, order *Order) (string, error)
// PlaceTFDisconnectOrder godoc
PlaceTFDisconnectOrder(ctx context.Context, disconnectOrderRequest *DisconnectOrderRequest) (string, error)
// PlaceTFOrder godoc
PlaceTFOrder(ctx context.Context, order *TollFreeOrder) (string, error)
// PortabilityCheck godoc
PortabilityCheck(ctx context.Context, portabilityCheckRequest *PortabilityCheckRequest) ([]string, error)
// SearchNumbers This Operation will search the available inventory for numbers from Peerless.
SearchNumbers(ctx context.Context, filters *NumberSearchParameters) (*NumberSearchParameters, error)
// SearchOrderDetailsByOrderId godoc
SearchOrderDetailsByOrderId(ctx context.Context, orderID int64, orderType string) (*OrderSearch, error)
// SupplementOrder Supplement requests for PortIn order. Supported supplement Types:
// <type> 1.cancel 2- change due date, 3- all other
SupplementOrder(ctx context.Context, supplementInfo *SupplementInfo, order *Order) (string, error)
// Upload This method can be used to upload required attachments to an order.
Upload(ctx context.Context, orderID string, attachments []Attachment) (bool, error)
// ValidateE911Address This operation will validate User Address for E911
ValidateE911Address(ctx context.Context, address BaseAddress) ([]BaseAddress, error)
// ViewNumberDetails This Operation will search all the features for the requested telephone numbers in the
// inventory from Peerless.
ViewNumberDetails(ctx context.Context, numbers []string) ([]OrderNumber, error)
}
// New creates an initializes a API service.
func New(url string, customer string, passcode string, userid string, logger *zap.Logger) (APIService, error) {
s := &service{
URL: url,
Authentication: &authInfo{
Customer: customer,
PassCode: passcode,
UserId: userid,
},
logger: logger,
}
if s.URL == "" {
return s, fmt.Errorf("must provider url")
}
s.logger.Debug("setup new service", zap.String("url", url), zap.String("customer", customer), zap.String("userid", userid))
return s, nil
}
// service implements the APIService interface.
type service struct {
URL string // URL of the server
UserAgent string // User-Agent header will be added to each request
URNamespace string // Uniform Resource Namespace
ThisNamespace string // SOAP This-Namespace (tns)
ExcludeActionNamespace bool // Include Namespace to SOAP Action header
Envelope string // Optional SOAP Envelope
Config *http.Client // Optional HTTP client
Authentication *authInfo // Authentication
logger *zap.Logger
}
// ActivateSOA was auto-generated from WSDL.
func (s *service) ActivateSOA(ctx context.Context, orderID []string) (bool, error) {
req := requestBody{
ActivateSOA: &activateSOA{
Authentication: s.Authentication,
OrderID: orderID,
},
}
res, err := s.call(ctx, req)
if err != nil {
return false, err
}
return res.ActivateSOA.Return, nil
}
// AddNotes was auto-generated from WSDL.
func (s *service) AddNotes(ctx context.Context, orderID, note string) (bool, error) {
req := requestBody{
AddNotes: &addNotes{
Authentication: s.Authentication,
OrderID: orderID,
Notes: note,
},
}
res, err := s.call(ctx, req)
if err != nil {
return false, err
}
return res.AddNotes.Return, nil
}
// CreateException was auto-generated from WSDL.
func (s *service) CreateException(ctx context.Context, ExceptionNote *ExceptionNote) (bool, error) {
req := requestBody{
CreateException: &createException{
Authentication: s.Authentication,
ExceptionNote: ExceptionNote,
},
}
res, err := s.call(ctx, req)
if err != nil {
return false, err
}
return res.CreateException.Return, nil
}
// DisconnectOrder was auto-generated from WSDL.
func (s *service) DisconnectOrder(ctx context.Context, DisconnectOrderRequest DisconnectOrderRequest) (string, error) {
req := requestBody{
DisconnectOrder: &disconnectOrder{
Authentication: s.Authentication,
DisconnectOrderRequest: &DisconnectOrderRequest,
},
}
res, err := s.call(ctx, req)
if err != nil {
return "", err
}
return res.DisconnectOrder.Return, nil
}
// Download was auto-generated from WSDL.
func (s *service) Download(ctx context.Context, orderID string) ([]Attachment, error) {
req := requestBody{
Download: &download{
Authentication: s.Authentication,
OrderID: orderID,
},
}
res, err := s.call(ctx, req)
if err != nil {
return nil, err
}
return res.Download.Return, nil
}
// GetHierarchicalView was auto-generated from WSDL.
func (s *service) GetHierarchicalView(ctx context.Context) (*HiearchicalView, error) {
req := requestBody{
GetHierarchicalView: &getHierarchicalView{
Authentication: s.Authentication,
},
}
res, err := s.call(ctx, req)
if err != nil {
return nil, err
}
return res.GetHierarchicalView.Return, nil
}
// GetNewNumberSearchFilters was auto-generated from WSDL.
func (s *service) GetNewNumberSearchFilters(ctx context.Context, filters *NumberSearchParameters) (*NumberSearchParameters, error) {
req := requestBody{
GetNewNumberSearchFilters: &getNewNumberSearchFilters{
Authentication: s.Authentication,
Filters: filters,
},
}
res, err := s.call(ctx, req)
if err != nil {
return nil, err
}
return res.GetNewNumberSearchFilters.Return, nil
}
// GetOrderStatus was auto-generated from WSDL.
func (s *service) GetOrderStatus(ctx context.Context, orderID string) (string, error) {
req := requestBody{
GetOrderStatus: &getOrderStatus{
OrderID: orderID,
},
}
res, err := s.call(ctx, req)
if err != nil {
return "", err
}
return res.GetOrderStatus.Return, nil
}
// GetOrdersByPONSearch was auto-generated from WSDL.
func (s *service) GetOrdersByPONSearch(ctx context.Context, pon string) ([]ResultPONOrderDetails, error) {
req := requestBody{
GetOrdersByPONSearch: &getOrdersByPONSearch{
Authentication: s.Authentication,
Pon: pon,
},
}
res, err := s.call(ctx, req)
if err != nil {
return nil, err
}
return res.GetOrdersByPONSearch.Return.Result, nil
}
// GetPortInRelatedOrders was auto-generated from WSDL.
func (s *service) GetPortInRelatedOrders(ctx context.Context, orderID int64) ([]ResultOrderDetails, error) {
req := requestBody{
GetPortInRelatedOrders: &getPortInRelatedOrders{
Authentication: s.Authentication,
OrderID: orderID,
},
}
res, err := s.call(ctx, req)
if err != nil {
return nil, err
}
return res.GetPortInRelatedOrders.Return.Result, nil
}
// GetStatusByNumberSearch was auto-generated from WSDL.
func (s *service) GetStatusByNumberSearch(ctx context.Context, telephoneNumber []string) ([]string, error) {
req := requestBody{
GetStatusByNumberSearch: &getStatusByNumberSearch{
Authentication: s.Authentication,
TelephoneNumber: telephoneNumber,
},
}
res, err := s.call(ctx, req)
if err != nil {
return nil, err
}
return res.GetStatusByNumberSearch.Return.Result, nil
}
// GetTnInventoryReport was auto-generated from WSDL.
func (s *service) GetTnInventoryReport(ctx context.Context, searchParams *TnInventoryForApiSearchParams) ([]TnInventory, error) {
req := requestBody{
GetTnInventoryReport: &getTnInventoryReport{
Authentication: s.Authentication,
SearchParams: searchParams,
},
}
res, err := s.call(ctx, req)
if err != nil {
return nil, err
}
return res.GetTnInventoryReport.Return, nil
}
// PlaceOrder was auto-generated from WSDL.
func (s *service) PlaceOrder(ctx context.Context, order *Order) (string, error) {
req := requestBody{
PlaceOrder: &placeOrder{
Authentication: s.Authentication,
Order: order,
},
}
res, err := s.call(ctx, req)
if err != nil {
return "", err
}
return res.PlaceOrder.Return, nil
}
// PlaceTFDisconnectOrder was auto-generated from WSDL.
func (s *service) PlaceTFDisconnectOrder(ctx context.Context, disconnectOrderRequest *DisconnectOrderRequest) (string, error) {
req := requestBody{
PlaceTFDisconnectOrder: &placeTFDisconnectOrder{
Authentication: s.Authentication,
DisconnectOrderRequest: disconnectOrderRequest,
},
}
res, err := s.call(ctx, req)
if err != nil {
return "", err
}
return res.PlaceTFDisconnectOrder.Return, nil
}
// PlaceTFOrder was auto-generated from WSDL.
func (s *service) PlaceTFOrder(ctx context.Context, order *TollFreeOrder) (string, error) {
req := requestBody{
PlaceTFOrder: &placeTFOrder{
Authentication: s.Authentication,
TFNOrder: order,
},
}
res, err := s.call(ctx, req)
if err != nil {
return "", err
}
return res.PlaceTFOrder.Return, nil
}
// PortabilityCheck was auto-generated from WSDL.
func (s *service) PortabilityCheck(ctx context.Context, portabilityCheckRequest *PortabilityCheckRequest) ([]string, error) {
req := requestBody{
PortabilityCheck: &portabilityCheck{
Authentication: s.Authentication,
PortabilityCheckRequest: portabilityCheckRequest,
},
}
res, err := s.call(ctx, req)
if err != nil {
return nil, err
}
return res.PortabilityCheck.Return.PortPsNumbers, nil
}
// SearchNumbers was auto-generated from WSDL.
func (s *service) SearchNumbers(ctx context.Context, filters *NumberSearchParameters) (*NumberSearchParameters, error) {
req := requestBody{
SearchNumbers: &searchNumbers{
Authentication: s.Authentication,
Filters: filters,
},
}
res, err := s.call(ctx, req)
if err != nil {
return nil, err
}
return res.SearchNumbers.Return, nil
}
// SearchOrderDetailsByOrderId was auto-generated from WSDL.
func (s *service) SearchOrderDetailsByOrderId(ctx context.Context, orderID int64, orderType string) (*OrderSearch, error) {
req := requestBody{
SearchOrderDetailsByOrderId: &searchOrderDetailsByOrderId{
Authentication: s.Authentication,
OrderID: orderID,
OrderType: orderType,
},
}
res, err := s.call(ctx, req)
if err != nil {
return nil, err
}
return res.SearchOrderDetailsByOrderId.Return, nil
}
// SupplementOrder was auto-generated from WSDL.
func (s *service) SupplementOrder(ctx context.Context, supplementInfo *SupplementInfo, order *Order) (string, error) {
req := requestBody{
SupplementOrder: &supplementOrder{
Authentication: s.Authentication,
SupplementInfo: supplementInfo,
Order: order,
},
}
res, err := s.call(ctx, req)
if err != nil {
return "", err
}
return res.SupplementOrder.Return, nil
}
// Upload was auto-generated from WSDL.
func (s *service) Upload(ctx context.Context, orderID string, attachments []Attachment) (bool, error) {
req := requestBody{
Upload: &upload{
Authentication: s.Authentication,
OrderID: orderID,
Attachments: attachments,
},
}
res, err := s.call(ctx, req)
if err != nil {
return false, err
}
return res.Upload.Return, nil
}
// ValidateE911Address was auto-generated from WSDL.
func (s *service) ValidateE911Address(ctx context.Context, address BaseAddress) ([]BaseAddress, error) {
req := requestBody{
ValidateE911Address: &validateE911Address{
Authentication: s.Authentication,
Address: address,
},
}
res, err := s.call(ctx, req)
if err != nil {
return nil, err
}
return res.ValidateE911Address.Return, nil
}
// ViewNumberDetails was auto-generated from WSDL.
func (s *service) ViewNumberDetails(ctx context.Context, numbers []string) ([]OrderNumber, error) {
req := requestBody{
ViewNumberDetails: &viewNumberDetails{
Authentication: s.Authentication,
TelephoneNumber: numbers,
},
}
res, err := s.call(ctx, req)
if err != nil {
return nil, err
}
return res.ViewNumberDetails.Return, nil
}