PaddleHQ / paddle-python-sdk

Python SDK for working with the Paddle API in server-side apps.
https://developer.paddle.com/
Apache License 2.0
11 stars 2 forks source link

paddle.businesses.archive() throws an error #7

Closed marinaglancy closed 1 month ago

marinaglancy commented 1 month ago

Describe the bug

Exception when trying to archive a business or update a business without changing the name.

Most likely because of missing parenthesis here: https://github.com/PaddleHQ/paddle-python-sdk/blob/main/paddle_billing/Resources/Businesses/Operations/UpdateBusiness.py#L9

Steps to reproduce

paddle.businesses.archive(customer.id, business.id) # ERROR
paddle.businesses.update(customer.id, business.id,
                                     UpdateBusiness(status=Status.Archived)) # ERROR

paddle.businesses.update(customer.id, business.id,
                                     UpdateBusiness(status=Status.Archived, name=business.name)) # <- Workaround

Expected behavior

expected behavior is not to raise an error :)

Code snippets

'--Exception--'
TypeError('Object of type type is not JSON serializable')
('Traceback (most recent call last):\n'
.....
 '  File "/var/task/billingpaddle.py", line 137, in update_customer\n'
 '    paddle.businesses.archive(customer.id, business.id)\n'
 '  File "/var/task/paddle_billing/Resources/Businesses/BusinessesClient.py", '
 'line 58, in archive\n'
 '    return self.update(customer_id, business_id, '
 'UpdateBusiness(status=Status.Archived))\n'
 '           '
 '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n'
 '  File "/var/task/paddle_billing/Resources/Businesses/BusinessesClient.py", '
 'line 48, in update\n'
 '    self.response = self.client.patch_raw(\n'
 '                    ^^^^^^^^^^^^^^^^^^^^^^\n'
 '  File "/var/task/paddle_billing/Client.py", line 177, in patch_raw\n'
 "    return self._make_request('PATCH', url, payload)\n"
 '           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n'
 '  File "/var/task/paddle_billing/Client.py", line 125, in _make_request\n'
 '    self.payload = self.serialize_json_payload(payload) if payload else '
 'None\n'
 '                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n'
 '  File "/var/task/paddle_billing/Client.py", line 102, in '
 'serialize_json_payload\n'
 '    json_payload = json_dumps(payload)\n'
 '                   ^^^^^^^^^^^^^^^^^^^\n'
 '  File "/var/lang/lib/python3.11/json/__init__.py", line 231, in dumps\n'
 '    return _default_encoder.encode(obj)\n'
 '           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n'
 '  File "/var/lang/lib/python3.11/json/encoder.py", line 200, in encode\n'
 '    chunks = self.iterencode(o, _one_shot=True)\n'
 '             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n'
 '  File "/var/lang/lib/python3.11/json/encoder.py", line 258, in iterencode\n'
 '    return _iterencode(o, 0)\n'
 '           ^^^^^^^^^^^^^^^^^\n'
 '  File "/var/lang/lib/python3.11/json/encoder.py", line 180, in default\n'
 "    raise TypeError(f'Object of type {o.__class__.__name__} '\n"
 'TypeError: Object of type type is not JSON serializable\n')


### Python version

3.11

### SDK version

1.0.1

### API version

1

### Additional context

_No response_
vijayasingam-paddle commented 1 month ago

Hi @marinaglancy, Thank you for raising this bug report.

I will check and fix this issue shortly.

Thank you.

vijayasingam-paddle commented 1 month ago

Hi @marinaglancy , You were correct. The issue was with the missing parenthesis in UpdateBusiness class. I have fixed this and released a new version 0.1.1

Please let us know if we can help you with anything else. Thank you.

marinaglancy commented 1 month ago

Thanks a lot. Do you guys tag versions?

vijayasingam-paddle commented 1 month ago

Do you guys tag versions?

As in GitHub releases? If yes, we do tag our releases. I missed to create a tag when i made this change. I have created one now.