Skip to content
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

[D] Feat/thinkific #6

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
87 changes: 8 additions & 79 deletions package-lock.json

Large diffs are not rendered by default.

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
4 changes: 2 additions & 2 deletions packages/pieces/shopify/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ To Obtain an Admin Token, follow these steps:
3. Click on Develop apps
4. Create an App
5. Fill the app name
6. Click on Configure Admin API Scopes (Select the following scopes 'read_orders', 'read_customers')
6. Click on Configure Admin API Scopes (Select the following scopes 'read_orders', 'read_customers') Note: Some steps may require more sensitive scopes
7. Click on Install app
8. Copy the Admin Access Token

**Shop Name**
1- You can find your shop name in the url For example, if the URL is https://example.myshopify.com/admin, then your shop name is **example**.
`
`;

export const shopifyAuth = PieceAuth.CustomAuth({
description: markdown,
Expand Down
149 changes: 149 additions & 0 deletions packages/pieces/shopify/src/lib/actions/create-customer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import {
createAction,
Property,
Validators,
} from '@activepieces/pieces-framework';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { shopifyAuth } from '../..';

export const createCustomer = createAction({
auth: shopifyAuth,
name: 'create_customer',
displayName: 'Create Customer',
description: 'Creates a customer.',

props: {
email: Property.ShortText({
displayName: 'Email',
required: true,
}),
firstName: Property.ShortText({
displayName: 'First Name',
required: true,
}),
lastName: Property.ShortText({
displayName: 'Last Name',
required: true,
}),
company: Property.ShortText({
displayName: 'Company',
required: false,
}),
street_address: Property.ShortText({
displayName: 'Street Address',
required: false,
}),

street_address_2: Property.ShortText({
displayName: 'Street Address 2',
required: false,
}),
city: Property.ShortText({
displayName: 'City',
required: false,
}),
state: Property.ShortText({
displayName: 'State/Province code',
required: false,
}),
country: Property.ShortText({
displayName: 'Country code',
required: false,
}),
zipcode: Property.ShortText({
displayName: 'Zip Code',
required: false,
}),

mark_email_as_verified: Property.Checkbox({
displayName: 'Mark Email as Verified',
required: true,
}),
phone: Property.ShortText({
displayName: 'Phone',
required: false,
}),
tags: Property.ShortText({
displayName: 'Tags',
required: false,
}),
note: Property.LongText({
displayName: 'Note',
required: false,
}),
accepts_marketing: Property.Checkbox({
displayName: 'Accepts Marketing',
required: false,
}),
tax_exempt: Property.Checkbox({
displayName: 'Tax Exempt',
required: false,
}),
send_email_invite: Property.Checkbox({
displayName: 'Send Email Invite',
required: false,
}),
},

async run(context) {
const {
email,
firstName,
lastName,
company,
street_address,
street_address_2,
city,
state,
country,
zipcode,
phone,
tags,
note,
accepts_marketing = false,
tax_exempt = false,
send_email_invite = false,
} = context.propsValue;

const shopName = context.auth.shopName;
const adminToken = context.auth.adminToken;

const response = await httpClient.sendRequest<{
customer: {
id: string;
};
}>({
method: HttpMethod.POST,
url: `https://${shopName}.myshopify.com/admin/api/2023-01/customers.json`,
headers: {
'X-Shopify-Access-Token': adminToken,
},
body: {
customer: {
email,
first_name: firstName,
last_name: lastName,
company,
addresses: [
{
address1: street_address,
address2: street_address_2,
city,
province: state,
country,
zip: zipcode,
},
],
send_email_invite,
phone,
tags,
note,
accepts_marketing,
tax_exempt,
},
},
});

return [response.body.customer];
},
});
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
22 changes: 22 additions & 0 deletions packages/pieces/shopify/src/lib/triggers/new-dispute.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { createShopifyWebhookTrigger } from '../common/register-webhook';

export const newDispute = createShopifyWebhookTrigger({
name: 'new_dispute',
description: 'Triggered when a new dispute is created',
topic: 'disputes/create',
displayName: 'New Dispute',
sampleData: {
id: 285332461850802050,
order_id: 820982911946154500,
type: 'chargeback',
amount: '11.50',
currency: 'CAD',
reason: 'fraudulent',
network_reason_code: '4837',
status: 'under_review',
evidence_due_by: '2021-12-30T19:00:00-05:00',
evidence_sent_on: null,
finalized_on: null,
initiated_at: '2021-12-31T19:00:00-05:00',
},
});
85 changes: 85 additions & 0 deletions packages/pieces/shopify/src/lib/triggers/new-product.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { createShopifyWebhookTrigger } from '../common/register-webhook';

export const newProduct = createShopifyWebhookTrigger({
name: 'new_product',
description: 'Triggered when a new product is created',
topic: 'products/create',
displayName: 'New Product',
sampleData: {
admin_graphql_api_id: 'gid://shopify/Product/788032119674292922',
body_html: 'An example T-Shirt',
created_at: null,
handle: 'example-t-shirt',
id: 788032119674292900,
product_type: 'Shirts',
published_at: '2021-12-31T19:00:00-05:00',
template_suffix: null,
title: 'Example T-Shirt',
updated_at: '2021-12-31T19:00:00-05:00',
vendor: 'Acme',
status: 'active',
published_scope: 'web',
tags: 'example, mens, t-shirt',
variants: [
{
admin_graphql_api_id: 'gid://shopify/ProductVariant/642667041472713922',
barcode: null,
compare_at_price: '24.99',
created_at: null,
fulfillment_service: 'manual',
id: 642667041472714000,
inventory_management: 'shopify',
inventory_policy: 'deny',
position: 0,
price: '19.99',
product_id: 788032119674292900,
sku: 'example-shirt-s',
taxable: true,
title: '',
updated_at: null,
option1: 'Small',
option2: null,
option3: null,
grams: 200,
image_id: null,
weight: 200,
weight_unit: 'g',
inventory_item_id: null,
inventory_quantity: 75,
old_inventory_quantity: 75,
requires_shipping: true,
},
{
admin_graphql_api_id: 'gid://shopify/ProductVariant/757650484644203962',
barcode: null,
compare_at_price: '24.99',
created_at: null,
fulfillment_service: 'manual',
id: 757650484644203900,
inventory_management: 'shopify',
inventory_policy: 'deny',
position: 0,
price: '19.99',
product_id: 788032119674292900,
sku: 'example-shirt-m',
taxable: true,
title: '',
updated_at: null,
option1: 'Medium',
option2: null,
option3: null,
grams: 200,
image_id: null,
weight: 200,
weight_unit: 'g',
inventory_item_id: null,
inventory_quantity: 50,
old_inventory_quantity: 50,
requires_shipping: true,
},
],
options: [],
images: [],
image: null,
},
});
36 changes: 36 additions & 0 deletions packages/pieces/shopify/src/lib/triggers/updated-customer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { createShopifyWebhookTrigger } from '../common/register-webhook';

export const updatedCustomer = createShopifyWebhookTrigger({
name: 'updated_customer',
description: 'Triggered when a customer is updated',
topic: 'customers/updated',
displayName: 'Updated Customer',
sampleData: {
id: 706405506930370000,
email: '[email protected]',
accepts_marketing: true,
created_at: '2021-12-31T19:00:00-05:00',
updated_at: '2021-12-31T19:00:00-05:00',
first_name: 'Bob',
last_name: 'Biller',
orders_count: 0,
state: 'disabled',
total_spent: '0.00',
last_order_id: null,
note: 'This customer loves ice cream',
verified_email: true,
multipass_identifier: null,
tax_exempt: false,
tags: '',
last_order_name: null,
currency: 'USD',
phone: null,
addresses: [],
accepts_marketing_updated_at: '2021-12-31T19:00:00-05:00',
marketing_opt_in_level: null,
tax_exemptions: [],
email_marketing_consent: null,
sms_marketing_consent: null,
admin_graphql_api_id: 'gid://shopify/Customer/706405506930370084',
},
});
Loading