Skip to content

Commit b1db803

Browse files
update Product type (#5)
1 parent 4b834e3 commit b1db803

File tree

1 file changed

+38
-16
lines changed

1 file changed

+38
-16
lines changed

product.go

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,46 @@ package go_certcentral
22

33
import (
44
"encoding/json"
5-
"io/ioutil"
5+
"io"
66
"net/http"
77
)
88

99
const productURL = "/product"
1010

11+
type ProductRsp struct {
12+
Products []Product `json:"products"`
13+
}
14+
1115
type Product struct {
12-
GroupName string `json:"group_name,omitempty"`
13-
NameID string `json:"name_id,omitempty"`
14-
Name string `json:"name,omitempty"`
15-
Type string `json:"type,omitempty"`
16-
ValidationType string `json:"validation_type,omitempty"`
17-
ValidationName string `json:"validation_name,omitempty"`
18-
ValidationDescription string `json:"validation_description,omitempty"`
16+
GroupName string `json:"group_name,omitempty"`
17+
NameID string `json:"name_id,omitempty"`
18+
Name string `json:"name,omitempty"`
19+
Type string `json:"type,omitempty"`
20+
ValidationType string `json:"validation_type,omitempty"`
21+
ValidationName string `json:"validation_name,omitempty"`
22+
ValidationDescription string `json:"validation_description,omitempty"`
23+
AllowedContainerIDs []int `json:"allowed_container_ids,omitempty"`
24+
AllowedValidityYears []int `json:"allowed_validity_years,omitempty"`
25+
AllowedOrderValidityYears []int `json:"allowed_order_validity_years,omitempty"`
26+
SignatureHashTypes SignatureHashTypes `json:"signature_hash_types,omitempty"`
27+
AllowedCACerts []AllowedCACert `json:"allowed_ca_certs,omitempty"`
28+
CSRRequired bool `json:"csr_required,omitempty"`
29+
ReplacementProductNameID string `json:"replacement_product_name_id,omitempty"`
30+
}
31+
32+
type SignatureHashTypes struct {
33+
AllowedHashTypes []AllowedHashType `json:"allowed_hash_types,omitempty"`
34+
DefaultHashTypeID string `json:"default_hash_type_id,omitempty"`
35+
}
36+
37+
type AllowedHashType struct {
38+
ID string `json:"id,omitempty"`
39+
Name string `json:"name,omitempty"`
40+
}
41+
42+
type AllowedCACert struct {
43+
ID string `json:"id,omitempty"`
44+
Name string `json:"name,omitempty"`
1945
}
2046

2147
func (c *Client) ListProducts() ([]Product, error) {
@@ -30,16 +56,12 @@ func (c *Client) ListProducts() ([]Product, error) {
3056
}
3157
defer res.Body.Close()
3258

33-
resBody, err := ioutil.ReadAll(res.Body)
59+
resBody, err := io.ReadAll(res.Body)
3460
if err != nil {
3561
return nil, err
3662
}
3763

38-
type data struct {
39-
Products []Product `json:"products"`
40-
}
41-
42-
var d data
43-
err = json.Unmarshal(resBody, &d)
44-
return d.Products, err
64+
var productRsp ProductRsp
65+
err = json.Unmarshal(resBody, &productRsp)
66+
return productRsp.Products, err
4567
}

0 commit comments

Comments
 (0)