GithubClient.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <Arduino.h>
  2. #include <WiFiClientSecure.h>
  3. #ifndef _GITHUB_CLIENT
  4. #define _GITHUB_CLIENT
  5. #define GITHUB_CLIENT_BUFFER_SIZE 32
  6. // #define GITHUB_RAW_FINGERPRINT "CC AA 48 48 66 46 0E 91 53 2C 9C 7C 23 2A B1 74 4D 29 9D 33"
  7. #define GITHUB_RAW_DOMAIN "raw.githubusercontent.com"
  8. // #define GITHUB_API_FINGERPRINT "35 85 74 EF 67 35 A7 CE 40 69 50 F3 C0 F6 80 CF 80 3B 2E 19"
  9. #define GITHUB_API_DOMAIN "api.github.com"
  10. class GithubClient {
  11. public:
  12. GithubClient(const char* domain)
  13. : domain(String(domain))
  14. { }
  15. Stream& stream(const String& path);
  16. bool download(const String& path, Stream& dest);
  17. bool download(const String& path, const String& fsPath);
  18. static GithubClient rawDownloader();
  19. static GithubClient apiClient();
  20. static String buildRepoPath(const String& username, const String& repo, const String& path);
  21. static String buildApiRequest(const String& username, const String& repo, const String& path);
  22. uint8_t buffer[GITHUB_CLIENT_BUFFER_SIZE];
  23. private:
  24. WiFiClientSecure client;
  25. const String domain;
  26. };
  27. #endif