diff --git a/components/taggun/actions/extract-data-from-url/extract-data-from-url.mjs b/components/taggun/actions/extract-data-from-url/extract-data-from-url.mjs new file mode 100644 index 0000000000000..c9da8ad58e1b4 --- /dev/null +++ b/components/taggun/actions/extract-data-from-url/extract-data-from-url.mjs @@ -0,0 +1,76 @@ +import app from "../../taggun.app.mjs"; + +export default { + key: "taggun-extract-data-from-url", + name: "Extract Data from URL", + description: "Provide a URL for a receipt or invoice to extract clear and basic data. [See the documentation](https://developers.taggun.io/reference/url-simple)", + version: "0.0.1", + annotations: { + openWorldHint: true, + destructiveHint: false, + readOnlyHint: true, + }, + type: "action", + props: { + app, + url: { + propDefinition: [ + app, + "url", + ], + }, + referenceId: { + propDefinition: [ + app, + "referenceId", + ], + optional: true, + }, + refresh: { + propDefinition: [ + app, + "refresh", + ], + }, + near: { + propDefinition: [ + app, + "near", + ], + }, + language: { + propDefinition: [ + app, + "language", + ], + }, + incognito: { + propDefinition: [ + app, + "incognito", + ], + }, + verbose: { + propDefinition: [ + app, + "verbose", + ], + }, + }, + async run({ $ }) { + const response = await this.app.urlDataExtraction({ + $, + verbose: this.verbose, + data: { + url: this.url, + referenceId: this.referenceId, + refresh: this.refresh, + near: this.near, + language: this.language, + incognito: this.incognito, + }, + }); + $.export("$summary", "Successfully sent the image for processing"); + return response; + }, +}; diff --git a/components/taggun/actions/submit-feedback/submit-feedback.mjs b/components/taggun/actions/submit-feedback/submit-feedback.mjs new file mode 100644 index 0000000000000..8edff38fce50a --- /dev/null +++ b/components/taggun/actions/submit-feedback/submit-feedback.mjs @@ -0,0 +1,61 @@ +import app from "../../taggun.app.mjs"; + +export default { + key: "taggun-submit-feedback", + name: "Submit Feedback", + description: "Add manually verified receipt data to a given receipt for feedback and training purposes. [See the documentation](https://developers.taggun.io/reference/improve-your-restuls)", + version: "0.0.1", + annotations: { + openWorldHint: true, + destructiveHint: false, + readOnlyHint: false, + }, + type: "action", + props: { + app, + referenceId: { + propDefinition: [ + app, + "referenceId", + ], + }, + totalAmount: { + propDefinition: [ + app, + "totalAmount", + ], + }, + taxAmount: { + propDefinition: [ + app, + "taxAmount", + ], + }, + merchantName: { + propDefinition: [ + app, + "merchantName", + ], + }, + currencyCode: { + propDefinition: [ + app, + "currencyCode", + ], + }, + }, + async run({ $ }) { + const response = await this.app.submitFeedback({ + $, + data: { + referenceId: this.referenceId, + totalAmount: this.totalAmount, + taxAmount: this.taxAmount, + merchantName: this.merchantName, + currencyCode: this.currencyCode, + }, + }); + $.export("$summary", "Successfully submitted feedback"); + return response; + }, +}; diff --git a/components/taggun/common/constants.mjs b/components/taggun/common/constants.mjs new file mode 100644 index 0000000000000..f20c68df8a204 --- /dev/null +++ b/components/taggun/common/constants.mjs @@ -0,0 +1,17 @@ +export default { + LANGUAGE_OPTIONS: [ + "en", + "es", + "fr", + "jp", + "he", + "iw", + "et", + "lv", + "lt", + "fi", + "el", + "zh", + "th", + ], +}; diff --git a/components/taggun/package.json b/components/taggun/package.json index 1be2d23a08b96..de5c97a1a24cf 100644 --- a/components/taggun/package.json +++ b/components/taggun/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/taggun", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Taggun Components", "main": "taggun.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } } diff --git a/components/taggun/taggun.app.mjs b/components/taggun/taggun.app.mjs index 74fb1a3da2669..733f3bd497842 100644 --- a/components/taggun/taggun.app.mjs +++ b/components/taggun/taggun.app.mjs @@ -1,11 +1,114 @@ +import { axios } from "@pipedream/platform"; +import constants from "./common/constants.mjs"; + export default { type: "app", app: "taggun", - propDefinitions: {}, + propDefinitions: { + url: { + type: "string", + label: "URL", + description: "Image URL to process", + }, + referenceId: { + type: "string", + label: "Reference ID", + description: "Custom reference ID for tracking the request", + }, + refresh: { + type: "boolean", + label: "Refresh", + description: "Force reprocessing of the image instead of using cached results", + optional: true, + }, + near: { + type: "string", + label: "Near", + description: "Provide a nearby location to improve result accuracy", + optional: true, + }, + language: { + type: "string", + label: "Language", + description: "Preferred language for extracted text", + options: constants.LANGUAGE_OPTIONS, + optional: true, + }, + incognito: { + type: "boolean", + label: "Incognito", + description: "Do not store or use the image for system training", + optional: true, + }, + totalAmount: { + type: "string", + label: "Total Amount", + description: "The expected total amount from the user", + optional: true, + }, + taxAmount: { + type: "string", + label: "Tax Amount", + description: "The expected tax amount from the user", + optional: true, + }, + merchantName: { + type: "string", + label: "Merchant Name", + description: "The expected merchant name from the user", + optional: true, + }, + currencyCode: { + type: "string", + label: "Currency Code", + description: "The expected currency code from the user", + optional: true, + }, + verbose: { + type: "boolean", + label: "Verbose", + description: "Whether the data extraction will be simple or verbose", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.taggun.io/api"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + "apikey": `${this.$auth.api_key}`, + "Content-Type": "application/json", + ...headers, + }, + }); + }, + async urlDataExtraction({ + verbose, ...args + }) { + return this._makeRequest({ + path: `/receipt/v1/${verbose + ? "verbose" + : "simple"}/url`, + method: "post", + ...args, + }); + }, + async submitFeedback(args = {}) { + return this._makeRequest({ + path: "/account/v1/feedback", + method: "post", + ...args, + }); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 24fdfc9612a14..22fae98551835 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14181,7 +14181,11 @@ importers: specifier: ^1.6.0 version: 1.6.6 - components/taggun: {} + components/taggun: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/taiga: dependencies: