question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Discussion] Updates in the Greenfield API

See original GitHub issue

We need to take a decision over how to do updates in BTCPayServer, and then keep consistency.

Should a POST update the whole structure or only specified field.

Imagine I want to update store with id 123 to my awesome store.

Should make POST handle partial update like: POST/PUT or PATCH /store/123

{
  "name": "my awesome store"
}

Or should POST update the whole thing, where you need to first GET /store/123

{
   "name" : "old name",
   "payjoinEnabled": true,
   "defaultCurrency": "USD"
}

Then update the whole thing POST /store/123

{
   "name" : "Awesome store",
   "payjoinEnabled": true,
   "defaultCurrency": "USD"
}

If some fields are not initialized, the server assume that it is set to a default value and update the field.

I am rejecting the following alternative:

  • Make both POST and PUT. This would double the amount of work for us, while not providing something that still can’t be done already whichever what solution we chose.
  • Using JSON PATCH. This is completely untyped, difficult to use, and not really spread anyway.

I checked how for example did slack API, and they seem to support POST with partial updates.

Twitter is also doing POST with partial update, but instead pass all by query string.

I think that from API perspective it makes sense to support partial update for POST.

Two API that need to be fixed if we decided to go that route:

  • Update payment requests
  • Update store

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
Kukkscommented, May 30, 2020

If you’re triggering some action based on a specific property change, you still need to validate that the value changed in comparison to the old value, so there is nothing gained in that regard.

I think it’s much more likely that you would have the whole object on the client, and if not, you can easily retrieve it before you update.

On Sat, 30 May 2020, 15:03 kmenashe, notifications@github.com wrote:

IMHO, Handling property related update logic (if any at all) is more cleaner with partial update

Can you elaborate?

Just takking from my experience I had recently…say you have a property update that triggers some post update actions. If you have full input object, you need to figure out what property was change and act upon. Partial specifies the relevant properties so no need to identify them. In addition, some times you don’t have the entire object on the client, and partial will still allow you to update. Hope I am making sense here.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/btcpayserver/btcpayserver/issues/1617#issuecomment-636328106, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN357SGLOTVEWN5GZ3A5N3RUD7Y3ANCNFSM4NOQ4DUQ .

1reaction
KfirMenashecommented, May 30, 2020

IMHO, Handling property related update logic (if any at all) is more cleaner with partial update

Can you elaborate?

Just takking from my experience I had recently…say you have a property update that triggers some post update actions. If you have full input object, you need to figure out what property was change and act upon. Partial specifies the relevant properties so no need to identify them. In addition, some times you don’t have the entire object on the client, and partial will still allow you to update. Hope I am making sense here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

BTCPay Greenfield API (v1)
BTCPay Server supports authenticating and authorizing users through an API Key that is generated by them. Send the API Key as a header...
Read more >
Greenfield Executable (Design Proposal)
Provides Greenfield executable SDK APIs for each language ... destroying the execution environment, and updating the receipt on-chain.
Read more >
BTCPay Server v1.7.6: Vulnerability Fixes and API Updates
Free, open-source & self-hosted, Bitcoin payment processor. BTCPay Server v1.7.6: Vulnerability Fixes and API Updates. There are two ...
Read more >
How to work in the Greenfield Workspace
Each patient will work within the Greenfield Workspace testing app or through any software with RESTful API calls. If you have a request...
Read more >
Brownfield vs. Greenfield Development: What's the ...
Greenfield projects in software development, there are plenty of differences. ... or updating some amount of existing code or enabling integrations.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found