@maxim_mazurok/gapi.client.travelimpactmodel-v1 0.0.20230104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts ADDED
@@ -0,0 +1,153 @@
1
+ /* Type definitions for non-npm package Travel Impact Model API v1 0.0 */
2
+ // Project: https://developers.google.com/travel/impact-model
3
+ // Definitions by: Maxim Mazurok <https://github.com/Maxim-Mazurok>
4
+ // Nick Amoscato <https://github.com/namoscato>
5
+ // Declan Vong <https://github.com/declanvong>
6
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7
+
8
+ // IMPORTANT
9
+ // This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
10
+ // In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
11
+ // Generated from: https://travelimpactmodel.googleapis.com/$discovery/rest?version=v1
12
+ // Revision: 20230104
13
+
14
+ /// <reference types="gapi.client" />
15
+
16
+ declare namespace gapi.client {
17
+ /** Load Travel Impact Model API v1 */
18
+ function load(urlOrObject: "https://travelimpactmodel.googleapis.com/$discovery/rest?version=v1"): Promise<void>;
19
+ /** @deprecated Please load APIs with discovery documents. */
20
+ function load(name: "travelimpactmodel", version: "v1"): Promise<void>;
21
+ /** @deprecated Please load APIs with discovery documents. */
22
+ function load(name: "travelimpactmodel", version: "v1", callback: () => any): void;
23
+
24
+ namespace travelimpactmodel {
25
+ interface ComputeFlightEmissionsRequest {
26
+ /** Required. Direct flights to return emission estimates for. */
27
+ flights?: Flight[];
28
+ }
29
+ interface ComputeFlightEmissionsResponse {
30
+ /** List of flight legs with emission estimates. */
31
+ flightEmissions?: FlightWithEmissions[];
32
+ /** The model version under which emission estimates for all flights in this response were computed. */
33
+ modelVersion?: ModelVersion;
34
+ }
35
+ interface Date {
36
+ /** Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant. */
37
+ day?: number;
38
+ /** Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day. */
39
+ month?: number;
40
+ /** Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year. */
41
+ year?: number;
42
+ }
43
+ interface EmissionsGramsPerPax {
44
+ /** Emissions for one passenger in business class in grams. This field is always computed and populated, regardless of whether the aircraft has business class seats or not. */
45
+ business?: number;
46
+ /** Emissions for one passenger in economy class in grams. This field is always computed and populated, regardless of whether the aircraft has economy class seats or not. */
47
+ economy?: number;
48
+ /** Emissions for one passenger in first class in grams. This field is always computed and populated, regardless of whether the aircraft has first class seats or not. */
49
+ first?: number;
50
+ /**
51
+ * Emissions for one passenger in premium economy class in grams. This field is always computed and populated, regardless of whether the aircraft has premium economy class seats or
52
+ * not.
53
+ */
54
+ premiumEconomy?: number;
55
+ }
56
+ interface Flight {
57
+ /** Required. Date of the flight in the time zone of the origin airport. Must be a date in the present or future. */
58
+ departureDate?: Date;
59
+ /** Required. IATA airport code for flight destination, e.g. "JFK". */
60
+ destination?: string;
61
+ /** Required. Flight number, e.g. 324. */
62
+ flightNumber?: number;
63
+ /** Required. IATA carrier code, e.g. "AA". */
64
+ operatingCarrierCode?: string;
65
+ /** Required. IATA airport code for flight origin, e.g. "LHR". */
66
+ origin?: string;
67
+ }
68
+ interface FlightWithEmissions {
69
+ /**
70
+ * Optional. Per-passenger emission estimate numbers. Will not be present if emissions could not be computed. For the list of reasons why emissions could not be computed, see
71
+ * ComputeFlightEmissions.
72
+ */
73
+ emissionsGramsPerPax?: EmissionsGramsPerPax;
74
+ /** Required. Matches the flight identifiers in the request. Note: all IATA codes are capitalized. */
75
+ flight?: Flight;
76
+ }
77
+ interface ModelVersion {
78
+ /** Dated versions: Model datasets are recreated with refreshed input data but no change to the algorithms regularly. */
79
+ dated?: string;
80
+ /**
81
+ * Major versions: Major changes to methodology (e.g. adding new data sources to the model that lead to major output changes). Such changes will be infrequent and announced well in
82
+ * advance. Might involve API version changes, which will respect guidelines in https://cloud.google.com/endpoints/docs/openapi/versioning-an-api#backwards-incompatible
83
+ */
84
+ major?: number;
85
+ /** Minor versions: Changes to the model that, while being consistent across schema versions, change the model parameters or implementation. */
86
+ minor?: number;
87
+ /** Patch versions: Implementation changes meant to address bugs or inaccuracies in the model implementation. */
88
+ patch?: number;
89
+ }
90
+ interface FlightsResource {
91
+ /**
92
+ * Stateless method to retrieve emission estimates. Details on how emission estimates are computed: https://github.com/google/travel-impact-model The response will contain all entries
93
+ * that match the input flight legs, in the same order. If there are no estimates available for a certain flight leg, the response will return the flight leg object with empty emission
94
+ * fields. The request will still be considered successful. Reasons for missing emission estimates include: - The flight is unknown to the server. - The input flight leg is missing one
95
+ * or more identifiers. - The flight date is in the past. - The aircraft type is not supported by the model. - Missing seat configuration. The request can contain up to 1000 flight
96
+ * legs. If the request has more than 1000 direct flights, if will fail with an INVALID_ARGUMENT error.
97
+ */
98
+ computeFlightEmissions(request: {
99
+ /** V1 error format. */
100
+ "$.xgafv"?: string;
101
+ /** OAuth access token. */
102
+ access_token?: string;
103
+ /** Data format for response. */
104
+ alt?: string;
105
+ /** JSONP */
106
+ callback?: string;
107
+ /** Selector specifying which fields to include in a partial response. */
108
+ fields?: string;
109
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
110
+ key?: string;
111
+ /** OAuth 2.0 token for the current user. */
112
+ oauth_token?: string;
113
+ /** Returns response with indentations and line breaks. */
114
+ prettyPrint?: boolean;
115
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
116
+ quotaUser?: string;
117
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
118
+ upload_protocol?: string;
119
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
120
+ uploadType?: string;
121
+ /** Request body */
122
+ resource: ComputeFlightEmissionsRequest;
123
+ }): Request<ComputeFlightEmissionsResponse>;
124
+ computeFlightEmissions(request: {
125
+ /** V1 error format. */
126
+ "$.xgafv"?: string;
127
+ /** OAuth access token. */
128
+ access_token?: string;
129
+ /** Data format for response. */
130
+ alt?: string;
131
+ /** JSONP */
132
+ callback?: string;
133
+ /** Selector specifying which fields to include in a partial response. */
134
+ fields?: string;
135
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
136
+ key?: string;
137
+ /** OAuth 2.0 token for the current user. */
138
+ oauth_token?: string;
139
+ /** Returns response with indentations and line breaks. */
140
+ prettyPrint?: boolean;
141
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
142
+ quotaUser?: string;
143
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
144
+ upload_protocol?: string;
145
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
146
+ uploadType?: string;
147
+ },
148
+ body: ComputeFlightEmissionsRequest): Request<ComputeFlightEmissionsResponse>;
149
+ }
150
+
151
+ const flights: FlightsResource;
152
+ }
153
+ }
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@maxim_mazurok/gapi.client.travelimpactmodel-v1",
3
+ "version": "0.0.20230104",
4
+ "description": "TypeScript typings for Travel Impact Model API v1",
5
+ "license": "MIT",
6
+ "author": {
7
+ "email": "maxim@mazurok.com",
8
+ "name": "Maxim Mazurok",
9
+ "url": "https://maxim.mazurok.com"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
14
+ },
15
+ "types": "index.d.ts",
16
+ "dependencies": {
17
+ "@types/gapi.client": "*",
18
+ "@types/gapi.client.discovery": "*"
19
+ }
20
+ }
package/readme.md ADDED
@@ -0,0 +1,52 @@
1
+ # TypeScript typings for Travel Impact Model API v1
2
+
3
+ Travel Impact Model API lets you query travel carbon emission estimates.
4
+ For detailed description please check [documentation](https://developers.google.com/travel/impact-model).
5
+
6
+ ## Installing
7
+
8
+ Install typings for Travel Impact Model API:
9
+
10
+ ```
11
+ npm install @types/gapi.client.travelimpactmodel-v1 --save-dev
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ You need to initialize Google API client in your code:
17
+
18
+ ```typescript
19
+ gapi.load('client', () => {
20
+ // now we can use gapi.client
21
+ // ...
22
+ });
23
+ ```
24
+
25
+ Then load api client wrapper:
26
+
27
+ ```typescript
28
+ gapi.client.load('https://travelimpactmodel.googleapis.com/$discovery/rest?version=v1', () => {
29
+ // now we can use:
30
+ // gapi.client.travelimpactmodel
31
+ });
32
+ ```
33
+
34
+ ```typescript
35
+ // Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
36
+ gapi.client.load('travelimpactmodel', 'v1', () => {
37
+ // now we can use:
38
+ // gapi.client.travelimpactmodel
39
+ });
40
+ ```
41
+
42
+
43
+
44
+ After that you can use Travel Impact Model API resources: <!-- TODO: make this work for multiple namespaces -->
45
+
46
+ ```typescript
47
+
48
+ /*
49
+ Stateless method to retrieve emission estimates. Details on how emission estimates are computed: https://github.com/google/travel-impact-model The response will contain all entries that match the input flight legs, in the same order. If there are no estimates available for a certain flight leg, the response will return the flight leg object with empty emission fields. The request will still be considered successful. Reasons for missing emission estimates include: - The flight is unknown to the server. - The input flight leg is missing one or more identifiers. - The flight date is in the past. - The aircraft type is not supported by the model. - Missing seat configuration. The request can contain up to 1000 flight legs. If the request has more than 1000 direct flights, if will fail with an INVALID_ARGUMENT error.
50
+ */
51
+ await gapi.client.travelimpactmodel.flights.computeFlightEmissions({ });
52
+ ```
package/tests.ts ADDED
@@ -0,0 +1,41 @@
1
+ /* This is stub file for gapi.client.travelimpactmodel-v1 definition tests */
2
+ // IMPORTANT
3
+ // This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
4
+ // In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
5
+
6
+ // Revision: 20230104
7
+
8
+ gapi.load('client', async () => {
9
+ /** now we can use gapi.client */
10
+
11
+ await gapi.client.load('https://travelimpactmodel.googleapis.com/$discovery/rest?version=v1');
12
+ /** now we can use gapi.client.travelimpactmodel */
13
+
14
+ run();
15
+
16
+ async function run() {
17
+ /**
18
+ * Stateless method to retrieve emission estimates. Details on how emission estimates are computed: https://github.com/google/travel-impact-model The response will contain all entries that
19
+ * match the input flight legs, in the same order. If there are no estimates available for a certain flight leg, the response will return the flight leg object with empty emission fields.
20
+ * The request will still be considered successful. Reasons for missing emission estimates include: - The flight is unknown to the server. - The input flight leg is missing one or more
21
+ * identifiers. - The flight date is in the past. - The aircraft type is not supported by the model. - Missing seat configuration. The request can contain up to 1000 flight legs. If the
22
+ * request has more than 1000 direct flights, if will fail with an INVALID_ARGUMENT error.
23
+ */
24
+ await gapi.client.travelimpactmodel.flights.computeFlightEmissions({
25
+ }, {
26
+ flights: [
27
+ {
28
+ departureDate: {
29
+ day: 42,
30
+ month: 42,
31
+ year: 42,
32
+ },
33
+ destination: "Test string",
34
+ flightNumber: 42,
35
+ operatingCarrierCode: "Test string",
36
+ origin: "Test string",
37
+ }
38
+ ],
39
+ });
40
+ }
41
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "lib": ["es6", "dom"],
5
+ "noImplicitAny": true,
6
+ "noImplicitThis": true,
7
+ "strictNullChecks": true,
8
+ "baseUrl": "../",
9
+ "typeRoots": [
10
+ "../"
11
+ ],
12
+ "types": [],
13
+ "noEmit": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "strictFunctionTypes": true
16
+ },
17
+ "files": ["index.d.ts", "tests.ts"]
18
+ }
package/tslint.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "dtslint/dtslint.json",
3
+ "rules": {
4
+ "no-redundant-jsdoc": false
5
+ }
6
+ }