-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathorders.go
77 lines (70 loc) · 2.32 KB
/
orders.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
package whmcsgo
// OrdersService provides access to the orders related functions
// in the WHMCS API.
//
// WHMCS API docs: https://developers.whmcs.com/api/api-index/
type OrdersService struct {
client *Client
}
// Order represents a WHCMS Order for an account
type Order struct {
ClientID *string `json:"clientid"`
PID *string `json:"pid"`
Domain *string `json:"domain"`
BillingCycle *string `json:"billingcycle"`
DomainType *string `json:"domaintype"`
RegPeriod *string `json:"regperiod"`
EppCode *int `json:"eppcode"`
NameServer1 *string `json:"nameserver1"`
PaymentMethod *string `json:"paymentmethod"`
HostName *string `json:"hostname"`
}
func (o Order) String() string {
return Stringify(o)
}
// AddOrder adds an new order
//
// WHMCs API docs: https://developers.whmcs.com/api-reference/addorder/
func (s *OrdersService) AddOrder(parms map[string]string) (*Order, *Response, error) {
order := new(Order)
resp, err := do(s.client, Params{parms: parms, u: "AddOrder"}, order)
if err != nil {
return nil, resp, err
}
return order, resp, err
}
// GetOrders the orders for a user. Passing the empty string will list
// orders for the authenticated user.
//
// WHMCS API docs: https://developers.whmcs.com/api-reference/getorders/
func (s *OrdersService) GetOrders(parms map[string]string) (*[]Order, *Response, error) {
orders := new([]Order)
resp, err := do(s.client, Params{parms: parms, u: "GetOrders"}, orders)
if err != nil {
return nil, resp, err
}
return orders, resp, err
}
// GetOrderStatuses the status of the order
//
// WHMCS API docs: https://developers.whmcs.com/api-reference/getorderstatuses/
// TO-DO this shall return *[]OrderStatus
func (s *OrdersService) GetOrderStatuses(parms map[string]string) (*Order, *Response, error) {
order := new(Order)
resp, err := do(s.client, Params{parms: parms, u: "GetOrderStatuses"}, order)
if err != nil {
return nil, resp, err
}
return order, resp, err
}
// CancelOrder Cancel a Pending Order
//
// WHMCS API docs: https://developers.whmcs.com/api-reference/cancelorder/
func (s *OrdersService) CancelOrder(parms map[string]string) (*Order, *Response, error) {
order := new(Order)
resp, err := do(s.client, Params{parms: parms, u: "CancelOrder"}, order)
if err != nil {
return nil, resp, err
}
return order, resp, err
}