Skip to content

Commit 97bd8b8

Browse files
committed
Bumped v1
Signed-off-by: Vishal Rana <[email protected]>
1 parent a3bb6f7 commit 97bd8b8

File tree

16 files changed

+589
-309
lines changed

16 files changed

+589
-309
lines changed

.idea/dictionaries/vr.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 226 additions & 225 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

currency.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package labstack
22

33
import (
44
"github.com/labstack/labstack-go/currency"
5-
"github.com/labstack/labstack-go/util"
65
"strconv"
76
)
87

@@ -23,7 +22,7 @@ func (c *Client) CurrencyConvert(req *currency.ConvertRequest) (*currency.Conver
2322
Message: e.Error(),
2423
}
2524
}
26-
if util.Error(r) {
25+
if isError(r) {
2726
return nil, err
2827
}
2928
return res, nil
@@ -41,7 +40,7 @@ func (c *Client) CurrencyList(req *currency.ListRequest) (*currency.ListResponse
4140
Message: e.Error(),
4241
}
4342
}
44-
if util.Error(r) {
43+
if isError(r) {
4544
return nil, err
4645
}
4746
return res, nil

domain.go

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package labstack
2+
3+
import (
4+
"github.com/labstack/labstack-go/domain"
5+
)
6+
7+
func (c *Client) DomainDNS(req *domain.DNSRequest) (*domain.DNSResponse, *Error) {
8+
res := new(domain.DNSResponse)
9+
err := new(Error)
10+
r, e := c.domainResty.R().
11+
SetPathParams(map[string]string{
12+
"type": req.Type,
13+
"domain": req.Domain,
14+
}).
15+
SetResult(res).
16+
SetError(err).
17+
Get("/{type}/{domain}")
18+
if e != nil {
19+
return nil, &Error{
20+
Message: err.Error(),
21+
}
22+
}
23+
if isError(r) {
24+
return nil, err
25+
}
26+
return res, nil
27+
}
28+
29+
func (c *Client) DomainSearch(req *domain.SearchRequest) (*domain.SearchResponse, *Error) {
30+
res := new(domain.SearchResponse)
31+
err := new(Error)
32+
r, e := c.domainResty.R().
33+
SetPathParams(map[string]string{
34+
"domain": req.Domain,
35+
}).
36+
SetResult(res).
37+
SetError(err).
38+
Get("/search/{domain}")
39+
if e != nil {
40+
return nil, &Error{
41+
Message: err.Error(),
42+
}
43+
}
44+
if isError(r) {
45+
return nil, err
46+
}
47+
return res, nil
48+
}
49+
50+
func (c *Client) DomainStatus(req *domain.StatusRequest) (*domain.StatusResponse, *Error) {
51+
res := new(domain.StatusResponse)
52+
err := new(Error)
53+
r, e := c.domainResty.R().
54+
SetPathParams(map[string]string{
55+
"domain": req.Domain,
56+
}).
57+
SetResult(res).
58+
SetError(err).
59+
Get("/status/{domain}")
60+
if e != nil {
61+
return nil, &Error{
62+
Message: err.Error(),
63+
}
64+
}
65+
if isError(r) {
66+
return nil, err
67+
}
68+
return res, nil
69+
}
70+
71+
func (c *Client) DomainWhois(req *domain.WhoisRequest) (*domain.WhoisResponse, *Error) {
72+
res := new(domain.WhoisResponse)
73+
err := new(Error)
74+
r, e := c.domainResty.R().
75+
SetPathParams(map[string]string{
76+
"domain": req.Domain,
77+
}).
78+
SetResult(res).
79+
SetError(err).
80+
Get("/whois/{domain}")
81+
if e != nil {
82+
return nil, &Error{
83+
Message: err.Error(),
84+
}
85+
}
86+
if isError(r) {
87+
return nil, err
88+
}
89+
return res, nil
90+
}

domain/domain.go

Lines changed: 97 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,102 @@
11
package domain
22

3-
import "github.com/go-resty/resty/v2"
4-
53
type (
6-
Domain struct {
7-
resty *resty.Client
4+
Record struct {
5+
Domain string `json:"domain"`
6+
Type string `json:"type"`
7+
Server string `json:"server"`
8+
A string `json:"a"`
9+
AAAA string `json:"aaaa"`
10+
CNAME string `json:"cname"`
11+
MX string `json:"mx"`
12+
NS string `json:"ns"`
13+
PTR string `json:"ptr"`
14+
Serial uint32 `json:"serial"`
15+
Refresh uint32 `json:"refresh"`
16+
Retry uint32 `json:"retry"`
17+
Expire uint32 `json:"expire"`
18+
Priority uint32 `json:"priority"`
19+
Weight uint32 `json:"weight"`
20+
Port uint32 `json:"port"`
21+
Target string `json:"target"`
22+
TXT []string `json:"txt"`
23+
TTL uint32 `json:"ttl"`
24+
Class string `json:"class"`
25+
SPF []string `json:"spf"`
26+
}
27+
28+
Result struct {
29+
Domain string `json:"domain"`
30+
Zone string `json:"zone"`
31+
}
32+
33+
Registrar struct {
34+
Id string `json:"id"`
35+
Name string `json:"name"`
36+
Url string `json:"url"`
37+
WhoisServer string `json:"whois_server"`
38+
}
39+
40+
Registrant struct {
41+
Id string `json:"id"`
42+
Name string `json:"name"`
43+
Organization string `json:"organization"`
44+
Street string `json:"street"`
45+
City string `json:"city"`
46+
State string `json:"state"`
47+
Zip string `json:"zip"`
48+
Country string `json:"country"`
49+
Phone string `json:"phone"`
50+
Fax string `json:"fax"`
51+
Email string `json:"email"`
52+
}
53+
54+
DNSRequest struct {
55+
Type string
56+
Domain string
57+
}
58+
59+
DNSResponse struct {
60+
Records []*Record
61+
}
62+
63+
SearchRequest struct {
64+
Domain string
65+
}
66+
67+
SearchResponse struct {
68+
Results []*Result
69+
}
70+
71+
StatusRequest struct {
72+
Domain string
73+
}
74+
75+
StatusResponse struct {
76+
Domain string `json:"domain"`
77+
Zone string `json:"zone"`
78+
Result string `json:"result"`
79+
Flags []string `json:"flags"`
80+
}
81+
82+
WhoisRequest struct {
83+
Domain string
84+
}
85+
86+
WhoisResponse struct {
87+
Domain string `json:"domain"`
88+
Id string `json:"id"`
89+
Status string `json:"status"`
90+
CreatedDate string `json:"created_date"`
91+
UpdatedDate string `json:"updated_date"`
92+
ExpiryDate string `json:"expiry_date"`
93+
NameServers []string `json:"name_servers"`
94+
Dnssec string `json:"dnssec"`
95+
Registrar *Registrar `json:"registrar"`
96+
Registrant *Registrant `json:"registrant"`
97+
Admin *Registrant `json:"admin"`
98+
Technical *Registrant `json:"technical"`
99+
Billing *Registrant `json:"billing"`
100+
Raw string `json:"raw"`
8101
}
9102
)

domain_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package labstack
2+
3+
import (
4+
"github.com/labstack/labstack-go/domain"
5+
"github.com/stretchr/testify/assert"
6+
"testing"
7+
)
8+
9+
func TestClient_DomainDNS(t *testing.T) {
10+
res, err := client.DomainDNS(&domain.DNSRequest{Type: "A", Domain: "twillio.com"})
11+
if assert.Nil(t, err) {
12+
assert.NotZero(t, len(res.Records))
13+
}
14+
}
15+
16+
func TestClient_DomainSearch(t *testing.T) {
17+
res, err := client.DomainSearch(&domain.SearchRequest{Domain: "twillio.com"})
18+
if assert.Nil(t, err) {
19+
assert.NotZero(t, len(res.Results))
20+
}
21+
}
22+
23+
func TestClient_DomainStatus(t *testing.T) {
24+
res, err := client.DomainStatus(&domain.StatusRequest{Domain: "twillio.com"})
25+
if assert.Nil(t, err) {
26+
assert.Equal(t, "unavailable", res.Result)
27+
}
28+
}
29+
30+
func TestClient_DomainWhois(t *testing.T) {
31+
res, err := client.DomainWhois(&domain.WhoisRequest{Domain: "twillio.com"})
32+
if assert.Nil(t, err) {
33+
assert.NotEmpty(t, res.Raw)
34+
}
35+
}

email.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@ package labstack
22

33
import (
44
"github.com/labstack/labstack-go/email"
5-
"github.com/labstack/labstack-go/util"
65
)
76

87
func (c *Client) EmailVerify(req *email.VerifyRequest) (*email.VerifyResponse, *Error) {
98
res := new(email.VerifyResponse)
10-
ae := new(Error)
11-
r, err := c.emailResty.R().
9+
err := new(Error)
10+
r, e := c.emailResty.R().
1211
SetPathParams(map[string]string{
1312
"email": req.Email,
1413
}).
1514
SetResult(res).
16-
SetError(ae).
15+
SetError(err).
1716
Get("/verify/{email}")
18-
if err != nil {
17+
if e != nil {
1918
return nil, &Error{
2019
Message: err.Error(),
2120
}
2221
}
23-
if util.Error(r) {
24-
return nil, ae
22+
if isError(r) {
23+
return nil, err
2524
}
2625
return res, nil
2726
}

email/email.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ type (
1313
Flags []string `json:"flags"`
1414
}
1515
)
16-

email/email_test.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

ip.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package labstack
22

33
import (
44
"github.com/labstack/labstack-go/ip"
5-
"github.com/labstack/labstack-go/util"
65
)
76

87
func (c *Client) IPLookup(req *ip.LookupRequest) (*ip.LookupResponse, error) {
@@ -20,7 +19,7 @@ func (c *Client) IPLookup(req *ip.LookupRequest) (*ip.LookupResponse, error) {
2019
Message: e.Error(),
2120
}
2221
}
23-
if util.Error(r) {
22+
if isError(r) {
2423
return nil, err
2524
}
2625
return res, nil

0 commit comments

Comments
 (0)