feat: new, more customizable client supporting API Key and user/password authentication

This commit is contained in:
Mateusz Filipowicz
2025-02-08 21:45:00 +01:00
committed by Mateusz Filipowicz
parent 8a0cf33e75
commit f79f21c4ad
87 changed files with 1286 additions and 960 deletions

View File

@@ -224,17 +224,17 @@ func (dst *SettingIpsWhitelist) UnmarshalJSON(b []byte) error {
func (c *Client) getSettingIps(ctx context.Context, site string) (*SettingIps, error) {
var respBody struct {
Meta meta `json:"meta"`
Meta Meta `json:"meta"`
Data []SettingIps `json:"data"`
}
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/ips", site), nil, &respBody)
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/ips", site), nil, &respBody)
if err != nil {
return nil, err
}
if len(respBody.Data) != 1 {
return nil, &NotFoundError{}
return nil, NotFoundError
}
d := respBody.Data[0]
@@ -243,18 +243,18 @@ func (c *Client) getSettingIps(ctx context.Context, site string) (*SettingIps, e
func (c *Client) updateSettingIps(ctx context.Context, site string, d *SettingIps) (*SettingIps, error) {
var respBody struct {
Meta meta `json:"meta"`
Meta Meta `json:"meta"`
Data []SettingIps `json:"data"`
}
d.Key = "ips"
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/ips", site), d, &respBody)
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/ips", site), d, &respBody)
if err != nil {
return nil, err
}
if len(respBody.Data) != 1 {
return nil, &NotFoundError{}
return nil, NotFoundError
}
new := respBody.Data[0]