-
Notifications
You must be signed in to change notification settings - Fork 0
/
ping.go
29 lines (23 loc) · 754 Bytes
/
ping.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package porkbun
import "context"
// PingResponse represents the response structure for the Ping API.
type PingResponse struct {
BaseResponse
YourIP string `json:"yourIp"` // The IP address of the client making the request.
}
// PingRequest represents the request structure for the Ping API.
type PingRequest struct {
BaseRequest
}
// Ping pings the Porkbun API to check its availability and returns the client's IP address.
func (s *Client) Ping(ctx context.Context) (*PingResponse, error) {
request := &PingRequest{}
response := &PingResponse{}
// Make a POST request to the /ping endpoint
resp, err := s.post(ctx, "/ping", request, response)
if err != nil {
return response, err
}
response.HTTPResponse = resp
return response, err
}