Skip to content

Commit

Permalink
fix: fix state queryparam value
Browse files Browse the repository at this point in the history
  • Loading branch information
kishanprmr committed Mar 18, 2024
1 parent 00d4e4e commit 534ecc0
Showing 1 changed file with 83 additions and 73 deletions.
156 changes: 83 additions & 73 deletions packages/pieces/community/freshdesk/src/lib/actions/get-contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,99 +6,109 @@ export const getContacts = createAction({
auth: freshdeskAuth,
name: 'get_contacts',
displayName: 'Get Freshdesk Contacts',
description: 'Get contact details from Freshdesk for all (optional filtered) contacts.',
description:
'Get contact details from Freshdesk for all (optional filtered) contacts.',

props: {
filter_type: Property.StaticDropdown({
displayName: 'Optional Filter',
description: 'Select one and provide the value.',
defaultValue: '',
required: false,
options: {
options: [
{
label: 'E-mail',
value: 'email'
},
{
label: 'Mobile',
value: 'mobile'
},
{
label: 'Phone',
value: 'phone'
},
{
label: 'Company ID',
value: 'company_id'
},
{
label: 'Updated Since',
value: 'updated_since'
}
]
}
displayName: 'Optional Filter',
description: 'Select one and provide the value.',
defaultValue: '',
required: false,
options: {
options: [
{
label: 'E-mail',
value: 'email',
},
{
label: 'Mobile',
value: 'mobile',
},
{
label: 'Phone',
value: 'phone',
},
{
label: 'Company ID',
value: 'company_id',
},
{
label: 'Updated Since',
value: 'updated_since',
},
],
},
}),
filter_value: Property.ShortText({
displayName: 'Filter value',
description: 'Provide value if previous option selected!',
required: false,
defaultValue: ''
filter_value: Property.ShortText({
displayName: 'Filter value',
description: 'Provide value if previous option selected!',
required: false,
defaultValue: '',
}),
filter_status: Property.StaticDropdown({
displayName: 'Optional Filter Status',
description: 'Can filter by state: blocked, deleted, unverified or verified.',
defaultValue: '',
required: false,
options: {
options: [
{
label: 'Blocked',
value: 'state=blocked'
},
{
label: 'Deleted',
value: 'state=deleted'
},
{
label: 'Unverified',
value: 'state=unverified'
},
{
label: 'Verified',
value: 'state=verified'
}
]
},
}),
per_page: Property.Number({
displayName: 'Results to return',
description: 'Freshdesk calls this per_page - set to 0 for all, if specified maximum is 100',
required: true,
defaultValue: 0,
}),
},
filter_status: Property.StaticDropdown({
displayName: 'Optional Filter Status',
description:
'Can filter by state: blocked, deleted, unverified or verified.',
defaultValue: '',
required: false,
options: {
options: [
{
label: 'Blocked',
value: 'blocked',
},
{
label: 'Deleted',
value: 'deleted',
},
{
label: 'Unverified',
value: 'unverified',
},
{
label: 'Verified',
value: 'verified',
},
],
},
}),
per_page: Property.Number({
displayName: 'Results to return',
description:
'Freshdesk calls this per_page - set to 0 for all, if specified maximum is 100',
required: true,
defaultValue: 0,
}),
},


async run(context) {
const FDapiToken = context.auth.access_token;


const headers = {
Authorization: FDapiToken,
'Content-Type': 'application/json',
};

// not needed for gettickets ?${queryParams.toString()}
const queryParams = new URLSearchParams();
if (context.propsValue.filter_type?.valueOf != null && context.propsValue.filter_value?.valueOf != null) {
queryParams.append(context.propsValue.filter_type?.toString(), context.propsValue.filter_value || '');
if (
context.propsValue.filter_type?.valueOf != null &&
context.propsValue.filter_value?.valueOf != null
) {
queryParams.append(
context.propsValue.filter_type?.toString(),
context.propsValue.filter_value || ''
);
}
if (context.propsValue.filter_status?.valueOf != null) {
queryParams.append('', context.propsValue.filter_status || '');
queryParams.append('state', context.propsValue.filter_status || '');
}
if (context.propsValue.per_page != 0) {
queryParams.append('per_page', context.propsValue.per_page.toString() || '100');
queryParams.append(
'per_page',
context.propsValue.per_page.toString() || '100'
);
}
// Remove trailing slash from base_url
const baseUrl = context.auth.base_url.replace(/\/$/, '');
Expand Down

0 comments on commit 534ecc0

Please sign in to comment.