edx-enterprise-subsidy-client 0.4.3__tar.gz → 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/CHANGELOG.rst +18 -0
  2. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/PKG-INFO +32 -4
  3. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/edx_enterprise_subsidy_client/__init__.py +1 -1
  4. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/edx_enterprise_subsidy_client/client.py +41 -0
  5. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/edx_enterprise_subsidy_client.egg-info/PKG-INFO +32 -4
  6. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/requirements/constraints.txt +0 -1
  7. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/setup.py +2 -2
  8. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/tests/test_client.py +38 -0
  9. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/LICENSE +0 -0
  10. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/LICENSE.txt +0 -0
  11. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/MANIFEST.in +0 -0
  12. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/README.rst +0 -0
  13. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/edx_enterprise_subsidy_client.egg-info/SOURCES.txt +0 -0
  14. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/edx_enterprise_subsidy_client.egg-info/dependency_links.txt +0 -0
  15. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/edx_enterprise_subsidy_client.egg-info/not-zip-safe +0 -0
  16. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/edx_enterprise_subsidy_client.egg-info/requires.txt +0 -0
  17. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/edx_enterprise_subsidy_client.egg-info/top_level.txt +0 -0
  18. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/requirements/base.in +0 -0
  19. {edx-enterprise-subsidy-client-0.4.3 → edx_enterprise_subsidy_client-1.0.0}/setup.cfg +0 -0
@@ -14,6 +14,24 @@ Change Log
14
14
  Unreleased
15
15
  **********
16
16
 
17
+ [1.0.0]
18
+ *******
19
+ * fix: Remove Python 3.8 Support
20
+ * chore: Update Python Requirements
21
+ * chore: Update pylintrc
22
+
23
+ [0.4.6]
24
+ *******
25
+ * fix: Update the name of reviewers team in github flow
26
+
27
+ [0.4.5]
28
+ *******
29
+ * fix: create_subsidy_deposit - metadata is optional (ENT-9133)
30
+
31
+ [0.4.4]
32
+ *******
33
+ * feat: add support for deposit creation (ENT-9133)
34
+
17
35
  [0.4.3]
18
36
  *******
19
37
  * feat: adding new subsidy client method to fetch subsidy aggregate data
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: edx-enterprise-subsidy-client
3
- Version: 0.4.3
3
+ Version: 1.0.0
4
4
  Summary: Client for interacting with the enterprise-subsidy service.
5
5
  Home-page: https://github.com/openedx/edx-enterprise-subsidy-client
6
6
  Author: edX
@@ -12,11 +12,21 @@ Classifier: Intended Audience :: Developers
12
12
  Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
13
13
  Classifier: Natural Language :: English
14
14
  Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.8
16
- Requires-Python: >=3.8
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Requires-Python: >=3.12
17
17
  License-File: LICENSE
18
18
  License-File: LICENSE.txt
19
19
  Requires-Dist: edx-rest-api-client
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: home-page
25
+ Dynamic: keywords
26
+ Dynamic: license
27
+ Dynamic: requires-dist
28
+ Dynamic: requires-python
29
+ Dynamic: summary
20
30
 
21
31
  edx-enterprise-subsidy-client
22
32
  #############################
@@ -225,6 +235,24 @@ Change Log
225
235
  Unreleased
226
236
  **********
227
237
 
238
+ [1.0.0]
239
+ *******
240
+ * fix: Remove Python 3.8 Support
241
+ * chore: Update Python Requirements
242
+ * chore: Update pylintrc
243
+
244
+ [0.4.6]
245
+ *******
246
+ * fix: Update the name of reviewers team in github flow
247
+
248
+ [0.4.5]
249
+ *******
250
+ * fix: create_subsidy_deposit - metadata is optional (ENT-9133)
251
+
252
+ [0.4.4]
253
+ *******
254
+ * feat: add support for deposit creation (ENT-9133)
255
+
228
256
  [0.4.3]
229
257
  *******
