Skip to content

Commit 87e87d0

Browse files
authored
New Components - jvzoo (#16829)
* new components * pnpm-lock.yaml * updates
1 parent 1e54be1 commit 87e87d0

File tree

5 files changed

+133
-0
lines changed

5 files changed

+133
-0
lines changed

components/jvzoo/jvzoo.app.mjs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { axios } from "@pipedream/platform";
2+
3+
export default {
4+
type: "app",
5+
app: "jvzoo",
6+
propDefinitions: {},
7+
methods: {
8+
_baseUrl() {
9+
return "https://api.jvzoo.com/v2.0";
10+
},
11+
_makeRequest({
12+
$ = this, path, ...opts
13+
}) {
14+
return axios($, {
15+
url: `${this._baseUrl()}${path}`,
16+
auth: {
17+
username: `${this.$auth.api_key}`,
18+
password: "x",
19+
},
20+
headers: {
21+
"Content-Type": "application/json",
22+
},
23+
...opts,
24+
});
25+
},
26+
getLatestTransactions({
27+
paykey, ...opts
28+
}) {
29+
return this._makeRequest({
30+
path: `/latest-transactions/${paykey}`,
31+
...opts,
32+
});
33+
},
34+
},
35+
};

components/jvzoo/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@pipedream/jvzoo",
3+
"version": "0.0.1",
4+
"description": "Pipedream Jvzoo Components",
5+
"main": "jvzoo.app.mjs",
6+
"keywords": [
7+
"pipedream",
8+
"jvzoo"
9+
],
10+
"homepage": "https://pipedream.com/apps/jvzoo",
11+
"author": "Pipedream <[email protected]> (https://pipedream.com)",
12+
"publishConfig": {
13+
"access": "public"
14+
}
15+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import jvzoo from "../../jvzoo.app.mjs";
2+
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
3+
import sampleEmit from "./test-event.mjs";
4+
5+
export default {
6+
key: "jvzoo-new-transaction-created",
7+
name: "New Transaction Created",
8+
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)",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
props: {
13+
jvzoo,
14+
db: "$.service.db",
15+
timer: {
16+
type: "$.interface.timer",
17+
default: {
18+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
19+
},
20+
},
21+
},
22+
methods: {
23+
_getPaykey() {
24+
return this.db.get("paykey");
25+
},
26+
_setPaykey(paykey) {
27+
this.db.set("paykey", paykey);
28+
},
29+
generateMeta(transaction) {
30+
return {
31+
id: transaction.transaction_id,
32+
summary: `New transaction created: ${transaction.transaction_id}`,
33+
ts: Date.parse(transaction.date),
34+
};
35+
},
36+
async processEvent(max) {
37+
const paykey = this._getPaykey();
38+
const params = paykey
39+
? {
40+
paykey,
41+
}
42+
: {};
43+
const { results } = await this.jvzoo.getLatestTransactions({
44+
params,
45+
});
46+
if (!results?.length) {
47+
return;
48+
}
49+
const transactions = max
50+
? results.slice(max * -1)
51+
: results;
52+
for (const transaction of transactions) {
53+
this.$emit(transaction, this.generateMeta(transaction));
54+
}
55+
this._setPaykey(results[results.length - 1].transaction_id);
56+
},
57+
},
58+
hooks: {
59+
async deploy() {
60+
await this.processEvent(25);
61+
},
62+
},
63+
async run() {
64+
await this.processEvent();
65+
},
66+
sampleEmit,
67+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export default {
2+
"transaction_id": "AP-1234567890ABCDEFG",
3+
"date": "2016-12-02T12:50:30+00:00",
4+
"product_name": "Example Product Name",
5+
"product_id": 123456,
6+
"status": "COMPLETED",
7+
"price": "27.00",
8+
"customer_email": "[email protected]",
9+
"ip": "1.1.1.1",
10+
"first_name": "Joe",
11+
"last_name": "Le Feuvre",
12+
"affiliate_id": 1,
13+
"affiliate_name": "John Doe"
14+
}

pnpm-lock.yaml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)