Skip to content

Commit c306db0

Browse files
authored
Add date filter on charge list (#75)
## Description Added date filtering to charge list.
1 parent 8fb13c6 commit c306db0

6 files changed

Lines changed: 27 additions & 13 deletions

File tree

.github/workflows/code-coverage.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: ["3.11"]
10+
python-version: ["3.13"]
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v4
1313
- name: Set up Python ${{ matrix.python-version }}
14-
uses: actions/setup-python@v1
14+
uses: actions/setup-python@v5
1515
with:
1616
python-version: ${{ matrix.python-version }}
1717
- name: Install dependencies
1818
run: |
1919
python -m pip install --upgrade pip .[tests]
20+
pip install setuptools
2021
- name: Run Test
2122
run: coverage run -m unittest
2223
- name: Generate report

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010

1111
steps:
1212
- name: Checkout code
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v4
1414

1515
- name: Set up Python
16-
uses: actions/setup-python@v2
16+
uses: actions/setup-python@v5
1717
with:
1818
python-version: 3.9
1919

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
12+
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13"]
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515
- name: Set up Python ${{ matrix.python-version }}
16-
uses: actions/setup-python@v1
16+
uses: actions/setup-python@v5
1717
with:
1818
python-version: ${{ matrix.python-version }}
1919
- name: Install dependencies

omise/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,12 @@ def retrieve(cls, charge_id=None):
737737
return _as_object(cls._request('get', cls._collection_path()))
738738

739739
@classmethod
740-
def list(cls):
740+
def list(cls, **kwargs):
741741
"""Return all charges that belongs to your account
742742
743743
:rtype: LazyCollection
744744
"""
745-
return LazyCollection(cls._collection_path())
745+
return LazyCollection(cls._collection_path(), fromDate=kwargs.pop('fromDate', None), toDate=kwargs.pop('toDate', None))
746746

747747
def reload(self):
748748
"""Reload the charge details.
@@ -1050,9 +1050,12 @@ def schedule(self):
10501050

10511051
class LazyCollection(object):
10521052
"""Proxy class representing a lazy collection of items."""
1053-
def __init__(self, collection_path):
1053+
1054+
def __init__(self, collection_path, **kwargs):
10541055
self.collection_path = collection_path
10551056
self._exhausted = False
1057+
self.fromDate = kwargs.pop('fromDate', None)
1058+
self.toDate = kwargs.pop('toDate', None)
10561059

10571060
def __len__(self):
10581061
return self._fetch_objects(limit=1, offset=0)['total']
@@ -1104,14 +1107,18 @@ def _update_listing(self, data):
11041107

11051108
def _fetch_objects(self, **kwargs):
11061109
order = kwargs.pop('order', None)
1110+
fromDate = self.fromDate
1111+
toDate = self.toDate
11071112

11081113
return Request(api_secret, api_main, api_version).send(
11091114
'get',
11101115
self.collection_path,
11111116
payload={
11121117
'limit': kwargs['limit'],
11131118
'offset': kwargs['offset'],
1114-
'order': order
1119+
'order': order,
1120+
'from': fromDate,
1121+
'to': toDate
11151122
}
11161123
)
11171124

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,9 @@
4040
"Programming Language :: Python :: 3.7",
4141
"Programming Language :: Python :: 3.8",
4242
"Programming Language :: Python :: 3.9",
43+
"Programming Language :: Python :: 3.10",
44+
"Programming Language :: Python :: 3.11",
45+
"Programming Language :: Python :: 3.12",
46+
"Programming Language :: Python :: 3.13",
4347
"Topic :: Software Development :: Libraries :: Python Modules",
4448
])

tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
[tox]
2-
envlist = py27, py37, py38, py39, py310, py311
2+
envlist = py27, py37, py38, py39, py310, py311, py312, py313
33

44
[testenv]
5+
deps =
6+
setuptools
57
commands =
68
pip install ".[tests]"
79
python -m unittest

0 commit comments

Comments
 (0)