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

Feat: update funding source expiry from concession group #36

Merged
merged 7 commits into from
Mar 21, 2024

Conversation

thekaveman
Copy link
Member

@thekaveman thekaveman commented Mar 18, 2024

Closes #29

Implements a generic PUT handler in the client, returning a ListResponse per the known API specs.

Implements update_concession_group_funding_source_expiry method to update the expiration of an existing funding source in a concession group. Parses the ListResponse and returns the first .list item. This should be the only list item according to the known API specs.

@thekaveman thekaveman added the api New API feature implementation or refactor label Mar 18, 2024
@thekaveman thekaveman self-assigned this Mar 18, 2024
Copy link

github-actions bot commented Mar 18, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  littlepay/api
  __init__.py 120
  client.py
  groups.py
Project Total  

This report was generated by python-coverage-comment-action

@thekaveman thekaveman force-pushed the feat/concession-expiry-put branch 2 times, most recently from 76fb5dd to 25ff58a Compare March 18, 2024 22:50
@thekaveman thekaveman linked an issue Mar 18, 2024 that may be closed by this pull request
Base automatically changed from feat/concession-expiry-post to main March 19, 2024 17:54
for a funding source already linked to a concession group
PUT returns a ListResponse, but with only a single item, so pull it out
and return that instead to simplify caller consumption
@thekaveman thekaveman marked this pull request as ready for review March 19, 2024 19:24
@thekaveman thekaveman requested a review from a team as a code owner March 19, 2024 19:24
@thekaveman
Copy link
Member Author

Question @angela-tran:

Do you think it makes sense to create a dataclass for the structure emitted by this PUT response? I.e.

{
  "id": "9002b586-9c53-43c6-b274-5615adb856ee",
  "participant_id": "test_participant",
  "concession_expiry": "2024-07-03T00:00:00Z",
  "concession_created_at": "2024-07-03T00:00:00Z",
  "concession_updated_at": "2024-07-03T00:00:00Z"
}

We could do some parsing of the datetime to make that easier to consume, and it would also be reused for #28. Or just leave it as a dict?

Thoughts?

@angela-tran
Copy link
Member

Question @angela-tran:

Do you think it makes sense to create a dataclass for the structure emitted by this PUT response? I.e.
...
We could do some parsing of the datetime to make that easier to consume, and it would also be reused for #28. Or just leave it as a dict?

Thoughts?

I think as a consumer, I would want to have the datetime objects rather than having to do the conversion myself, so the dataclass sounds good to me.

parses optional datetime values when provided
@thekaveman
Copy link
Member Author

thekaveman commented Mar 19, 2024

Thanks @angela-tran, PR is updated with a new dataclass and now ready for review.

Seeing a test failure in Python 3.10 related to parsing a datetime from ISO 8601 format 😠

Yep, it seems like before Python 3.11, datetime.fromisoformat() only supported the exact format output from datetime.isoformat() i.e. without the trailing Z character and with a time zone offset from UTC like +00:00 https://docs.python.org/3.11/library/datetime.html#datetime.datetime.fromisoformat

Return a datetime corresponding to a date_string in any valid ISO 8601 format...

Changed in version 3.11: Previously, this method only supported formats that could be emitted by date.isoformat() or datetime.isoformat().

I could update the code to handle this case, or we could move up to Python 3.11+ ... thoughts?

It felt easier to update the code than worry about changing compatibility with Python versions. Although benefits is using Python 3.11, it seems easier to support 3.10 for now.

@thekaveman thekaveman marked this pull request as draft March 19, 2024 20:56
@thekaveman thekaveman marked this pull request as ready for review March 19, 2024 21:21
@thekaveman thekaveman marked this pull request as draft March 19, 2024 21:36
support Python 3.10+ by fixing datetime parsing from known ISO 8601 format
with 'Z' offset character for UTC

see https://docs.python.org/3.11/library/datetime.html#datetime.datetime.fromisoformat
@thekaveman thekaveman marked this pull request as ready for review March 19, 2024 21:52
Copy link
Member

@angela-tran angela-tran left a comment

Choose a reason for hiding this comment

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

This looks good to me 👍

@thekaveman thekaveman merged commit 330428c into main Mar 21, 2024
3 checks passed
@thekaveman thekaveman deleted the feat/concession-expiry-put branch March 21, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api New API feature implementation or refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement PUT funding source expiry date endpoint
2 participants