Skip to content

Commit

Permalink
Merge pull request #935 from zapier/PDE-5506-switch-to-different-swapi
Browse files Browse the repository at this point in the history
PDE-5506: fix(test): move swapi.dev to swapi.info for dynamic-dropdown template
  • Loading branch information
eliangcs authored Dec 18, 2024
2 parents 37b2b61 + 22e22ae commit b14943c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions example-apps/dynamic-dropdown/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ bower_components

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/
dist/

# Dependency directories
node_modules/
Expand Down
2 changes: 1 addition & 1 deletion example-apps/dynamic-dropdown/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ Find out more on the latest docs: https://github.com/zapier/zapier-platform/blob

# The "dynamic-dropdown" Template

This example integration uses the [Star Wars API](https://swapi.dev/) to provide a dynamic listing of choices for an `inputField` in a trigger.
This example integration uses the [Star Wars API](https://swapi.info/) to provide a dynamic listing of choices for an `inputField` in a trigger.

![](https://cdn.zappy.app/d985065c5098089795d9b60c77791e12.png)
2 changes: 1 addition & 1 deletion example-apps/dynamic-dropdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"zapier-platform-core": "16.0.0"
},
"devDependencies": {
"jest": "^25.5.3"
"jest": "^29.6.0"
},
"private": true
}
11 changes: 8 additions & 3 deletions example-apps/dynamic-dropdown/triggers/people.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@ const perform = async (z, bundle) => {
// Ideally, we should poll through all the pages of results, but in this
// example we're going to omit that part. Thus, this trigger only "see" the
// people in their first page of results.
const response = await z.request({ url: 'https://swapi.dev/api/people/' });
let peopleArray = response.data.results;
const response = await z.request({ url: 'https://swapi.info/api/people/' });
let peopleArray = response.data;

if (bundle.inputData.species_id) {
// The Zap's setup has requested a specific species of person. Since the
// API/endpoint can't perform the filtering, we'll perform it here, within
// the integration, and return the matching objects/records back to Zapier.
peopleArray = peopleArray.filter((person) => {
const speciesID = extractID(person.species[0]);
let speciesID;
if (!person.species || !person.species.length) {
speciesID = 1; // Assume human if species is not provided
} else {
speciesID = extractID(person.species[0]);
}
return speciesID === bundle.inputData.species_id;
});
}
Expand Down
4 changes: 2 additions & 2 deletions example-apps/dynamic-dropdown/triggers/species.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { extractID } = require('../utils');
// Fetches a list of records from the endpoint
const perform = async (z, bundle) => {
const request = {
url: 'https://swapi.dev/api/species/',
url: 'https://swapi.info/api/species/',
params: {},
};

Expand All @@ -13,7 +13,7 @@ const perform = async (z, bundle) => {
}

const response = await z.request(request);
const speciesArray = response.data.results;
const speciesArray = response.data;
return speciesArray.map((species) => {
species.id = extractID(species.url);
return species;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The "dynamic-dropdown" Template

This example integration uses the [Star Wars API](https://swapi.dev/) to provide a dynamic listing of choices for an `inputField` in a trigger.
This example integration uses the [Star Wars API](https://swapi.info/) to provide a dynamic listing of choices for an `inputField` in a trigger.

![](https://cdn.zappy.app/d985065c5098089795d9b60c77791e12.png)
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const perform = async (z, bundle) => {
// Ideally, we should poll through all the pages of results, but in this
// example we're going to omit that part. Thus, this trigger only "see" the
// people in their first page of results.
const response = await z.request({ url: 'https://swapi.dev/api/people/' });
let peopleArray = response.data.results;
const response = await z.request({ url: 'https://swapi.info/api/people/' });
let peopleArray = response.data;

if (bundle.inputData.species_id) {
// The Zap's setup has requested a specific species of person. Since the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { extractID } = require('../utils');
// Fetches a list of records from the endpoint
const perform = async (z, bundle) => {
const request = {
url: 'https://swapi.dev/api/species/',
url: 'https://swapi.info/api/species/',
params: {},
};

Expand All @@ -13,7 +13,7 @@ const perform = async (z, bundle) => {
}

const response = await z.request(request);
const speciesArray = response.data.results;
const speciesArray = response.data;
return speciesArray.map((species) => {
species.id = extractID(species.url);
return species;
Expand Down

0 comments on commit b14943c

Please sign in to comment.