Skip to content

Commit

Permalink
[16.0][FIX] account_statement_import_online_gocardless : Correction o…
Browse files Browse the repository at this point in the history
…f the endpoint token/refresh request datas, plus the behavior of the _gocardless_get_token method which in case of a non expired refresh token was calling the endpoint token/new instead of token/refresh
  • Loading branch information
arpol-dev committed Jan 7, 2025
1 parent 2298d49 commit 271ae91
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions account_statement_import_online_gocardless/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ Contributors
* `Alusage <https://nicolas.alusage.fr>`__:

* Nicolas JEUDY <https://github.com/njeudy>
* `ArPol <https://arpol.fr>`__:

* Armand POLMARD <https://github.com/arpol-dev>

Maintainers
~~~~~~~~~~~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ def _gocardless_get_token(self):
# Refresh token
if (
self.gocardless_refresh_token
and now > self.gocardless_refresh_expiration
and now < self.gocardless_refresh_expiration
):
endpoint = "token/refresh"
request_data = {"refresh": self.gocardless_refresh_token}

Check warning on line 90 in account_statement_import_online_gocardless/models/online_bank_statement_provider.py

View check run for this annotation

Codecov / codecov/patch

account_statement_import_online_gocardless/models/online_bank_statement_provider.py#L90

Added line #L90 was not covered by tests
else:
endpoint = "token/new"
request_data = {"secret_id": self.username, "secret_key": self.password}

Check warning on line 93 in account_statement_import_online_gocardless/models/online_bank_statement_provider.py

View check run for this annotation

Codecov / codecov/patch

account_statement_import_online_gocardless/models/online_bank_statement_provider.py#L93

Added line #L93 was not covered by tests
_response, data = self._gocardless_request(
endpoint,
request_type="post",
data=json.dumps(
{"secret_id": self.username, "secret_key": self.password}
),
data=json.dumps(request_data),
basic_auth=True,
)
expiration_date = now + relativedelta(seconds=data.get("access_expires", 0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
* `Alusage <https://nicolas.alusage.fr>`__:

* Nicolas JEUDY <https://github.com/njeudy>
* `ArPol <https://arpol.fr>`__:

* Armand POLMARD <https://github.com/arpol-dev>
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,10 @@ <h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
<li>Nicolas JEUDY &lt;<a class="reference external" href="https://github.com/njeudy">https://github.com/njeudy</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://arpol.fr">ArPol</a>:<ul>
<li>Armand POLMARD &lt;<a class="reference external" href="https://github.com/arpol-dev">https://github.com/arpol-dev</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down

0 comments on commit 271ae91

Please sign in to comment.