Skip to content
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

Version handling #58

Merged
merged 4 commits into from
Apr 9, 2024
Merged

Version handling #58

merged 4 commits into from
Apr 9, 2024

Conversation

jfcumsille
Copy link
Contributor

@jfcumsille jfcumsille commented Apr 9, 2024

Description

No se podían hacer request con una versión de API especifica

Requirements

Se agrega la opción de pasarle una versión al cliente

@jfcumsille jfcumsille self-assigned this Apr 9, 2024
@jfcumsille jfcumsille force-pushed the version_handling branch 2 times, most recently from 7f05485 to 1351b53 Compare April 9, 2024 17:26
@jfcumsille jfcumsille requested a review from daleal April 9, 2024 17:40

def create_client(self, params=False):
if not params:
def create_client(self, params=False, version=False):
Copy link
Member

Choose a reason for hiding this comment

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

Acá version debería ser None, y de ahí revisar if version is None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

jaja no había cachado que habías comentado e hice rebase :shame:. Lo cambié a None y al final no fue necesario el if, se lo paso siempre no más y quedó el if del params solamente

Comment on lines 20 to 21
if params and not version:
return Client(
self.base_url, self.api_key, self.user_agent, params=self.params
)
if not params and version:
return Client(
self.base_url, self.api_key, self.user_agent, version=self.version
)
Copy link
Member

Choose a reason for hiding this comment

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

Así te ahorrai uno de estos if, puedes pasarle la versión siempre

@@ -12,11 +12,26 @@ def setup_method(self):
self.api_key = "super_secret_api_key"
self.user_agent = "fintoc-python/test"
self.params = {"first_param": "first_value", "second_param": "second_value"}
self.version = "2023-01-01"
Copy link
Member

Choose a reason for hiding this comment

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

La idea es defaultear siempre None, y que cuando llames al inicializador de Fintoc puedas pasarle una versión si quieres sobreescribir la default

@jfcumsille jfcumsille requested a review from daleal April 9, 2024 18:24
Copy link
Member

@daleal daleal left a comment

Choose a reason for hiding this comment

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

Buena! Dejé un miiiini comentario (para sacar algo del código nuevo). Además, haría un test extra en la clase Fintoc que inicialice la clase con el API version y después chequee que el headers del cliente incluye el Fintoc-Version, y otro que inicialice la clase sin API version y chequee que los headers del cliente no incluyen Fintoc-Version, para que sea lo más E2E posible dentro del flujo de ese parámetro

fintoc/client.py Outdated
@@ -62,6 +71,7 @@ def extend(
return Client(
base_url=base_url or self.base_url,
api_key=api_key or self.api_key,
api_version=api_version or self.api_version,
Copy link
Member

Choose a reason for hiding this comment

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

Encuentro que la API version debería siempre extenderse de la del parent. Así que acá sacaría el parámetro api_version del método extend y diría solamente api_version=self.api_version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

buenaa! ahi subí unas mejoras 🙂

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (dd44e61) to head (7053901).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #58   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           45        45           
  Lines          462       466    +4     
=========================================
+ Hits           462       466    +4     
Files Coverage Δ
fintoc/client.py 100.00% <100.00%> (ø)
fintoc/core.py 100.00% <100.00%> (ø)

@jfcumsille jfcumsille requested a review from daleal April 9, 2024 18:58
Copy link
Member

@daleal daleal left a comment

Choose a reason for hiding this comment

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

Se ve genial!

@jfcumsille jfcumsille merged commit 67486da into master Apr 9, 2024
5 checks passed
@jfcumsille jfcumsille deleted the version_handling branch April 9, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants