Exemplo n.º 1
0
        public async Task <IEnumerable <EnergySiteProduct> > fetchProducts(TeslaAuthToken authToken)
        {
            UriBuilder uri = OwnerApiClientImpl.apiRoot
                             .WithPathSegment("products");

            try {
                HttpRequestMessage request = OwnerApiClientImpl.createRequest(HttpMethod.Get, uri, authToken);
                using HttpResponseMessage response = await httpClient.SendAsync(request);

                var products = await readContentAsJson <ProductsResponse>(response);

                return(products.response);
            } catch (HttpRequestException e) {
                throw new TeslaException("Failed to fetch site ID of the solar panels at the house", e);
            }
        }
        public async Task <HistoricalCalendarDataResponse> fetchHistoricalCalendarData(long siteId,
                                                                                       LocalDate dayInDesiredMonth, DateTimeZone reportTimeZone, TeslaAuthToken authToken)
        {
            ZonedDateTime endOfMonth = getEndOfMonth(dayInDesiredMonth, reportTimeZone);
            UriBuilder    uri        = OwnerApiClientImpl.apiRoot
                                       .WithPathSegment("energy_sites")
                                       .WithPathSegment(siteId.ToString())
                                       .WithPathSegment("calendar_history")
                                       .WithParameter("kind", "energy")
                                       .WithParameter("period", "month")
                                       .WithParameter("end_date", ISO_8601_DATETIME_MILLIS_ZONE.Format(endOfMonth));

            try {
                HttpRequestMessage request = OwnerApiClientImpl.createRequest(HttpMethod.Get, uri, authToken);
                using HttpResponseMessage response = await httpClient.SendAsync(request);

                var historicalCalendarData = await readContentAsJson <HistoricalCalendarData>(response);

                return(historicalCalendarData.response);
            } catch (HttpRequestException e) {
                throw new TeslaException($"Failed to get historical solar calendar data for the month ending on {endOfMonth}", e);
            }
        }
Exemplo n.º 3
0
 public ProductClientImpl(OwnerApiClientImpl client) : base(client.apiClient)
 {
 }
Exemplo n.º 4
0
 public OwnerApiAuthenticationClientImpl(OwnerApiClientImpl client) : base(client.apiClient)
 {
 }
 public EnergySiteClientImpl(OwnerApiClientImpl client) : base(client.apiClient)
 {
 }