230
258
  * feat: adding new subsidy client method to fetch subsidy aggregate data
@@ -2,6 +2,6 @@
2
2
  Client for interacting with the enterprise-subsidy service..
3
3
  """
4
4
 
5
- __version__ = '0.4.3'
5
+ __version__ = '1.0.0'
6
6
 
7
7
  from .client import EnterpriseSubsidyAPIClient, EnterpriseSubsidyAPIClientV2, get_enterprise_subsidy_api_client
@@ -291,6 +291,7 @@ class EnterpriseSubsidyAPIClientV2(EnterpriseSubsidyAPIClient): # pylint: disab
291
291
  """
292
292
  V2_BASE_URL = EnterpriseSubsidyAPIClient.API_BASE_URL + 'v2/'
293
293
  TRANSACTIONS_LIST_ENDPOINT = V2_BASE_URL + 'subsidies/{subsidy_uuid}/admin/transactions/'
294
+ DEPOSITS_CREATE_ENDPOINT = V2_BASE_URL + 'subsidies/{subsidy_uuid}/admin/deposits/'
294
295
 
295
296
  def list_subsidy_transactions(
296
297
  self, subsidy_uuid, include_aggregates=True,
@@ -370,3 +371,43 @@ class EnterpriseSubsidyAPIClientV2(EnterpriseSubsidyAPIClient): # pylint: disab
370
371
  )
371
372
  response.raise_for_status()
372
373
  return response.json()
374
+
375
+ def create_subsidy_deposit(
376
+ self,
377
+ subsidy_uuid,
378
+ desired_deposit_quantity,
379
+ sales_contract_reference_id,
380
+ sales_contract_reference_provider,
381
+ metadata=None,
382
+ idempotency_key=None,
383
+ ):
384
+ """
385
+ Creates a deposit in the given subsidy, requires operator-level permissions.
386
+
387
+ Raises:
388
+ requests.exceptions.HTTPError:
389
+ - 403 Forbidden: If auth failed.
390
+ - 429 Too Many Requests: If the ledger was locked (resource contention, try again later).
391
+ - 400 Bad Request: If any of the values were invalid. Reasons include:
392
+ * non-positive quantity.
393
+ * provider slug does not exist in database.
394
+ - 422 Unprocessable Entity: Catchall status for anything that prevented the deposit from being
395
+ created. Reasons include, but are not limited to:
396
+ * Subsidy is inactive.
397
+ * Another deposit with same idempotency_key already exists.
398
+ """
399
+ request_payload = {
400
+ 'desired_deposit_quantity': desired_deposit_quantity,
401
+ 'sales_contract_reference_id': sales_contract_reference_id,
402
+ 'sales_contract_reference_provider': sales_contract_reference_provider,
403
+ }
404
+ if metadata is not None:
405
+ request_payload['metadata'] = metadata
406
+ if idempotency_key is not None:
407
+ request_payload['idempotency_key'] = idempotency_key
408
+ response = self.client.post(
409
+ self.DEPOSITS_CREATE_ENDPOINT.format(subsidy_uuid=subsidy_uuid),
410
+ json=request_payload,
411
+ )
412
+ response.raise_for_status()
413
+ return response.json()
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: edx-enterprise-subsidy-client
3
- Version: 0.4.3
3
+ Version: 1.0.0
4
4
  Summary: Client for interacting with the enterprise-subsidy service.
5
5
  Home-page: https://github.com/openedx/edx-enterprise-subsidy-client
6
6
  Author: edX
@@ -12,11 +12,21 @@ Classifier: Intended Audience :: Developers
12
12
  Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
13
13
  Classifier: Natural Language :: English
14
14
  Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.8
16
- Requires-Python: >=3.8
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Requires-Python: >=3.12
17
17
  License-File: LICENSE
18
18
  License-File: LICENSE.txt
