apple-maps-server-sdk 1.0.3 → 1.0.5
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/lib/index.js +10 -18
- package/package.json +1 -1
- package/src/index.ts +7 -16
package/lib/index.js
CHANGED
|
@@ -31,12 +31,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
35
|
const axios_1 = __importStar(require("axios"));
|
|
39
|
-
const qs_1 = __importDefault(require("qs"));
|
|
40
36
|
class AppleMaps {
|
|
41
37
|
constructor({ authorizationToken }) {
|
|
42
38
|
this.accessToken = "";
|
|
@@ -68,13 +64,12 @@ class AppleMaps {
|
|
|
68
64
|
geocode(input) {
|
|
69
65
|
var _a;
|
|
70
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const params = qs_1.default.stringify(input);
|
|
72
67
|
try {
|
|
73
68
|
const response = yield this.apiClient.get("/geocode", {
|
|
74
69
|
headers: {
|
|
75
70
|
Authorization: `Bearer ${this.accessToken}`,
|
|
76
71
|
},
|
|
77
|
-
params,
|
|
72
|
+
params: input,
|
|
78
73
|
});
|
|
79
74
|
return response.data;
|
|
80
75
|
}
|
|
@@ -94,15 +89,14 @@ class AppleMaps {
|
|
|
94
89
|
});
|
|
95
90
|
}
|
|
96
91
|
reverseGeocode(input) {
|
|
97
|
-
var _a;
|
|
92
|
+
var _a, _b;
|
|
98
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
const params = qs_1.default.stringify(input);
|
|
100
94
|
try {
|
|
101
95
|
const response = yield this.apiClient.get("/reverseGeocode", {
|
|
102
96
|
headers: {
|
|
103
97
|
Authorization: `Bearer ${this.accessToken}`,
|
|
104
98
|
},
|
|
105
|
-
params,
|
|
99
|
+
params: input,
|
|
106
100
|
});
|
|
107
101
|
return response.data;
|
|
108
102
|
}
|
|
@@ -113,7 +107,7 @@ class AppleMaps {
|
|
|
113
107
|
return this.reverseGeocode(input);
|
|
114
108
|
}
|
|
115
109
|
else {
|
|
116
|
-
throw error;
|
|
110
|
+
throw (_b = error.response) === null || _b === void 0 ? void 0 : _b.data;
|
|
117
111
|
}
|
|
118
112
|
}
|
|
119
113
|
else
|
|
@@ -122,15 +116,14 @@ class AppleMaps {
|
|
|
122
116
|
});
|
|
123
117
|
}
|
|
124
118
|
eta(input) {
|
|
125
|
-
var _a;
|
|
119
|
+
var _a, _b;
|
|
126
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
const params = qs_1.default.stringify(input);
|
|
128
121
|
try {
|
|
129
122
|
const response = yield this.apiClient.get("/etas", {
|
|
130
123
|
headers: {
|
|
131
124
|
Authorization: `Bearer ${this.accessToken}`,
|
|
132
125
|
},
|
|
133
|
-
params,
|
|
126
|
+
params: input,
|
|
134
127
|
});
|
|
135
128
|
return response.data;
|
|
136
129
|
}
|
|
@@ -141,7 +134,7 @@ class AppleMaps {
|
|
|
141
134
|
return this.eta(input);
|
|
142
135
|
}
|
|
143
136
|
else {
|
|
144
|
-
throw error;
|
|
137
|
+
throw (_b = error.response) === null || _b === void 0 ? void 0 : _b.data;
|
|
145
138
|
}
|
|
146
139
|
}
|
|
147
140
|
else
|
|
@@ -150,15 +143,14 @@ class AppleMaps {
|
|
|
150
143
|
});
|
|
151
144
|
}
|
|
152
145
|
search(input) {
|
|
153
|
-
var _a;
|
|
146
|
+
var _a, _b;
|
|
154
147
|
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
-
const params = qs_1.default.stringify(input);
|
|
156
148
|
try {
|
|
157
149
|
const response = yield this.apiClient.get("/search", {
|
|
158
150
|
headers: {
|
|
159
151
|
Authorization: `Bearer ${this.accessToken}`,
|
|
160
152
|
},
|
|
161
|
-
params,
|
|
153
|
+
params: input,
|
|
162
154
|
});
|
|
163
155
|
return response.data;
|
|
164
156
|
}
|
|
@@ -169,7 +161,7 @@ class AppleMaps {
|
|
|
169
161
|
return this.search(input);
|
|
170
162
|
}
|
|
171
163
|
else {
|
|
172
|
-
throw error;
|
|
164
|
+
throw (_b = error.response) === null || _b === void 0 ? void 0 : _b.data;
|
|
173
165
|
}
|
|
174
166
|
}
|
|
175
167
|
else
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import axios, { AxiosError, AxiosInstance } from "axios";
|
|
2
|
-
import qs from "qs";
|
|
3
2
|
|
|
4
3
|
class AppleMaps {
|
|
5
4
|
accessToken: string;
|
|
@@ -38,14 +37,12 @@ class AppleMaps {
|
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
async geocode(input: GeocodeInput): Promise<GeocodeResponse> {
|
|
41
|
-
const params = qs.stringify(input);
|
|
42
|
-
|
|
43
40
|
try {
|
|
44
41
|
const response = await this.apiClient.get("/geocode", {
|
|
45
42
|
headers: {
|
|
46
43
|
Authorization: `Bearer ${this.accessToken}`,
|
|
47
44
|
},
|
|
48
|
-
params,
|
|
45
|
+
params: input,
|
|
49
46
|
});
|
|
50
47
|
|
|
51
48
|
return response.data;
|
|
@@ -62,14 +59,12 @@ class AppleMaps {
|
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
async reverseGeocode(input: ReverseGeocodeInput): Promise<ReverseGeocodeResponse> {
|
|
65
|
-
const params = qs.stringify(input);
|
|
66
|
-
|
|
67
62
|
try {
|
|
68
63
|
const response = await this.apiClient.get("/reverseGeocode", {
|
|
69
64
|
headers: {
|
|
70
65
|
Authorization: `Bearer ${this.accessToken}`,
|
|
71
66
|
},
|
|
72
|
-
params,
|
|
67
|
+
params: input,
|
|
73
68
|
});
|
|
74
69
|
|
|
75
70
|
return response.data;
|
|
@@ -79,21 +74,19 @@ class AppleMaps {
|
|
|
79
74
|
await this.getAccessToken();
|
|
80
75
|
return this.reverseGeocode(input);
|
|
81
76
|
} else {
|
|
82
|
-
throw error;
|
|
77
|
+
throw error.response?.data;
|
|
83
78
|
}
|
|
84
79
|
} else throw error;
|
|
85
80
|
}
|
|
86
81
|
}
|
|
87
82
|
|
|
88
83
|
async eta(input: ETAInput): Promise<ETAResponse> {
|
|
89
|
-
const params = qs.stringify(input);
|
|
90
|
-
|
|
91
84
|
try {
|
|
92
85
|
const response = await this.apiClient.get("/etas", {
|
|
93
86
|
headers: {
|
|
94
87
|
Authorization: `Bearer ${this.accessToken}`,
|
|
95
88
|
},
|
|
96
|
-
params,
|
|
89
|
+
params: input,
|
|
97
90
|
});
|
|
98
91
|
|
|
99
92
|
return response.data;
|
|
@@ -103,21 +96,19 @@ class AppleMaps {
|
|
|
103
96
|
await this.getAccessToken();
|
|
104
97
|
return this.eta(input);
|
|
105
98
|
} else {
|
|
106
|
-
throw error;
|
|
99
|
+
throw error.response?.data;
|
|
107
100
|
}
|
|
108
101
|
} else throw error;
|
|
109
102
|
}
|
|
110
103
|
}
|
|
111
104
|
|
|
112
105
|
async search(input: SearchInput): Promise<SearchResponse> {
|
|
113
|
-
const params = qs.stringify(input);
|
|
114
|
-
|
|
115
106
|
try {
|
|
116
107
|
const response = await this.apiClient.get("/search", {
|
|
117
108
|
headers: {
|
|
118
109
|
Authorization: `Bearer ${this.accessToken}`,
|
|
119
110
|
},
|
|
120
|
-
params,
|
|
111
|
+
params: input,
|
|
121
112
|
});
|
|
122
113
|
|
|
123
114
|
return response.data;
|
|
@@ -127,7 +118,7 @@ class AppleMaps {
|
|
|
127
118
|
await this.getAccessToken();
|
|
128
119
|
return this.search(input);
|
|
129
120
|
} else {
|
|
130
|
-
throw error;
|
|
121
|
+
throw error.response?.data;
|
|
131
122
|
}
|
|
132
123
|
} else throw error;
|
|
133
124
|
}
|