Package: upchatpy
UpChatPy: Upgrade.Chat Python WrapperThis package provides a fully async, type-hinted wraper for theUpgrade.ChatAPI.ReferencesUpgrade.Chat is a platform that facilitates monetization for community services, particularly Discord. This wrapper aims to simplify integration with other 3rd party apps.HomepageFAQAPI DocsInstallationTo install the package, run the following command:pipinstallupchatpyUsageBefore you can start using the API, you need to obtain your client ID and client secret from Upgrade.Chat. Once you have them, you can begin by creating aClientinstance:fromupchatpyimportClientclient_id='your_client_id'client_secret='your_client_secret'client=Client(client_id,client_secret)AuthenticationThe wrapper handles authentication automatically when making API calls. However, you can manually authenticate and retrieve the access token as follows:awaitclient.get_auth()print(client.access_token)# Access token is now availableFetching OrdersTo fetch orders, use the following method:orders_response=awaitclient.get_orders()fororderinorders_response.data:print(order.uuid,order.total)To fetch all orders with pagination support:asyncfororders_responseinclient.aget_orders():fororderinorders_response.data:print(order.uuid,order.total)To fetch a specific order by UUID:order_uuid='your_order_uuid'order_response=awaitclient.get_order(order_uuid)print(order_response.data.total)Fetching ProductsFetch a list of products using:products_response=awaitclient.get_products()forproductinproducts_response.data:print(product.uuid,product.name)To fetch all products with pagination support:asyncforproducts_responseinclient.aget_products():forproductinproducts_response.data:print(product.uuid,product.name)To fetch a product order by UUID:product_uuid='your_product_uuid'product_response=awaitclient.get_product(product_uuid)print(product_response.data.name)Fetching UsersTo get a list of users, you can do:users_response=awaitclient.get_users()foruserinusers_response.data:print(user.discord_id,user.username)Fetching WebhooksFetch a list of webhooks using:webhooks_response=awaitclient.get_webhooks()forwebhookinwebhooks_response.data:print(webhook.id,webhook.uri)To fetch all webhooks with pagination support:asyncforwebhooks_responseinclient.aget_webhooks():forwebhookinwebhooks_response.data:print(webhook.id,webhook.url)To fetch a specific webhook by ID:webhook_id='your_webhook_id'webhook_response=awaitclient.get_webhook(webhook_id)print(webhook_response.data.id,webhook_response.data.url)Fetching Webhook EventsFetch a list of webhooks events using:webhook_events_response=awaitclient.get_webhook_events()forwebhook_eventinwebhook_events_response.data:print(webhook_event.id,webhook_event.webhook_id)To fetch a list of webhook events with pagination support:asyncforwebhook_events_responseinclient.aget_webhook_events():forwebhook_eventinwebhook_events_response.data:print(webhook_event.id,webhook_event.webhook_id)To fetch a specific webhook event by ID:event_id='your_event_id'webhook_event_response=awaitclient.get_webhook_event(event_id)print(webhook_event_response.data.id)Validating Webhook EventsTo validate a webhook event by ID:event_id='your_event_id'webhook_valid_response=awaitclient.validate_webhook_event(event_id)print(webhook_valid_response.data.is_valid)Checking SubscriptionsTheuser_is_subscribedmethod enables you to check if a user is currently subscribed to a specific product. This can be useful for verifying user access to features or content based on their subscription status.# Replace the following with the actual product UUID and user Discord IDproduct_uuid="c1eaaee5-9620-4343-b9da-test123"user_discord_id="12312312312312312"is_subscribed=awaitclient.user_is_subscribed(product_id,user_discord_id)print(is_subscribed)>>TrueorFalseException HandlingThe Upgrade.Chat Python Wrapper provides custom exceptions to help you handle potential errors that may occur during API interaction.Custom ExceptionsAuthenticationError: Raised when there is a problem with client authentication, such as incorrect client ID or client secret.HTTPError: Raised for general HTTP-related errors when making API requests.ResourceNotFoundError: Raised when a requested resource is not found on the Upgrade.Chat API.Example UsagefromupchatpyimportClientfromupchatpy.exceptionsimportAuthenticationError,HTTPError,ResourceNotFoundErrorclient_id='your_client_id'client_secret='your_client_secret'client=Client(client_id,client_secret)asyncdefmain():try:orders_response=awaitclient.get_orders()fororderinorders_response.data:print(order.uuid,order.total)exceptAuthenticationErrorase:print(f"Authentication failed with status code{e.status_code}:{e.message}")exceptResourceNotFoundErrorase:print(f"Resource not found with status code{e.status_code}:{e.message}")exceptHTTPErrorase:print(f"HTTP error with status code{e.status_code}:{e.message}")exceptExceptionase:print(f"An unexpected error occurred:{e}")DevelopmentThis package is under active development, and contributions are welcome! If you encounter any issues or have feature requests, please submit them to the project's issue tracker.LicenseThis wrapper is distributed under the MIT license. See theLICENSEfile for more information.