-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathp2p.go
41 lines (37 loc) · 898 Bytes
/
p2p.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
30
31
32
33
34
35
36
37
38
39
40
41
// https://documenter.getpostman.com/view/8765260/TzzHnDGw#55629b48-821c-49cf-af14-ce76cfe0d65f
package qvapay
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"strings"
)
// Offers
// curl --location --request GET 'https://qvapay.com/api/p2p/index'
func (c *client) Offers(ctx context.Context, query QueryParams) (map[string]any, error) {
requestUrl, err := url.Parse(c.url + "/p2p/index")
if err != nil {
return nil, err
}
ParseUrlQueryParams(query, requestUrl)
status, res, err := c.apiCall(
ctx,
http.MethodGet,
requestUrl.String(),
nil,
)
if err != nil {
return nil, err
}
if status != http.StatusOK {
return nil, HandleAPIErrorResponse(res)
}
result := map[string]any{}
err = json.NewDecoder(strings.NewReader(res)).Decode(&result)
if err != nil {
return nil, fmt.Errorf("decoding error for data %s: %v", res, err)
}
return result, nil
}