You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

client.go 479 B

123456789101112131415161718192021222324252627282930
  1. package unifyops
  2. import (
  3. "fmt"
  4. "gitlink.org.cn/cloudream/common/api"
  5. )
  6. type response[T any] struct {
  7. Code int `json:"code"`
  8. Message string `json:"message"`
  9. Data T `json:"data"`
  10. }
  11. func (r *response[T]) ToError() *api.CodeMessageError {
  12. return &api.CodeMessageError{
  13. Code: fmt.Sprintf("%d", r.Code),
  14. Message: r.Message,
  15. }
  16. }
  17. type Client struct {
  18. baseURL string
  19. }
  20. func NewClient(baseURL string) *Client {
  21. return &Client{
  22. baseURL: baseURL,
  23. }
  24. }