Skip to content

refactor: unify api.send_*_request() functions#435

Merged
raphael0202 merged 1 commit intoopenfoodfacts:developfrom
Freso:send_request
Mar 3, 2026
Merged

refactor: unify api.send_*_request() functions#435
raphael0202 merged 1 commit intoopenfoodfacts:developfrom
Freso:send_request

Conversation

@Freso
Copy link
Copy Markdown
Contributor

@Freso Freso commented Feb 15, 2026

Description

  • Right now we have 3 different send_*_request() functions that all implement a lot of the same logic and mostly only differ in the HTTP method used.
  • This means that if we want to add additional HTTP method calls (e.g., Folksonomy’s API has DELETE and PUT endpoints), it would require more send_*_request() functions which again would need to implement some of the same logic again and just add more functions needed to maintain for downstream end-users.

Solution

  • This creates a new function, _send_request(), which combines the functionality of the three existing send_*_request() functions
  • It also makes the three api.send_*_request() functions wrappers around this new function and deprecates them so they can be removed in 4.0.0.

@Freso
Copy link
Copy Markdown
Contributor Author

Freso commented Feb 17, 2026

I’ve added a couple of tests, but not sure what other tests to add for now, esp. given most of the “pathways” are getting testing via the TestProducts class.

Freso added a commit to Freso/openfoodfacts-python that referenced this pull request Feb 17, 2026
Freso added a commit to Freso/openfoodfacts-python that referenced this pull request Feb 21, 2026
Comment thread src/openfoodfacts/api.py Outdated
Comment thread src/openfoodfacts/api.py Outdated
Comment thread src/openfoodfacts/api.py
Copy link
Copy Markdown
Contributor

@raphael0202 raphael0202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, that's better this way indeed! :)
I added a couple of comments

@github-project-automation github-project-automation Bot moved this from In progress to Review in progress in 🐍 Python SDK - Keep on par with the API Feb 27, 2026
@Freso Freso force-pushed the send_request branch 2 times, most recently from d00bc07 to 941b8c6 Compare March 2, 2026 10:15
\## Description

- Right now we have 3 different `send_*_request()` functions that all
  implement a lot of the same logic and mostly only differ in the HTTP
  method used.
- This means that if we want to add additional HTTP method calls (e.g.,
  Folksonomy’s API has `DELETE` and `PUT` endpoints), it would require
  more `send_*_request()` functions which again would need to implement
  some of the same logic again and just add more functions needed to
  maintain for downstream end-users.

\## Solution

- This creates a new function, `send_request()`, which combines the
  functionality of the three existing `send_*_request()` functions
- It also makes the three `api.send_*_request()` functions wrappers
  around this new function
@Freso Freso requested a review from raphael0202 March 2, 2026 10:35
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

@raphael0202 raphael0202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@github-project-automation github-project-automation Bot moved this from Review in progress to Reviewer approved in 🐍 Python SDK - Keep on par with the API Mar 3, 2026
@raphael0202 raphael0202 merged commit df7d26e into openfoodfacts:develop Mar 3, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from Reviewer approved to Done in 🐍 Python SDK - Keep on par with the API Mar 3, 2026
@Freso Freso deleted the send_request branch March 3, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants