❔ Need some advise regarding HTTP Request
Hello, I have a few operations here and would appreciate some guidance on how to carry them out.
I therefore have a payer table. It has a column for the remaining balance.
Additionally, I have a contribution table where the funds from payers go.
I must update the Payer's remaining Balance if the payer adds a contribution (HTTP POST).
Should I have to make two APIs?
1. Making a Contribution
2. Updating the balance that remains
Or a single API that updates the remaining balance and create contributions?
16 Replies
you should separate this
because one is chained to the other
it's a conditional case 1 yes -> case 2 yes
case 1 no -> case 2 no
also update sounds more like a patch
not a post
you probably have to affect more tables
so yes
post + patch
Oh yes! I understand now!
for transaction history + balances
Patch kinda new to me. I will make some research on this one
is your balance calculated every time or do you store it?
stored
then patch
what is the difference between put?
patch = partial
put = total
Name: John Doe
Age: 21
Address: No Number 22
Patch:
Name = Jane Doe
Put:
Name = Jane Doe
Age = 21
Address: No Number 22
if u do put wrong you mess everything up
if you do
Put:
Name: Jane Doe
then do get you will only get
Name: Jane Doe
depends on the system
you might get everything else null, don't know the outcomes
but it's bad
put modifies the entire entity, patch only modifies it partially
post creates entities
so if i only modify the Balance its recommended to use patch
if you are not modifying the entire entity
always patch
Yes, thankyou very much. It is a big help to me!
Didn't knoe there is a way like this!
the exact definition of put is
modify the entire entity or create it
so it's kinda like a post with steroids
very dangerous
I will take note on this. Thank you very much!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.