Skip to content

Commit

Permalink
fix: se soluciona problemas con sendContacts para el provider meta
Browse files Browse the repository at this point in the history
se corrige el nombre phone a phones (plural) y se pasa por el map para recibir los phones.
se adicionan todos los campos soportados por meta (addresses, emails, urls, org, etc)
  • Loading branch information
Jorge Chavarriaga committed Nov 9, 2023
1 parent b5e57e0 commit 3bcbb97
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 20 deletions.
Empty file modified .husky/commit-msg
100644 → 100755
Empty file.
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
Empty file modified .husky/pre-push
100644 → 100755
Empty file.
66 changes: 46 additions & 20 deletions packages/provider/src/meta/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,14 @@ class MetaProvider extends ProviderClass {
text: 'text-string',
},
{
type: "currency",
type: 'currency',
currency: {
fallback_value: "$100.99",
code: "USD",
amount_1000: 100990
}
fallback_value: '$100.99',
code: 'USD',
amount_1000: 100990,
},
},
]
],
},
{
type: 'button',
Expand All @@ -410,13 +410,13 @@ class MetaProvider extends ProviderClass {
parameters: [
{
type: 'payload',
payload: 'aGlzIHRoaXMgaXMgY29v'
payload: 'aGlzIHRoaXMgaXMgY29v',
},
],
},
]
],
},
};
}
return this.sendMessageMeta(body)
}

Expand All @@ -431,14 +431,40 @@ class MetaProvider extends ProviderClass {
const parseContacts = contact.map((contact) => ({
name: {
formatted_name: contact.name,
first_name: contact.first_name,
last_name: contact.last_name,
middle_name: contact.middle_name,
suffix: contact.suffix,
prefix: contact.prefix,
},
phone: [
{
phone: contact.phone,
wa_id: contact.phone,
type: 'MOBILE',
},
],
birthday: contact.birthday,
phones: contact.phones.map((phone) => ({
phone: phone.phone,
wa_id: phone.wa_id,
type: phone.type,
})),
emails: contact.emails.map((email) => ({
email: email.email,
type: email.type,
})),
org: {
company: contact.company,
department: contact.department,
title: contact.title,
},
urls: contact.urls.map((url) => ({
url: url.url,
type: url.type,
})),
addresses: contact.addresses.map((address) => ({
street: address.street,
city: address.city,
state: address.state,
zip: address.zip,
country: address.country,
country_code: address.counry_code,
type: address.type,
})),
}))

const body = {
Expand Down Expand Up @@ -474,10 +500,10 @@ class MetaProvider extends ProviderClass {
action: {
name: 'catalog_message',
parameters: {
"thumbnail_product_retailer_id": itemCatalogId,
}
}
}
thumbnail_product_retailer_id: itemCatalogId,
},
},
},
}
return this.sendMessageMeta(body)
}
Expand Down

0 comments on commit 3bcbb97

Please sign in to comment.