Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Update parser for payment requirement fields #26

Merged
merged 1 commit into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions duffel_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ def maybe_parse_date_entries(key, value):
"pay_by",
"confirmed_at",
"cancelled_at",
"price_guarantee_expires_at",
"synced_at",
"payment_required_by",
]:
return datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%fZ")

if key in [
"price_guarantee_expires_at",
"payment_required_by",
]:
return datetime.strptime(value, "%Y-%m-%dT%H:%M:%SZ")

if key in [
"departing_at",
"arriving_at",
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/create-offer-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
}
],
"payment_requirements": {
"payment_required_by": "2020-01-17T10:42:14.545Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14.545Z",
"payment_required_by": "2020-01-17T10:42:14Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14Z",
"requires_instant_payment": false
},
"slices": [
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/create-order.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
],
"payment_status": {
"awaiting_payment": true,
"payment_required_by": "2020-01-17T10:42:14.545Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14.545Z"
"payment_required_by": "2020-01-17T10:42:14Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14Z"
},
"payments": [
{
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/get-offer-by-id.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
}
],
"payment_requirements": {
"payment_required_by": "2020-01-17T10:42:14.545Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14.545Z",
"payment_required_by": "2020-01-17T10:42:14Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14Z",
"requires_instant_payment": false
},
"slices": [
Expand Down Expand Up @@ -230,4 +230,4 @@
"total_emissions_kg": "460",
"updated_at": "2020-01-17T10:12:14.545Z"
}
}
}
6 changes: 3 additions & 3 deletions tests/fixtures/get-offer-request-by-id.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
}
],
"payment_requirements": {
"payment_required_by": "2020-01-17T10:42:14.545Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14.545Z",
"payment_required_by": "2020-01-17T10:42:14Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14Z",
"requires_instant_payment": false
},
"slices": [
Expand Down Expand Up @@ -311,4 +311,4 @@
}
]
}
}
}
6 changes: 3 additions & 3 deletions tests/fixtures/get-offer-requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
}
],
"payment_requirements": {
"payment_required_by": "2020-01-17T10:42:14.545Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14.545Z",
"payment_required_by": "2020-01-17T10:42:14Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14Z",
"requires_instant_payment": false
},
"slices": [
Expand Down Expand Up @@ -317,4 +317,4 @@
"after": "g2wAAAACbQAAABBBZXJvbWlzdC1LaGFya2l2bQAAAB=",
"limit": 50
}
}
}
6 changes: 3 additions & 3 deletions tests/fixtures/get-offers.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
}
],
"payment_requirements": {
"payment_required_by": "2020-01-17T10:42:14.545Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14.545Z",
"payment_required_by": "2020-01-17T10:42:14Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14Z",
"requires_instant_payment": false
},
"slices": [
Expand Down Expand Up @@ -219,4 +219,4 @@
"after": "g2wAAAACbQAAABBBZXJvbWlzdC1LaGFya2l2bQAAAB=",
"limit": 50
}
}
}
4 changes: 2 additions & 2 deletions tests/fixtures/get-order-by-id.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
],
"payment_status": {
"awaiting_payment": true,
"payment_required_by": "2020-01-17T10:42:14.545Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14.545Z"
"payment_required_by": "2020-01-17T10:42:14Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14Z"
},
"services": [
{
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/get-orders.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
],
"payment_status": {
"awaiting_payment": true,
"payment_required_by": "2020-01-17T10:42:14.545Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14.545Z"
"payment_required_by": "2020-01-17T10:42:14Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14Z"
},
"payments": [
{
Expand Down Expand Up @@ -260,4 +260,4 @@
"after": "g2wAAAACbQAAABBBZXJvbWlzdC1LaGFya2l2bQAAAB=",
"limit": 50
}
}
}
4 changes: 2 additions & 2 deletions tests/fixtures/update-order-by-id.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
],
"payment_status": {
"awaiting_payment": true,
"payment_required_by": "2020-01-17T10:42:14.545Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14.545Z"
"payment_required_by": "2020-01-17T10:42:14Z",
"price_guarantee_expires_at": "2020-01-17T10:42:14Z"
},
"services": [
{
Expand Down