Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apple-maps-server-sdk

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apple-maps-server-sdk - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

src/inputs.d.ts

14

lib/index.d.ts

@@ -1,1 +0,13 @@

export declare const Greeter: (name: string) => string;
import { AxiosInstance } from "axios";
declare class AppleMaps {
accessToken: string;
authorizationToken: string;
apiClient: AxiosInstance;
constructor(authorizationToken: string);
getAccessToken(): Promise<undefined>;
geocode(input: GeocodeInput): Promise<GeocodeResponse>;
reverseGeocode(input: ReverseGeocodeInput): Promise<ReverseGeocodeResponse>;
eta(input: ETAInput): Promise<ETAResponse>;
search(input: SearchInput): Promise<SearchResponse>;
}
export default AppleMaps;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Greeter = void 0;
var Greeter = function (name) { return "Hello ".concat(name); };
exports.Greeter = Greeter;
const axios_1 = __importStar(require("axios"));
const qs_1 = __importDefault(require("qs"));
class AppleMaps {
constructor(authorizationToken) {
this.accessToken = "";
this.authorizationToken = authorizationToken;
this.apiClient = axios_1.default.create({
baseURL: "https://maps-api.apple.com/v1",
});
}
getAccessToken() {
return __awaiter(this, void 0, void 0, function* () {
try {
const response = yield this.apiClient.get("/token", {
headers: {
Authorization: `Bearer ${this.authorizationToken}`,
},
});
this.accessToken = response.data.accessToken;
}
catch (error) {
console.error(error);
}
return;
});
}
geocode(input) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const params = qs_1.default.stringify(input);
try {
const response = yield this.apiClient.get("/geocode", {
headers: {
Authorization: `Bearer ${this.accessToken}`,
},
params,
});
return response.data;
}
catch (error) {
if (error instanceof axios_1.AxiosError) {
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
yield this.getAccessToken();
return this.geocode(input);
}
else {
throw error;
}
}
else
throw error;
}
});
}
reverseGeocode(input) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const params = qs_1.default.stringify(input);
try {
const response = yield this.apiClient.get("/reverseGeocode", {
headers: {
Authorization: `Bearer ${this.accessToken}`,
},
params,
});
return response.data;
}
catch (error) {
if (error instanceof axios_1.AxiosError) {
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
yield this.getAccessToken();
return this.reverseGeocode(input);
}
else {
throw error;
}
}
else
throw error;
}
});
}
eta(input) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const params = qs_1.default.stringify(input);
try {
const response = yield this.apiClient.get("/etas", {
headers: {
Authorization: `Bearer ${this.accessToken}`,
},
params,
});
return response.data;
}
catch (error) {
if (error instanceof axios_1.AxiosError) {
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
yield this.getAccessToken();
return this.eta(input);
}
else {
throw error;
}
}
else
throw error;
}
});
}
search(input) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const params = qs_1.default.stringify(input);
try {
const response = yield this.apiClient.get("/search", {
headers: {
Authorization: `Bearer ${this.accessToken}`,
},
params,
});
return response.data;
}
catch (error) {
if (error instanceof axios_1.AxiosError) {
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
yield this.getAccessToken();
return this.search(input);
}
else {
throw error;
}
}
else
throw error;
}
});
}
}
exports.default = AppleMaps;
{
"name": "apple-maps-server-sdk",
"version": "1.0.0",
"version": "1.0.1",
"description": "An SDK for the Apple Maps Server API",

@@ -24,4 +24,9 @@ "main": "lib/index.js",

"devDependencies": {
"@types/qs": "^6.9.7",
"typescript": "^4.9.4"
},
"dependencies": {
"axios": "^1.2.2",
"qs": "^6.11.0"
}
}

@@ -1,1 +0,130 @@

export const Greeter = (name: string) => `Hello ${name}`;
import axios, { AxiosError, AxiosInstance } from "axios";
import qs from "qs";
class AppleMaps {
accessToken: string;
authorizationToken: string;
apiClient: AxiosInstance;
constructor(authorizationToken: string) {
this.accessToken = "";
this.authorizationToken = authorizationToken;
this.apiClient = axios.create({
baseURL: "https://maps-api.apple.com/v1",
});
}
async getAccessToken(): Promise<undefined> {
try {
const response = await this.apiClient.get("/token", {
headers: {
Authorization: `Bearer ${this.authorizationToken}`,
},
});
this.accessToken = response.data.accessToken;
} catch (error) {
console.error(error);
}
return;
}
async geocode(input: GeocodeInput): Promise<GeocodeResponse> {
const params = qs.stringify(input);
try {
const response = await this.apiClient.get("/geocode", {
headers: {
Authorization: `Bearer ${this.accessToken}`,
},
params,
});
return response.data;
} catch (error) {
if (error instanceof AxiosError) {
if (error.response?.status === 401) {
await this.getAccessToken();
return this.geocode(input);
} else {
throw error;
}
} else throw error;
}
}
async reverseGeocode(input: ReverseGeocodeInput): Promise<ReverseGeocodeResponse> {
const params = qs.stringify(input);
try {
const response = await this.apiClient.get("/reverseGeocode", {
headers: {
Authorization: `Bearer ${this.accessToken}`,
},
params,
});
return response.data;
} catch (error) {
if (error instanceof AxiosError) {
if (error.response?.status === 401) {
await this.getAccessToken();
return this.reverseGeocode(input);
} else {
throw error;
}
} else throw error;
}
}
async eta(input: ETAInput): Promise<ETAResponse> {
const params = qs.stringify(input);
try {
const response = await this.apiClient.get("/etas", {
headers: {
Authorization: `Bearer ${this.accessToken}`,
},
params,
});
return response.data;
} catch (error) {
if (error instanceof AxiosError) {
if (error.response?.status === 401) {
await this.getAccessToken();
return this.eta(input);
} else {
throw error;
}
} else throw error;
}
}
async search(input: SearchInput): Promise<SearchResponse> {
const params = qs.stringify(input);
try {
const response = await this.apiClient.get("/search", {
headers: {
Authorization: `Bearer ${this.accessToken}`,
},
params,
});
return response.data;
} catch (error) {
if (error instanceof AxiosError) {
if (error.response?.status === 401) {
await this.getAccessToken();
return this.search(input);
} else {
throw error;
}
} else throw error;
}
}
}
export default AppleMaps;

6

tsconfig.json
{
"compilerOptions": {
"target": "es5",
"target": "ES6",
"module": "commonjs",
"declaration": true,
"outDir": "./lib",
"strict": true
"strict": true,
"esModuleInterop": true,
},

@@ -9,0 +11,0 @@ "include": ["src"],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc