Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fs from "fs";
import { checkTmp } from "../../common/utils.mjs";
import app from "../../what_are_those.app.mjs";

export default {
key: "what_are_those-find-sneakers-by-sku",
name: "Find Sneakers by SKU",
description: "Identifies sneakers from a size tag photo and returns sneaker name and details. [See the documentation](https://documenter.getpostman.com/view/3847098/2sAY4rDQDs#4f6a49f9-3393-42cd-8474-3856a79888af)",
version: "0.0.1",
type: "action",
props: {
app,
sizeTagImage: {
type: "string",
label: "Size Tag Image",
description: "The path to the size tag image in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp).",
},
},
async run({ $ }) {
const data = fs.readFileSync(checkTmp(this.sizeTagImage));
const base64Image = Buffer.from(data, "binary").toString("base64");

const response = await this.app.identifySneakersFromSizeTag({
$,
data: base64Image,
});

$.export("$summary", `Identified sneaker: ${response}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import FormData from "form-data";
import fs from "fs";
import { checkTmp } from "../../common/utils.mjs";
import app from "../../what_are_those.app.mjs";

export default {
key: "what_are_those-grade-sneakers-condition",
name: "Grade and Authenticate Sneakers",
description: "Grades and authenticates sneakers using provided images. [See the documentation](https://documenter.getpostman.com/view/3847098/2sAY4rDQDs#13d527e8-5d8f-4511-857c-b40b8dd921b8)",
version: "0.0.1",
type: "action",
props: {
app,
frontImage: {
type: "string",
label: "Front Image",
description: "Base64 encoded or multipart form data image of the front.",
},
leftImage: {
type: "string",
label: "Left Image",
description: "Base64 encoded or multipart form data image of the left side.",
},
rightImage: {
type: "string",
label: "Right Image",
description: "Base64 encoded or multipart form data image of the right side.",
},
soleImage: {
type: "string",
label: "Sole Image",
description: "Base64 encoded or multipart form data image of the sole.",
},
insoleImage: {
type: "string",
label: "Insole Image",
description: "Base64 encoded or multipart form data image of the insole.",
},
sizeTagImage: {
type: "string",
label: "Size Tag Image",
description: "Base64 encoded or multipart form data image of the size tag.",
},
type: {
type: "string",
label: "Use Type",
description: "the type parameter to see specific types of data.",
options: [
"grading",
"authentication",
],
optional: true,
},
},
async run({ $ }) {
const data = new FormData();
data.append("image1", fs.createReadStream(checkTmp(this.frontImage)));
data.append("image2", fs.createReadStream(checkTmp(this.leftImage)));
data.append("image3", fs.createReadStream(checkTmp(this.rightImage)));
data.append("image4", fs.createReadStream(checkTmp(this.soleImage)));
data.append("image5", fs.createReadStream(checkTmp(this.insoleImage)));
data.append("image6", fs.createReadStream(checkTmp(this.sizeTagImage)));

const response = await this.app.gradeAuthenticateSneakers({
headers: {
...data.getHeaders(),
},
data: data,
maxBodyLength: Infinity,
params: {
type: this.type,
},
});
$.export("$summary", "Successfully graded and authenticated sneakers.");
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import FormData from "form-data";
import fs from "fs";
import { checkTmp } from "../../common/utils.mjs";
import app from "../../what_are_those.app.mjs";

export default {
key: "what_are_those-identify-sneakers-from-photo",
name: "Identify Sneakers from Photo",
description: "Identifies sneakers from an uploaded image and returns details such as name, links, images, prices, and confidence scores. [See the documentation](https://documenter.getpostman.com/view/3847098/2sAY4rDQDs#957c900c-501f-4c8f-9b8b-71655a8cfb5d).",
version: "0.0.1",
type: "action",
props: {
app,
image: {
type: "string",
label: "Image",
description: "The path to the size tag image in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp).",
},
},
async run({ $ }) {
const data = new FormData();
data.append("image1", fs.createReadStream(checkTmp(this.image)));

const response = await this.app.identifySneakers({
headers: {
...data.getHeaders(),
},
data: data,
});

$.export("$summary", `Identified ${response.names} sneakers successfully`);
return response;
},
};
6 changes: 6 additions & 0 deletions components/what_are_those/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const checkTmp = (filename) => {
if (!filename.startsWith("/tmp")) {
return "/tmp/filename";
}
return filename;
};
7 changes: 5 additions & 2 deletions components/what_are_those/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/what_are_those",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream What Are Those Components",
"main": "what_are_those.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"
}
}
}
42 changes: 37 additions & 5 deletions components/what_are_those/what_are_those.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "what_are_those",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_headers(headers = {}) {
return {
"x-api-key": this.$auth.api_key,
...headers,
};
},
_makeRequest({
$ = this, headers, ...opts
}) {
return axios($, {
headers: this._headers(headers),
...opts,
});
},
identifySneakers(opts = {}) {
return this._makeRequest({
method: "POST",
url: "https://ayq6s37rv6.execute-api.us-east-1.amazonaws.com/Prod/rec?data_type=multi",
...opts,
});
},
gradeAuthenticateSneakers(opts = {}) {
return this._makeRequest({
method: "POST",
url: "https://6mdt6kw7ig.execute-api.us-east-1.amazonaws.com/Prod/list?data_type=multi",
...opts,
});
},
identifySneakersFromSizeTag(opts = {}) {
return this._makeRequest({
method: "POST",
url: "https://0blrzg7ahc.execute-api.us-east-1.amazonaws.com/Prod/sku",
...opts,
});
},
},
};
};
29 changes: 12 additions & 17 deletions pnpm-lock.yaml

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

Loading