@maxim_mazurok/gapi.client.areainsights-v1 0.0.20241211
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 +164 -0
- package/package.json +20 -0
- package/readme.md +76 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/* Type definitions for non-npm package Places Insights API v1 0.0 */
|
|
2
|
+
// Project: https://g3doc.corp.google.com/geo/platform/area_insights/README.md?cl=head
|
|
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://areainsights.googleapis.com/$discovery/rest?version=v1
|
|
12
|
+
// Revision: 20241211
|
|
13
|
+
|
|
14
|
+
/// <reference types="gapi.client" />
|
|
15
|
+
|
|
16
|
+
declare namespace gapi.client {
|
|
17
|
+
/** Load Places Insights API v1 */
|
|
18
|
+
function load(
|
|
19
|
+
urlOrObject: 'https://areainsights.googleapis.com/$discovery/rest?version=v1'
|
|
20
|
+
): Promise<void>;
|
|
21
|
+
/** @deprecated Please load APIs with discovery documents. */
|
|
22
|
+
function load(name: 'areainsights', version: 'v1'): Promise<void>;
|
|
23
|
+
/** @deprecated Please load APIs with discovery documents. */
|
|
24
|
+
function load(name: 'areainsights', version: 'v1', callback: () => any): void;
|
|
25
|
+
|
|
26
|
+
namespace areainsights {
|
|
27
|
+
interface Circle {
|
|
28
|
+
/** The latitude and longitude of the center of the circle. */
|
|
29
|
+
latLng?: LatLng;
|
|
30
|
+
/** The Place resource name of the center of the circle. Only point places are supported. */
|
|
31
|
+
place?: string;
|
|
32
|
+
/** Optional. The radius of the circle in meters */
|
|
33
|
+
radius?: number;
|
|
34
|
+
}
|
|
35
|
+
interface ComputeInsightsRequest {
|
|
36
|
+
/** Required. Insight filter. */
|
|
37
|
+
filter?: Filter;
|
|
38
|
+
/** Required. Insights to compute. Currently only INSIGHT_COUNT and INSIGHT_PLACES are supported. */
|
|
39
|
+
insights?: string[];
|
|
40
|
+
}
|
|
41
|
+
interface ComputeInsightsResponse {
|
|
42
|
+
/** Result for Insights.INSIGHT_COUNT. */
|
|
43
|
+
count?: string;
|
|
44
|
+
/** Result for Insights.INSIGHT_PLACES. */
|
|
45
|
+
placeInsights?: PlaceInsight[];
|
|
46
|
+
}
|
|
47
|
+
interface CustomArea {
|
|
48
|
+
/** Required. The custom area represented as a polygon */
|
|
49
|
+
polygon?: Polygon;
|
|
50
|
+
}
|
|
51
|
+
interface Filter {
|
|
52
|
+
/** Required. Restricts results to places which are located in the area specified by location filters. */
|
|
53
|
+
locationFilter?: LocationFilter;
|
|
54
|
+
/** Optional. Restricts results to places whose operating status is included on this list. If operating_status is not set, OPERATING_STATUS_OPERATIONAL is used as default. */
|
|
55
|
+
operatingStatus?: string[];
|
|
56
|
+
/** Optional. Restricts results to places whose price level is included on this list. If price_level is not set, all price levels are included in the results. */
|
|
57
|
+
priceLevels?: string[];
|
|
58
|
+
/** Optional. Restricts results to places whose average user ratings are in the range specified by rating_filter. If rating_filter is not set, all ratings are included in the result. */
|
|
59
|
+
ratingFilter?: RatingFilter;
|
|
60
|
+
/** Required. Place type filters. */
|
|
61
|
+
typeFilter?: TypeFilter;
|
|
62
|
+
}
|
|
63
|
+
interface LatLng {
|
|
64
|
+
/** The latitude in degrees. It must be in the range [-90.0, +90.0]. */
|
|
65
|
+
latitude?: number;
|
|
66
|
+
/** The longitude in degrees. It must be in the range [-180.0, +180.0]. */
|
|
67
|
+
longitude?: number;
|
|
68
|
+
}
|
|
69
|
+
interface LocationFilter {
|
|
70
|
+
/** Area as a circle. */
|
|
71
|
+
circle?: Circle;
|
|
72
|
+
/** Custom area specified by a polygon. */
|
|
73
|
+
customArea?: CustomArea;
|
|
74
|
+
/** Area as region. */
|
|
75
|
+
region?: Region;
|
|
76
|
+
}
|
|
77
|
+
interface PlaceInsight {
|
|
78
|
+
/** The unique identifier of the place. This resource name can be used to retrieve details about the place using the [Places API](https://developers.google.com/maps/documentation/places/web-service/reference/rest/v1/places/get). */
|
|
79
|
+
place?: string;
|
|
80
|
+
}
|
|
81
|
+
interface Polygon {
|
|
82
|
+
/** Optional. The coordinates that define the polygon. */
|
|
83
|
+
coordinates?: LatLng[];
|
|
84
|
+
}
|
|
85
|
+
interface RatingFilter {
|
|
86
|
+
/** Optional. Restricts results to places whose average user rating is strictly less than or equal to max_rating. Values must be between 1.0 and 5.0. */
|
|
87
|
+
maxRating?: number;
|
|
88
|
+
/** Optional. Restricts results to places whose average user rating is greater than or equal to min_rating. Values must be between 1.0 and 5.0. */
|
|
89
|
+
minRating?: number;
|
|
90
|
+
}
|
|
91
|
+
interface Region {
|
|
92
|
+
/** The unique identifier of a specific geographic region. */
|
|
93
|
+
place?: string;
|
|
94
|
+
}
|
|
95
|
+
interface TypeFilter {
|
|
96
|
+
/** Optional. Excluded primary Place types. */
|
|
97
|
+
excludedPrimaryTypes?: string[];
|
|
98
|
+
/** Optional. Excluded Place types. */
|
|
99
|
+
excludedTypes?: string[];
|
|
100
|
+
/** Optional. Included primary Place types. */
|
|
101
|
+
includedPrimaryTypes?: string[];
|
|
102
|
+
/** Optional. Included Place types. */
|
|
103
|
+
includedTypes?: string[];
|
|
104
|
+
}
|
|
105
|
+
interface V1Resource {
|
|
106
|
+
/** Compute Insights RPC This method lets you retrieve insights about areas using a variaty of filter such as: area, place type, operating status, price level and ratings. Currently "count" and "places" insights are supported. With "count" insights you can answer questions such as "How many restaurant are located in California that are operational, are inexpensive and have an average rating of at least 4 stars" (see `insight` enum for more details). With "places" insights, you can determine which places match the requested filter. Clients can then use those place resource names to fetch more details about each individual place using the Places API. */
|
|
107
|
+
computeInsights(request: {
|
|
108
|
+
/** V1 error format. */
|
|
109
|
+
'$.xgafv'?: string;
|
|
110
|
+
/** OAuth access token. */
|
|
111
|
+
access_token?: string;
|
|
112
|
+
/** Data format for response. */
|
|
113
|
+
alt?: string;
|
|
114
|
+
/** JSONP */
|
|
115
|
+
callback?: string;
|
|
116
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
117
|
+
fields?: string;
|
|
118
|
+
/** 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. */
|
|
119
|
+
key?: string;
|
|
120
|
+
/** OAuth 2.0 token for the current user. */
|
|
121
|
+
oauth_token?: string;
|
|
122
|
+
/** Returns response with indentations and line breaks. */
|
|
123
|
+
prettyPrint?: boolean;
|
|
124
|
+
/** 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. */
|
|
125
|
+
quotaUser?: string;
|
|
126
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
127
|
+
upload_protocol?: string;
|
|
128
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
129
|
+
uploadType?: string;
|
|
130
|
+
/** Request body */
|
|
131
|
+
resource: ComputeInsightsRequest;
|
|
132
|
+
}): Request<ComputeInsightsResponse>;
|
|
133
|
+
computeInsights(
|
|
134
|
+
request: {
|
|
135
|
+
/** V1 error format. */
|
|
136
|
+
'$.xgafv'?: string;
|
|
137
|
+
/** OAuth access token. */
|
|
138
|
+
access_token?: string;
|
|
139
|
+
/** Data format for response. */
|
|
140
|
+
alt?: string;
|
|
141
|
+
/** JSONP */
|
|
142
|
+
callback?: string;
|
|
143
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
144
|
+
fields?: string;
|
|
145
|
+
/** 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. */
|
|
146
|
+
key?: string;
|
|
147
|
+
/** OAuth 2.0 token for the current user. */
|
|
148
|
+
oauth_token?: string;
|
|
149
|
+
/** Returns response with indentations and line breaks. */
|
|
150
|
+
prettyPrint?: boolean;
|
|
151
|
+
/** 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. */
|
|
152
|
+
quotaUser?: string;
|
|
153
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
154
|
+
upload_protocol?: string;
|
|
155
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
156
|
+
uploadType?: string;
|
|
157
|
+
},
|
|
158
|
+
body: ComputeInsightsRequest
|
|
159
|
+
): Request<ComputeInsightsResponse>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const v1: V1Resource;
|
|
163
|
+
}
|
|
164
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maxim_mazurok/gapi.client.areainsights-v1",
|
|
3
|
+
"version": "0.0.20241211",
|
|
4
|
+
"description": "TypeScript typings for Places Insights API v1",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Maxim Mazurok",
|
|
12
|
+
"email": "maxim@mazurok.com",
|
|
13
|
+
"url": "https://maxim.mazurok.com"
|
|
14
|
+
},
|
|
15
|
+
"types": "index.d.ts",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@types/gapi.client": "*",
|
|
18
|
+
"@types/gapi.client.discovery-v1": "*"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# TypeScript typings for Places Insights API v1
|
|
2
|
+
|
|
3
|
+
Places Insights API.
|
|
4
|
+
For detailed description please check [documentation](https://g3doc.corp.google.com/geo/platform/area_insights/README.md?cl=head).
|
|
5
|
+
|
|
6
|
+
## Installing
|
|
7
|
+
|
|
8
|
+
Install typings for Places Insights API:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
npm install @types/gapi.client.areainsights-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(
|
|
29
|
+
'https://areainsights.googleapis.com/$discovery/rest?version=v1',
|
|
30
|
+
() => {
|
|
31
|
+
// now we can use:
|
|
32
|
+
// gapi.client.areainsights
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
|
|
39
|
+
gapi.client.load('areainsights', 'v1', () => {
|
|
40
|
+
// now we can use:
|
|
41
|
+
// gapi.client.areainsights
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Don't forget to authenticate your client before sending any request to resources:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
// declare client_id registered in Google Developers Console
|
|
49
|
+
var client_id = '',
|
|
50
|
+
scope = [
|
|
51
|
+
// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
|
|
52
|
+
'https://www.googleapis.com/auth/cloud-platform',
|
|
53
|
+
],
|
|
54
|
+
immediate = true;
|
|
55
|
+
// ...
|
|
56
|
+
|
|
57
|
+
gapi.auth.authorize(
|
|
58
|
+
{client_id: client_id, scope: scope, immediate: immediate},
|
|
59
|
+
authResult => {
|
|
60
|
+
if (authResult && !authResult.error) {
|
|
61
|
+
/* handle successful authorization */
|
|
62
|
+
} else {
|
|
63
|
+
/* handle authorization error */
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
After that you can use Places Insights API resources: <!-- TODO: make this work for multiple namespaces -->
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
/*
|
|
73
|
+
Compute Insights RPC This method lets you retrieve insights about areas using a variaty of filter such as: area, place type, operating status, price level and ratings. Currently "count" and "places" insights are supported. With "count" insights you can answer questions such as "How many restaurant are located in California that are operational, are inexpensive and have an average rating of at least 4 stars" (see `insight` enum for more details). With "places" insights, you can determine which places match the requested filter. Clients can then use those place resource names to fetch more details about each individual place using the Places API.
|
|
74
|
+
*/
|
|
75
|
+
await gapi.client.areainsights.computeInsights({});
|
|
76
|
+
```
|