calendar_api_url_generator.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef GOOGLE_APIS_CALENDAR_CALENDAR_API_URL_GENERATOR_H_
  5. #define GOOGLE_APIS_CALENDAR_CALENDAR_API_URL_GENERATOR_H_
  6. #include <string>
  7. #include "base/time/time.h"
  8. #include "google_apis/gaia/gaia_urls.h"
  9. #include "third_party/abseil-cpp/absl/types/optional.h"
  10. #include "url/gurl.h"
  11. namespace google_apis {
  12. namespace calendar {
  13. // This class is used to generate URLs for communicating with calendar api
  14. // servers for production, and a local server for testing.
  15. class CalendarApiUrlGenerator {
  16. public:
  17. CalendarApiUrlGenerator();
  18. CalendarApiUrlGenerator(const CalendarApiUrlGenerator& src);
  19. CalendarApiUrlGenerator& operator=(const CalendarApiUrlGenerator& src);
  20. ~CalendarApiUrlGenerator();
  21. // Returns a URL to fetch a list of calendar events.
  22. // |start_time| Start time of the event window
  23. // |end_time| End time of the aforementioned window
  24. // |single_events| If true, expand recurring events into instances and only
  25. // return single one-off events and instances of recurring
  26. // events, but not the underlying recurring events
  27. // themselves
  28. // |max_attendees| The maximum number of attendees to include in the response.
  29. // If there are more than the specified number of attendees,
  30. // only the participant is returned. Optional.
  31. GURL GetCalendarEventListUrl(const base::Time& start_time,
  32. const base::Time& end_time,
  33. bool single_events,
  34. absl::optional<int> max_attendees) const;
  35. // Returns a URL to fetch a map of calendar color id to color code.
  36. GURL GetCalendarColorListUrl() const;
  37. // The base url can be set here. It defaults to the production base url.
  38. void SetBaseUrlForTesting(const std::string& url) { base_url_ = GURL(url); }
  39. private:
  40. GURL base_url_{GaiaUrls::GetInstance()->google_apis_origin_url()};
  41. };
  42. } // namespace calendar
  43. } // namespace google_apis
  44. #endif // GOOGLE_APIS_CALENDAR_CALENDAR_API_URL_GENERATOR_H_