/
billing_order_service.go
69 lines (60 loc) · 2.52 KB
/
billing_order_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
/*******************************************************************************
* IBM Confidential
* OCO Source Materials
* IBM Cloud Container Service, 5737-D43
* (C) Copyright IBM Corp. 2018 All Rights Reserved.
* The source code for this program is not published or otherwise divested of
* its trade secrets, irrespective of what has been deposited with
* the U.S. Copyright Office.
******************************************************************************/
package backend
import (
"github.com/softlayer/softlayer-go/datatypes"
"github.com/softlayer/softlayer-go/services"
)
// BillingOrderService is a wrapping interface for the softlayer-go API's BillingOrderService
//go:generate counterfeiter -o fakes/billing_order_service.go --fake-name BillingOrderService . BillingOrderService
type BillingOrderService interface {
Filter(filter string) BillingOrderService
Mask(string) BillingOrderService
ID(int) BillingOrderService
GetObject() (datatypes.Billing_Order, error)
GetAllObjects() ([]datatypes.Billing_Order, error)
}
// BillingOrderServiceSL is a softlayer implementation of the BillingOrderService interface.
// All functions pass directly to the equivalent SL function
type BillingOrderServiceSL struct {
billingOrderService services.Billing_Order
}
// Filter pass-through for BillingOrderService.Filter
func (bos *BillingOrderServiceSL) Filter(filter string) BillingOrderService {
return &BillingOrderServiceSL{billingOrderService: bos.billingOrderService.Filter(filter)}
}
// Mask pass-through for BillingOrderService.Mask
func (bos *BillingOrderServiceSL) Mask(mask string) BillingOrderService {
return &BillingOrderServiceSL{billingOrderService: bos.billingOrderService.Mask(mask)}
}
// ID pass-through for BillingOrderService.ID
func (bos *BillingOrderServiceSL) ID(id int) BillingOrderService {
return &BillingOrderServiceSL{billingOrderService: bos.billingOrderService.Id(id)}
}
// GetObject returns the billing order
func (bos *BillingOrderServiceSL) GetObject() (datatypes.Billing_Order, error) {
var blOrder datatypes.Billing_Order
var blError error
blError = retry(func() error {
blOrder, blError = bos.billingOrderService.GetObject()
return blError
})
return blOrder, blError
}
// GetAllObjects returns all billing orders
func (bos *BillingOrderServiceSL) GetAllObjects() ([]datatypes.Billing_Order, error) {
var blOrder []datatypes.Billing_Order
var blError error
blError = retry(func() error {
blOrder, blError = bos.billingOrderService.GetAllObjects()
return blError
})
return blOrder, blError
}