Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions components/geoapify/actions/get-ip-location/get-ip-location.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import geoapify from "../../geoapify.app.mjs";

export default {
key: "geoapify-get-ip-location",
name: "Get IP Location",
description: "Retrieves geographical coordinates for a given IP address. [See the documentation](https://apidocs.geoapify.com/docs/ip-geolocation/)",
version: "0.0.1",
type: "action",
props: {
geoapify,
ipAddress: {
type: "string",
label: "IP Address",
description: "The IP address to lookup",
optional: true,
},
},
async run({ $ }) {
const response = await this.geoapify.geolocateIP({
$,
params: {
ipAddress: this.ipAddress,
},
});
$.export("$summary", `Retrieved location for IP: ${response.ip}`);
return response;
},
};
70 changes: 70 additions & 0 deletions components/geoapify/actions/get-route/get-route.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import geoapify from "../../geoapify.app.mjs";

export default {
key: "geoapify-get-route",
name: "Get Route",
description: "Calculates a route between two sets of latitude and longitude points. [See the documentation](https://apidocs.geoapify.com/docs/routing/)",
version: "0.0.1",
type: "action",
props: {
geoapify,
fromLatitude: {
type: "string",
label: "From Latitude",
description: "The latitude of the starting point",
},
fromLongitude: {
type: "string",
label: "From Longitude",
description: "The longitude of the starting point",
},
toLatitude: {
type: "string",
label: "To Latitude",
description: "The latitude of the destination point",
},
toLongitude: {
type: "string",
label: "To Longitude",
description: "The longitude of the destination point",
},
mode: {
propDefinition: [
geoapify,
"mode",
],
},
type: {
propDefinition: [
geoapify,
"routeOptimizationType",
],
},
units: {
propDefinition: [
geoapify,
"units",
],
},
format: {
propDefinition: [
geoapify,
"format",
],
},
},
async run({ $ }) {
const route = await this.geoapify.calculateRoute({
$,
params: {
waypoints: `${this.fromLatitude},${this.fromLongitude}|${this.toLatitude},${this.toLongitude}`,
mode: this.mode,
type: this.type,
units: this.units,
format: this.format,
},
});
$.export("$summary", "Route calculated successfully");
return route;
},
};
41 changes: 41 additions & 0 deletions components/geoapify/actions/search-address/search-address.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import geoapify from "../../geoapify.app.mjs";

export default {
key: "geoapify-search-address",
name: "Search Address",
description: "Retrieves geocoding information for a given address. [See the documentation](https://apidocs.geoapify.com/docs/geocoding/forward-geocoding/)",
version: "0.0.1",
type: "action",
props: {
geoapify,
address: {
type: "string",
label: "Address",
description: "The address to search. E.g. `44 Montgomery St., San Francisco, CA 94104`",
},
type: {
propDefinition: [
geoapify,
"locationType",
],
},
format: {
propDefinition: [
geoapify,
"format",
],
},
},
async run({ $ }) {
const response = await this.geoapify.geocodeAddress({
$,
params: {
text: this.address,
type: this.type,
format: this.format,
},
});
$.export("$summary", `Successfully retrieved geocoding information for address: ${this.address}`);
return response;
},
};
54 changes: 54 additions & 0 deletions components/geoapify/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const LOCATION_TYPES = [
"country",
"state",
"city",
"postcode",
"street",
"amenity",
"locality",
];

const FORMATS = [
"json",
"xml",
"geojson",
];

const TRANSPORTATION_MODES = [
"drive",
"light_truck",
"medium_truck",
"truck",
"heavy_truck",
"truck_dangerous_goods",
"long_truck",
"bus",
"scooter",
"motorcycle",
"bicycle",
"mountain_bike",
"road_bike",
"walk",
"hike",
"transit",
"approximated_transit",
];

const ROUTE_OPTIMIZATION_TYPES = [
"balanced",
"short",
"less_maneuvers",
];

const UNITS = [
"metric",
"imperial",
];

export default {
LOCATION_TYPES,
FORMATS,
TRANSPORTATION_MODES,
ROUTE_OPTIMIZATION_TYPES,
UNITS,
};
80 changes: 75 additions & 5 deletions components/geoapify/geoapify.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,81 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "geoapify",
propDefinitions: {},
propDefinitions: {
locationType: {
type: "string",
label: "Type",
description: "The location type. If set to `locality`, returns administrative areas including postcodes, districts, cities, counties, and states.",
options: constants.LOCATION_TYPES,
optional: true,
},
format: {
type: "string",
label: "Format",
description: "The format of the response, default value is `geojson`",
options: constants.FORMATS,
optional: true,
},
mode: {
type: "string",
label: "Mode",
description: "The mode of transportation",
options: constants.TRANSPORTATION_MODES,
},
routeOptimizationType: {
type: "string",
label: "Type",
description: "The route optimization type",
options: constants.ROUTE_OPTIMIZATION_TYPES,
optional: true,
},
units: {
type: "string",
label: "Units",
description: "Distance units for the calculated route, the default value is `metric`",
options: constants.UNITS,
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.geoapify.com/v1";
},
_makeRequest({
$ = this,
path,
params,
...otherOpts
}) {
return axios($, {
...otherOpts,
url: `${this._baseUrl()}${path}`,
params: {
...params,
apiKey: this.$auth.api_key,
},
});
},
geocodeAddress(opts = {}) {
return this._makeRequest({
path: "/geocode/search",
...opts,
});
},
calculateRoute(opts = {}) {
return this._makeRequest({
path: "/routing",
...opts,
});
},
geolocateIP(opts = {}) {
return this._makeRequest({
path: "/ipinfo",
...opts,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/geoapify/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/geoapify",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Geoapify Components",
"main": "geoapify.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading