-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
226a3a1
commit 08ac176
Showing
54 changed files
with
2,750 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ApiCallGenerator, ApiConfig, ApiCallGeneratorConfig, ApiCallOptions } from './api.types'; | ||
export default class Api { | ||
readonly key: string; | ||
static readonly defaultOrigin = "https://monitoringapi.solaredge.com"; | ||
static readonly dateFormat = "yyyy-MM-dd"; | ||
static readonly dateTimeFormat = "yyyy-MM-dd HH:mm:ss"; | ||
static isValidApiKey(key: string): boolean; | ||
static serializeDate(date: Date): string; | ||
static serializeDateTime(date: Date): string; | ||
private static parseDateOrTimeRange; | ||
private static serializeRange; | ||
readonly config: Readonly<ApiConfig>; | ||
constructor(key: string, config?: Partial<ApiConfig>); | ||
call<T>(path: string, options?: Partial<ApiCallOptions>): Promise<T>; | ||
callGenerator<T>(config: ApiCallGeneratorConfig<T>): ApiCallGenerator<T>; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
export interface ApiConfig { | ||
/** | ||
* URL origin of the API without a trailing slash. | ||
* @default https://monitoringapi.solaredge.com | ||
*/ | ||
origin: string; | ||
} | ||
export interface DateRange { | ||
dateRange: [Date, Date]; | ||
} | ||
export interface DateRangeParams { | ||
startDate: Date; | ||
endDate: Date; | ||
} | ||
export interface DateTimeRange { | ||
timeRange: [Date, Date]; | ||
} | ||
export interface DateTimeRangeParams { | ||
startTime: Date; | ||
endTime: Date; | ||
} | ||
export declare type DateOrTimeRange = DateRange | DateTimeRange; | ||
export declare type DateOrTimeRangeParams = DateRangeParams | DateTimeRangeParams; | ||
export interface TimeUnitParam { | ||
timeUnit: TimeUnit; | ||
} | ||
export declare type Serialized<T> = T extends Date ? string : T extends object ? { | ||
[k in keyof T]: Serialized<T[k]>; | ||
} : T; | ||
export declare const enum TimeUnit { | ||
QuarterHour = "QUARTER_OF_AN_HOUR", | ||
Hour = "HOUR", | ||
Day = "DAY", | ||
Week = "WEEK", | ||
Month = "MONTH", | ||
Year = "YEAR" | ||
} | ||
export declare const enum SortOrder { | ||
Ascending = "ASC", | ||
Descending = "DESC" | ||
} | ||
export declare const enum SiteStatus { | ||
Active = "Active", | ||
Pending = "Pending", | ||
Disabled = "Disabled", | ||
All = "All" | ||
} | ||
export declare const enum Meter { | ||
Production = "Production", | ||
Consumption = "Consumption", | ||
SelfConsumption = "SelfConsumption", | ||
FeedIn = "FeedIn", | ||
Purchased = "Purchased" | ||
} | ||
export interface ApiCallOptions { | ||
params: Record<string, any>; | ||
} | ||
export declare type ApiCallGeneratorConfig<T> = { | ||
apiPath: string; | ||
interval: Duration; | ||
timeUnit?: TimeUnit; | ||
/** Parses the API response into a collection to be iterated over. */ | ||
parser: (res: any) => T[]; | ||
} & DateOrTimeRange; | ||
/** | ||
* Generator that yields individual collection items, lazily calling the API to | ||
* fetch more. Returns number of API calls performed. | ||
*/ | ||
export declare type ApiCallGenerator<T> = AsyncGenerator<T, ApiCallGeneratorReturn, void>; | ||
export interface ApiCallGeneratorReturn { | ||
config: ApiCallGeneratorConfig<unknown>; | ||
apiCallTotal: number; | ||
recordTotal: number; | ||
} | ||
export interface Range { | ||
type: RangeType; | ||
start: Date; | ||
end: Date; | ||
} | ||
export declare enum RangeType { | ||
Date = 0, | ||
DateTime = 1 | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ApiCallGenerator, DateRange, DateTimeRange, TimeUnitParam } from '../api/api.types'; | ||
import { EquipmentChange, InverterTelemetry, SiteDataPeriod, SiteDetails, SiteEnvironmentalBenefits, SiteEquipmentList, SiteMeasurement, SitesParams, SolaredgeClientOptions } from './client.types'; | ||
export default class Client { | ||
private readonly api; | ||
constructor({ apiKey, apiOrigin }: SolaredgeClientOptions); | ||
/** | ||
* Returns a list of sites related to the given token, which is the account api key. | ||
* This API accepts parameters for convenient search, sort and pagination. | ||
*/ | ||
fetchSiteList(params?: SitesParams): Promise<SiteDetails[]>; | ||
fetchSiteDetails(siteId: string): Promise<SiteDetails>; | ||
/** | ||
* Return the energy production start and end dates of the site. | ||
*/ | ||
fetchSiteDataPeriod(siteId: string): Promise<SiteDataPeriod>; | ||
fetchSiteEnergyGenerator(siteId: string, options: DateRange & Partial<TimeUnitParam>): ApiCallGenerator<SiteMeasurement>; | ||
fetchSitePowerGenerator(siteId: string, options: DateTimeRange): ApiCallGenerator<SiteMeasurement>; | ||
fetchSiteCurrentPowerFlow(siteId: string): Promise<unknown>; | ||
fetchSiteStorageData(siteId: string): Promise<unknown>; | ||
fetchSiteEnvironmentalBenefits(siteId: string, metricUnits?: boolean): Promise<SiteEnvironmentalBenefits>; | ||
fetchSiteEquipmentList(siteId: string): Promise<SiteEquipmentList>; | ||
fetchSiteEquipmentChangeLog(siteId: string, equipmentId: string): Promise<EquipmentChange[]>; | ||
fetchInverterTelemetryGenerator(siteId: string, inverterId: string, options: DateTimeRange): ApiCallGenerator<InverterTelemetry>; | ||
private static measurementsResponseParser; | ||
} |
Oops, something went wrong.