19
19
  Requires-Dist: edx-rest-api-client
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: home-page
25
+ Dynamic: keywords
26
+ Dynamic: license
27
+ Dynamic: requires-dist
28
+ Dynamic: requires-python
29
+ Dynamic: summary
20
30
 
21
31
  edx-enterprise-subsidy-client
22
32
  #############################
@@ -225,6 +235,24 @@ Change Log
225
235
  Unreleased
226
236
  **********
227
237
 
238
+ [1.0.0]
239
+ *******
240
+ * fix: Remove Python 3.8 Support
241
+ * chore: Update Python Requirements
242
+ * chore: Update pylintrc
243
+
244
+ [0.4.6]
245
+ *******
246
+ * fix: Update the name of reviewers team in github flow
247
+
248
+ [0.4.5]
249
+ *******
250
+ * fix: create_subsidy_deposit - metadata is optional (ENT-9133)
251
+
252
+ [0.4.4]
253
+ *******
254
+ * feat: add support for deposit creation (ENT-9133)
255
+
228
256
  [0.4.3]
229
257
  *******
230
258
  * feat: adding new subsidy client method to fetch subsidy aggregate data
@@ -10,4 +10,3 @@
10
10
 
11
11
  # Common constraints for edx repos
12
12
  -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
13
- backports.zoneinfo;python_version<"3.9"
@@ -115,7 +115,7 @@ setup(
115
115
 
116
116
  include_package_data=True,
117
117
  install_requires=load_requirements('requirements/base.in'),
118
- python_requires=">=3.8",
118
+ python_requires=">=3.12",
119
119
  license="AGPL 3.0",
120
120
  zip_safe=False,
121
121
  keywords='Python edx',
@@ -125,6 +125,6 @@ setup(
125
125
  'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
126
126
  'Natural Language :: English',
127
127
  'Programming Language :: Python :: 3',
128
- 'Programming Language :: Python :: 3.8',
128
+ 'Programming Language :: Python :: 3.12',
129
129
  ],
130
130
  )
@@ -172,3 +172,41 @@ def test_v2_list_subsidy_transactions(mock_oauth_client):
172
172
  'page_size': 1,
173
173
  },
174
174
  )
175
+
176
+
177
+ @mock.patch('edx_enterprise_subsidy_client.client.OAuthAPIClient', return_value=mock.MagicMock())
178
+ def test_client_v2_create_subsidy_deposit(mock_oauth_client):
179
+ """
180
+ Test the client's ability to create subsidy deposits.
181
+ """
182
+ mocked_data = {
183
+ 'uuid': str(uuid.uuid4()),
184
+ }
185
+ mock_post = mock_oauth_client.return_value.post
186
+ mock_post.return_value = MockResponse(mocked_data, 201)
187
+
188
+ subsidy_service_client = EnterpriseSubsidyAPIClientV2()
189
+
190
+ payload = {
191
+ 'subsidy_uuid': uuid.uuid4(),
192
+ 'desired_deposit_quantity': 100,
193
+ 'sales_contract_reference_id': str(uuid.uuid4()),
194
+ 'sales_contract_reference_provider': 'foo-bar',
195
+ 'idempotency_key': 'hello',
196
+ 'metadata': {'key': 'value'},
197
+ }
198
+
199
+ response = subsidy_service_client.create_subsidy_deposit(**payload)
200
+
201
+ assert response == mocked_data
202
+ expected_url = EnterpriseSubsidyAPIClientV2.DEPOSITS_CREATE_ENDPOINT.format(
203
+ subsidy_uuid=payload['subsidy_uuid'],
204
+ )
205
+ expected_post_payload = {
206
+ 'desired_deposit_quantity': 100,
207
+ 'sales_contract_reference_id': payload['sales_contract_reference_id'],
208
+ 'sales_contract_reference_provider': 'foo-bar',
209
+ 'idempotency_key': 'hello',
210
+ 'metadata': {'key': 'value'},
211
+ }
212
+ mock_post.assert_called_once_with(expected_url, json=expected_post_payload)