OneSignal / onesignal-python-api

Other
17 stars 6 forks source link

[Bug]: TypeError: CreateNotificationSuccessResponse._from_openapi_data() missing 1 required positional argument: 'recipients' #17

Closed apple-ec closed 1 year ago

apple-ec commented 1 year ago

What happened?

The latest version of the package is sending the notification successfully to the device but ends up with TypeError.

Steps to reproduce?

import onesignal
from onesignal.api import default_api
from onesignal.model.notification import Notification

configuration = onesignal.Configuration(
    app_key = "<REST API KEY>"
)

with onesignal.ApiClient(configuration) as api_client:
    api_instance = default_api.DefaultApi(api_client)

    notification = Notification(
        app_id="<APP ID>",
        include_player_ids=["<PLAYER ID>"],
        name="hi",
        subtitle= {
            "en": "Hello"
        },
        contents={
        "en": "Welcome to onesignal"
        }
    ) 

    try:
        api_response = api_instance.create_notification(notification)
    except onesignal.ApiException as e:
        print("Exception when calling DefaultApi->create_notification: %s\n" % e)

What did you expect to happen?

I expected the library to send notification without any errors

Relevant log output

Traceback (most recent call last):
  File "/Users/admin/Desktop/send_notification.py", line 30, in <module>
    api_response = api_instance.create_notification(notification)
  File "/Users/admin/.pyenv/versions/3.10.10/lib/python3.10/site-packages/onesignal/api/default_api.py", line 1704, in create_notification
    return self.create_notification_endpoint.call_with_http_info(**kwargs)
  File "/Users/admin/.pyenv/versions/3.10.10/lib/python3.10/site-packages/onesignal/api_client.py", line 881, in call_with_http_info
    return self.api_client.call_api(
  File "/Users/admin/.pyenv/versions/3.10.10/lib/python3.10/site-packages/onesignal/api_client.py", line 423, in call_api
    return self.__call_api(resource_path, method,
  File "/Users/admin/.pyenv/versions/3.10.10/lib/python3.10/site-packages/onesignal/api_client.py", line 228, in __call_api
    return_data = self.deserialize(
  File "/Users/admin/.pyenv/versions/3.10.10/lib/python3.10/site-packages/onesignal/api_client.py", line 334, in deserialize
    deserialized_data = validate_and_convert_types(
  File "/Users/admin/.pyenv/versions/3.10.10/lib/python3.10/site-packages/onesignal/model_utils.py", line 1583, in validate_and_convert_types
    converted_instance = attempt_convert_item(
  File "/Users/admin/.pyenv/versions/3.10.10/lib/python3.10/site-packages/onesignal/model_utils.py", line 1463, in attempt_convert_item
    return deserialize_model(input_value, valid_class,
  File "/Users/admin/.pyenv/versions/3.10.10/lib/python3.10/site-packages/onesignal/model_utils.py", line 1377, in deserialize_model
    return model_class._new_from_openapi_data(**kw_args)
  File "/Users/admin/.pyenv/versions/3.10.10/lib/python3.10/site-packages/onesignal/model_utils.py", line 49, in wrapped_init
    return fn(_self, *args, **kwargs)
  File "/Users/admin/.pyenv/versions/3.10.10/lib/python3.10/site-packages/onesignal/model_utils.py", line 372, in _new_from_openapi_data
    return cls._from_openapi_data(*args, **kwargs)
  File "/Users/admin/.pyenv/versions/3.10.10/lib/python3.10/site-packages/onesignal/model_utils.py", line 49, in wrapped_init
    return fn(_self, *args, **kwargs)
TypeError: CreateNotificationSuccessResponse._from_openapi_data() missing 1 required positional argument: 'recipients'

Code of Conduct

emawby commented 1 year ago

@apple-ec Thank you for reporting we are aware of the issue and are working on a fix ASAP!

kesheshyan commented 1 year ago

Hey @apple-ec . Thank you for reporting this issue and thank you for using our library. May I ask you to specify the version of the library you are referring to? Is it:

Have you pulled it directly from the GitHub or from the pip?

soudhaf commented 1 year ago

@kesheshyan the last version in pip is outdated it's 1.0.2

kesheshyan commented 1 year ago

I've updated PIP to the latest version 2.0.0. Please let us know if the problem still persist. https://pypi.org/project/onesignal-python-api/

apple-ec commented 1 year ago

Thank you. I will upgrade my package and will let you know

apple-ec commented 1 year ago

It is working as expected now. Thank you