From 426c2ed38d3df922a40ded47b7da8cb28e9c91b6 Mon Sep 17 00:00:00 2001 From: rbelnap Date: Tue, 25 Apr 2017 11:24:55 -0400 Subject: [PATCH] add BaseURL option to namecheap creds to allow setting sandbox endpoint (#97) --- docs/_providers/namecheap.md | 16 ++++++++++++++++ providers/namecheap/namecheap.go | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/docs/_providers/namecheap.md b/docs/_providers/namecheap.md index 4530386c8..10d7761a3 100644 --- a/docs/_providers/namecheap.md +++ b/docs/_providers/namecheap.md @@ -22,6 +22,22 @@ username and key: } {% endhighlight %} +You can optionally specify BaseURL to use a different endpoint - typically the +sandbox: + +{% highlight json %} +{ + "namecheap.com":{ + "apikey": "yourApiKeyFromNameCheap", + "apiuser": "yourUsername" + "BaseURL": "https://api.sandbox.namecheap.com/xml.response" + } +} +{% endhighlight %} + +if BaseURL is omitted, the production namecheap url is used. + + ## Metadata This provider does not recognize any special metadata fields unique to diff --git a/providers/namecheap/namecheap.go b/providers/namecheap/namecheap.go index 8735dc17d..1cecf594b 100644 --- a/providers/namecheap/namecheap.go +++ b/providers/namecheap/namecheap.go @@ -27,6 +27,13 @@ func newReg(m map[string]string) (providers.Registrar, error) { return nil, fmt.Errorf("Namecheap apikey and apiuser must be provided.") } api.client = nc.NewClient(api.ApiUser, api.ApiKey, api.ApiUser) + + // if BaseURL is specified in creds, use that url + BaseURL, ok := m["BaseURL"] + if ok { + api.client.BaseURL = BaseURL + } + return api, nil }