Skip to content

Commit c9fdcc0

Browse files
committed
what_are_those init
1 parent af6dda5 commit c9fdcc0

File tree

5 files changed

+255
-4
lines changed

5 files changed

+255
-4
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import what_are_those from "../../what_are_those.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "what_are_those-find-sneakers-by-sku",
6+
name: "Find Sneakers by SKU",
7+
description: "Identifies sneakers from a size tag photo and returns sneaker name and details. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
what_are_those: {
12+
type: "app",
13+
app: "what_are_those",
14+
},
15+
sizeTagPhoto: {
16+
propDefinition: [
17+
"what_are_those",
18+
"sizeTagPhoto",
19+
],
20+
},
21+
},
22+
async run({ $ }) {
23+
const sneakerData = await this.what_are_those.identifySneakersFromSizeTag({
24+
sizeTagPhoto: this.sizeTagPhoto,
25+
});
26+
const sneakerName = sneakerData.name;
27+
const sneakerDetails = sneakerData.details;
28+
$.export("$summary", `Identified sneaker: ${sneakerName}`);
29+
return {
30+
name: sneakerName,
31+
details: sneakerDetails,
32+
};
33+
},
34+
};
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import what_are_those from "../../what_are_those.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "what_are_those-grade-sneakers-condition",
6+
name: "Grade and Authenticate Sneakers",
7+
description: "Grades and authenticates sneakers using provided images. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
what_are_those,
12+
frontImage: {
13+
propDefinition: [
14+
what_are_those,
15+
"frontImage",
16+
],
17+
},
18+
leftImage: {
19+
propDefinition: [
20+
what_are_those,
21+
"leftImage",
22+
],
23+
},
24+
rightImage: {
25+
propDefinition: [
26+
what_are_those,
27+
"rightImage",
28+
],
29+
},
30+
soleImage: {
31+
propDefinition: [
32+
what_are_those,
33+
"soleImage",
34+
],
35+
},
36+
insoleImage: {
37+
propDefinition: [
38+
what_are_those,
39+
"insoleImage",
40+
],
41+
},
42+
sizeTagImage: {
43+
propDefinition: [
44+
what_are_those,
45+
"sizeTagImage",
46+
],
47+
},
48+
type: {
49+
propDefinition: [
50+
what_are_those,
51+
"type",
52+
],
53+
optional: true,
54+
},
55+
},
56+
async run({ $ }) {
57+
const response = await this.what_are_those.gradeAuthenticateSneakers({
58+
frontImage: this.frontImage,
59+
leftImage: this.leftImage,
60+
rightImage: this.rightImage,
61+
soleImage: this.soleImage,
62+
insoleImage: this.insoleImage,
63+
sizeTagImage: this.sizeTagImage,
64+
type: this.type,
65+
});
66+
$.export("$summary", "Successfully graded and authenticated sneakers.");
67+
return response;
68+
},
69+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import what_are_those from "../../what_are_those.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "what_are_those-identify-sneakers-from-photo",
6+
name: "Identify Sneakers from Photo",
7+
description: "Identifies sneakers from an uploaded image and returns details such as name, links, images, prices, and confidence scores. [See the documentation]().",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
what_are_those,
12+
image: {
13+
propDefinition: [
14+
what_are_those,
15+
"image",
16+
],
17+
},
18+
},
19+
async run({ $ }) {
20+
const response = await this.what_are_those.identifySneakers({
21+
image: this.image,
22+
});
23+
const sneakerCount = Array.isArray(response)
24+
? response.length
25+
: 1;
26+
$.export("$summary", `Identified ${sneakerCount} sneakers successfully`);
27+
return response;
28+
},
29+
};

components/what_are_those/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}
Lines changed: 122 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,130 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "what_are_those",
4-
propDefinitions: {},
6+
version: "0.0.{{ts}}",
7+
propDefinitions: {
8+
// Props for identifying sneakers from an uploaded image
9+
image: {
10+
type: "string",
11+
label: "Image",
12+
description: "Base64 encoded or multipart form data image.",
13+
},
14+
// Props for grading and authenticating sneakers
15+
frontImage: {
16+
type: "string",
17+
label: "Front Image",
18+
description: "Base64 encoded or multipart form data image of the front.",
19+
},
20+
leftImage: {
21+
type: "string",
22+
label: "Left Image",
23+
description: "Base64 encoded or multipart form data image of the left side.",
24+
},
25+
rightImage: {
26+
type: "string",
27+
label: "Right Image",
28+
description: "Base64 encoded or multipart form data image of the right side.",
29+
},
30+
soleImage: {
31+
type: "string",
32+
label: "Sole Image",
33+
description: "Base64 encoded or multipart form data image of the sole.",
34+
},
35+
insoleImage: {
36+
type: "string",
37+
label: "Insole Image",
38+
description: "Base64 encoded or multipart form data image of the insole.",
39+
},
40+
sizeTagImage: {
41+
type: "string",
42+
label: "Size Tag Image",
43+
description: "Base64 encoded or multipart form data image of the size tag.",
44+
},
45+
type: {
46+
type: "string",
47+
label: "Type",
48+
description: "Optional parameter for grading-only results.",
49+
optional: true,
50+
},
51+
// Props for identifying sneakers from a size tag photo
52+
sizeTagPhoto: {
53+
type: "string",
54+
label: "Size Tag Photo",
55+
description: "File or base64 encoded data of the size tag photo.",
56+
},
57+
},
558
methods: {
6-
// this.$auth contains connected account data
59+
// Existing method
760
authKeys() {
861
console.log(Object.keys(this.$auth));
962
},
63+
// Base URL for the API
64+
_baseUrl() {
65+
return "https://api.whatarethose.com";
66+
},
67+
// Method to make API requests
68+
async _makeRequest(opts = {}) {
69+
const {
70+
$ = this, method = "GET", path = "/", headers, ...otherOpts
71+
} = opts;
72+
return axios($, {
73+
method,
74+
url: `${this._baseUrl()}${path}`,
75+
headers: {
76+
...headers,
77+
Authorization: `Bearer ${this.$auth.api_token}`,
78+
},
79+
...otherOpts,
80+
});
81+
},
82+
// Method to identify sneakers from an uploaded image
83+
async identifySneakers(opts = {}) {
84+
const { image } = opts;
85+
return this._makeRequest({
86+
method: "POST",
87+
path: "/identify_sneakers",
88+
data: {
89+
image: image,
90+
},
91+
});
92+
},
93+
// Method to grade and authenticate sneakers from multiple images
94+
async gradeAuthenticateSneakers(opts = {}) {
95+
const {
96+
frontImage,
97+
leftImage,
98+
rightImage,
99+
soleImage,
100+
insoleImage,
101+
sizeTagImage,
102+
type,
103+
} = opts;
104+
return this._makeRequest({
105+
method: "POST",
106+
path: "/grade_authenticate_sneakers",
107+
data: {
108+
front: frontImage,
109+
left: leftImage,
110+
right: rightImage,
111+
sole: soleImage,
112+
insole: insoleImage,
113+
size_tag: sizeTagImage,
114+
type: type,
115+
},
116+
});
117+
},
118+
// Method to identify sneakers from a size tag photo
119+
async identifySneakersFromSizeTag(opts = {}) {
120+
const { sizeTagPhoto } = opts;
121+
return this._makeRequest({
122+
method: "POST",
123+
path: "/identify_from_size_tag",
124+
data: {
125+
size_tag_photo: sizeTagPhoto,
126+
},
127+
});
128+
},
10129
},
11-
};
130+
};

0 commit comments

Comments
 (0)