| 1 |
package proton |
| 2 |
|
| 3 |
import ( |
| 4 |
"context" |
| 5 |
|
| 6 |
"github.com/go-resty/resty/v2" |
| 7 |
) |
| 8 |
|
| 9 |
func (c *Client) ListShares(ctx context.Context, all bool) ([]ShareMetadata, error) { |
| 10 |
var res struct { |
| 11 |
Shares []ShareMetadata |
| 12 |
} |
| 13 |
|
| 14 |
if err := c.do(ctx, func(r *resty.Request) (*resty.Response, error) { |
| 15 |
if all { |
| 16 |
r.SetQueryParam("ShowAll", "1") |
| 17 |
} |
| 18 |
|
| 19 |
return r.SetResult(&res).Get("/drive/shares") |
| 20 |
}); err != nil { |
| 21 |
return nil, err |
| 22 |
} |
| 23 |
|
| 24 |
return res.Shares, nil |
| 25 |
} |
| 26 |
|
| 27 |
func (c *Client) GetShare(ctx context.Context, shareID string) (Share, error) { |
| 28 |
var res struct { |
| 29 |
Share |
| 30 |
} |
| 31 |
|
| 32 |
if err := c.do(ctx, func(r *resty.Request) (*resty.Response, error) { |
| 33 |
return r.SetResult(&res).Get("/drive/shares/" + shareID) |
| 34 |
}); err != nil { |
| 35 |
return Share{}, err |
| 36 |
} |
| 37 |
|
| 38 |
return res.Share, nil |
| 39 |
} |