Skip to content
24 changes: 20 additions & 4 deletions components/ikas/ikas.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "ikas",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.myikas.com/api/v1/admin/graphql";
},
_headers() {
return {
"Content-Type": "application/json",
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
};
},
makeRequest({
$ = this, ...opts
}) {
return axios($, {
method: "POST",
url: this._baseUrl(),
headers: this._headers(),
...opts,
});
},
},
};
8 changes: 6 additions & 2 deletions components/ikas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/ikas",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Ikas Components",
"main": "ikas.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,9 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.0"
}
}
}

55 changes: 55 additions & 0 deletions components/ikas/sources/common/base.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import ikas from "../../ikas.app.mjs";

export default {
props: {
ikas,
http: {
type: "$.interface.http",
customResponse: false,
},
db: "$.service.db",
},
hooks: {
async activate() {
const { data } = await this.ikas.makeRequest({
data: {
"query": `mutation {
saveWebhook(
input: {
scopes: "${this.getScope()}"
endpoint: "${this.http.endpoint}"
}
) {
createdAt
deleted
endpoint
id
scope
updatedAt
}
}`,
},
});
this.db.set("webhookId", data.saveWebhook[0].id);
},
async deactivate() {
const webhookId = this.db.get("webhookId");
if (webhookId) {
await this.ikas.makeRequest({
data: {
"query": `mutation {
deleteWebhook(scopes: ["${this.getScope()}"])
}`,
},
});
}
},
},
async run({ body }) {
this.$emit(body, {
id: body.id,
summary: this.getSummary(body),
ts: body.createdAt,
});
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "ikas-new-customer-instant",
name: "New Customer (Instant)",
description: "Emit new event when a customer account is created on ikas. **You can only have one webhook of each type at the same time.**",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getScope() {
return "store/customer/created";
},
getSummary(body) {
const data = JSON.parse(body.data);
return `New customer created with Id: ${data.id}.`;
},
},
sampleEmit,
};
9 changes: 9 additions & 0 deletions components/ikas/sources/new-customer-instant/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
"authorizedAppId":"12345678-1234-1234-1234-123456789012",
"createdAt":"2024-07-11T19:06:04.736Z",
"data":"{\"createdAt\":\"2024-07-11T19:04:19.158Z\",\"updatedAt\":\"2024-07-11T19:04:19.158Z\",\"merchantId\":\"12345678-1234-1234-1234-123456789012\",\"deleted\":false,\"firstName\":\"Customer \",\"lastName\":\"Test\",\"fullName\":\"Customer Test\",\"email\":\"[email protected]\",\"isEmailVerified\":false,\"attributes\":null,\"phone\":null,\"isPhoneVerified\":false,\"addresses\":[],\"note\":null,\"accountStatus\":null,\"subscriptionStatus\":\"NOT_SUBSCRIBED\",\"smsSubscriptionStatus\":null,\"phoneSubscriptionStatus\":null,\"tagIds\":null,\"customerGroupIds\":null,\"preferredLanguage\":null,\"b2bStatus\":null,\"priceListRules\":null,\"priceListId\":null,\"isEmailBounced\":false,\"customerSegmentIds\":[],\"gender\":null,\"birthDate\":null,\"customerSequence\":1,\"id\":\"12345678-1234-1234-1234-123456789012\"}",
"id":"12345678-1234-1234-1234-123456789012-12345678-1234-1234-1234-123456789012",
"merchantId":"12345678-1234-1234-1234-123456789012",
"scope":"store/customer/created",
"signature":"373045525decbad86b3a09f4bac07cd2a6611801c8a2c9ec9be4973be269a522"
}
23 changes: 23 additions & 0 deletions components/ikas/sources/new-order-instant/new-order-instant.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "ikas-new-order-instant",
name: "New Order Created (Instant)",
description: "Emit new event when a new order is created on ikas.",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getScope() {
return "store/order/created";
},
getSummary(body) {
const data = JSON.parse(body.data);
return `New order created with Id: ${data.id}.`;
},
},
sampleEmit,
};
9 changes: 9 additions & 0 deletions components/ikas/sources/new-order-instant/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
"authorizedAppId":"12345678-1234-1234-1234-123456789012",
"createdAt":"2024-07-11T19:06:04.736Z",
"data":"{\"createdAt\":\"2024-07-11T21:22:48.992Z\",\"updatedAt\":\"2024-07-11T21:23:16.543Z\",\"merchantId\":\"12345678-1234-1234-1234-123456789012\",\"deleted\":false,\"billingAddress\":null,\"cartId\":\"12345678-1234-1234-1234-123456789012\",\"cartStatus\":2,\"checkoutId\":\"12345678-1234-1234-1234-123456789012\",\"availableShippingMethods\":[],\"createdBy\":2,\"campaignOffers\":[],\"clientIp\":\"123.123.12.12\",\"currencyCode\":\"USD\",\"currencyRates\":[],\"customer\":{\"id\":\"12345678-1234-1234-1234-123456789012\",\"firstName\":\"Customer\",\"lastName\":\"Test\",\"fullName\":\"Customer Test\",\"email\":\"[email protected]\",\"notificationsAccepted\":false,\"isGuestCheckout\":true,\"lastOrderDate\":null},\"dueDate\":\"2024-07-11T21:23:16.377Z\",\"itemCount\":1,\"note\":null,\"giftPackageLines\":[],\"orderLineItems\":[{\"createdAt\":\"2024-07-11T21:23:16.543Z\",\"updatedAt\":\"2024-07-11T21:23:16.543Z\",\"deleted\":false,\"price\":123,\"discountPrice\":null,\"finalPrice\":123,\"taxValue\":null,\"quantity\":1,\"currencyCode\":\"USD\",\"discount\":null,\"variant\":{\"id\":\"12345678-1234-1234-1234-123456789012\",\"productId\":\"12345678-1234-1234-1234-123456789012\",\"name\":\"product test\",\"barcodeList\":[],\"variantValues\":[],\"slug\":\"product-test\",\"tagIds\":[],\"tags\":[],\"prices\":[{\"sellPrice\":123}],\"type\":1,\"categories\":[]},\"status\":\"UNFULFILLED\",\"sourceId\":null,\"id\":\"12345678-1234-1234-1234-123456789012\"}],\"orderNumber\":\"1001\",\"orderedAt\":\"2024-07-11T21:22:48.993Z\",\"priceListId\":null,\"salesChannelId\":\"ADMIN\",\"shippingAddress\":null,\"shippingMethod\":\"SHIPMENT\",\"storefrontRouting\":null,\"totalFinalPrice\":123,\"netTotalFinalPrice\":123,\"totalPrice\":123,\"userAgent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36\",\"taxLines\":[],\"attributes\":[],\"branchSession\":null,\"branchSessionId\":null,\"invoices\":[],\"orderPackages\":[],\"orderPaymentStatus\":\"WAITING\",\"orderTagIds\":null,\"paymentMethods\":[],\"priceList\":null,\"salesChannel\":{\"id\":\"ADMIN\",\"name\":\"ADMIN\",\"type\":6},\"status\":\"DRAFT\",\"storefront\":null,\"storefrontTheme\":null,\"terminalId\":null,\"sourceId\":null,\"archived\":false,\"orderSequence\":1,\"id\":\"12345678-1234-1234-1234-123456789012\"}",
"id":"12345678-1234-1234-1234-123456789012-12345678-1234-1234-1234-123456789012",
"merchantId":"12345678-1234-1234-1234-123456789012",
"scope":"store/order/created",
"signature":"373045525decbad86b3a09f4bac07cd2a6611801c8a2c9ec9be4973be269a522"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "ikas-new-product-instant",
name: "New Product Created (Instant)",
description: "Emit new event when a product is created on ikas.",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getScope() {
return "store/product/created";
},
getSummary(body) {
const data = JSON.parse(body.data);
return `New product created with Id: ${data.id}.`;
},
},
sampleEmit,
};
9 changes: 9 additions & 0 deletions components/ikas/sources/new-product-instant/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
"authorizedAppId":"12345678-1234-1234-1234-123456789012",
"createdAt":"2024-07-11T19:06:04.736Z",
"data":"{\"deleted\":false,\"name\":\"product test\",\"shortDescription\":null,\"weight\":null,\"maxQuantityPerCart\":null,\"groupVariantsByVariantTypeId\":null,\"type\":\"PHYSICAL\",\"productVariantTypes\":[],\"categoryIds\":null,\"variants\":[{\"deleted\":false,\"sku\":null,\"barcodeList\":null,\"weight\":null,\"isActive\":true,\"sellIfOutOfStock\":null,\"images\":null,\"prices\":[{\"sellPrice\":123,\"discountPrice\":null,\"buyPrice\":null,\"currency\":null,\"priceListId\":null}],\"hsCode\":null,\"unit\":null,\"bundleSettings\":null,\"fileId\":null,\"id\":\"12345678-1234-1234-1234-123456789012\"}],\"attributes\":[],\"tagIds\":null,\"brandId\":null,\"vendorId\":null,\"metaData\":{\"deleted\":false,\"slug\":\"product-test\",\"pageTitle\":\"product test\",\"canonicals\":null,\"disableIndex\":null,\"targetType\":1,\"targetId\":\"12345678-1234-1234-1234-123456789012\",\"metadataOverrides\":null,\"id\":\"12345678-1234-1234-1234-123456789012\"},\"salesChannels\":[{\"id\":\"12345678-1234-1234-1234-123456789012\",\"status\":1,\"maxQuantityPerCart\":null,\"minQuantityPerCart\":null,\"quantitySettings\":null,\"productVolumeDiscountId\":null},{\"id\":\"12345678-1234-1234-1234-123456789012\",\"status\":1,\"maxQuantityPerCart\":null,\"minQuantityPerCart\":null,\"quantitySettings\":null,\"productVolumeDiscountId\":null}],\"productOptionSetId\":null,\"baseUnit\":null,\"googleTaxonomyId\":null,\"dynamicPriceListIds\":null,\"productVolumeDiscountId\":null,\"brand\":null,\"id\":\"12345678-1234-1234-1234-123456789012\",\"createdAt\":\"2024-07-11T21:20:50.506Z\",\"updatedAt\":\"2024-07-11T21:20:50.506Z\",\"merchantId\":\"12345678-1234-1234-1234-123456789012\"}",
"id":"12345678-1234-1234-1234-123456789012-12345678-1234-1234-1234-123456789012",
"merchantId":"12345678-1234-1234-1234-123456789012",
"scope":"store/product/created",
"signature":"373045525decbad86b3a09f4bac07cd2a6611801c8a2c9ec9be4973be269a522"
}
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

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