From 7e248c1134c81fbfd63c317516eb769a28d195b0 Mon Sep 17 00:00:00 2001 From: AnasNaouchi Date: Mon, 3 Feb 2025 01:44:56 +0700 Subject: [PATCH 1/6] Add date filter on charge list --- omise/__init__.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/omise/__init__.py b/omise/__init__.py index 810ef9c..ae9daac 100644 --- a/omise/__init__.py +++ b/omise/__init__.py @@ -737,12 +737,12 @@ def retrieve(cls, charge_id=None): return _as_object(cls._request('get', cls._collection_path())) @classmethod - def list(cls): + def list(cls, **kwargs): """Return all charges that belongs to your account :rtype: LazyCollection """ - return LazyCollection(cls._collection_path()) + return LazyCollection(cls._collection_path(), fromDate = kwargs.pop('fromDate', None), toDate = kwargs.pop('toDate', None)) def reload(self): """Reload the charge details. @@ -1050,9 +1050,12 @@ def schedule(self): class LazyCollection(object): """Proxy class representing a lazy collection of items.""" - def __init__(self, collection_path): + + def __init__(self, collection_path, **kwargs): self.collection_path = collection_path self._exhausted = False + self.fromDate = kwargs.pop('fromDate') + self.toDate = kwargs.pop('toDate') def __len__(self): return self._fetch_objects(limit=1, offset=0)['total'] @@ -1104,6 +1107,8 @@ def _update_listing(self, data): def _fetch_objects(self, **kwargs): order = kwargs.pop('order', None) + fromDate = self.fromDate + toDate = self.toDate return Request(api_secret, api_main, api_version).send( 'get', @@ -1111,7 +1116,9 @@ def _fetch_objects(self, **kwargs): payload={ 'limit': kwargs['limit'], 'offset': kwargs['offset'], - 'order': order + 'order': order, + 'from': fromDate, + 'to': toDate } ) From c6664e7df1f74822fc947427d46ffc9489791fca Mon Sep 17 00:00:00 2001 From: AnasNaouchi Date: Mon, 3 Feb 2025 01:52:15 +0700 Subject: [PATCH 2/6] Fix test by adding None value --- omise/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/omise/__init__.py b/omise/__init__.py index ae9daac..2d7c4a6 100644 --- a/omise/__init__.py +++ b/omise/__init__.py @@ -742,7 +742,7 @@ def list(cls, **kwargs): :rtype: LazyCollection """ - return LazyCollection(cls._collection_path(), fromDate = kwargs.pop('fromDate', None), toDate = kwargs.pop('toDate', None)) + return LazyCollection(cls._collection_path(), fromDate=kwargs.pop('fromDate', None), toDate=kwargs.pop('toDate', None)) def reload(self): """Reload the charge details. @@ -1054,8 +1054,8 @@ class LazyCollection(object): def __init__(self, collection_path, **kwargs): self.collection_path = collection_path self._exhausted = False - self.fromDate = kwargs.pop('fromDate') - self.toDate = kwargs.pop('toDate') + self.fromDate = kwargs.pop('fromDate', None) + self.toDate = kwargs.pop('toDate', None) def __len__(self): return self._fetch_objects(limit=1, offset=0)['total'] From f276db67624b5ee9d51031a17e059ff5b2884071 Mon Sep 17 00:00:00 2001 From: AnasNaouchi Date: Mon, 3 Feb 2025 16:06:26 +0700 Subject: [PATCH 3/6] Remove EOF python matrix versions --- .github/workflows/code-coverage.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index d850f7f..d025cc4 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.11"] + python-version: ["3.13"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5f28ca1..00b34a5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From dedb14c3ae351a5e7bdcfaa479e70639df0151c3 Mon Sep 17 00:00:00 2001 From: AnasNaouchi Date: Mon, 3 Feb 2025 16:20:30 +0700 Subject: [PATCH 4/6] Update actions checkout and setup versions --- .github/workflows/code-coverage.yml | 4 ++-- .github/workflows/publish.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index d025cc4..770dfac 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -9,9 +9,9 @@ jobs: matrix: python-version: ["3.13"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index baa044c..382f741 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,10 +10,10 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.9 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 00b34a5..9363c44 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,9 +11,9 @@ jobs: matrix: python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies From 4646e577294f9fc890addef5857ad1add718c279 Mon Sep 17 00:00:00 2001 From: AnasNaouchi Date: Mon, 3 Feb 2025 16:56:40 +0700 Subject: [PATCH 5/6] Add setuptools to tet setup --- setup.py | 4 ++++ tox.ini | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d69bb77..f4b2e2e 100644 --- a/setup.py +++ b/setup.py @@ -40,5 +40,9 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Software Development :: Libraries :: Python Modules", ]) diff --git a/tox.ini b/tox.ini index 4cf9fce..f4ae801 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,9 @@ [tox] -envlist = py27, py37, py38, py39, py310, py311 +envlist = py27, py37, py38, py39, py310, py311, py312, py313 [testenv] +deps = + setuptools commands = pip install ".[tests]" python -m unittest From 2ffcb1cfc3dbc4e31c983ce6443f8c3768548942 Mon Sep 17 00:00:00 2001 From: AnasNaouchi Date: Mon, 3 Feb 2025 17:08:19 +0700 Subject: [PATCH 6/6] Install setuptools explicitly in coverage CI --- .github/workflows/code-coverage.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 770dfac..435cdde 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -17,6 +17,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip .[tests] + pip install setuptools - name: Run Test run: coverage run -m unittest - name: Generate report