-
Notifications
You must be signed in to change notification settings - Fork 0
/
users.go
50 lines (44 loc) · 1.31 KB
/
users.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
package namecheap
import (
"net/url"
)
const (
usersGetPricing = "namecheap.users.getPricing"
)
type UsersGetPricingResult struct {
ProductType string `xml:"Name,attr"`
ProductCategory []struct {
Name string `xml:"Name,attr"`
Product []struct {
Name string `xml:"Name,attr"`
Price []struct {
Duration int `xml:"Duration,attr"`
DurationType string `xml:"DurationType,attr"`
Price float64 `xml:"Price,attr"`
RegularPrice float64 `xml:"RegularPrice,attr"`
YourPrice float64 `xml:"YourPrice,attr"`
CouponPrice float64 `xml:"CouponPrice,attr"`
Currency string `xml:"Currency,attr"`
} `xml:"Price"`
} `xml:"Product"`
} `xml:"ProductCategory"`
}
func (client *Client) UsersGetPricing(productType, productCategory, productName string) ([]UsersGetPricingResult, error) {
requestInfo := &ApiRequest{
command: usersGetPricing,
method: "GET",
params: url.Values{},
}
requestInfo.params.Set("ProductType", productType)
if len(productCategory) > 0 && productCategory != "*" {
requestInfo.params.Set("ProductCategory", productCategory)
}
if len(productName) > 0 && productName != "*" {
requestInfo.params.Set("ProductName", productName)
}
resp, err := client.do(requestInfo)
if err != nil {
return nil, err
}
return resp.UsersGetPricing, nil
}