-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - ikas #12815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
New Components - ikas #12815
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
84b49c3
ikas init
luancazarine 96245ef
[Components] ikas #12409
luancazarine b360f04
Merge branch 'master' into issue-12409
luancazarine c23bd84
pnpm update
luancazarine 5e51023
Update components/ikas/sources/common/base.mjs
luancazarine bbff72b
some adjusts
luancazarine 131c257
fix descriptions
michelle0927 16712e9
Merge remote-tracking branch 'origin/master' into issue-12409
michelle0927 91ebcc5
add response data parse
luancazarine 0ebb240
fix test-events
luancazarine ae9eca8
fix test-events.mjs
michelle0927 f13cb75
Merge remote-tracking branch 'origin/master' into issue-12409
michelle0927 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
}, | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": [ | ||
|
@@ -11,5 +11,9 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.0.0" | ||
} | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import ikas from "../../ikas.app.mjs"; | ||
|
||
export default { | ||
props: { | ||
ikas, | ||
http: { | ||
type: "$.interface.http", | ||
customResponse: false, | ||
}, | ||
db: "$.service.db", | ||
alert: { | ||
type: "alert", | ||
alertType: "warning", | ||
content: "Please note that you can have only one webhook of each type at the same time, any change will overwrite the current webhook configuration.", | ||
}, | ||
}, | ||
methods: { | ||
_getWebhookId() { | ||
return this.db.get("webhookId"); | ||
}, | ||
_setWebhookId(webhookId) { | ||
return this.db.set("webhookId", webhookId); | ||
}, | ||
}, | ||
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._setWebhookId(data.saveWebhook[0].id); | ||
}, | ||
async deactivate() { | ||
const webhookId = this._getWebhookId(); | ||
if (webhookId) { | ||
await this.ikas.makeRequest({ | ||
data: { | ||
"query": `mutation { | ||
deleteWebhook(scopes: ["${this.getScope()}"]) | ||
}`, | ||
}, | ||
}); | ||
} | ||
}, | ||
}, | ||
async run({ body }) { | ||
const data = JSON.parse(body.data); | ||
body.data = data; | ||
|
||
this.$emit(body, { | ||
id: body.id, | ||
summary: this.getSummary(data), | ||
ts: Date.parse(body.createdAt), | ||
}); | ||
}, | ||
}; |
22 changes: 22 additions & 0 deletions
22
components/ikas/sources/new-customer-instant/new-customer-instant.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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(data) { | ||
return `New customer created with Id: ${data.id}.`; | ||
}, | ||
}, | ||
sampleEmit, | ||
}; |
40 changes: 40 additions & 0 deletions
40
components/ikas/sources/new-customer-instant/test-event.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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", | ||
}; |
22 changes: 22 additions & 0 deletions
22
components/ikas/sources/new-order-instant/new-order-instant.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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. **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/order/created"; | ||
}, | ||
getSummary(data) { | ||
return `New order created with Id: ${data.id}.`; | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
sampleEmit, | ||
}; |
106 changes: 106 additions & 0 deletions
106
components/ikas/sources/new-order-instant/test-event.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
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", | ||
}; |
22 changes: 22 additions & 0 deletions
22
components/ikas/sources/new-product-instant/new-product-instant.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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. **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/product/created"; | ||
}, | ||
getSummary(data) { | ||
return `New product created with Id: ${data.id}.`; | ||
}, | ||
}, | ||
sampleEmit, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.