-
Notifications
You must be signed in to change notification settings - Fork 0
/
billing.go
118 lines (88 loc) · 3.05 KB
/
billing.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
package clcv2
import (
"time"
"fmt"
)
type InvoiceData struct {
// ID of the account alias being queried
Id string
// payment terms associated with the account
Terms string
// Description of the account name
CompanyName string
// Short code for a particular account
AccountAlias string
// Short code for a particular account that receives the bill for the accountAlias usage
PricingAccountAlias string
// Short code for the parent account alias associated with the account alias being queried
ParentAccountAlias string
// First line of the address associated with accountAlias
Address1 string
// Second line of the address associated with accountAlias
// FIXME: not found in v2 output (Oct 2015)
Address2 string
// City associated with the accountAlias
City string
// State or province associated with the accountAlias
StateProvince string
// Postal code associated with the accountAlias
PostalCode string
// Billing email address associated with the accountAlias
BillingContactEmail string
// Additional billing email address associated with the accountAlias
InvoiceCCEmail string
// Invoice amount in dollars
TotalAmount float64
// Date the invoice is finalized
InvoiceDate time.Time
// Purchase Order associated with the Invoice
// FIXME: not found in output (Oct 2015)
PoNumber string
// Usage details of a resource or collection of similar resources
LineItems []struct{
// Quantity of the line item
Quantity int
// Text description of the line item
Description string
// Unit cost of the line item
UnitCost float64
// Total cost of the line item
ItemTotal float64
// Location of the line item
ServiceLocation string
// Individual line item description and cost.
// For instance, may refer to the servers within a group.
ItemDetails []struct {
// Typically the name of the lowest level billed resource, such as a server name.
Description string
// Cost of this resource.
Cost float64
}
}
}
// Get a list of invoicing data (estimates) for a given account alias for a given month.
// @year: Year of usage, in YYYY format.
// @month: Month of usage, in M{,M} format
// @date: Date of the invoice data (only month and year are used)..
// @pricingAccount: Short code of the account that sends the invoice for the account alias.
func (c *Client) GetInvoiceData(year, month int, pricingAccount string) (res InvoiceData, err error) {
path := fmt.Sprintf("/v2/invoice/%s/%4d/%d", c.AccountAlias, year, month)
if pricingAccount != "" {
path += "?pricingAccount=" + pricingAccount
}
err = c.getCLCResponse("GET", path, nil, &res)
return res, err
}
// Used by the 'Get Group Billing Details' call
type ServerBillingDetails struct {
// Cost of templates stored in the group
TemplateCost float64
// Cost of archived servers in this group
ArchiveCost float64
// Projected charges for the servers given current usage
MonthlyEstimate float64
// Charges up until the requested time
MonthToDate float64
// Charges for the most recent hour
CurrentHour float64
}