endpoint.go 728 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package api
  2. import "net/http"
  3. func (api *Client) Get(
  4. u string,
  5. result interface{},
  6. ) error {
  7. params := RequestOptions{
  8. Method: http.MethodGet,
  9. Headers: makeHeaders(api.options.AccessToken),
  10. }
  11. return api.doRequest(u, params, result)
  12. }
  13. func (api *Client) Post(
  14. u string,
  15. request any,
  16. result any,
  17. ) error {
  18. params := RequestOptions{
  19. Method: http.MethodPost,
  20. Body: request,
  21. Headers: makeHeaders(api.options.AccessToken),
  22. }
  23. return api.doRequest(u, params, result)
  24. }
  25. func (api *Client) Patch(
  26. u string,
  27. request any,
  28. result any,
  29. ) error {
  30. params := RequestOptions{
  31. Method: http.MethodPatch,
  32. Body: request,
  33. Headers: makeHeaders(api.options.AccessToken),
  34. }
  35. return api.doRequest(u, params, result)
  36. }