// WARNING: Please don't edit this file. It was generated by Python/WinRT v1.0.0-beta.10

#include "pybase.h"
#include "py.Windows.UI.Notifications.Management.h"


namespace py::cpp::Windows::UI::Notifications::Management
{
    struct module_state
    {
        PyObject* type_UserNotificationListenerAccessStatus;
        PyTypeObject* type_UserNotificationListener;
    };

    static PyObject* register_UserNotificationListenerAccessStatus(PyObject* module, PyObject* type) noexcept
    {
        auto state = reinterpret_cast<module_state*>(PyModule_GetState(module));
        assert(state);

        if (state->type_UserNotificationListenerAccessStatus)
        {
            PyErr_SetString(PyExc_RuntimeError, "type has already been registered");
            return nullptr;
        }

        if (!PyType_Check(type))
        {
            PyErr_SetString(PyExc_TypeError, "argument is not a type");
            return nullptr;
        }

        state->type_UserNotificationListenerAccessStatus = type;
        Py_INCREF(state->type_UserNotificationListenerAccessStatus);


        Py_RETURN_NONE;
    }

    // ----- UserNotificationListener class --------------------
    static constexpr const char* const type_name_UserNotificationListener = "UserNotificationListener";

    static PyObject* _new_UserNotificationListener(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
    {
        py::set_invalid_activation_error(type_name_UserNotificationListener);
        return nullptr;
    }

    static void _dealloc_UserNotificationListener(py::wrapper::Windows::UI::Notifications::Management::UserNotificationListener* self) noexcept
    {
        auto tp = Py_TYPE(self);

        if (PyType_IS_GC(tp))
        {
            PyObject_GC_UnTrack(self);
        }

        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* UserNotificationListener_ClearNotifications(py::wrapper::Windows::UI::Notifications::Management::UserNotificationListener* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.UI.Notifications.Management.UserNotificationListener", L"ClearNotifications", 0))
            {
                py::set_arg_count_version_error(0);
                return nullptr;
            }

            try
            {
                self->obj.ClearNotifications();
                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* UserNotificationListener_GetAccessStatus(py::wrapper::Windows::UI::Notifications::Management::UserNotificationListener* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.UI.Notifications.Management.UserNotificationListener", L"GetAccessStatus", 0))
            {
                py::set_arg_count_version_error(0);
                return nullptr;
            }

            try
            {
                return py::convert(self->obj.GetAccessStatus());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* UserNotificationListener_GetNotification(py::wrapper::Windows::UI::Notifications::Management::UserNotificationListener* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.UI.Notifications.Management.UserNotificationListener", L"GetNotification", 1))
            {
                py::set_arg_count_version_error(1);
                return nullptr;
            }

            try
            {
                auto param0 = py::convert_to<uint32_t>(args, 0);

                return py::convert(self->obj.GetNotification(param0));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* UserNotificationListener_GetNotificationsAsync(py::wrapper::Windows::UI::Notifications::Management::UserNotificationListener* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.UI.Notifications.Management.UserNotificationListener", L"GetNotificationsAsync", 1))
            {
                py::set_arg_count_version_error(1);
                return nullptr;
            }

            try
            {
                auto param0 = py::convert_to<winrt::Windows::UI::Notifications::NotificationKinds>(args, 0);

                return py::convert(self->obj.GetNotificationsAsync(param0));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* UserNotificationListener_RemoveNotification(py::wrapper::Windows::UI::Notifications::Management::UserNotificationListener* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.UI.Notifications.Management.UserNotificationListener", L"RemoveNotification", 1))
            {
                py::set_arg_count_version_error(1);
                return nullptr;
            }

            try
            {
                auto param0 = py::convert_to<uint32_t>(args, 0);

                self->obj.RemoveNotification(param0);
                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* UserNotificationListener_RequestAccessAsync(py::wrapper::Windows::UI::Notifications::Management::UserNotificationListener* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.UI.Notifications.Management.UserNotificationListener", L"RequestAccessAsync", 0))
            {
                py::set_arg_count_version_error(0);
                return nullptr;
            }

            try
            {
                return py::convert(self->obj.RequestAccessAsync());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* UserNotificationListener_get_Current(PyObject* /*unused*/, void* /*unused*/) noexcept
    {
        if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Notifications.Management.UserNotificationListener", L"Current"))
        {
            PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
            return nullptr;
        }

        try
        {
            return py::convert(winrt::Windows::UI::Notifications::Management::UserNotificationListener::Current());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* UserNotificationListener_add_NotificationChanged(py::wrapper::Windows::UI::Notifications::Management::UserNotificationListener* self, PyObject* arg) noexcept
    {
        if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.UI.Notifications.Management.UserNotificationListener", L"NotificationChanged"))
        {
            PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
            return nullptr;
        }

        try
        {
            auto param0 = py::convert_to<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::UI::Notifications::Management::UserNotificationListener, winrt::Windows::UI::Notifications::UserNotificationChangedEventArgs>>(arg);

            return py::convert(self->obj.NotificationChanged(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* UserNotificationListener_remove_NotificationChanged(py::wrapper::Windows::UI::Notifications::Management::UserNotificationListener* self, PyObject* arg) noexcept
    {
        if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.UI.Notifications.Management.UserNotificationListener", L"NotificationChanged"))
        {
            PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
            return nullptr;
        }

        try
        {
            auto param0 = py::convert_to<winrt::event_token>(arg);

            self->obj.NotificationChanged(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_UserNotificationListener(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::UI::Notifications::Management::UserNotificationListener>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_UserNotificationListener(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::UI::Notifications::Management::UserNotificationListener>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_UserNotificationListener[] = {
        { "clear_notifications", reinterpret_cast<PyCFunction>(UserNotificationListener_ClearNotifications), METH_VARARGS, nullptr },
        { "get_access_status", reinterpret_cast<PyCFunction>(UserNotificationListener_GetAccessStatus), METH_VARARGS, nullptr },
        { "get_notification", reinterpret_cast<PyCFunction>(UserNotificationListener_GetNotification), METH_VARARGS, nullptr },
        { "get_notifications_async", reinterpret_cast<PyCFunction>(UserNotificationListener_GetNotificationsAsync), METH_VARARGS, nullptr },
        { "remove_notification", reinterpret_cast<PyCFunction>(UserNotificationListener_RemoveNotification), METH_VARARGS, nullptr },
        { "request_access_async", reinterpret_cast<PyCFunction>(UserNotificationListener_RequestAccessAsync), METH_VARARGS, nullptr },
        { "add_notification_changed", reinterpret_cast<PyCFunction>(UserNotificationListener_add_NotificationChanged), METH_O, nullptr },
        { "remove_notification_changed", reinterpret_cast<PyCFunction>(UserNotificationListener_remove_NotificationChanged), METH_O, nullptr },
        { "_assign_array_", _assign_array_UserNotificationListener, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_UserNotificationListener), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_UserNotificationListener[] = {
        { }
    };

    static PyType_Slot _type_slots_UserNotificationListener[] = 
    {
        { Py_tp_new, reinterpret_cast<void*>(_new_UserNotificationListener) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_UserNotificationListener) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_UserNotificationListener) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_UserNotificationListener) },
        { },
    };

    static PyType_Spec type_spec_UserNotificationListener =
    {
        "_toasts_winrt_Windows_UI_Notifications_Management.UserNotificationListener",
        sizeof(py::wrapper::Windows::UI::Notifications::Management::UserNotificationListener),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_UserNotificationListener
    };

    static PyGetSetDef getset_UserNotificationListener_Meta[] = {
        { "current", reinterpret_cast<getter>(UserNotificationListener_get_Current), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot type_slots_UserNotificationListener_Meta[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_UserNotificationListener_Meta) },
        { }
    };

    static PyType_Spec type_spec_UserNotificationListener_Meta =
    {
        "_toasts_winrt_Windows_UI_Notifications_Management.UserNotificationListener_Meta",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_UserNotificationListener_Meta
    };

    // ----- Windows.UI.Notifications.Management Initialization --------------------
    PyDoc_STRVAR(module_doc, "Windows::UI::Notifications::Management");

    static PyMethodDef module_methods[] = {
        {"_register_UserNotificationListenerAccessStatus", register_UserNotificationListenerAccessStatus, METH_O, "registers type"},
        {}};


    static int module_traverse(PyObject* module, visitproc visit, void* arg) noexcept
    {
        auto state = reinterpret_cast<module_state*>(PyModule_GetState(module));

        if (!state)
        {
            return 0;
        }

        Py_VISIT(state->type_UserNotificationListenerAccessStatus);
        Py_VISIT(state->type_UserNotificationListener);

        return 0;
    }

    static int module_clear(PyObject* module) noexcept
    {
        auto state = reinterpret_cast<module_state*>(PyModule_GetState(module));

        if (!state)
        {
            return 0;
        }

        Py_CLEAR(state->type_UserNotificationListenerAccessStatus);
        Py_CLEAR(state->type_UserNotificationListener);

        return 0;
    }


    static PyModuleDef module_def
        = {PyModuleDef_HEAD_INIT,
           "_toasts_winrt_Windows_UI_Notifications_Management",
           module_doc,
           sizeof(module_state),
           module_methods,
           nullptr,
           module_traverse,
           module_clear,
           nullptr};

} // py::cpp::Windows::UI::Notifications::Management

PyMODINIT_FUNC PyInit__toasts_winrt_Windows_UI_Notifications_Management(void) noexcept
{
    using namespace py::cpp::Windows::UI::Notifications::Management;

    py::pyobj_handle module{PyModule_Create(&module_def)};

    if (!module)
    {
        return nullptr;
    }

    auto object_type = py::get_python_type<py::Object>();
    if (!object_type)
    {
        return nullptr;
    }

    py::pyobj_handle object_bases{PyTuple_Pack(1, object_type)};

    if (!object_bases)
    {
        return nullptr;
    }

    auto state = reinterpret_cast<module_state*>(PyModule_GetState(module.get()));
    assert(state);

    py::pyobj_handle type_UserNotificationListener_Meta{PyType_FromSpec(&type_spec_UserNotificationListener_Meta)};
    if (!type_UserNotificationListener_Meta)
    {
        return nullptr;
    }

    state->type_UserNotificationListener = py::register_python_type(module.get(), type_name_UserNotificationListener, &type_spec_UserNotificationListener, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_UserNotificationListener_Meta.get()));
    if (!state->type_UserNotificationListener)
    {
        return nullptr;
    }


    return module.detach();
}

PyObject* py::py_type<winrt::Windows::UI::Notifications::Management::UserNotificationListenerAccessStatus>::get_python_type() noexcept {
    using namespace py::cpp::Windows::UI::Notifications::Management;

    PyObject* module = PyState_FindModule(&module_def);

    if (!module) {
        PyErr_SetString(PyExc_RuntimeError, "could not find module for Windows::UI::Notifications::Management");
        return nullptr;
    }

    auto state = reinterpret_cast<module_state*>(PyModule_GetState(module));
    assert(state);

    auto python_type = state->type_UserNotificationListenerAccessStatus;

    if (!python_type) {
        PyErr_SetString(PyExc_RuntimeError, "type winrt::Windows::UI::Notifications::Management::UserNotificationListenerAccessStatus is not registered");
        return nullptr;
    }

    return python_type;
}

PyTypeObject* py::winrt_type<winrt::Windows::UI::Notifications::Management::UserNotificationListener>::get_python_type() noexcept {
    using namespace py::cpp::Windows::UI::Notifications::Management;

    PyObject* module = PyState_FindModule(&module_def);

    if (!module) {
        PyErr_SetString(PyExc_RuntimeError, "could not find module for Windows::UI::Notifications::Management");
        return nullptr;
    }

    auto state = reinterpret_cast<module_state*>(PyModule_GetState(module));
    assert(state);

    auto python_type = state->type_UserNotificationListener;

    if (!python_type) {
        PyErr_SetString(PyExc_RuntimeError, "type winrt::Windows::UI::Notifications::Management::UserNotificationListener is not registered");
        return nullptr;
    }

    return python_type;
}
