dnscontrol/vendor/github.com/prasmussen/gandi-api/client/client.go
2016-08-22 18:31:50 -06:00

37 lines
653 B
Go

package client
import "github.com/kolo/xmlrpc"
const (
Production SystemType = iota
Testing
)
type SystemType int
func (self SystemType) Url() string {
if self == Production {
return "https://rpc.gandi.net/xmlrpc/"
}
return "https://rpc.ote.gandi.net/xmlrpc/"
}
type Client struct {
Key string
Url string
}
func New(apiKey string, system SystemType) *Client {
return &Client{
Key: apiKey,
Url: system.Url(),
}
}
func (self *Client) Call(serviceMethod string, args []interface{}, reply interface{}) error {
rpc, err := xmlrpc.NewClient(self.Url, nil)
if err != nil {
return err
}
return rpc.Call(serviceMethod, args, reply)
}