Skip to content

Commit 0e1ea33

Browse files
committed
Small fixes
1 parent 7840f8b commit 0e1ea33

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

create_email.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package temp_mail_go
22

33
import (
44
"context"
5+
"net/http"
56
"time"
67
)
78

@@ -60,7 +61,7 @@ func (c *Client) CreateEmail(ctx context.Context, options CreateEmailOptions) (C
6061
DomainType: options.DomainType,
6162
Domain: options.Domain,
6263
}
63-
request, err := c.newRequest(ctx, "POST", "/v1/emails", req)
64+
request, err := c.newRequest(ctx, http.MethodPost, "/v1/emails", req)
6465
if err != nil {
6566
return CreateEmailResponse{}, nil, err
6667
}

list_domains.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package temp_mail_go
2+
3+
import (
4+
"context"
5+
"net/http"
6+
)
7+
8+
// ListDomainsResponse represents the response for the listDomainsHandler.
9+
type ListDomainsResponse struct {
10+
Domains []ListDomainsDomainResponse `json:"domains"`
11+
}
12+
13+
// ListDomainsDomainResponse represents one domain in the listDomainsHandler response.
14+
type ListDomainsDomainResponse struct {
15+
// Name of the domain.
16+
Name string `json:"name"`
17+
// Type of the domain.
18+
// Possible values: "public", "premium", "custom"
19+
Type string `json:"type"`
20+
}
21+
22+
// ListDomains returns a list of domains available for use.
23+
func (c *Client) ListDomains(ctx context.Context) ([]ListDomainsResponse, *Response, error) {
24+
req, err := c.newRequest(ctx, http.MethodGet, "/v1/domains", nil)
25+
if err != nil {
26+
return nil, nil, err
27+
}
28+
29+
var resp []ListDomainsResponse
30+
response, err := c.do(req, &resp)
31+
if err != nil {
32+
return nil, nil, err
33+
}
34+
35+
return resp, response, nil
36+
}

rate_limit.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package temp_mail_go
22

33
import (
44
"context"
5+
"net/http"
56
"time"
67
)
78

@@ -30,7 +31,7 @@ type rateLimitResponse struct {
3031

3132
// RateLimit returns the current rate limit for the client.
3233
func (c *Client) RateLimit(ctx context.Context) (Rate, *Response, error) {
33-
req, err := c.newRequest(ctx, "GET", "/v1/rate_limit", nil)
34+
req, err := c.newRequest(ctx, http.MethodGet, "/v1/rate_limit", nil)
3435
if err != nil {
3536
return Rate{}, nil, err
3637
}

0 commit comments

Comments
 (0)