@@ -16,12 +16,13 @@ import (
16
16
// TYPES
17
17
18
18
type Domain struct {
19
- Domain string `json:"domain"`
20
- Services map [string ]Service `json:"services,omitempty"`
19
+ Domain string `json:"domain"`
20
+ Services map [string ]* Service `json:"services,omitempty"`
21
21
}
22
22
23
23
type Service struct {
24
- Name string `json:"name"`
24
+ Call string `json:"call,omitempty"`
25
+ Name string `json:"name,omitempty"`
25
26
Description string `json:"description,omitempty,wrap"`
26
27
Fields map [string ]Field `json:"fields,omitempty,wrap"`
27
28
}
@@ -59,7 +60,7 @@ func (c *Client) Domains() ([]Domain, error) {
59
60
}
60
61
61
62
// Return callable services for a domain
62
- func (c * Client ) Services (domain string ) ([]Service , error ) {
63
+ func (c * Client ) Services (domain string ) ([]* Service , error ) {
63
64
var response []Domain
64
65
if err := c .Do (nil , & response , client .OptPath ("services" )); err != nil {
65
66
return nil , err
@@ -69,11 +70,13 @@ func (c *Client) Services(domain string) ([]Service, error) {
69
70
continue
70
71
}
71
72
if len (v .Services ) == 0 {
72
- // No services found
73
- return []Service {}, nil
74
- } else {
75
- return maps .Values (v .Services ), nil
73
+ return nil , nil
76
74
}
75
+ // Populate the Id field
76
+ for k , v := range v .Services {
77
+ v .Call = k
78
+ }
79
+ return maps .Values (v .Services ), nil
77
80
}
78
81
// Return not found
79
82
return nil , ErrNotFound .Withf ("domain not found: %q" , domain )
0 commit comments