Client for the pixeldrain API. Used by pixeldrain itself for tranferring data between the web UI and API server. And for rendering JSON responses
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
992 B

4 years ago
4 years ago
  1. package pixelapi
  2. // Recaptcha stores the reCaptcha site key
  3. type Recaptcha struct {
  4. SiteKey string `json:"site_key"`
  5. }
  6. // GetMiscRecaptcha gets the reCaptcha site key from the pixelapi server. If
  7. // reCaptcha is disabled the key will be empty
  8. func (p *PixelAPI) GetMiscRecaptcha() (resp Recaptcha, err error) {
  9. return resp, p.jsonRequest("GET", "misc/recaptcha", &resp)
  10. }
  11. // GetMiscViewToken requests a viewtoken from the server. The viewtoken is valid
  12. // for a limited amount of time and can be used to add views to a file.
  13. // Viewtokens can only be requested from localhost
  14. func (p *PixelAPI) GetMiscViewToken() (resp string, err error) {
  15. return resp, p.jsonRequest("GET", "misc/viewtoken", &resp)
  16. }
  17. // SiaPrice is the price of one siacoin
  18. type SiaPrice struct {
  19. Price float64 `json:"price"`
  20. }
  21. // GetSiaPrice gets the price of one siacoin
  22. func (p *PixelAPI) GetSiaPrice() (resp float64, err error) {
  23. var sp SiaPrice
  24. return sp.Price, p.jsonRequest("GET", "misc/sia_price", &sp)
  25. }