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
35 changes: 35 additions & 0 deletions components/jvzoo/jvzoo.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "jvzoo",
propDefinitions: {},
methods: {
_baseUrl() {
return "https://api.jvzoo.com/v2.0";
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
auth: {
username: `${this.$auth.api_key}`,
password: "x",
},
headers: {
"Content-Type": "application/json",
},
...opts,
});
},
getLatestTransactions({
paykey, ...opts
}) {
return this._makeRequest({
path: `/latest-transactions/${paykey}`,
...opts,
});
},
},
};
15 changes: 15 additions & 0 deletions components/jvzoo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@pipedream/jvzoo",
"version": "0.0.1",
"description": "Pipedream Jvzoo Components",
"main": "jvzoo.app.mjs",
"keywords": [
"pipedream",
"jvzoo"
],
"homepage": "https://pipedream.com/apps/jvzoo",
"author": "Pipedream <[email protected]> (https://pipedream.com)",
"publishConfig": {
"access": "public"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import jvzoo from "../../jvzoo.app.mjs";
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
import sampleEmit from "./test-event.mjs";

export default {
key: "jvzoo-new-transaction-created",
name: "New Transaction Created",
description: "Emit new event when a new transaction is created. [See the documentation](https://api.jvzoo.com/docs/versions/v2.0.html#transactions-latest-transactions-get)",
version: "0.0.1",
type: "source",
dedupe: "unique",
props: {
jvzoo,
db: "$.service.db",
timer: {
type: "$.interface.timer",
default: {
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
},
},
},
methods: {
_getPaykey() {
return this.db.get("paykey");
},
_setPaykey(paykey) {
this.db.set("paykey", paykey);
},
generateMeta(transaction) {
return {
id: transaction.transaction_id,
summary: `New transaction created: ${transaction.transaction_id}`,
ts: Date.parse(transaction.date),
};
},
async processEvent(max) {
const paykey = this._getPaykey();
const params = paykey
? {
paykey,
}
: {};
const { results } = await this.jvzoo.getLatestTransactions({
params,
});
if (!results?.length) {
return;
}
const transactions = max
? results.slice(max * -1)
: results;
for (const transaction of transactions) {
this.$emit(transaction, this.generateMeta(transaction));
}
this._setPaykey(results[results.length - 1].transaction_id);
},
},
hooks: {
async deploy() {
await this.processEvent(25);
},
},
async run() {
await this.processEvent();
},
sampleEmit,
};
14 changes: 14 additions & 0 deletions components/jvzoo/sources/new-transaction-created/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
"transaction_id": "AP-1234567890ABCDEFG",
"date": "2016-12-02T12:50:30+00:00",
"product_name": "Example Product Name",
"product_id": 123456,
"status": "COMPLETED",
"price": "27.00",
"customer_email": "[email protected]",
"ip": "1.1.1.1",
"first_name": "Joe",
"last_name": "Le Feuvre",
"affiliate_id": 1,
"affiliate_name": "John Doe"
}
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

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

Loading