-
Notifications
You must be signed in to change notification settings - Fork 495
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
Customer API endpoint doesn't update metadata #995
Comments
I believe you should use PUT request on papercups/lib/chat_api_web/router.ex Line 52 in 7c850c4
The reason papercups/lib/chat_api/customers.ex Lines 254 to 258 in 7c850c4
papercups/lib/chat_api/customers/customer.ex Lines 91 to 119 in 7c850c4
But when you look at changeset used in papercups/lib/chat_api/customers/customer.ex Lines 121 to 143 in 7c850c4
|
Thanks for the lead @jeepers3327! I forgot to mention in my initial description that I did try a
even though the FWIW: I also tried |
Hi @CharlesMangwa, Note: I don't really launch the application on my local or the hosted version, I just give out advice based on the code. |
hey @jeepers3327, thanks for your help, it's much appreciated! There seem to be different scopes actually: papercups/lib/chat_api_web/router.ex Line 35 in 1ad023a
papercups/lib/chat_api_web/router.ex Line 182 in 1ad023a
with only the former accepting papercups/lib/chat_api_web/router.ex Line 52 in 1ad023a
That could explain why trying to access
as papercups/lib/chat_api_web/router.ex Line 51 in 1ad023a
|
Have you checked if metadata field was filled when you update it or does it nullify the current metadata value |
There's no metadata ( |
Hi @CharlesMangwa, I've found the bug and how to fix it, though I need to ask for confirmation from @reichert621 regarding the fix. From line 131 - 142, it fetches papercups/lib/chat_api_web/controllers/customer_controller.ex Lines 127 to 144 in 7c850c4
Based from the line map transformation the given map below (came from PUT request):
will become
and since updating a metadata calls papercups/lib/chat_api/customers/customer.ex Lines 121 to 142 in 7c850c4
FixThe fix is actually simple, instead of papercups/lib/chat_api/customers.ex Lines 284 to 290 in 7c850c4
I make it like this
After applying the change, here's what Ecto.Changeset prints out.
|
Hey @jeepers3327! Do you think you could put up a PR with this fix pls? |
My apologies @CharlesMangwa for delay PR , I've been away for about a month due to unforeseen events. |
No worries @jeepers3327! Take care of yourself first, the PR can wait 🙌 |
Closed by #1000 (comment). |
Describe the bug
After following the docs to update a customer, the metadata is always returned as
null
.To Reproduce
Steps to reproduce the behavior:
Bearer
token & make aGET
request to retrieve any customerid
viahttps://app.papercups.io/api/v1/customers/
id
, make aPUT
request tohttps://app.papercups.io/api/v1/customers/[id]/
with a body, ie:200
butdata.metadata
is stillnull
Expected behavior
data.metadata
would return the provided"random_custom_field": "034c0f85-0be3-4086-acf8-85ed8f4f1228",
.The text was updated successfully, but these errors were encountered: