From 9ef10ab8cdb4b566b61ebfa104acaef5df275696 Mon Sep 17 00:00:00 2001 From: MagicBella Date: Mon, 2 Mar 2026 06:13:37 +0000 Subject: [PATCH] chore: regen sdk --- .../auto-bump-magicbell-go-1772432016.md | 5 + README.md | 203 ++++- cmd/project-client/examples/example.go | 12 +- cmd/user-client/examples/example.go | 12 +- docs/project-client/README.md | 125 ++- docs/project-client/models/apns_config.md | 10 +- .../models/apns_config_collection.md | 8 +- .../models/apns_config_payload.md | 16 +- docs/project-client/models/apns_token.md | 26 +- .../models/apns_token_collection.md | 8 +- docs/project-client/models/broadcast.md | 152 ++-- .../models/broadcast_collection.md | 8 +- .../models/category_delivery_config.md | 40 +- .../models/create_run_response.md | 7 + docs/project-client/models/discard_result.md | 8 +- docs/project-client/models/event.md | 19 +- .../project-client/models/event_collection.md | 8 +- .../models/event_source_config.md | 9 + .../models/event_source_config_collection.md | 8 + .../models/event_source_config_payload.md | 7 + .../models/execute_workflow_request.md | 8 + docs/project-client/models/expo_config.md | 10 +- .../models/expo_config_collection.md | 8 +- .../models/expo_config_payload.md | 6 +- docs/project-client/models/expo_token.md | 14 +- .../models/expo_token_collection.md | 8 +- docs/project-client/models/fcm_config.md | 10 +- .../models/fcm_config_collection.md | 8 +- .../models/fcm_config_payload.md | 34 +- docs/project-client/models/fcm_token.md | 24 +- .../models/fcm_token_collection.md | 8 +- .../project-client/models/get_run_response.md | 23 + docs/project-client/models/github_config.md | 10 +- .../models/github_config_collection.md | 8 +- docs/project-client/models/inbox_config.md | 10 +- .../models/inbox_config_collection.md | 8 +- .../models/inbox_config_payload.md | 222 +++-- .../models/inbox_token_response.md | 16 +- .../models/inbox_token_response_collection.md | 8 +- .../models/integration_config_collection.md | 8 +- docs/project-client/models/mailgun_config.md | 10 +- .../models/mailgun_config_collection.md | 8 +- .../models/mailgun_config_payload.md | 4 +- docs/project-client/models/ping_config.md | 10 +- .../models/ping_config_collection.md | 8 +- docs/project-client/models/sendgrid_config.md | 10 +- .../models/sendgrid_config_collection.md | 8 +- .../models/sendgrid_config_payload.md | 12 +- docs/project-client/models/ses_config.md | 10 +- .../models/ses_config_collection.md | 8 +- .../project-client/models/slack_bot_config.md | 9 + .../models/slack_bot_config_collection.md | 8 + .../models/slack_bot_config_payload.md | 7 + docs/project-client/models/slack_config.md | 10 +- .../models/slack_config_collection.md | 8 +- docs/project-client/models/slack_token.md | 24 +- .../models/slack_token_collection.md | 8 +- docs/project-client/models/smtp_config.md | 47 + .../models/smtp_config_object.md | 9 + .../models/smtp_config_object_collection.md | 8 + docs/project-client/models/stripe_config.md | 10 +- .../models/stripe_config_collection.md | 8 +- .../models/stripe_config_payload.md | 1 + docs/project-client/models/teams_token.md | 14 +- .../models/teams_token_collection.md | 8 +- docs/project-client/models/twilio_config.md | 10 +- .../models/twilio_config_collection.md | 8 +- docs/project-client/models/user.md | 24 +- docs/project-client/models/user_collection.md | 8 +- docs/project-client/models/web_push_token.md | 8 +- .../models/web_push_token_collection.md | 8 +- docs/project-client/models/webpush_config.md | 10 +- .../models/webpush_config_collection.md | 8 +- .../models/webpush_config_payload.md | 8 +- .../models/workflow_definition.md | 19 + docs/project-client/models/workflow_list.md | 27 + docs/project-client/models/workflow_run.md | 22 + .../models/workflow_run_collection.md | 8 + .../services/broadcasts_service.md | 76 +- .../services/channels_service.md | 326 +++++-- .../project-client/services/events_service.md | 12 +- .../services/integrations_service.md | 828 ++++++++++++++---- docs/project-client/services/users_service.md | 33 +- .../services/workflows_service.md | 283 ++++++ docs/project-client/snippets/snippets.json | 181 ++-- docs/user-client/README.md | 94 +- docs/user-client/models/apns_token.md | 24 +- .../models/apns_token_collection.md | 8 +- docs/user-client/models/apns_token_payload.md | 16 +- docs/user-client/models/count_response.md | 7 + docs/user-client/models/discard_result.md | 8 +- docs/user-client/models/expo_token.md | 14 +- .../models/expo_token_collection.md | 8 +- docs/user-client/models/expo_token_payload.md | 6 +- docs/user-client/models/fcm_token.md | 24 +- .../models/fcm_token_collection.md | 8 +- docs/user-client/models/fcm_token_payload.md | 16 +- .../models/inbox_config_payload.md | 222 +++-- docs/user-client/models/inbox_token.md | 8 +- .../models/inbox_token_response.md | 16 +- .../models/inbox_token_response_collection.md | 8 +- docs/user-client/models/notification.md | 34 +- .../models/notification_collection.md | 8 +- docs/user-client/models/slack_installation.md | 72 +- .../user-client/models/slack_start_install.md | 12 +- docs/user-client/models/slack_token.md | 24 +- .../models/slack_token_collection.md | 8 +- .../user-client/models/slack_token_payload.md | 16 +- docs/user-client/models/teams_token.md | 14 +- .../models/teams_token_collection.md | 8 +- docs/user-client/models/user_preferences.md | 26 + .../web_push_start_installation_response.md | 8 +- docs/user-client/models/web_push_token.md | 8 +- .../models/web_push_token_collection.md | 8 +- docs/user-client/services/channels_service.md | 516 +++++++++-- .../services/integrations_service.md | 358 ++++++-- .../services/notifications_service.md | 115 ++- docs/user-client/snippets/snippets.json | 111 ++- pkg/project-client/broadcasts/broadcast.go | 593 +------------ .../broadcasts/broadcast_status.go | 66 ++ .../broadcasts/broadcasts_service.go | 35 +- pkg/project-client/broadcasts/email.go | 66 ++ pkg/project-client/broadcasts/errors.go | 27 + pkg/project-client/broadcasts/in_app.go | 66 ++ pkg/project-client/broadcasts/mobile_push.go | 66 ++ pkg/project-client/broadcasts/overrides.go | 41 + .../broadcasts/overrides_channels.go | 67 ++ pkg/project-client/broadcasts/providers.go | 145 +++ .../broadcasts/request_params.go | 7 + pkg/project-client/broadcasts/sms.go | 66 ++ .../broadcasts/status_status.go | 10 + pkg/project-client/broadcasts/summary.go | 41 + pkg/project-client/channels/apns_token.go | 33 +- .../channels/category_delivery_config.go | 80 +- .../category_delivery_config_channels.go | 65 ++ pkg/project-client/channels/channel.go | 14 + .../channels/channels_service.go | 224 +++-- pkg/project-client/channels/discard_result.go | 4 +- pkg/project-client/channels/expo_token.go | 13 +- pkg/project-client/channels/fcm_token.go | 34 +- .../channels/inbox_token_response.go | 16 +- .../channels/installation_id.go | 9 + pkg/project-client/channels/keys.go | 41 + pkg/project-client/channels/oauth.go | 53 ++ pkg/project-client/channels/request_params.go | 72 ++ pkg/project-client/channels/slack_token.go | 83 +- .../channels/slack_token_webhook.go | 28 + pkg/project-client/channels/teams_token.go | 35 +- .../channels/teams_token_webhook.go | 26 + pkg/project-client/channels/web_push_token.go | 48 +- pkg/project-client/client/client.go | 15 + pkg/project-client/clientconfig/config.go | 11 +- .../clientconfig/environments.go | 2 + pkg/project-client/events/event.go | 38 +- pkg/project-client/events/events_service.go | 29 +- pkg/project-client/events/request_params.go | 7 + .../integrations/apns_config_payload.go | 26 +- pkg/project-client/integrations/badge.go | 9 + pkg/project-client/integrations/banner.go | 67 ++ pkg/project-client/integrations/default_.go | 119 +++ .../integrations/default_hover.go | 28 + .../integrations/default_state.go | 28 + pkg/project-client/integrations/dialog.go | 54 ++ .../integrations/event_source_config.go | 50 ++ .../event_source_config_collection.go | 41 + .../event_source_config_payload.go | 26 + .../integrations/expo_config_payload.go | 1 + .../integrations/fcm_config_payload.go | 37 +- pkg/project-client/integrations/footer.go | 67 ++ pkg/project-client/integrations/header.go | 80 ++ pkg/project-client/integrations/icon.go | 41 + pkg/project-client/integrations/images.go | 28 + .../integrations/inbox_config_payload.go | 827 +---------------- .../integrations/integrations_service.go | 455 +++++++--- .../integrations/mailgun_config_payload.go | 58 +- .../mailgun_config_payload_from.go | 52 ++ .../integrations/notification.go | 54 ++ .../integrations/payload_version.go | 9 + pkg/project-client/integrations/region.go | 8 + .../integrations/request_params.go | 79 ++ pkg/project-client/integrations/security.go | 10 + .../integrations/sendgrid_config_payload.go | 106 +-- .../sendgrid_config_payload_from.go | 52 ++ .../sendgrid_config_payload_reply_to.go | 52 ++ .../integrations/ses_config_payload.go | 51 +- .../integrations/ses_config_payload_from.go | 52 ++ .../integrations/slack_bot_config.go | 50 ++ .../slack_bot_config_collection.go | 41 + .../integrations/slack_bot_config_payload.go | 26 + .../integrations/smtp_config.go | 105 +++ .../integrations/smtp_config_from.go | 41 + .../integrations/smtp_config_object.go | 50 ++ .../smtp_config_object_collection.go | 41 + .../integrations/smtp_config_reply_to.go | 41 + .../integrations/stripe_config_payload.go | 13 + pkg/project-client/integrations/theme.go | 106 +++ pkg/project-client/integrations/type_.go | 8 + pkg/project-client/integrations/unread.go | 67 ++ .../integrations/unread_hover.go | 28 + .../integrations/unread_state.go | 28 + pkg/project-client/integrations/unseen.go | 67 ++ .../integrations/unseen_badge.go | 28 + .../integrations/unseen_hover.go | 28 + .../integrations/unseen_state.go | 28 + .../integrations/webpush_config_payload.go | 4 +- .../internal/clients/rest/client.go | 39 +- .../rest/handlers/bearer_token_handler.go | 49 +- .../clients/rest/handlers/handler_chain.go | 38 +- .../clients/rest/handlers/hook_handler.go | 51 +- .../handlers/request_validation_handler.go | 48 +- .../handlers/response_validation_handler.go | 37 +- .../clients/rest/handlers/retry_handler.go | 55 +- .../rest/handlers/terminating_handler.go | 70 +- .../rest/handlers/unmarshal_handler.go | 172 +++- .../clients/rest/hooks/default_hook.go | 7 + .../internal/clients/rest/hooks/hook.go | 5 + .../rest/httptransport/content-type.go | 2 + .../rest/httptransport/error_response.go | 19 +- .../rest/httptransport/request-builder.go | 26 + .../clients/rest/httptransport/request.go | 6 + .../clients/rest/httptransport/response.go | 8 + .../clients/rest/httptransport/stream.go | 193 ++++ .../internal/configmanager/config_manager.go | 41 + .../internal/contenttypes/from_binary.go | 25 +- .../internal/contenttypes/from_form_data.go | 33 +- .../contenttypes/from_form_url_encoded.go | 27 +- .../internal/contenttypes/from_json.go | 2 + .../internal/contenttypes/from_text.go | 18 +- .../internal/contenttypes/to_binary.go | 2 + .../internal/contenttypes/to_form_data.go | 9 +- .../contenttypes/to_form_url_encoded.go | 2 + .../internal/contenttypes/to_json.go | 2 + .../internal/contenttypes/to_text.go | 2 + .../internal/marshal/from_complex_object.go | 3 + .../serialization/serialize_object.go | 9 + .../internal/unmarshal/to_complex_object.go | 25 +- .../internal/unmarshal/to_object.go | 2 + .../internal/unmarshal/to_primitive.go | 8 + .../internal/unmarshal/unmarshal.go | 9 +- .../internal/unmarshal/unmarshal_nullable.go | 4 + pkg/project-client/internal/utils/utils.go | 14 + .../validation/validate_array_length.go | 4 + .../validation/validate_array_unique.go | 2 + .../internal/validation/validate_max.go | 2 + .../internal/validation/validate_min.go | 2 + .../validation/validate_multiple_of.go | 2 + .../internal/validation/validate_pattern.go | 2 + .../internal/validation/validate_required.go | 4 + .../internal/validation/validation.go | 91 +- pkg/project-client/shared/client_error.go | 25 +- pkg/project-client/shared/client_response.go | 13 +- pkg/project-client/shared/user.go | 30 +- pkg/project-client/users/request_params.go | 9 + pkg/project-client/users/users_service.go | 35 +- pkg/project-client/util/nullable.go | 6 + pkg/project-client/util/to_pointer.go | 2 + .../workflows/create_run_response.go | 27 + .../workflows/execute_workflow_request.go | 52 ++ .../workflows/get_run_response.go | 74 ++ .../workflows/get_run_response_status.go | 74 ++ pkg/project-client/workflows/items.go | 50 ++ pkg/project-client/workflows/items_steps.go | 67 ++ .../workflows/workflow_definition.go | 53 ++ .../workflows/workflow_definition_steps.go | 69 ++ pkg/project-client/workflows/workflow_list.go | 26 + pkg/project-client/workflows/workflow_run.go | 62 ++ .../workflows/workflow_run_collection.go | 41 + .../workflows/workflow_run_status.go | 74 ++ .../workflows/workflows_service.go | 194 ++++ pkg/user-client/channels/apns_token.go | 27 +- .../channels/apns_token_installation_id.go | 9 + .../channels/apns_token_payload.go | 15 +- .../apns_token_payload_installation_id.go | 9 + pkg/user-client/channels/categories.go | 62 ++ pkg/user-client/channels/channels.go | 38 + pkg/user-client/channels/channels_service.go | 318 +++++-- pkg/user-client/channels/discard_result.go | 4 +- pkg/user-client/channels/expo_token.go | 13 +- .../channels/expo_token_payload.go | 1 + pkg/user-client/channels/fcm_token.go | 34 +- pkg/user-client/channels/fcm_token_payload.go | 22 +- pkg/user-client/channels/inbox_token.go | 4 +- .../channels/inbox_token_response.go | 16 +- pkg/user-client/channels/request_params.go | 72 ++ pkg/user-client/channels/slack_token.go | 83 +- pkg/user-client/channels/slack_token_oauth.go | 53 ++ .../channels/slack_token_payload.go | 71 -- .../channels/slack_token_payload_oauth.go | 53 ++ .../channels/slack_token_payload_webhook.go | 28 + .../channels/slack_token_webhook.go | 28 + pkg/user-client/channels/teams_token.go | 35 +- .../channels/teams_token_payload.go | 23 - .../channels/teams_token_payload_webhook.go | 26 + .../channels/teams_token_webhook.go | 26 + pkg/user-client/channels/user_preferences.go | 26 + pkg/user-client/channels/web_push_token.go | 48 +- .../channels/web_push_token_keys.go | 41 + pkg/user-client/client/client.go | 7 + pkg/user-client/clientconfig/config.go | 11 +- pkg/user-client/clientconfig/environments.go | 2 + pkg/user-client/integrations/authed_user.go | 92 ++ pkg/user-client/integrations/banner.go | 67 ++ pkg/user-client/integrations/default_.go | 119 +++ pkg/user-client/integrations/default_hover.go | 28 + pkg/user-client/integrations/default_state.go | 28 + pkg/user-client/integrations/dialog.go | 54 ++ pkg/user-client/integrations/enterprise.go | 40 + pkg/user-client/integrations/footer.go | 67 ++ pkg/user-client/integrations/header.go | 80 ++ pkg/user-client/integrations/icon.go | 41 + pkg/user-client/integrations/images.go | 28 + .../integrations/inbox_config_payload.go | 827 +---------------- .../integrations/incoming_webhook.go | 53 ++ .../integrations/integrations_service.go | 128 ++- .../integrations/slack_installation.go | 235 +---- .../integrations/slack_start_install.go | 10 +- pkg/user-client/integrations/team.go | 40 + pkg/user-client/integrations/theme.go | 106 +++ .../integrations/theme_notification.go | 54 ++ pkg/user-client/integrations/unread.go | 67 ++ pkg/user-client/integrations/unread_hover.go | 28 + pkg/user-client/integrations/unread_state.go | 28 + pkg/user-client/integrations/unseen.go | 67 ++ pkg/user-client/integrations/unseen_badge.go | 28 + pkg/user-client/integrations/unseen_hover.go | 28 + pkg/user-client/integrations/unseen_state.go | 28 + .../web_push_start_installation_response.go | 2 + .../internal/clients/rest/client.go | 39 +- .../rest/handlers/bearer_token_handler.go | 49 +- .../clients/rest/handlers/handler_chain.go | 38 +- .../clients/rest/handlers/hook_handler.go | 51 +- .../handlers/request_validation_handler.go | 48 +- .../handlers/response_validation_handler.go | 37 +- .../clients/rest/handlers/retry_handler.go | 55 +- .../rest/handlers/terminating_handler.go | 70 +- .../rest/handlers/unmarshal_handler.go | 172 +++- .../clients/rest/hooks/default_hook.go | 7 + .../internal/clients/rest/hooks/hook.go | 5 + .../rest/httptransport/content-type.go | 2 + .../rest/httptransport/error_response.go | 19 +- .../rest/httptransport/request-builder.go | 26 + .../clients/rest/httptransport/request.go | 6 + .../clients/rest/httptransport/response.go | 8 + .../clients/rest/httptransport/stream.go | 193 ++++ .../internal/configmanager/config_manager.go | 20 + .../internal/contenttypes/from_binary.go | 25 +- .../internal/contenttypes/from_form_data.go | 33 +- .../contenttypes/from_form_url_encoded.go | 27 +- .../internal/contenttypes/from_json.go | 2 + .../internal/contenttypes/from_text.go | 18 +- .../internal/contenttypes/to_binary.go | 2 + .../internal/contenttypes/to_form_data.go | 9 +- .../contenttypes/to_form_url_encoded.go | 2 + .../internal/contenttypes/to_json.go | 2 + .../internal/contenttypes/to_text.go | 2 + .../internal/marshal/from_complex_object.go | 3 + .../serialization/serialize_object.go | 9 + .../internal/unmarshal/to_complex_object.go | 25 +- .../internal/unmarshal/to_object.go | 2 + .../internal/unmarshal/to_primitive.go | 8 + .../internal/unmarshal/unmarshal.go | 9 +- .../internal/unmarshal/unmarshal_nullable.go | 4 + pkg/user-client/internal/utils/utils.go | 14 + .../validation/validate_array_length.go | 4 + .../validation/validate_array_unique.go | 2 + .../internal/validation/validate_max.go | 2 + .../internal/validation/validate_min.go | 2 + .../validation/validate_multiple_of.go | 2 + .../internal/validation/validate_pattern.go | 2 + .../internal/validation/validate_required.go | 4 + .../internal/validation/validation.go | 91 +- .../notifications/count_response.go | 27 + pkg/user-client/notifications/notification.go | 45 +- .../notifications/notifications_service.go | 87 +- .../notifications/request_params.go | 40 + pkg/user-client/shared/client_error.go | 25 +- pkg/user-client/shared/client_response.go | 13 +- .../shared/web_push_token_payload.go | 38 - .../shared/web_push_token_payload_keys.go | 41 + pkg/user-client/util/nullable.go | 6 + pkg/user-client/util/to_pointer.go | 2 + 381 files changed, 12620 insertions(+), 5378 deletions(-) create mode 100644 .changeset/auto-bump-magicbell-go-1772432016.md create mode 100644 docs/project-client/models/create_run_response.md create mode 100644 docs/project-client/models/event_source_config.md create mode 100644 docs/project-client/models/event_source_config_collection.md create mode 100644 docs/project-client/models/event_source_config_payload.md create mode 100644 docs/project-client/models/execute_workflow_request.md create mode 100644 docs/project-client/models/get_run_response.md create mode 100644 docs/project-client/models/slack_bot_config.md create mode 100644 docs/project-client/models/slack_bot_config_collection.md create mode 100644 docs/project-client/models/slack_bot_config_payload.md create mode 100644 docs/project-client/models/smtp_config.md create mode 100644 docs/project-client/models/smtp_config_object.md create mode 100644 docs/project-client/models/smtp_config_object_collection.md create mode 100644 docs/project-client/models/workflow_definition.md create mode 100644 docs/project-client/models/workflow_list.md create mode 100644 docs/project-client/models/workflow_run.md create mode 100644 docs/project-client/models/workflow_run_collection.md create mode 100644 docs/project-client/services/workflows_service.md create mode 100644 docs/user-client/models/count_response.md create mode 100644 docs/user-client/models/user_preferences.md create mode 100644 pkg/project-client/broadcasts/broadcast_status.go create mode 100644 pkg/project-client/broadcasts/email.go create mode 100644 pkg/project-client/broadcasts/errors.go create mode 100644 pkg/project-client/broadcasts/in_app.go create mode 100644 pkg/project-client/broadcasts/mobile_push.go create mode 100644 pkg/project-client/broadcasts/overrides.go create mode 100644 pkg/project-client/broadcasts/overrides_channels.go create mode 100644 pkg/project-client/broadcasts/providers.go create mode 100644 pkg/project-client/broadcasts/sms.go create mode 100644 pkg/project-client/broadcasts/status_status.go create mode 100644 pkg/project-client/broadcasts/summary.go create mode 100644 pkg/project-client/channels/category_delivery_config_channels.go create mode 100644 pkg/project-client/channels/channel.go create mode 100644 pkg/project-client/channels/installation_id.go create mode 100644 pkg/project-client/channels/keys.go create mode 100644 pkg/project-client/channels/oauth.go create mode 100644 pkg/project-client/channels/slack_token_webhook.go create mode 100644 pkg/project-client/channels/teams_token_webhook.go create mode 100644 pkg/project-client/integrations/badge.go create mode 100644 pkg/project-client/integrations/banner.go create mode 100644 pkg/project-client/integrations/default_.go create mode 100644 pkg/project-client/integrations/default_hover.go create mode 100644 pkg/project-client/integrations/default_state.go create mode 100644 pkg/project-client/integrations/dialog.go create mode 100644 pkg/project-client/integrations/event_source_config.go create mode 100644 pkg/project-client/integrations/event_source_config_collection.go create mode 100644 pkg/project-client/integrations/event_source_config_payload.go create mode 100644 pkg/project-client/integrations/footer.go create mode 100644 pkg/project-client/integrations/header.go create mode 100644 pkg/project-client/integrations/icon.go create mode 100644 pkg/project-client/integrations/images.go create mode 100644 pkg/project-client/integrations/mailgun_config_payload_from.go create mode 100644 pkg/project-client/integrations/notification.go create mode 100644 pkg/project-client/integrations/payload_version.go create mode 100644 pkg/project-client/integrations/region.go create mode 100644 pkg/project-client/integrations/security.go create mode 100644 pkg/project-client/integrations/sendgrid_config_payload_from.go create mode 100644 pkg/project-client/integrations/sendgrid_config_payload_reply_to.go create mode 100644 pkg/project-client/integrations/ses_config_payload_from.go create mode 100644 pkg/project-client/integrations/slack_bot_config.go create mode 100644 pkg/project-client/integrations/slack_bot_config_collection.go create mode 100644 pkg/project-client/integrations/slack_bot_config_payload.go create mode 100644 pkg/project-client/integrations/smtp_config.go create mode 100644 pkg/project-client/integrations/smtp_config_from.go create mode 100644 pkg/project-client/integrations/smtp_config_object.go create mode 100644 pkg/project-client/integrations/smtp_config_object_collection.go create mode 100644 pkg/project-client/integrations/smtp_config_reply_to.go create mode 100644 pkg/project-client/integrations/theme.go create mode 100644 pkg/project-client/integrations/type_.go create mode 100644 pkg/project-client/integrations/unread.go create mode 100644 pkg/project-client/integrations/unread_hover.go create mode 100644 pkg/project-client/integrations/unread_state.go create mode 100644 pkg/project-client/integrations/unseen.go create mode 100644 pkg/project-client/integrations/unseen_badge.go create mode 100644 pkg/project-client/integrations/unseen_hover.go create mode 100644 pkg/project-client/integrations/unseen_state.go create mode 100644 pkg/project-client/internal/clients/rest/httptransport/stream.go create mode 100644 pkg/project-client/workflows/create_run_response.go create mode 100644 pkg/project-client/workflows/execute_workflow_request.go create mode 100644 pkg/project-client/workflows/get_run_response.go create mode 100644 pkg/project-client/workflows/get_run_response_status.go create mode 100644 pkg/project-client/workflows/items.go create mode 100644 pkg/project-client/workflows/items_steps.go create mode 100644 pkg/project-client/workflows/workflow_definition.go create mode 100644 pkg/project-client/workflows/workflow_definition_steps.go create mode 100644 pkg/project-client/workflows/workflow_list.go create mode 100644 pkg/project-client/workflows/workflow_run.go create mode 100644 pkg/project-client/workflows/workflow_run_collection.go create mode 100644 pkg/project-client/workflows/workflow_run_status.go create mode 100644 pkg/project-client/workflows/workflows_service.go create mode 100644 pkg/user-client/channels/apns_token_installation_id.go create mode 100644 pkg/user-client/channels/apns_token_payload_installation_id.go create mode 100644 pkg/user-client/channels/categories.go create mode 100644 pkg/user-client/channels/channels.go create mode 100644 pkg/user-client/channels/slack_token_oauth.go create mode 100644 pkg/user-client/channels/slack_token_payload_oauth.go create mode 100644 pkg/user-client/channels/slack_token_payload_webhook.go create mode 100644 pkg/user-client/channels/slack_token_webhook.go create mode 100644 pkg/user-client/channels/teams_token_payload_webhook.go create mode 100644 pkg/user-client/channels/teams_token_webhook.go create mode 100644 pkg/user-client/channels/user_preferences.go create mode 100644 pkg/user-client/channels/web_push_token_keys.go create mode 100644 pkg/user-client/integrations/authed_user.go create mode 100644 pkg/user-client/integrations/banner.go create mode 100644 pkg/user-client/integrations/default_.go create mode 100644 pkg/user-client/integrations/default_hover.go create mode 100644 pkg/user-client/integrations/default_state.go create mode 100644 pkg/user-client/integrations/dialog.go create mode 100644 pkg/user-client/integrations/enterprise.go create mode 100644 pkg/user-client/integrations/footer.go create mode 100644 pkg/user-client/integrations/header.go create mode 100644 pkg/user-client/integrations/icon.go create mode 100644 pkg/user-client/integrations/images.go create mode 100644 pkg/user-client/integrations/incoming_webhook.go create mode 100644 pkg/user-client/integrations/team.go create mode 100644 pkg/user-client/integrations/theme.go create mode 100644 pkg/user-client/integrations/theme_notification.go create mode 100644 pkg/user-client/integrations/unread.go create mode 100644 pkg/user-client/integrations/unread_hover.go create mode 100644 pkg/user-client/integrations/unread_state.go create mode 100644 pkg/user-client/integrations/unseen.go create mode 100644 pkg/user-client/integrations/unseen_badge.go create mode 100644 pkg/user-client/integrations/unseen_hover.go create mode 100644 pkg/user-client/integrations/unseen_state.go create mode 100644 pkg/user-client/internal/clients/rest/httptransport/stream.go create mode 100644 pkg/user-client/notifications/count_response.go create mode 100644 pkg/user-client/shared/web_push_token_payload_keys.go diff --git a/.changeset/auto-bump-magicbell-go-1772432016.md b/.changeset/auto-bump-magicbell-go-1772432016.md new file mode 100644 index 0000000..114cff5 --- /dev/null +++ b/.changeset/auto-bump-magicbell-go-1772432016.md @@ -0,0 +1,5 @@ +--- +"magicbell-go": minor +--- + +Automatic minor version bump for changes in `magicbell-go`. diff --git a/README.md b/README.md index 37488ea..cab79d3 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,60 @@ sdk := client.NewClient(config) sdk.SetAccessToken("YOUR-TOKEN") ``` +## Setting a Custom Timeout + +You can set a custom timeout for the SDK's HTTP requests as follows: + +```go +import "time" + +config := clientconfig.NewConfig() + +sdk := client.NewClient(config) + +sdk.SetTimeout(10 * time.Second) +``` + +# Sample Usage + +Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint: + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + "github.com/magicbell/magicbell-go/pkg/project-client/util" + "github.com/magicbell/magicbell-go/pkg/project-client/broadcasts" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +params := broadcasts.ListBroadcastsRequestParams{ + Limit: util.ToPointer(int64(0)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), +} + +response, err := client.Broadcasts.ListBroadcasts(context.Background(), params) +if err != nil { + panic(err) +} + +fmt.Println(response) + +``` + ## Services The SDK provides various services to interact with the API. -
+
Below is a list of all available services with links to their detailed documentation: | Name | @@ -62,6 +111,7 @@ The SDK provides various services to interact with the API. | [EventsService](docs/project-client/services/events_service.md) | | [IntegrationsService](docs/project-client/services/integrations_service.md) | | [UsersService](docs/project-client/services/users_service.md) | +| [WorkflowsService](docs/project-client/services/workflows_service.md) |
@@ -83,15 +133,16 @@ This response wrapper is used to return the response data from the API. It conta | Data | `T` | The body of the API response | | Metadata | `ClientResponseMetadata` | Status code and headers returned by the API | -#### `ClientError` +#### `ClientError[T]` This response wrapper is used to return an error. It contains the following fields: -| Name | Type | Description | -| :------- | :----------------------- | :------------------------------------------ | -| Err | `error` | The error that occurred | -| Body | `T` | The body of the API response | -| Metadata | `ClientResponseMetadata` | Status code and headers returned by the API | +| Name | Type | Description | +| :------- | :-------------------- | :---------------------------------------------------------------- | +| Err | `error` | The error that occurred | +| Data | `*T` | The deserialized error response data (nil if unmarshaling failed) | +| Body | `[]byte` | The raw body of the API response | +| Metadata | `ClientErrorMetadata` | Status code and headers returned by the API | #### `ClientResponseMetadata` @@ -108,16 +159,19 @@ This struct is shared by both response wrappers and contains the following field The SDK includes several models that represent the data structures used in API requests and responses. These models help in organizing and managing the data efficiently. -
+
Below is a list of all available models with links to their detailed documentation: | Name | Description | | :-------------------------------------------------------------------------------------- | :---------- | | [BroadcastCollection](docs/project-client/models/broadcast_collection.md) | | | [Broadcast](docs/project-client/models/broadcast.md) | | +| [User](docs/project-client/models/user.md) | | +| [Links](docs/project-client/models/links.md) | | | [CategoryDeliveryConfig](docs/project-client/models/category_delivery_config.md) | | | [InboxTokenResponseCollection](docs/project-client/models/inbox_token_response_collection.md) | | | [InboxTokenResponse](docs/project-client/models/inbox_token_response.md) | | +| [Links](docs/project-client/models/links.md) | | | [DiscardResult](docs/project-client/models/discard_result.md) | | | [ApnsTokenCollection](docs/project-client/models/apns_token_collection.md) | | | [ApnsToken](docs/project-client/models/apns_token.md) | | @@ -133,50 +187,69 @@ The SDK includes several models that represent the data structures used in API r | [WebPushToken](docs/project-client/models/web_push_token.md) | | | [EventCollection](docs/project-client/models/event_collection.md) | | | [Event](docs/project-client/models/event.md) | | +| [Links](docs/project-client/models/links.md) | | | [IntegrationConfigCollection](docs/project-client/models/integration_config_collection.md) | | +| [IntegrationConfig](docs/project-client/models/integration_config.md) | | +| [Links](docs/project-client/models/links.md) | | | [ApnsConfigCollection](docs/project-client/models/apns_config_collection.md) | | +| [ApnsConfig](docs/project-client/models/apns_config.md) | | | [ApnsConfigPayload](docs/project-client/models/apns_config_payload.md) | | +| [EventSourceConfigCollection](docs/project-client/models/event_source_config_collection.md) | | +| [EventSourceConfig](docs/project-client/models/event_source_config.md) | | +| [EventSourceConfigPayload](docs/project-client/models/event_source_config_payload.md) | | | [ExpoConfigCollection](docs/project-client/models/expo_config_collection.md) | | +| [ExpoConfig](docs/project-client/models/expo_config.md) | | | [ExpoConfigPayload](docs/project-client/models/expo_config_payload.md) | | | [FcmConfigCollection](docs/project-client/models/fcm_config_collection.md) | | +| [FcmConfig](docs/project-client/models/fcm_config.md) | | | [FcmConfigPayload](docs/project-client/models/fcm_config_payload.md) | | | [GithubConfigCollection](docs/project-client/models/github_config_collection.md) | | +| [GithubConfig](docs/project-client/models/github_config.md) | | | [GithubConfigPayload](docs/project-client/models/github_config_payload.md) | | | [InboxConfigCollection](docs/project-client/models/inbox_config_collection.md) | | +| [InboxConfig](docs/project-client/models/inbox_config.md) | | | [InboxConfigPayload](docs/project-client/models/inbox_config_payload.md) | | +| [SlackBotConfigCollection](docs/project-client/models/slack_bot_config_collection.md) | | +| [SlackBotConfig](docs/project-client/models/slack_bot_config.md) | | +| [SlackBotConfigPayload](docs/project-client/models/slack_bot_config_payload.md) | | | [MailgunConfigCollection](docs/project-client/models/mailgun_config_collection.md) | | +| [MailgunConfig](docs/project-client/models/mailgun_config.md) | | | [MailgunConfigPayload](docs/project-client/models/mailgun_config_payload.md) | | | [PingConfigCollection](docs/project-client/models/ping_config_collection.md) | | +| [PingConfig](docs/project-client/models/ping_config.md) | | | [PingConfigPayload](docs/project-client/models/ping_config_payload.md) | | | [SendgridConfigCollection](docs/project-client/models/sendgrid_config_collection.md) | | +| [SendgridConfig](docs/project-client/models/sendgrid_config.md) | | | [SendgridConfigPayload](docs/project-client/models/sendgrid_config_payload.md) | | | [SesConfigCollection](docs/project-client/models/ses_config_collection.md) | | +| [SesConfig](docs/project-client/models/ses_config.md) | | | [SesConfigPayload](docs/project-client/models/ses_config_payload.md) | | | [SlackConfigCollection](docs/project-client/models/slack_config_collection.md) | | +| [SlackConfig](docs/project-client/models/slack_config.md) | | | [SlackConfigPayload](docs/project-client/models/slack_config_payload.md) | | +| [SmtpConfigObjectCollection](docs/project-client/models/smtp_config_object_collection.md) | | +| [SmtpConfigObject](docs/project-client/models/smtp_config_object.md) | | +| [SmtpConfig](docs/project-client/models/smtp_config.md) | | | [StripeConfigCollection](docs/project-client/models/stripe_config_collection.md) | | +| [StripeConfig](docs/project-client/models/stripe_config.md) | | | [StripeConfigPayload](docs/project-client/models/stripe_config_payload.md) | | | [TwilioConfigCollection](docs/project-client/models/twilio_config_collection.md) | | +| [TwilioConfig](docs/project-client/models/twilio_config.md) | | | [TwilioConfigPayload](docs/project-client/models/twilio_config_payload.md) | | | [WebpushConfigCollection](docs/project-client/models/webpush_config_collection.md) | | +| [WebpushConfig](docs/project-client/models/webpush_config.md) | | | [WebpushConfigPayload](docs/project-client/models/webpush_config_payload.md) | | | [UserCollection](docs/project-client/models/user_collection.md) | | | [User](docs/project-client/models/user.md) | | | [Links](docs/project-client/models/links.md) | | -| [IntegrationConfig](docs/project-client/models/integration_config.md) | | -| [ApnsConfig](docs/project-client/models/apns_config.md) | | -| [ExpoConfig](docs/project-client/models/expo_config.md) | | -| [FcmConfig](docs/project-client/models/fcm_config.md) | | -| [GithubConfig](docs/project-client/models/github_config.md) | | -| [InboxConfig](docs/project-client/models/inbox_config.md) | | -| [MailgunConfig](docs/project-client/models/mailgun_config.md) | | -| [PingConfig](docs/project-client/models/ping_config.md) | | -| [SendgridConfig](docs/project-client/models/sendgrid_config.md) | | -| [SesConfig](docs/project-client/models/ses_config.md) | | -| [SlackConfig](docs/project-client/models/slack_config.md) | | -| [StripeConfig](docs/project-client/models/stripe_config.md) | | -| [TwilioConfig](docs/project-client/models/twilio_config.md) | | -| [WebpushConfig](docs/project-client/models/webpush_config.md) | | +| [WorkflowList](docs/project-client/models/workflow_list.md) | | +| [WorkflowDefinition](docs/project-client/models/workflow_definition.md) | | +| [CreateRunResponse](docs/project-client/models/create_run_response.md) | | +| [ExecuteWorkflowRequest](docs/project-client/models/execute_workflow_request.md) | | +| [GetRunResponse](docs/project-client/models/get_run_response.md) | | +| [WorkflowRunCollection](docs/project-client/models/workflow_run_collection.md) | | +| [WorkflowRun](docs/project-client/models/workflow_run.md) | | +| [Links](docs/project-client/models/links.md) | |
@@ -224,11 +297,60 @@ sdk := client.NewClient(config) sdk.SetAccessToken("YOUR-TOKEN") ``` +## Setting a Custom Timeout + +You can set a custom timeout for the SDK's HTTP requests as follows: + +```go +import "time" + +config := clientconfig.NewConfig() + +sdk := client.NewClient(config) + +sdk.SetTimeout(10 * time.Second) +``` + +# Sample Usage + +Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint: + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/user-client/client" + "github.com/magicbell/magicbell-go/pkg/user-client/util" + "github.com/magicbell/magicbell-go/pkg/user-client/channels" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +params := channels.ListInboxTokensRequestParams{ + Limit: util.ToPointer(int64(8)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), +} + +response, err := client.Channels.ListInboxTokens(context.Background(), params) +if err != nil { + panic(err) +} + +fmt.Println(response) + +``` + ## Services The SDK provides various services to interact with the API. -
+
Below is a list of all available services with links to their detailed documentation: | Name | @@ -257,15 +379,16 @@ This response wrapper is used to return the response data from the API. It conta | Data | `T` | The body of the API response | | Metadata | `ClientResponseMetadata` | Status code and headers returned by the API | -#### `ClientError` +#### `ClientError[T]` This response wrapper is used to return an error. It contains the following fields: -| Name | Type | Description | -| :------- | :----------------------- | :------------------------------------------ | -| Err | `error` | The error that occurred | -| Body | `T` | The body of the API response | -| Metadata | `ClientResponseMetadata` | Status code and headers returned by the API | +| Name | Type | Description | +| :------- | :-------------------- | :---------------------------------------------------------------- | +| Err | `error` | The error that occurred | +| Data | `*T` | The deserialized error response data (nil if unmarshaling failed) | +| Body | `[]byte` | The raw body of the API response | +| Metadata | `ClientErrorMetadata` | Status code and headers returned by the API | #### `ClientResponseMetadata` @@ -282,42 +405,46 @@ This struct is shared by both response wrappers and contains the following field The SDK includes several models that represent the data structures used in API requests and responses. These models help in organizing and managing the data efficiently. -
+
Below is a list of all available models with links to their detailed documentation: | Name | Description | | :----------------------------------------------------------------------------------------------- | :---------- | | [InboxTokenResponseCollection](docs/user-client/models/inbox_token_response_collection.md) | | -| [InboxToken](docs/user-client/models/inbox_token.md) | | | [InboxTokenResponse](docs/user-client/models/inbox_token_response.md) | | +| [Links](docs/user-client/models/links.md) | | +| [InboxToken](docs/user-client/models/inbox_token.md) | | | [DiscardResult](docs/user-client/models/discard_result.md) | | | [ApnsTokenCollection](docs/user-client/models/apns_token_collection.md) | | -| [ApnsTokenPayload](docs/user-client/models/apns_token_payload.md) | | | [ApnsToken](docs/user-client/models/apns_token.md) | | +| [ApnsTokenPayload](docs/user-client/models/apns_token_payload.md) | | | [ExpoTokenCollection](docs/user-client/models/expo_token_collection.md) | | -| [ExpoTokenPayload](docs/user-client/models/expo_token_payload.md) | | | [ExpoToken](docs/user-client/models/expo_token.md) | | +| [ExpoTokenPayload](docs/user-client/models/expo_token_payload.md) | | | [FcmTokenCollection](docs/user-client/models/fcm_token_collection.md) | | -| [FcmTokenPayload](docs/user-client/models/fcm_token_payload.md) | | | [FcmToken](docs/user-client/models/fcm_token.md) | | +| [FcmTokenPayload](docs/user-client/models/fcm_token_payload.md) | | | [SlackTokenCollection](docs/user-client/models/slack_token_collection.md) | | -| [SlackTokenPayload](docs/user-client/models/slack_token_payload.md) | | | [SlackToken](docs/user-client/models/slack_token.md) | | +| [SlackTokenPayload](docs/user-client/models/slack_token_payload.md) | | | [TeamsTokenCollection](docs/user-client/models/teams_token_collection.md) | | -| [TeamsTokenPayload](docs/user-client/models/teams_token_payload.md) | | | [TeamsToken](docs/user-client/models/teams_token.md) | | +| [TeamsTokenPayload](docs/user-client/models/teams_token_payload.md) | | +| [UserPreferences](docs/user-client/models/user_preferences.md) | | | [WebPushTokenCollection](docs/user-client/models/web_push_token_collection.md) | | -| [WebPushTokenPayload](docs/user-client/models/web_push_token_payload.md) | | | [WebPushToken](docs/user-client/models/web_push_token.md) | | +| [WebPushTokenPayload](docs/user-client/models/web_push_token_payload.md) | | | [InboxConfigPayload](docs/user-client/models/inbox_config_payload.md) | | | [SlackInstallation](docs/user-client/models/slack_installation.md) | | | [SlackFinishInstallResponse](docs/user-client/models/slack_finish_install_response.md) | | -| [SlackStartInstall](docs/user-client/models/slack_start_install.md) | | | [SlackStartInstallResponseContent](docs/user-client/models/slack_start_install_response_content.md) | | +| [SlackStartInstall](docs/user-client/models/slack_start_install.md) | | +| [WebPushTokenPayload](docs/user-client/models/web_push_token_payload.md) | | | [WebPushStartInstallationResponse](docs/user-client/models/web_push_start_installation_response.md) | | | [NotificationCollection](docs/user-client/models/notification_collection.md) | | | [Notification](docs/user-client/models/notification.md) | | | [Links](docs/user-client/models/links.md) | | +| [CountResponse](docs/user-client/models/count_response.md) | |
diff --git a/cmd/project-client/examples/example.go b/cmd/project-client/examples/example.go index be3d60f..7bf960a 100644 --- a/cmd/project-client/examples/example.go +++ b/cmd/project-client/examples/example.go @@ -2,15 +2,15 @@ package main import ( "bufio" - "context" "fmt" "os" "strings" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/broadcasts" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" - - "github.com/magicbell/magicbell-go/pkg/project-client/broadcasts" + "github.com/magicbell/magicbell-go/pkg/project-client/util" ) func main() { @@ -19,7 +19,11 @@ func main() { config := clientconfig.NewConfig() client := client.NewClient(config) - params := broadcasts.ListBroadcastsRequestParams{} + params := broadcasts.ListBroadcastsRequestParams{ + Limit: util.ToPointer(int64(0)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), + } response, err := client.Broadcasts.ListBroadcasts(context.Background(), params) if err != nil { diff --git a/cmd/user-client/examples/example.go b/cmd/user-client/examples/example.go index 4b0ed6a..5e892df 100644 --- a/cmd/user-client/examples/example.go +++ b/cmd/user-client/examples/example.go @@ -2,15 +2,15 @@ package main import ( "bufio" - "context" "fmt" "os" "strings" + "context" + "github.com/magicbell/magicbell-go/pkg/user-client/channels" "github.com/magicbell/magicbell-go/pkg/user-client/client" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" - - "github.com/magicbell/magicbell-go/pkg/user-client/channels" + "github.com/magicbell/magicbell-go/pkg/user-client/util" ) func main() { @@ -19,7 +19,11 @@ func main() { config := clientconfig.NewConfig() client := client.NewClient(config) - params := channels.ListInboxTokensRequestParams{} + params := channels.ListInboxTokensRequestParams{ + Limit: util.ToPointer(int64(8)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), + } response, err := client.Channels.ListInboxTokens(context.Background(), params) if err != nil { diff --git a/docs/project-client/README.md b/docs/project-client/README.md index 5b6f4d6..52c60b1 100644 --- a/docs/project-client/README.md +++ b/docs/project-client/README.md @@ -8,6 +8,14 @@ title: "project-client" This SDK is compatible with the following versions: `Go >= 1.19.0` +## Installation + +To get started with the SDK, we recommend installing using `go get`: + +```bash +go get client +``` + ## Authentication ### Access Token Authentication @@ -46,11 +54,60 @@ sdk := client.NewClient(config) sdk.SetAccessToken("YOUR-TOKEN") ``` +## Setting a Custom Timeout + +You can set a custom timeout for the SDK's HTTP requests as follows: + +```go +import "time" + +config := clientconfig.NewConfig() + +sdk := client.NewClient(config) + +sdk.SetTimeout(10 * time.Second) +``` + +# Sample Usage + +Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint: + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + "github.com/magicbell/magicbell-go/pkg/project-client/util" + "github.com/magicbell/magicbell-go/pkg/project-client/broadcasts" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +params := broadcasts.ListBroadcastsRequestParams{ + Limit: util.ToPointer(int64(0)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), +} + +response, err := client.Broadcasts.ListBroadcasts(context.Background(), params) +if err != nil { + panic(err) +} + +fmt.Println(response) + +``` + ## Services The SDK provides various services to interact with the API. -
+
Below is a list of all available services with links to their detailed documentation: | Name | @@ -60,6 +117,7 @@ The SDK provides various services to interact with the API. | [EventsService](services/events_service.md) | | [IntegrationsService](services/integrations_service.md) | | [UsersService](services/users_service.md) | +| [WorkflowsService](services/workflows_service.md) |
@@ -81,15 +139,16 @@ This response wrapper is used to return the response data from the API. It conta | Data | `T` | The body of the API response | | Metadata | `ClientResponseMetadata` | Status code and headers returned by the API | -#### `ClientError` +#### `ClientError[T]` This response wrapper is used to return an error. It contains the following fields: -| Name | Type | Description | -| :------- | :----------------------- | :------------------------------------------ | -| Err | `error` | The error that occurred | -| Body | `T` | The body of the API response | -| Metadata | `ClientResponseMetadata` | Status code and headers returned by the API | +| Name | Type | Description | +| :------- | :-------------------- | :---------------------------------------------------------------- | +| Err | `error` | The error that occurred | +| Data | `*T` | The deserialized error response data (nil if unmarshaling failed) | +| Body | `[]byte` | The raw body of the API response | +| Metadata | `ClientErrorMetadata` | Status code and headers returned by the API | #### `ClientResponseMetadata` @@ -106,16 +165,19 @@ This struct is shared by both response wrappers and contains the following field The SDK includes several models that represent the data structures used in API requests and responses. These models help in organizing and managing the data efficiently. -
+
Below is a list of all available models with links to their detailed documentation: | Name | Description | | :-------------------------------------------------------------------------------------- | :---------- | | [BroadcastCollection](models/broadcast_collection.md) | | | [Broadcast](models/broadcast.md) | | +| [User](models/user.md) | | +| [Links](models/links.md) | | | [CategoryDeliveryConfig](models/category_delivery_config.md) | | | [InboxTokenResponseCollection](models/inbox_token_response_collection.md) | | | [InboxTokenResponse](models/inbox_token_response.md) | | +| [Links](models/links.md) | | | [DiscardResult](models/discard_result.md) | | | [ApnsTokenCollection](models/apns_token_collection.md) | | | [ApnsToken](models/apns_token.md) | | @@ -131,49 +193,68 @@ The SDK includes several models that represent the data structures used in API r | [WebPushToken](models/web_push_token.md) | | | [EventCollection](models/event_collection.md) | | | [Event](models/event.md) | | +| [Links](models/links.md) | | | [IntegrationConfigCollection](models/integration_config_collection.md) | | +| [IntegrationConfig](models/integration_config.md) | | +| [Links](models/links.md) | | | [ApnsConfigCollection](models/apns_config_collection.md) | | +| [ApnsConfig](models/apns_config.md) | | | [ApnsConfigPayload](models/apns_config_payload.md) | | +| [EventSourceConfigCollection](models/event_source_config_collection.md) | | +| [EventSourceConfig](models/event_source_config.md) | | +| [EventSourceConfigPayload](models/event_source_config_payload.md) | | | [ExpoConfigCollection](models/expo_config_collection.md) | | +| [ExpoConfig](models/expo_config.md) | | | [ExpoConfigPayload](models/expo_config_payload.md) | | | [FcmConfigCollection](models/fcm_config_collection.md) | | +| [FcmConfig](models/fcm_config.md) | | | [FcmConfigPayload](models/fcm_config_payload.md) | | | [GithubConfigCollection](models/github_config_collection.md) | | +| [GithubConfig](models/github_config.md) | | | [GithubConfigPayload](models/github_config_payload.md) | | | [InboxConfigCollection](models/inbox_config_collection.md) | | +| [InboxConfig](models/inbox_config.md) | | | [InboxConfigPayload](models/inbox_config_payload.md) | | +| [SlackBotConfigCollection](models/slack_bot_config_collection.md) | | +| [SlackBotConfig](models/slack_bot_config.md) | | +| [SlackBotConfigPayload](models/slack_bot_config_payload.md) | | | [MailgunConfigCollection](models/mailgun_config_collection.md) | | +| [MailgunConfig](models/mailgun_config.md) | | | [MailgunConfigPayload](models/mailgun_config_payload.md) | | | [PingConfigCollection](models/ping_config_collection.md) | | +| [PingConfig](models/ping_config.md) | | | [PingConfigPayload](models/ping_config_payload.md) | | | [SendgridConfigCollection](models/sendgrid_config_collection.md) | | +| [SendgridConfig](models/sendgrid_config.md) | | | [SendgridConfigPayload](models/sendgrid_config_payload.md) | | | [SesConfigCollection](models/ses_config_collection.md) | | +| [SesConfig](models/ses_config.md) | | | [SesConfigPayload](models/ses_config_payload.md) | | | [SlackConfigCollection](models/slack_config_collection.md) | | +| [SlackConfig](models/slack_config.md) | | | [SlackConfigPayload](models/slack_config_payload.md) | | +| [SmtpConfigObjectCollection](models/smtp_config_object_collection.md) | | +| [SmtpConfigObject](models/smtp_config_object.md) | | +| [SmtpConfig](models/smtp_config.md) | | | [StripeConfigCollection](models/stripe_config_collection.md) | | +| [StripeConfig](models/stripe_config.md) | | | [StripeConfigPayload](models/stripe_config_payload.md) | | | [TwilioConfigCollection](models/twilio_config_collection.md) | | +| [TwilioConfig](models/twilio_config.md) | | | [TwilioConfigPayload](models/twilio_config_payload.md) | | | [WebpushConfigCollection](models/webpush_config_collection.md) | | +| [WebpushConfig](models/webpush_config.md) | | | [WebpushConfigPayload](models/webpush_config_payload.md) | | | [UserCollection](models/user_collection.md) | | | [User](models/user.md) | | | [Links](models/links.md) | | -| [IntegrationConfig](models/integration_config.md) | | -| [ApnsConfig](models/apns_config.md) | | -| [ExpoConfig](models/expo_config.md) | | -| [FcmConfig](models/fcm_config.md) | | -| [GithubConfig](models/github_config.md) | | -| [InboxConfig](models/inbox_config.md) | | -| [MailgunConfig](models/mailgun_config.md) | | -| [PingConfig](models/ping_config.md) | | -| [SendgridConfig](models/sendgrid_config.md) | | -| [SesConfig](models/ses_config.md) | | -| [SlackConfig](models/slack_config.md) | | -| [StripeConfig](models/stripe_config.md) | | -| [TwilioConfig](models/twilio_config.md) | | -| [WebpushConfig](models/webpush_config.md) | | +| [WorkflowList](models/workflow_list.md) | | +| [WorkflowDefinition](models/workflow_definition.md) | | +| [CreateRunResponse](models/create_run_response.md) | | +| [ExecuteWorkflowRequest](models/execute_workflow_request.md) | | +| [GetRunResponse](models/get_run_response.md) | | +| [WorkflowRunCollection](models/workflow_run_collection.md) | | +| [WorkflowRun](models/workflow_run.md) | | +| [Links](models/links.md) | |
diff --git a/docs/project-client/models/apns_config.md b/docs/project-client/models/apns_config.md index fcebe37..e030eab 100644 --- a/docs/project-client/models/apns_config.md +++ b/docs/project-client/models/apns_config.md @@ -2,8 +2,8 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :----------------------------- | :------- | :---------- | -| Config | integrations.ApnsConfigPayload | ✅ | | -| Id | string | ✅ | | -| Name | string | ✅ | | +| Name | Type | Required | Description | +| :----- | :------------------------------------------------------- | :------- | :---------- | +| Config | [integrations.ApnsConfigPayload](apns_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/apns_config_collection.md b/docs/project-client/models/apns_config_collection.md index 6813be7..b846a8c 100644 --- a/docs/project-client/models/apns_config_collection.md +++ b/docs/project-client/models/apns_config_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :------------------------ | :------- | :---------- | -| Data | []integrations.ApnsConfig | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------------------------ | :------- | :---------- | +| Data | [][integrations.ApnsConfig](apns_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/apns_config_payload.md b/docs/project-client/models/apns_config_payload.md index a7fca2d..4b330b8 100644 --- a/docs/project-client/models/apns_config_payload.md +++ b/docs/project-client/models/apns_config_payload.md @@ -5,23 +5,27 @@ | Name | Type | Required | Description | | :------------- | :-------------------------- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | AppId | string | ✅ | The default bundle identifier of the application that is configured with this project. It can be overriden on a per token basis, when registering device tokens. | -| Badge | integrations.Badge | ✅ | | +| Badge | integrations.Badge | ✅ | Controls whether the app icon badge counts unread or unseen notifications. | | Certificate | string | ✅ | The APNs certificate in P8 format. Generate it at [developer.apple.com](https://developer.apple.com/account/resources/authkeys/add) with the 'Apple Push Notification service (APNs)' option selected. | -| KeyId | string | ✅ | | -| TeamId | string | ✅ | | -| PayloadVersion | integrations.PayloadVersion | ❌ | | +| KeyId | string | ✅ | The 10-character Key ID from your Apple Developer account used with the P8 certificate. | +| TeamId | string | ✅ | The Apple Developer Team ID that owns the configured key. | +| PayloadVersion | integrations.PayloadVersion | ❌ | Internal payload format version used by MagicBell. | # Badge +Controls whether the app icon badge counts unread or unseen notifications. + **Properties** | Name | Type | Required | Description | | :----- | :----- | :------- | :---------- | -| unread | string | ✅ | "unread" | -| unseen | string | ✅ | "unseen" | +| Unread | string | ✅ | "unread" | +| Unseen | string | ✅ | "unseen" | # PayloadVersion +Internal payload format version used by MagicBell. + **Properties** | Name | Type | Required | Description | diff --git a/docs/project-client/models/apns_token.md b/docs/project-client/models/apns_token.md index 3b649d8..a6384bf 100644 --- a/docs/project-client/models/apns_token.md +++ b/docs/project-client/models/apns_token.md @@ -2,23 +2,23 @@ **Properties** -| Name | Type | Required | Description | -| :------------- | :------------------------------- | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| CreatedAt | string | ✅ | | -| DeviceToken | string | ✅ | | -| Id | string | ✅ | | -| AppId | string | ❌ | (Optional) The bundle identifier of the application that is registering this token. Use this field to override the default identifier specified in the projects APNs integration. | -| DiscardedAt | string | ❌ | | -| InstallationId | channels.ApnsTokenInstallationId | ❌ | (Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in `production`. | -| UpdatedAt | string | ❌ | | +| Name | Type | Required | Description | +| :------------- | :---------------------- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------- | +| CreatedAt | string | ✅ | The timestamp when the token was created. | +| DeviceToken | string | ✅ | The APNs device token to register with MagicBell. | +| Id | string | ✅ | The unique identifier for the token. | +| AppId | string | ❌ | The bundle identifier of the application registering this token. Use this to override the default identifier configured on the APNs integration. | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded, if applicable. | +| InstallationId | channels.InstallationId | ❌ | The APNs environment this token belongs to. If omitted we assume it targets `production`. | +| UpdatedAt | string | ❌ | The timestamp when the token metadata last changed. | -# ApnsTokenInstallationId +# InstallationId -(Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in `production`. +The APNs environment this token belongs to. If omitted we assume it targets `production`. **Properties** | Name | Type | Required | Description | | :---------- | :----- | :------- | :------------ | -| development | string | ✅ | "development" | -| production | string | ✅ | "production" | +| Development | string | ✅ | "development" | +| Production | string | ✅ | "production" | diff --git a/docs/project-client/models/apns_token_collection.md b/docs/project-client/models/apns_token_collection.md index 0b26eb2..b8638ba 100644 --- a/docs/project-client/models/apns_token_collection.md +++ b/docs/project-client/models/apns_token_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :------------------- | :------- | :---------- | -| Data | []channels.ApnsToken | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------------------ | :------- | :---------- | +| Data | [][channels.ApnsToken](apns_token.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/broadcast.md b/docs/project-client/models/broadcast.md index cf2b9f6..6d4e4e7 100644 --- a/docs/project-client/models/broadcast.md +++ b/docs/project-client/models/broadcast.md @@ -2,127 +2,147 @@ **Properties** -| Name | Type | Required | Description | -| :--------------- | :------------------------- | :------- | :-------------------------------------------- | -| Recipients | []shared.User | ✅ | | -| Title | string | ✅ | | -| ActionUrl | string | ❌ | | -| Category | string | ❌ | | -| Content | string | ❌ | | -| CreatedAt | string | ❌ | The timestamp when the broadcast was created. | -| CustomAttributes | any | ❌ | | -| Id | string | ❌ | The unique id for this broadcast. | -| Overrides | broadcasts.Overrides | ❌ | | -| Status | broadcasts.BroadcastStatus | ❌ | | -| Topic | string | ❌ | | +| Name | Type | Required | Description | +| :--------------- | :------------------------- | :------- | :-------------------------------------------------------------------------- | +| Recipients | [][shared.User](user.md) | ✅ | A collection of users or filters that determine who receives the broadcast. | +| Title | string | ✅ | The subject or headline that will be shown to recipients. | +| ActionUrl | string | ❌ | The URL recipients will be directed to when interacting with the broadcast. | +| Category | string | ❌ | The label used to group broadcasts. | +| Content | string | ❌ | The body content delivered with the broadcast. | +| CreatedAt | string | ❌ | The timestamp when the broadcast was created. | +| CustomAttributes | any | ❌ | Arbitrary custom data associated with the broadcast. | +| Id | string | ❌ | The unique id for this broadcast. | +| Overrides | broadcasts.Overrides | ❌ | Channel- or provider-specific values that override the defaults. | +| Status | broadcasts.BroadcastStatus | ❌ | The runtime state of the broadcast execution. | +| Topic | string | ❌ | The topic that further classifies the broadcast. | # Overrides +Channel- or provider-specific values that override the defaults. + **Properties** -| Name | Type | Required | Description | -| :-------- | :--------------------------- | :------- | :---------- | -| Channels | broadcasts.OverridesChannels | ❌ | | -| Providers | broadcasts.Providers | ❌ | | +| Name | Type | Required | Description | +| :-------- | :--------------------------- | :------- | :------------------------------------------------------------- | +| Channels | broadcasts.OverridesChannels | ❌ | Overrides that are scoped to individual delivery channels. | +| Providers | broadcasts.Providers | ❌ | Overrides that are scoped to specific providers for a channel. | # OverridesChannels +Overrides that are scoped to individual delivery channels. + **Properties** -| Name | Type | Required | Description | -| :--------- | :-------------------- | :------- | :---------- | -| Email | broadcasts.Email | ❌ | | -| InApp | broadcasts.InApp | ❌ | | -| MobilePush | broadcasts.MobilePush | ❌ | | -| Sms | broadcasts.Sms | ❌ | | +| Name | Type | Required | Description | +| :--------- | :-------------------- | :------- | :--------------------------------------- | +| Email | broadcasts.Email | ❌ | Overrides for email notifications. | +| InApp | broadcasts.InApp | ❌ | Overrides for in-app notifications. | +| MobilePush | broadcasts.MobilePush | ❌ | Overrides for mobile push notifications. | +| Sms | broadcasts.Sms | ❌ | Overrides for SMS notifications. | # Email +Overrides for email notifications. + **Properties** -| Name | Type | Required | Description | -| :-------- | :----- | :------- | :---------- | -| ActionUrl | string | ❌ | | -| Content | string | ❌ | | -| Title | string | ❌ | | +| Name | Type | Required | Description | +| :-------- | :----- | :------- | :---------------------------------------------------------- | +| ActionUrl | string | ❌ | The link associated with the channel-specific notification. | +| Content | string | ❌ | The channel-specific content. | +| Title | string | ❌ | The channel-specific title. | # InApp +Overrides for in-app notifications. + **Properties** -| Name | Type | Required | Description | -| :-------- | :----- | :------- | :---------- | -| ActionUrl | string | ❌ | | -| Content | string | ❌ | | -| Title | string | ❌ | | +| Name | Type | Required | Description | +| :-------- | :----- | :------- | :---------------------------------------------------------- | +| ActionUrl | string | ❌ | The link associated with the channel-specific notification. | +| Content | string | ❌ | The channel-specific content. | +| Title | string | ❌ | The channel-specific title. | # MobilePush +Overrides for mobile push notifications. + **Properties** -| Name | Type | Required | Description | -| :-------- | :----- | :------- | :---------- | -| ActionUrl | string | ❌ | | -| Content | string | ❌ | | -| Title | string | ❌ | | +| Name | Type | Required | Description | +| :-------- | :----- | :------- | :---------------------------------------------------------- | +| ActionUrl | string | ❌ | The link associated with the channel-specific notification. | +| Content | string | ❌ | The channel-specific content. | +| Title | string | ❌ | The channel-specific title. | # Sms +Overrides for SMS notifications. + **Properties** -| Name | Type | Required | Description | -| :-------- | :----- | :------- | :---------- | -| ActionUrl | string | ❌ | | -| Content | string | ❌ | | -| Title | string | ❌ | | +| Name | Type | Required | Description | +| :-------- | :----- | :------- | :---------------------------------------------------------- | +| ActionUrl | string | ❌ | The link associated with the channel-specific notification. | +| Content | string | ❌ | The channel-specific content. | +| Title | string | ❌ | The channel-specific title. | # Providers +Overrides that are scoped to specific providers for a channel. + **Properties** -| Name | Type | Required | Description | -| :------- | :--- | :------- | :---------- | -| Apns | any | ❌ | | -| Expo | any | ❌ | | -| Fcm | any | ❌ | | -| Mailgun | any | ❌ | | -| Sendgrid | any | ❌ | | -| Ses | any | ❌ | | -| Slack | any | ❌ | | -| Teams | any | ❌ | | -| Twilio | any | ❌ | | -| WebPush | any | ❌ | | +| Name | Type | Required | Description | +| :------- | :--- | :------- | :--------------------------------------------------------------- | +| Apns | any | ❌ | Provider-specific overrides for Apple Push Notification service. | +| Expo | any | ❌ | Provider-specific overrides for Expo push notifications. | +| Fcm | any | ❌ | Provider-specific overrides for Firebase Cloud Messaging. | +| Mailgun | any | ❌ | Provider-specific overrides for Mailgun. | +| Sendgrid | any | ❌ | Provider-specific overrides for Sendgrid. | +| Ses | any | ❌ | Provider-specific overrides for AWS SES. | +| Slack | any | ❌ | Provider-specific overrides for Slack. | +| Teams | any | ❌ | Provider-specific overrides for Microsoft Teams. | +| Twilio | any | ❌ | Provider-specific overrides for Twilio. | +| WebPush | any | ❌ | Provider-specific overrides for the web push provider. | # BroadcastStatus +The runtime state of the broadcast execution. + **Properties** -| Name | Type | Required | Description | -| :------ | :---------------------- | :------- | :---------- | -| Errors | []broadcasts.Errors | ✅ | | -| Status | broadcasts.StatusStatus | ✅ | | -| Summary | broadcasts.Summary | ✅ | | +| Name | Type | Required | Description | +| :------ | :---------------------- | :------- | :----------------------------------------------------------- | +| Errors | []broadcasts.Errors | ✅ | A list of errors encountered while processing the broadcast. | +| Status | broadcasts.StatusStatus | ✅ | The overall processing status of the broadcast. | +| Summary | broadcasts.Summary | ✅ | The summary counts for total recipients and failures. | # Errors **Properties** -| Name | Type | Required | Description | -| :------ | :----- | :------- | :---------- | -| Message | string | ❌ | | +| Name | Type | Required | Description | +| :------ | :----- | :------- | :-------------------------------------- | +| Message | string | ❌ | The details about the processing error. | # StatusStatus +The overall processing status of the broadcast. + **Properties** | Name | Type | Required | Description | | :--------- | :----- | :------- | :----------- | -| enqueued | string | ✅ | "enqueued" | -| processing | string | ✅ | "processing" | -| processed | string | ✅ | "processed" | +| Enqueued | string | ✅ | "enqueued" | +| Processing | string | ✅ | "processing" | +| Processed | string | ✅ | "processed" | # Summary +The summary counts for total recipients and failures. + **Properties** | Name | Type | Required | Description | diff --git a/docs/project-client/models/broadcast_collection.md b/docs/project-client/models/broadcast_collection.md index a615440..3e48a76 100644 --- a/docs/project-client/models/broadcast_collection.md +++ b/docs/project-client/models/broadcast_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :--------------------- | :------- | :---------- | -| Data | []broadcasts.Broadcast | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------------------- | :------- | :---------- | +| Data | [][broadcasts.Broadcast](broadcast.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/category_delivery_config.md b/docs/project-client/models/category_delivery_config.md index d522394..7507cc2 100644 --- a/docs/project-client/models/category_delivery_config.md +++ b/docs/project-client/models/category_delivery_config.md @@ -2,32 +2,34 @@ **Properties** -| Name | Type | Required | Description | -| :------- | :---------------------------------------- | :------- | :---------- | -| Channels | []channels.CategoryDeliveryConfigChannels | ✅ | | -| Key | string | ✅ | | -| Disabled | bool | ❌ | | +| Name | Type | Required | Description | +| :------- | :---------------------------------------- | :------- | :--------------------------------------------------------- | +| Channels | []channels.CategoryDeliveryConfigChannels | ✅ | Ordered channel steps the delivery planner should execute. | +| Key | string | ✅ | Unique identifier for this delivery plan. | +| Disabled | bool | ❌ | Disables the plan so it cannot be executed. | # CategoryDeliveryConfigChannels **Properties** -| Name | Type | Required | Description | -| :------ | :--------------- | :------- | :---------- | -| Channel | channels.Channel | ✅ | | -| Delay | int64 | ❌ | | -| If\_ | string | ❌ | | +| Name | Type | Required | Description | +| :------ | :--------------- | :------- | :-------------------------------------------------------- | +| Channel | channels.Channel | ✅ | Name of the channel used for this step. | +| Delay | int64 | ❌ | Delay in seconds to wait after the previous step. | +| If\_ | string | ❌ | Conditional expression evaluated before running the step. | # Channel +Name of the channel used for this step. + **Properties** -| Name | Type | Required | Description | -| :---------- | :----- | :------- | :------------ | -| in_app | string | ✅ | "in_app" | -| slack | string | ✅ | "slack" | -| web_push | string | ✅ | "web_push" | -| mobile_push | string | ✅ | "mobile_push" | -| teams | string | ✅ | "teams" | -| email | string | ✅ | "email" | -| sms | string | ✅ | "sms" | +| Name | Type | Required | Description | +| :--------- | :----- | :------- | :------------ | +| InApp | string | ✅ | "in_app" | +| Slack | string | ✅ | "slack" | +| WebPush | string | ✅ | "web_push" | +| MobilePush | string | ✅ | "mobile_push" | +| Teams | string | ✅ | "teams" | +| Email | string | ✅ | "email" | +| Sms | string | ✅ | "sms" | diff --git a/docs/project-client/models/create_run_response.md b/docs/project-client/models/create_run_response.md new file mode 100644 index 0000000..af45f9c --- /dev/null +++ b/docs/project-client/models/create_run_response.md @@ -0,0 +1,7 @@ +# CreateRunResponse + +**Properties** + +| Name | Type | Required | Description | +| :--- | :----- | :------- | :----------------------------------------------- | +| Id | string | ✅ | Identifier of the workflow run that was created. | diff --git a/docs/project-client/models/discard_result.md b/docs/project-client/models/discard_result.md index 6b66395..0fa1bb7 100644 --- a/docs/project-client/models/discard_result.md +++ b/docs/project-client/models/discard_result.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---------- | :----- | :------- | :---------- | -| DiscardedAt | string | ❌ | | -| Id | string | ❌ | | +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :--------------------------------------------- | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded. | +| Id | string | ❌ | The unique identifier for the discarded token. | diff --git a/docs/project-client/models/event.md b/docs/project-client/models/event.md index dfb81b5..15516a3 100644 --- a/docs/project-client/models/event.md +++ b/docs/project-client/models/event.md @@ -2,12 +2,13 @@ **Properties** -| Name | Type | Required | Description | -| :-------- | :----- | :------- | :---------- | -| Id | string | ✅ | | -| Timestamp | string | ✅ | | -| Type\_ | string | ✅ | | -| Code | int64 | ❌ | | -| Context | any | ❌ | | -| Level | string | ❌ | | -| Log | string | ❌ | | +| Name | Type | Required | Description | +| :-------- | :----- | :------- | :---------------------------------------------- | +| Id | string | ✅ | The unique identifier for the event. | +| Timestamp | string | ✅ | The time at which the event was recorded. | +| Type\_ | string | ✅ | The type of event that occurred. | +| Code | int64 | ❌ | The numeric code that categorizes the event. | +| Context | any | ❌ | Additional contextual attributes for the event. | +| Level | string | ❌ | The severity level assigned to the event. | +| Log | string | ❌ | A human-readable log message. | +| Payload | any | ❌ | The raw payload delivered by the event source. | diff --git a/docs/project-client/models/event_collection.md b/docs/project-client/models/event_collection.md index 190c0a6..a8670cf 100644 --- a/docs/project-client/models/event_collection.md +++ b/docs/project-client/models/event_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :------------- | :------- | :---------- | -| Data | []events.Event | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------- | :------- | :---------- | +| Data | [][events.Event](event.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/event_source_config.md b/docs/project-client/models/event_source_config.md new file mode 100644 index 0000000..724dc71 --- /dev/null +++ b/docs/project-client/models/event_source_config.md @@ -0,0 +1,9 @@ +# EventSourceConfig + +**Properties** + +| Name | Type | Required | Description | +| :----- | :---------------------------------------------------------------------- | :------- | :---------- | +| Config | [integrations.EventSourceConfigPayload](event_source_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/event_source_config_collection.md b/docs/project-client/models/event_source_config_collection.md new file mode 100644 index 0000000..e284a90 --- /dev/null +++ b/docs/project-client/models/event_source_config_collection.md @@ -0,0 +1,8 @@ +# EventSourceConfigCollection + +**Properties** + +| Name | Type | Required | Description | +| :---- | :--------------------------------------------------------- | :------- | :---------- | +| Data | [][integrations.EventSourceConfig](event_source_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/event_source_config_payload.md b/docs/project-client/models/event_source_config_payload.md new file mode 100644 index 0000000..72903e7 --- /dev/null +++ b/docs/project-client/models/event_source_config_payload.md @@ -0,0 +1,7 @@ +# EventSourceConfigPayload + +**Properties** + +| Name | Type | Required | Description | +| :----- | :----- | :------- | :---------- | +| Source | string | ✅ | | diff --git a/docs/project-client/models/execute_workflow_request.md b/docs/project-client/models/execute_workflow_request.md new file mode 100644 index 0000000..ae3f7d5 --- /dev/null +++ b/docs/project-client/models/execute_workflow_request.md @@ -0,0 +1,8 @@ +# ExecuteWorkflowRequest + +**Properties** + +| Name | Type | Required | Description | +| :---- | :----- | :------- | :----------------------------------------------------------------------------- | +| Key | string | ✅ | The unique workflow key to execute (e.g. integration.stripe.charge.succeeded). | +| Input | any | ❌ | Optional JSON payload that will be passed as the workflow input context. | diff --git a/docs/project-client/models/expo_config.md b/docs/project-client/models/expo_config.md index 3ed714b..1734dbf 100644 --- a/docs/project-client/models/expo_config.md +++ b/docs/project-client/models/expo_config.md @@ -2,8 +2,8 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :----------------------------- | :------- | :---------- | -| Config | integrations.ExpoConfigPayload | ✅ | | -| Id | string | ✅ | | -| Name | string | ✅ | | +| Name | Type | Required | Description | +| :----- | :------------------------------------------------------- | :------- | :---------- | +| Config | [integrations.ExpoConfigPayload](expo_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/expo_config_collection.md b/docs/project-client/models/expo_config_collection.md index 18529ee..36f6b88 100644 --- a/docs/project-client/models/expo_config_collection.md +++ b/docs/project-client/models/expo_config_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :------------------------ | :------- | :---------- | -| Data | []integrations.ExpoConfig | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------------------------ | :------- | :---------- | +| Data | [][integrations.ExpoConfig](expo_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/expo_config_payload.md b/docs/project-client/models/expo_config_payload.md index de39767..d20b14f 100644 --- a/docs/project-client/models/expo_config_payload.md +++ b/docs/project-client/models/expo_config_payload.md @@ -2,6 +2,6 @@ **Properties** -| Name | Type | Required | Description | -| :---------- | :----- | :------- | :---------- | -| AccessToken | string | ✅ | | +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :------------------------------------------------------------- | +| AccessToken | string | ✅ | The Expo access token used to authenticate push notifications. | diff --git a/docs/project-client/models/expo_token.md b/docs/project-client/models/expo_token.md index 18362a4..ac79d94 100644 --- a/docs/project-client/models/expo_token.md +++ b/docs/project-client/models/expo_token.md @@ -2,10 +2,10 @@ **Properties** -| Name | Type | Required | Description | -| :---------- | :----- | :------- | :---------- | -| CreatedAt | string | ✅ | | -| DeviceToken | string | ✅ | | -| Id | string | ✅ | | -| DiscardedAt | string | ❌ | | -| UpdatedAt | string | ❌ | | +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :--------------------------------------------------------- | +| CreatedAt | string | ✅ | The timestamp when the token was created. | +| DeviceToken | string | ✅ | The Expo push token returned by the Expo client. | +| Id | string | ✅ | The unique identifier for the token. | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded, if applicable. | +| UpdatedAt | string | ❌ | The timestamp when the token metadata last changed. | diff --git a/docs/project-client/models/expo_token_collection.md b/docs/project-client/models/expo_token_collection.md index 016b17e..86aa56b 100644 --- a/docs/project-client/models/expo_token_collection.md +++ b/docs/project-client/models/expo_token_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :------------------- | :------- | :---------- | -| Data | []channels.ExpoToken | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------------------ | :------- | :---------- | +| Data | [][channels.ExpoToken](expo_token.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/fcm_config.md b/docs/project-client/models/fcm_config.md index 7c33824..dcf8079 100644 --- a/docs/project-client/models/fcm_config.md +++ b/docs/project-client/models/fcm_config.md @@ -2,8 +2,8 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :---------------------------- | :------- | :---------- | -| Config | integrations.FcmConfigPayload | ✅ | | -| Id | string | ✅ | | -| Name | string | ✅ | | +| Name | Type | Required | Description | +| :----- | :----------------------------------------------------- | :------- | :---------- | +| Config | [integrations.FcmConfigPayload](fcm_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/fcm_config_collection.md b/docs/project-client/models/fcm_config_collection.md index 1cdb186..8339d37 100644 --- a/docs/project-client/models/fcm_config_collection.md +++ b/docs/project-client/models/fcm_config_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :----------------------- | :------- | :---------- | -| Data | []integrations.FcmConfig | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :---------------------------------------- | :------- | :---------- | +| Data | [][integrations.FcmConfig](fcm_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/fcm_config_payload.md b/docs/project-client/models/fcm_config_payload.md index 2ff975f..802e380 100644 --- a/docs/project-client/models/fcm_config_payload.md +++ b/docs/project-client/models/fcm_config_payload.md @@ -2,24 +2,26 @@ **Properties** -| Name | Type | Required | Description | -| :---------------------- | :------------------ | :------- | :---------- | -| AuthProviderX509CertUrl | string | ✅ | | -| AuthUri | string | ✅ | | -| ClientEmail | string | ✅ | | -| ClientId | string | ✅ | | -| ClientX509CertUrl | string | ✅ | | -| PrivateKey | string | ✅ | | -| PrivateKeyId | string | ✅ | | -| ProjectId | string | ✅ | | -| TokenUri | string | ✅ | | -| Type\_ | integrations.Type\_ | ✅ | | -| UniverseDomain | string | ✅ | | +| Name | Type | Required | Description | +| :---------------------- | :------------------ | :------- | :----------------------------------------------------------------------------------------------- | +| AuthProviderX509CertUrl | string | ✅ | URL for Google's OAuth provider x509 certificates used to validate tokens. | +| AuthUri | string | ✅ | OAuth authorization endpoint used when exchanging Firebase credentials. | +| ClientEmail | string | ✅ | The client email address from the Firebase service account. | +| ClientId | string | ✅ | The numeric client identifier for the Firebase service account. | +| ClientX509CertUrl | string | ✅ | URL to the public x509 certificate for this service account. | +| PrivateKey | string | ✅ | The PEM encoded service account private key used to sign Firebase credentials. | +| PrivateKeyId | string | ✅ | Identifier of the private key inside the downloaded service account JSON. | +| ProjectId | string | ✅ | The Firebase project ID associated with this service account. | +| TokenUri | string | ✅ | OAuth token endpoint used to mint access tokens for FCM. | +| Type\_ | integrations.Type\_ | ✅ | Indicates the kind of Google credential. Service accounts always use the `service_account` type. | +| UniverseDomain | string | ✅ | The Google Cloud universe domain hosting the Firebase APIs. | # Type\_ +Indicates the kind of Google credential. Service accounts always use the `service_account` type. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------------- | -| service_account | string | ✅ | "service_account" | +| Name | Type | Required | Description | +| :------------- | :----- | :------- | :---------------- | +| ServiceAccount | string | ✅ | "service_account" | diff --git a/docs/project-client/models/fcm_token.md b/docs/project-client/models/fcm_token.md index 159a1df..cb90fcf 100644 --- a/docs/project-client/models/fcm_token.md +++ b/docs/project-client/models/fcm_token.md @@ -2,20 +2,10 @@ **Properties** -| Name | Type | Required | Description | -| :------------- | :------------------------------ | :------- | :---------- | -| CreatedAt | string | ✅ | | -| DeviceToken | string | ✅ | | -| Id | string | ✅ | | -| DiscardedAt | string | ❌ | | -| InstallationId | channels.FcmTokenInstallationId | ❌ | | -| UpdatedAt | string | ❌ | | - -# FcmTokenInstallationId - -**Properties** - -| Name | Type | Required | Description | -| :---------- | :----- | :------- | :------------ | -| development | string | ✅ | "development" | -| production | string | ✅ | "production" | +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :--------------------------------------------------------------------------------- | +| CreatedAt | string | ✅ | The timestamp when the token was created. | +| DeviceToken | string | ✅ | The Firebase Cloud Messaging device registration token to associate with the user. | +| Id | string | ✅ | The unique identifier for the token. | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded, if applicable. | +| UpdatedAt | string | ❌ | The timestamp when the token metadata last changed. | diff --git a/docs/project-client/models/fcm_token_collection.md b/docs/project-client/models/fcm_token_collection.md index 234da3f..0a2f5cd 100644 --- a/docs/project-client/models/fcm_token_collection.md +++ b/docs/project-client/models/fcm_token_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :------------------ | :------- | :---------- | -| Data | []channels.FcmToken | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :---------------------------------- | :------- | :---------- | +| Data | [][channels.FcmToken](fcm_token.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/get_run_response.md b/docs/project-client/models/get_run_response.md new file mode 100644 index 0000000..715fa39 --- /dev/null +++ b/docs/project-client/models/get_run_response.md @@ -0,0 +1,23 @@ +# GetRunResponse + +**Properties** + +| Name | Type | Required | Description | +| :---------- | :----------------------------- | :------- | :---------- | +| CreatedAt | string | ❌ | | +| Id | string | ❌ | | +| Input | any | ❌ | | +| Status | workflows.GetRunResponseStatus | ❌ | | +| WorkflowKey | string | ❌ | | + +# GetRunResponseStatus + +**Properties** + +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :---------- | +| CompletedAt | string | ❌ | | +| Error | string | ❌ | | +| NextStep | int64 | ❌ | | +| StartedAt | string | ❌ | | +| State | int64 | ❌ | | diff --git a/docs/project-client/models/github_config.md b/docs/project-client/models/github_config.md index 0842ce4..1e0b87e 100644 --- a/docs/project-client/models/github_config.md +++ b/docs/project-client/models/github_config.md @@ -2,8 +2,8 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :------------------------------- | :------- | :---------- | -| Config | integrations.GithubConfigPayload | ✅ | | -| Id | string | ✅ | | -| Name | string | ✅ | | +| Name | Type | Required | Description | +| :----- | :----------------------------------------------------------- | :------- | :---------- | +| Config | [integrations.GithubConfigPayload](github_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/github_config_collection.md b/docs/project-client/models/github_config_collection.md index f26dd75..b2e0a15 100644 --- a/docs/project-client/models/github_config_collection.md +++ b/docs/project-client/models/github_config_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :-------------------------- | :------- | :---------- | -| Data | []integrations.GithubConfig | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :---------------------------------------------- | :------- | :---------- | +| Data | [][integrations.GithubConfig](github_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/inbox_config.md b/docs/project-client/models/inbox_config.md index 9c82ea2..262e5d9 100644 --- a/docs/project-client/models/inbox_config.md +++ b/docs/project-client/models/inbox_config.md @@ -2,8 +2,8 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :------------------------------ | :------- | :---------- | -| Config | integrations.InboxConfigPayload | ✅ | | -| Id | string | ✅ | | -| Name | string | ✅ | | +| Name | Type | Required | Description | +| :----- | :--------------------------------------------------------- | :------- | :---------- | +| Config | [integrations.InboxConfigPayload](inbox_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/inbox_config_collection.md b/docs/project-client/models/inbox_config_collection.md index eb1cac9..0010d65 100644 --- a/docs/project-client/models/inbox_config_collection.md +++ b/docs/project-client/models/inbox_config_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :------------------------- | :------- | :---------- | -| Data | []integrations.InboxConfig | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :-------------------------------------------- | :------- | :---------- | +| Data | [][integrations.InboxConfig](inbox_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/inbox_config_payload.md b/docs/project-client/models/inbox_config_payload.md index c763970..1590f64 100644 --- a/docs/project-client/models/inbox_config_payload.md +++ b/docs/project-client/models/inbox_config_payload.md @@ -2,186 +2,222 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :------------------ | :------- | :---------- | -| Images | integrations.Images | ✅ | | -| Locale | string | ✅ | | -| Theme | integrations.Theme | ✅ | | +| Name | Type | Required | Description | +| :----- | :------------------ | :------- | :---------------------------------------------------------------- | +| Images | integrations.Images | ✅ | Image overrides for assets used in the inbox UI. | +| Locale | string | ✅ | Locale code (ISO language tag) used to localize built-in strings. | +| Theme | integrations.Theme | ✅ | Visual customization options for the hosted inbox widget. | # Images +Image overrides for assets used in the inbox UI. + **Properties** -| Name | Type | Required | Description | -| :------------ | :----- | :------- | :---------- | -| EmptyInboxUrl | string | ✅ | | +| Name | Type | Required | Description | +| :------------ | :----- | :------- | :------------------------------------------------------ | +| EmptyInboxUrl | string | ✅ | URL for the illustration shown when the inbox is empty. | # Theme +Visual customization options for the hosted inbox widget. + **Properties** -| Name | Type | Required | Description | -| :----------- | :------------------------ | :------- | :---------- | -| Banner | integrations.Banner | ❌ | | -| Dialog | integrations.Dialog | ❌ | | -| Footer | integrations.Footer | ❌ | | -| Header | integrations.Header | ❌ | | -| Icon | integrations.Icon | ❌ | | -| Notification | integrations.Notification | ❌ | | -| UnseenBadge | integrations.UnseenBadge | ❌ | | +| Name | Type | Required | Description | +| :----------- | :------------------------ | :------- | :--------------------------------------------- | +| Banner | integrations.Banner | ❌ | Top banner styling options. | +| Dialog | integrations.Dialog | ❌ | Styling for confirmation and action dialogs. | +| Footer | integrations.Footer | ❌ | Footer styling for the inbox modal. | +| Header | integrations.Header | ❌ | Header styling for the inbox modal. | +| Icon | integrations.Icon | ❌ | Launcher icon styling overrides. | +| Notification | integrations.Notification | ❌ | Styling overrides for notification list items. | +| UnseenBadge | integrations.UnseenBadge | ❌ | Badge styling for unseen notification counts. | # Banner +Top banner styling options. + **Properties** -| Name | Type | Required | Description | -| :---------------- | :------ | :------- | :---------- | -| BackgroundColor | string | ✅ | | -| FontSize | string | ✅ | | -| TextColor | string | ✅ | | -| BackgroundOpacity | float64 | ❌ | | +| Name | Type | Required | Description | +| :---------------- | :------ | :------- | :---------------------------------------- | +| BackgroundColor | string | ✅ | Banner background color. | +| FontSize | string | ✅ | Font size for banner text. | +| TextColor | string | ✅ | Banner text color. | +| BackgroundOpacity | float64 | ❌ | Opacity applied to the banner background. | # Dialog +Styling for confirmation and action dialogs. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------- | -| AccentColor | string | ✅ | | -| BackgroundColor | string | ✅ | | -| TextColor | string | ✅ | | +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :---------------------------------------------- | +| AccentColor | string | ✅ | Accent color for dialog buttons and highlights. | +| BackgroundColor | string | ✅ | Dialog background color. | +| TextColor | string | ✅ | Dialog text color. | # Footer +Footer styling for the inbox modal. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------- | -| BackgroundColor | string | ✅ | | -| BorderRadius | string | ✅ | | -| FontSize | string | ✅ | | -| TextColor | string | ✅ | | +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :--------------------------------------------- | +| BackgroundColor | string | ✅ | Footer background color. | +| BorderRadius | string | ✅ | Border radius applied to the footer container. | +| FontSize | string | ✅ | Font size used in the footer. | +| TextColor | string | ✅ | Footer text color. | # Header +Header styling for the inbox modal. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------- | -| BackgroundColor | string | ✅ | | -| BorderRadius | string | ✅ | | -| FontFamily | string | ✅ | | -| FontSize | string | ✅ | | -| TextColor | string | ✅ | | +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :--------------------------------------------- | +| BackgroundColor | string | ✅ | Header background color. | +| BorderRadius | string | ✅ | Border radius applied to the header container. | +| FontFamily | string | ✅ | CSS font family for the header title. | +| FontSize | string | ✅ | Font size used in the header. | +| TextColor | string | ✅ | Header text color. | # Icon +Launcher icon styling overrides. + **Properties** -| Name | Type | Required | Description | -| :---------- | :----- | :------- | :---------- | -| BorderColor | string | ✅ | | -| Width | string | ✅ | | +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :------------------------------------------- | +| BorderColor | string | ✅ | CSS color used for the icon border. | +| Width | string | ✅ | Width of the launcher icon (any CSS length). | # Notification +Styling overrides for notification list items. + **Properties** -| Name | Type | Required | Description | -| :-------- | :--------------------- | :------- | :---------- | -| Default\_ | integrations.Default\_ | ✅ | | -| Unread | integrations.Unread | ✅ | | -| Unseen | integrations.Unseen | ✅ | | +| Name | Type | Required | Description | +| :-------- | :--------------------- | :------- | :---------------------------------------------- | +| Default\_ | integrations.Default\_ | ✅ | Base styles applied to every notification item. | +| Unread | integrations.Unread | ✅ | Overrides for unread notifications. | +| Unseen | integrations.Unseen | ✅ | Overrides for unseen notifications. | # Default\_ +Base styles applied to every notification item. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :------------------------ | :------- | :---------- | -| BackgroundColor | string | ✅ | | -| BorderRadius | string | ✅ | | -| FontFamily | string | ✅ | | -| FontSize | string | ✅ | | -| Margin | string | ✅ | | -| TextColor | string | ✅ | | -| Hover | integrations.DefaultHover | ❌ | | -| State | integrations.DefaultState | ❌ | | +| Name | Type | Required | Description | +| :-------------- | :------------------------ | :------- | :--------------------------------------------------------- | +| BackgroundColor | string | ✅ | Background color for notifications in their default state. | +| BorderRadius | string | ✅ | Border radius applied to each notification card. | +| FontFamily | string | ✅ | Font family for notification text. | +| FontSize | string | ✅ | Font size for notification text. | +| Margin | string | ✅ | CSS margin applied around each notification card. | +| TextColor | string | ✅ | Default text color for notifications. | +| Hover | integrations.DefaultHover | ❌ | Styles applied when a notification is hovered. | +| State | integrations.DefaultState | ❌ | Accent colors for notification state indicators. | # DefaultHover +Styles applied when a notification is hovered. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------- | -| BackgroundColor | string | ✅ | | +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :------------------------- | +| BackgroundColor | string | ✅ | Background color on hover. | # DefaultState +Accent colors for notification state indicators. + **Properties** -| Name | Type | Required | Description | -| :---- | :----- | :------- | :---------- | -| Color | string | ✅ | | +| Name | Type | Required | Description | +| :---- | :----- | :------- | :---------------------------------- | +| Color | string | ✅ | Color used for the state indicator. | # Unread +Overrides for unread notifications. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----------------------- | :------- | :---------- | -| BackgroundColor | string | ✅ | | -| TextColor | string | ✅ | | -| Hover | integrations.UnreadHover | ❌ | | -| State | integrations.UnreadState | ❌ | | +| Name | Type | Required | Description | +| :-------------- | :----------------------- | :------- | :------------------------------------------------ | +| BackgroundColor | string | ✅ | Background color applied to unread notifications. | +| TextColor | string | ✅ | Text color used when a notification is unread. | +| Hover | integrations.UnreadHover | ❌ | Hover styles for unread notifications. | +| State | integrations.UnreadState | ❌ | State indicator styling for unread notifications. | # UnreadHover +Hover styles for unread notifications. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------- | -| BackgroundColor | string | ✅ | | +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :-------------------------------------------------- | +| BackgroundColor | string | ✅ | Background color on hover for unread notifications. | # UnreadState +State indicator styling for unread notifications. + **Properties** -| Name | Type | Required | Description | -| :---- | :----- | :------- | :---------- | -| Color | string | ✅ | | +| Name | Type | Required | Description | +| :---- | :----- | :------- | :------------------------------------ | +| Color | string | ✅ | Color for the unread state indicator. | # Unseen +Overrides for unseen notifications. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----------------------- | :------- | :---------- | -| BackgroundColor | string | ✅ | | -| TextColor | string | ✅ | | -| Hover | integrations.UnseenHover | ❌ | | -| State | integrations.UnseenState | ❌ | | +| Name | Type | Required | Description | +| :-------------- | :----------------------- | :------- | :------------------------------------------------ | +| BackgroundColor | string | ✅ | Background color applied to unseen notifications. | +| TextColor | string | ✅ | Text color used when a notification is unseen. | +| Hover | integrations.UnseenHover | ❌ | Hover styles for unseen notifications. | +| State | integrations.UnseenState | ❌ | State indicator styling for unseen notifications. | # UnseenHover +Hover styles for unseen notifications. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------- | -| BackgroundColor | string | ✅ | | +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :-------------------------------------------------- | +| BackgroundColor | string | ✅ | Background color on hover for unseen notifications. | # UnseenState +State indicator styling for unseen notifications. + **Properties** -| Name | Type | Required | Description | -| :---- | :----- | :------- | :---------- | -| Color | string | ✅ | | +| Name | Type | Required | Description | +| :---- | :----- | :------- | :------------------------------------ | +| Color | string | ✅ | Color for the unseen state indicator. | # UnseenBadge +Badge styling for unseen notification counts. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------- | -| BackgroundColor | string | ✅ | | +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :---------------------- | +| BackgroundColor | string | ✅ | Badge background color. | diff --git a/docs/project-client/models/inbox_token_response.md b/docs/project-client/models/inbox_token_response.md index f932e3c..27f6a36 100644 --- a/docs/project-client/models/inbox_token_response.md +++ b/docs/project-client/models/inbox_token_response.md @@ -2,11 +2,11 @@ **Properties** -| Name | Type | Required | Description | -| :----------- | :----- | :------- | :---------- | -| CreatedAt | string | ✅ | | -| Id | string | ✅ | | -| Token | string | ✅ | | -| ConnectionId | string | ❌ | | -| DiscardedAt | string | ❌ | | -| UpdatedAt | string | ❌ | | +| Name | Type | Required | Description | +| :----------- | :----- | :------- | :------------------------------------------------------------------------- | +| CreatedAt | string | ✅ | The timestamp when the token was created. | +| Id | string | ✅ | The unique identifier for the token. | +| Token | string | ✅ | The in-app inbox token generated for this user. | +| ConnectionId | string | ❌ | Realtime connection ID to restrict delivery to a specific Ably connection. | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded, if applicable. | +| UpdatedAt | string | ❌ | The timestamp when the token metadata last changed. | diff --git a/docs/project-client/models/inbox_token_response_collection.md b/docs/project-client/models/inbox_token_response_collection.md index b3bb125..cf5a84b 100644 --- a/docs/project-client/models/inbox_token_response_collection.md +++ b/docs/project-client/models/inbox_token_response_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :---------------------------- | :------- | :---------- | -| Data | []channels.InboxTokenResponse | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------------------------------------- | :------- | :---------- | +| Data | [][channels.InboxTokenResponse](inbox_token_response.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/integration_config_collection.md b/docs/project-client/models/integration_config_collection.md index 468c7e1..8c9c3ea 100644 --- a/docs/project-client/models/integration_config_collection.md +++ b/docs/project-client/models/integration_config_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :------------------------------- | :------- | :---------- | -| Data | []integrations.IntegrationConfig | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :-------------------------------------------------------- | :------- | :---------- | +| Data | [][integrations.IntegrationConfig](integration_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/mailgun_config.md b/docs/project-client/models/mailgun_config.md index 8506728..db83965 100644 --- a/docs/project-client/models/mailgun_config.md +++ b/docs/project-client/models/mailgun_config.md @@ -2,8 +2,8 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :-------------------------------- | :------- | :---------- | -| Config | integrations.MailgunConfigPayload | ✅ | | -| Id | string | ✅ | | -| Name | string | ✅ | | +| Name | Type | Required | Description | +| :----- | :------------------------------------------------------------- | :------- | :---------- | +| Config | [integrations.MailgunConfigPayload](mailgun_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/mailgun_config_collection.md b/docs/project-client/models/mailgun_config_collection.md index 6211312..a136614 100644 --- a/docs/project-client/models/mailgun_config_collection.md +++ b/docs/project-client/models/mailgun_config_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :--------------------------- | :------- | :---------- | -| Data | []integrations.MailgunConfig | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------------------------------ | :------- | :---------- | +| Data | [][integrations.MailgunConfig](mailgun_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/mailgun_config_payload.md b/docs/project-client/models/mailgun_config_payload.md index f8903a7..e677638 100644 --- a/docs/project-client/models/mailgun_config_payload.md +++ b/docs/project-client/models/mailgun_config_payload.md @@ -15,8 +15,8 @@ | Name | Type | Required | Description | | :--- | :----- | :------- | :---------- | -| us | string | ✅ | "us" | -| eu | string | ✅ | "eu" | +| Us | string | ✅ | "us" | +| Eu | string | ✅ | "eu" | # MailgunConfigPayloadFrom diff --git a/docs/project-client/models/ping_config.md b/docs/project-client/models/ping_config.md index 1c71512..8ecd492 100644 --- a/docs/project-client/models/ping_config.md +++ b/docs/project-client/models/ping_config.md @@ -2,8 +2,8 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :----------------------------- | :------- | :---------- | -| Config | integrations.PingConfigPayload | ✅ | | -| Id | string | ✅ | | -| Name | string | ✅ | | +| Name | Type | Required | Description | +| :----- | :------------------------------------------------------- | :------- | :---------- | +| Config | [integrations.PingConfigPayload](ping_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/ping_config_collection.md b/docs/project-client/models/ping_config_collection.md index 25f9da6..61eff6d 100644 --- a/docs/project-client/models/ping_config_collection.md +++ b/docs/project-client/models/ping_config_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :------------------------ | :------- | :---------- | -| Data | []integrations.PingConfig | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------------------------ | :------- | :---------- | +| Data | [][integrations.PingConfig](ping_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/sendgrid_config.md b/docs/project-client/models/sendgrid_config.md index 6d5a38e..205728a 100644 --- a/docs/project-client/models/sendgrid_config.md +++ b/docs/project-client/models/sendgrid_config.md @@ -2,8 +2,8 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :--------------------------------- | :------- | :---------- | -| Config | integrations.SendgridConfigPayload | ✅ | | -| Id | string | ✅ | | -| Name | string | ✅ | | +| Name | Type | Required | Description | +| :----- | :--------------------------------------------------------------- | :------- | :---------- | +| Config | [integrations.SendgridConfigPayload](sendgrid_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/sendgrid_config_collection.md b/docs/project-client/models/sendgrid_config_collection.md index 0fb76c8..6ef3a10 100644 --- a/docs/project-client/models/sendgrid_config_collection.md +++ b/docs/project-client/models/sendgrid_config_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :---------------------------- | :------- | :---------- | -| Data | []integrations.SendgridConfig | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :-------------------------------------------------- | :------- | :---------- | +| Data | [][integrations.SendgridConfig](sendgrid_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/sendgrid_config_payload.md b/docs/project-client/models/sendgrid_config_payload.md index 2edac0c..fa941c5 100644 --- a/docs/project-client/models/sendgrid_config_payload.md +++ b/docs/project-client/models/sendgrid_config_payload.md @@ -2,11 +2,11 @@ **Properties** -| Name | Type | Required | Description | -| :------ | :------------------------------------- | :------- | :----------------------- | -| ApiKey | string | ✅ | The API key for Sendgrid | -| From | integrations.SendgridConfigPayloadFrom | ❌ | | -| ReplyTo | integrations.ReplyTo | ❌ | | +| Name | Type | Required | Description | +| :------ | :---------------------------------------- | :------- | :----------------------- | +| ApiKey | string | ✅ | The API key for Sendgrid | +| From | integrations.SendgridConfigPayloadFrom | ❌ | | +| ReplyTo | integrations.SendgridConfigPayloadReplyTo | ❌ | | # SendgridConfigPayloadFrom @@ -17,7 +17,7 @@ | Email | string | ✅ | The email address to send from | | Name | string | ❌ | The name to send from | -# ReplyTo +# SendgridConfigPayloadReplyTo **Properties** diff --git a/docs/project-client/models/ses_config.md b/docs/project-client/models/ses_config.md index 87ae51e..80ba9e5 100644 --- a/docs/project-client/models/ses_config.md +++ b/docs/project-client/models/ses_config.md @@ -2,8 +2,8 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :---------------------------- | :------- | :---------- | -| Config | integrations.SesConfigPayload | ✅ | | -| Id | string | ✅ | | -| Name | string | ✅ | | +| Name | Type | Required | Description | +| :----- | :----------------------------------------------------- | :------- | :---------- | +| Config | [integrations.SesConfigPayload](ses_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/ses_config_collection.md b/docs/project-client/models/ses_config_collection.md index 29cb80a..a3d181d 100644 --- a/docs/project-client/models/ses_config_collection.md +++ b/docs/project-client/models/ses_config_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :----------------------- | :------- | :---------- | -| Data | []integrations.SesConfig | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :---------------------------------------- | :------- | :---------- | +| Data | [][integrations.SesConfig](ses_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/slack_bot_config.md b/docs/project-client/models/slack_bot_config.md new file mode 100644 index 0000000..38065d4 --- /dev/null +++ b/docs/project-client/models/slack_bot_config.md @@ -0,0 +1,9 @@ +# SlackBotConfig + +**Properties** + +| Name | Type | Required | Description | +| :----- | :---------------------------------------------------------------- | :------- | :---------- | +| Config | [integrations.SlackBotConfigPayload](slack_bot_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/slack_bot_config_collection.md b/docs/project-client/models/slack_bot_config_collection.md new file mode 100644 index 0000000..459d895 --- /dev/null +++ b/docs/project-client/models/slack_bot_config_collection.md @@ -0,0 +1,8 @@ +# SlackBotConfigCollection + +**Properties** + +| Name | Type | Required | Description | +| :---- | :--------------------------------------------------- | :------- | :---------- | +| Data | [][integrations.SlackBotConfig](slack_bot_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/slack_bot_config_payload.md b/docs/project-client/models/slack_bot_config_payload.md new file mode 100644 index 0000000..067ce28 --- /dev/null +++ b/docs/project-client/models/slack_bot_config_payload.md @@ -0,0 +1,7 @@ +# SlackBotConfigPayload + +**Properties** + +| Name | Type | Required | Description | +| :------ | :--- | :------- | :---------- | +| Enabled | bool | ✅ | | diff --git a/docs/project-client/models/slack_config.md b/docs/project-client/models/slack_config.md index bdd750f..b7598e9 100644 --- a/docs/project-client/models/slack_config.md +++ b/docs/project-client/models/slack_config.md @@ -2,8 +2,8 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :------------------------------ | :------- | :---------- | -| Config | integrations.SlackConfigPayload | ✅ | | -| Id | string | ✅ | | -| Name | string | ✅ | | +| Name | Type | Required | Description | +| :----- | :--------------------------------------------------------- | :------- | :---------- | +| Config | [integrations.SlackConfigPayload](slack_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/slack_config_collection.md b/docs/project-client/models/slack_config_collection.md index df24a5e..0519726 100644 --- a/docs/project-client/models/slack_config_collection.md +++ b/docs/project-client/models/slack_config_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :------------------------- | :------- | :---------- | -| Data | []integrations.SlackConfig | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :-------------------------------------------- | :------- | :---------- | +| Data | [][integrations.SlackConfig](slack_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/slack_token.md b/docs/project-client/models/slack_token.md index 197ca1e..5429832 100644 --- a/docs/project-client/models/slack_token.md +++ b/docs/project-client/models/slack_token.md @@ -4,22 +4,22 @@ | Name | Type | Required | Description | | :---------- | :------------------------- | :------- | :-------------------------------------------------------------------------------------------------- | -| CreatedAt | string | ✅ | | -| Id | string | ✅ | | -| DiscardedAt | string | ❌ | | +| CreatedAt | string | ✅ | The timestamp when the token was created. | +| Id | string | ✅ | The unique identifier for the token. | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded, if applicable. | | Oauth | channels.Oauth | ❌ | | -| UpdatedAt | string | ❌ | | +| UpdatedAt | string | ❌ | The timestamp when the token metadata last changed. | | Webhook | channels.SlackTokenWebhook | ❌ | Obtained directly from the incoming_webhook object in the installation response from the Slack API. | # Oauth **Properties** -| Name | Type | Required | Description | -| :------------- | :----- | :------- | :---------- | -| ChannelId | string | ✅ | | -| InstallationId | string | ✅ | | -| Scope | string | ❌ | | +| Name | Type | Required | Description | +| :------------- | :----- | :------- | :--------------------------------------------------------------- | +| ChannelId | string | ✅ | The ID of the Slack channel this installation is associated with | +| InstallationId | string | ✅ | A unique identifier for this Slack workspace installation | +| Scope | string | ❌ | The OAuth scope granted during installation | # SlackTokenWebhook @@ -27,6 +27,6 @@ Obtained directly from the incoming_webhook object in the installation response **Properties** -| Name | Type | Required | Description | -| :--- | :----- | :------- | :---------- | -| Url | string | ✅ | | +| Name | Type | Required | Description | +| :--- | :----- | :------- | :------------------------------------------ | +| Url | string | ✅ | The URL for the incoming webhook from Slack | diff --git a/docs/project-client/models/slack_token_collection.md b/docs/project-client/models/slack_token_collection.md index f8d5581..cb50f05 100644 --- a/docs/project-client/models/slack_token_collection.md +++ b/docs/project-client/models/slack_token_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :-------------------- | :------- | :---------- | -| Data | []channels.SlackToken | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :-------------------------------------- | :------- | :---------- | +| Data | [][channels.SlackToken](slack_token.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/smtp_config.md b/docs/project-client/models/smtp_config.md new file mode 100644 index 0000000..6cee728 --- /dev/null +++ b/docs/project-client/models/smtp_config.md @@ -0,0 +1,47 @@ +# SmtpConfig + +**Properties** + +| Name | Type | Required | Description | +| :------- | :----------------------------- | :------- | :------------------------------ | +| From | integrations.SmtpConfigFrom | ✅ | Default sender email address | +| Host | string | ✅ | SMTP server hostname | +| Password | string | ✅ | SMTP authentication password | +| Port | int64 | ✅ | SMTP server port | +| Username | string | ✅ | SMTP authentication username | +| ReplyTo | integrations.SmtpConfigReplyTo | ❌ | Reply-to email address | +| Security | integrations.Security | ❌ | SMTP security/encryption method | + +# SmtpConfigFrom + +Default sender email address + +**Properties** + +| Name | Type | Required | Description | +| :---- | :----- | :------- | :------------------- | +| Email | string | ✅ | Sender email address | +| Name | string | ❌ | Sender name | + +# SmtpConfigReplyTo + +Reply-to email address + +**Properties** + +| Name | Type | Required | Description | +| :---- | :----- | :------- | :--------------------- | +| Email | string | ✅ | Reply-to email address | +| Name | string | ❌ | Reply-to name | + +# Security + +SMTP security/encryption method + +**Properties** + +| Name | Type | Required | Description | +| :------- | :----- | :------- | :---------- | +| None | string | ✅ | "none" | +| Ssl | string | ✅ | "ssl" | +| Starttls | string | ✅ | "starttls" | diff --git a/docs/project-client/models/smtp_config_object.md b/docs/project-client/models/smtp_config_object.md new file mode 100644 index 0000000..f2138c2 --- /dev/null +++ b/docs/project-client/models/smtp_config_object.md @@ -0,0 +1,9 @@ +# SmtpConfigObject + +**Properties** + +| Name | Type | Required | Description | +| :----- | :---------------------------------------- | :------- | :---------- | +| Config | [integrations.SmtpConfig](smtp_config.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/smtp_config_object_collection.md b/docs/project-client/models/smtp_config_object_collection.md new file mode 100644 index 0000000..091d79b --- /dev/null +++ b/docs/project-client/models/smtp_config_object_collection.md @@ -0,0 +1,8 @@ +# SmtpConfigObjectCollection + +**Properties** + +| Name | Type | Required | Description | +| :---- | :------------------------------------------------------- | :------- | :---------- | +| Data | [][integrations.SmtpConfigObject](smtp_config_object.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/stripe_config.md b/docs/project-client/models/stripe_config.md index 358331b..a46adb6 100644 --- a/docs/project-client/models/stripe_config.md +++ b/docs/project-client/models/stripe_config.md @@ -2,8 +2,8 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :------------------------------- | :------- | :---------- | -| Config | integrations.StripeConfigPayload | ✅ | | -| Id | string | ✅ | | -| Name | string | ✅ | | +| Name | Type | Required | Description | +| :----- | :----------------------------------------------------------- | :------- | :---------- | +| Config | [integrations.StripeConfigPayload](stripe_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/stripe_config_collection.md b/docs/project-client/models/stripe_config_collection.md index f9d9656..a88a801 100644 --- a/docs/project-client/models/stripe_config_collection.md +++ b/docs/project-client/models/stripe_config_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :-------------------------- | :------- | :---------- | -| Data | []integrations.StripeConfig | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :---------------------------------------------- | :------- | :---------- | +| Data | [][integrations.StripeConfig](stripe_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/stripe_config_payload.md b/docs/project-client/models/stripe_config_payload.md index 1647ad0..a06ca15 100644 --- a/docs/project-client/models/stripe_config_payload.md +++ b/docs/project-client/models/stripe_config_payload.md @@ -5,3 +5,4 @@ | Name | Type | Required | Description | | :------------------- | :----- | :------- | :--------------------------------------------------------- | | WebhookSigningSecret | string | ✅ | The signing secret to verify incoming requests from Stripe | +| Id | string | ❌ | The unique identifier for this configuration | diff --git a/docs/project-client/models/teams_token.md b/docs/project-client/models/teams_token.md index 0ab10d7..6a5620d 100644 --- a/docs/project-client/models/teams_token.md +++ b/docs/project-client/models/teams_token.md @@ -2,13 +2,13 @@ **Properties** -| Name | Type | Required | Description | -| :---------- | :------------------------- | :------- | :---------- | -| CreatedAt | string | ✅ | | -| Id | string | ✅ | | -| DiscardedAt | string | ❌ | | -| UpdatedAt | string | ❌ | | -| Webhook | channels.TeamsTokenWebhook | ❌ | | +| Name | Type | Required | Description | +| :---------- | :------------------------- | :------- | :--------------------------------------------------------- | +| CreatedAt | string | ✅ | The timestamp when the token was created. | +| Id | string | ✅ | The unique identifier for the token. | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded, if applicable. | +| UpdatedAt | string | ❌ | The timestamp when the token metadata last changed. | +| Webhook | channels.TeamsTokenWebhook | ❌ | | # TeamsTokenWebhook diff --git a/docs/project-client/models/teams_token_collection.md b/docs/project-client/models/teams_token_collection.md index 1ca3537..b837dca 100644 --- a/docs/project-client/models/teams_token_collection.md +++ b/docs/project-client/models/teams_token_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :-------------------- | :------- | :---------- | -| Data | []channels.TeamsToken | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :-------------------------------------- | :------- | :---------- | +| Data | [][channels.TeamsToken](teams_token.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/twilio_config.md b/docs/project-client/models/twilio_config.md index 173deed..76d0797 100644 --- a/docs/project-client/models/twilio_config.md +++ b/docs/project-client/models/twilio_config.md @@ -2,8 +2,8 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :------------------------------- | :------- | :---------- | -| Config | integrations.TwilioConfigPayload | ✅ | | -| Id | string | ✅ | | -| Name | string | ✅ | | +| Name | Type | Required | Description | +| :----- | :----------------------------------------------------------- | :------- | :---------- | +| Config | [integrations.TwilioConfigPayload](twilio_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/twilio_config_collection.md b/docs/project-client/models/twilio_config_collection.md index 579e6a6..bfb8a6f 100644 --- a/docs/project-client/models/twilio_config_collection.md +++ b/docs/project-client/models/twilio_config_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :-------------------------- | :------- | :---------- | -| Data | []integrations.TwilioConfig | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :---------------------------------------------- | :------- | :---------- | +| Data | [][integrations.TwilioConfig](twilio_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/user.md b/docs/project-client/models/user.md index fb39e6c..ee86b36 100644 --- a/docs/project-client/models/user.md +++ b/docs/project-client/models/user.md @@ -2,15 +2,15 @@ **Properties** -| Name | Type | Required | Description | -| :--------------- | :----- | :------- | :---------- | -| CreatedAt | string | ❌ | | -| CustomAttributes | any | ❌ | | -| Email | string | ❌ | | -| ExternalId | string | ❌ | | -| FirstName | string | ❌ | | -| Id | string | ❌ | | -| LastName | string | ❌ | | -| LastNotifiedAt | string | ❌ | | -| LastSeenAt | string | ❌ | | -| UpdatedAt | string | ❌ | | +| Name | Type | Required | Description | +| :--------------- | :----- | :------- | :-------------------------------------------------------- | +| CreatedAt | string | ❌ | The timestamp when the user was created. | +| CustomAttributes | any | ❌ | Arbitrary custom values stored on the user. | +| Email | string | ❌ | The primary email address of the user. | +| ExternalId | string | ❌ | The user identifier from an external system. | +| FirstName | string | ❌ | The first name of the user. | +| Id | string | ❌ | The unique identifier for the user. | +| LastName | string | ❌ | The last name of the user. | +| LastNotifiedAt | string | ❌ | The timestamp when the user last received a notification. | +| LastSeenAt | string | ❌ | The timestamp when the user last opened the inbox. | +| UpdatedAt | string | ❌ | The timestamp when the user was last updated. | diff --git a/docs/project-client/models/user_collection.md b/docs/project-client/models/user_collection.md index f95ebf2..042a778 100644 --- a/docs/project-client/models/user_collection.md +++ b/docs/project-client/models/user_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :------------ | :------- | :---------- | -| Data | []shared.User | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :----------------------- | :------- | :---------- | +| Data | [][shared.User](user.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/web_push_token.md b/docs/project-client/models/web_push_token.md index 265b418..fd68abb 100644 --- a/docs/project-client/models/web_push_token.md +++ b/docs/project-client/models/web_push_token.md @@ -4,12 +4,12 @@ | Name | Type | Required | Description | | :---------- | :------------ | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| CreatedAt | string | ✅ | | +| CreatedAt | string | ✅ | The timestamp when the token was created. | | Endpoint | string | ✅ | The push subscription URL obtained from PushSubscription.endpoint after calling registration.pushManager.subscribe(). This is the unique URL for this device that push messages will be sent to. | -| Id | string | ✅ | | +| Id | string | ✅ | The unique identifier for the token. | | Keys | channels.Keys | ✅ | The encryption keys from the PushSubscription.getKey() method, needed to encrypt push messages for this subscription. | -| DiscardedAt | string | ❌ | | -| UpdatedAt | string | ❌ | | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded, if applicable. | +| UpdatedAt | string | ❌ | The timestamp when the token metadata last changed. | # Keys diff --git a/docs/project-client/models/web_push_token_collection.md b/docs/project-client/models/web_push_token_collection.md index ed16554..6446fe5 100644 --- a/docs/project-client/models/web_push_token_collection.md +++ b/docs/project-client/models/web_push_token_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :---------------------- | :------- | :---------- | -| Data | []channels.WebPushToken | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------------------------- | :------- | :---------- | +| Data | [][channels.WebPushToken](web_push_token.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/webpush_config.md b/docs/project-client/models/webpush_config.md index 1feede3..d62ace0 100644 --- a/docs/project-client/models/webpush_config.md +++ b/docs/project-client/models/webpush_config.md @@ -2,8 +2,8 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :-------------------------------- | :------- | :---------- | -| Config | integrations.WebpushConfigPayload | ✅ | | -| Id | string | ✅ | | -| Name | string | ✅ | | +| Name | Type | Required | Description | +| :----- | :------------------------------------------------------------- | :------- | :---------- | +| Config | [integrations.WebpushConfigPayload](webpush_config_payload.md) | ✅ | | +| Id | string | ✅ | | +| Name | string | ✅ | | diff --git a/docs/project-client/models/webpush_config_collection.md b/docs/project-client/models/webpush_config_collection.md index b149f5a..542b849 100644 --- a/docs/project-client/models/webpush_config_collection.md +++ b/docs/project-client/models/webpush_config_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :--------------------------- | :------- | :---------- | -| Data | []integrations.WebpushConfig | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------------------------------ | :------- | :---------- | +| Data | [][integrations.WebpushConfig](webpush_config.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/models/webpush_config_payload.md b/docs/project-client/models/webpush_config_payload.md index 00270b8..49f97a0 100644 --- a/docs/project-client/models/webpush_config_payload.md +++ b/docs/project-client/models/webpush_config_payload.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :--------- | :----- | :------- | :------------------------------------------------------------------- | -| PrivateKey | string | ✅ | VAPID private key - from the pair you generated. | -| PublicKey | string | ✅ | VAPID public key - generate one at https://tools.reactpwa.com/vapid. | +| Name | Type | Required | Description | +| :--------- | :----- | :------- | :---------------------------------------------------------------------- | +| PrivateKey | string | ✅ | VAPID private key. | +| PublicKey | string | ✅ | VAPID public key - read more at https://magicbell.com/tools/vapid-keys. | diff --git a/docs/project-client/models/workflow_definition.md b/docs/project-client/models/workflow_definition.md new file mode 100644 index 0000000..3ab884e --- /dev/null +++ b/docs/project-client/models/workflow_definition.md @@ -0,0 +1,19 @@ +# WorkflowDefinition + +**Properties** + +| Name | Type | Required | Description | +| :------- | :---------------------------------- | :------- | :--------------------------------------------------------------------- | +| Key | string | ✅ | Unique identifier for this workflow definition. | +| Steps | []workflows.WorkflowDefinitionSteps | ✅ | Ordered list describing each action that will run inside the workflow. | +| Disabled | bool | ❌ | When true, prevents the workflow from being triggered. | + +# WorkflowDefinitionSteps + +**Properties** + +| Name | Type | Required | Description | +| :------ | :----- | :------- | :---------------------------------------------------------------- | +| Command | string | ✅ | Command to execute (e.g., broadcast, pause, wait, abort) | +| If\_ | string | ❌ | JMESPath condition that must evaluate truthy for the step to run. | +| Input | any | ❌ | Optional payload passed to the command when it executes. | diff --git a/docs/project-client/models/workflow_list.md b/docs/project-client/models/workflow_list.md new file mode 100644 index 0000000..1158d7a --- /dev/null +++ b/docs/project-client/models/workflow_list.md @@ -0,0 +1,27 @@ +# WorkflowList + +**Properties** + +| Name | Type | Required | Description | +| :---- | :---------------- | :------- | :---------- | +| Items | []workflows.Items | ❌ | | + +# Items + +**Properties** + +| Name | Type | Required | Description | +| :------- | :--------------------- | :------- | :---------- | +| Key | string | ✅ | | +| Steps | []workflows.ItemsSteps | ✅ | | +| Disabled | bool | ❌ | | + +# ItemsSteps + +**Properties** + +| Name | Type | Required | Description | +| :------ | :----- | :------- | :------------------------------------------------------- | +| Command | string | ✅ | Command to execute (e.g., broadcast, pause, wait, abort) | +| If\_ | string | ❌ | | +| Input | any | ❌ | | diff --git a/docs/project-client/models/workflow_run.md b/docs/project-client/models/workflow_run.md new file mode 100644 index 0000000..16ea66a --- /dev/null +++ b/docs/project-client/models/workflow_run.md @@ -0,0 +1,22 @@ +# WorkflowRun + +**Properties** + +| Name | Type | Required | Description | +| :---------- | :-------------------------- | :------- | :---------- | +| CreatedAt | string | ❌ | | +| Id | string | ❌ | | +| Status | workflows.WorkflowRunStatus | ❌ | | +| WorkflowKey | string | ❌ | | + +# WorkflowRunStatus + +**Properties** + +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :---------- | +| CompletedAt | string | ❌ | | +| Error | string | ❌ | | +| NextStep | int64 | ❌ | | +| StartedAt | string | ❌ | | +| State | int64 | ❌ | | diff --git a/docs/project-client/models/workflow_run_collection.md b/docs/project-client/models/workflow_run_collection.md new file mode 100644 index 0000000..bb85e68 --- /dev/null +++ b/docs/project-client/models/workflow_run_collection.md @@ -0,0 +1,8 @@ +# WorkflowRunCollection + +**Properties** + +| Name | Type | Required | Description | +| :---- | :----------------------------------------- | :------- | :---------- | +| Data | [][workflows.WorkflowRun](workflow_run.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/project-client/services/broadcasts_service.md b/docs/project-client/services/broadcasts_service.md index def4ef7..b622f8f 100644 --- a/docs/project-client/services/broadcasts_service.md +++ b/docs/project-client/services/broadcasts_service.md @@ -32,18 +32,22 @@ Retrieves a paginated list of broadcasts for the project. Returns basic informat import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/broadcasts" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := broadcasts.ListBroadcastsRequestParams{ - + Limit: util.ToPointer(int64(0)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } response, err := client.Broadcasts.ListBroadcasts(context.Background(), params) @@ -78,6 +82,7 @@ Creates a new broadcast. When a broadcast is created, it generates individual no import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -85,34 +90,35 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) email := broadcasts.Email{ - ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "ActionUrl" }), - Content: util.ToPointer("Content"), - Title: util.ToPointer("Title"), + ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "action_url" }), + Content: util.ToPointer("content"), + Title: util.ToPointer("title"), } inApp := broadcasts.InApp{ - ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "ActionUrl" }), - Content: util.ToPointer("Content"), - Title: util.ToPointer("Title"), + ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "action_url" }), + Content: util.ToPointer("content"), + Title: util.ToPointer("title"), } mobilePush := broadcasts.MobilePush{ - ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "ActionUrl" }), - Content: util.ToPointer("Content"), - Title: util.ToPointer("Title"), + ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "action_url" }), + Content: util.ToPointer("content"), + Title: util.ToPointer("title"), } sms := broadcasts.Sms{ - ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "ActionUrl" }), - Content: util.ToPointer("Content"), - Title: util.ToPointer("Title"), + ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "action_url" }), + Content: util.ToPointer("content"), + Title: util.ToPointer("title"), } overridesChannels := broadcasts.OverridesChannels{ @@ -143,29 +149,29 @@ overrides := broadcasts.Overrides{ user := shared.User{ - CreatedAt: util.ToPointer(util.Nullable[string]{ Value: "CreatedAt" }), + CreatedAt: util.ToPointer(util.Nullable[string]{ Value: "created_at" }), CustomAttributes: []byte{}, - Email: util.ToPointer(util.Nullable[string]{ Value: "Email" }), - ExternalId: util.ToPointer(util.Nullable[string]{ Value: "ExternalId" }), - FirstName: util.ToPointer(util.Nullable[string]{ Value: "FirstName" }), - Id: util.ToPointer("Id"), - LastName: util.ToPointer(util.Nullable[string]{ Value: "LastName" }), - LastNotifiedAt: util.ToPointer(util.Nullable[string]{ Value: "LastNotifiedAt" }), - LastSeenAt: util.ToPointer(util.Nullable[string]{ Value: "LastSeenAt" }), - UpdatedAt: util.ToPointer(util.Nullable[string]{ Value: "UpdatedAt" }), + Email: util.ToPointer(util.Nullable[string]{ Value: "email" }), + ExternalId: util.ToPointer(util.Nullable[string]{ Value: "external_id" }), + FirstName: util.ToPointer(util.Nullable[string]{ Value: "first_name" }), + Id: util.ToPointer("id"), + LastName: util.ToPointer(util.Nullable[string]{ Value: "last_name" }), + LastNotifiedAt: util.ToPointer(util.Nullable[string]{ Value: "last_notified_at" }), + LastSeenAt: util.ToPointer(util.Nullable[string]{ Value: "last_seen_at" }), + UpdatedAt: util.ToPointer(util.Nullable[string]{ Value: "updated_at" }), } errors := broadcasts.Errors{ - Message: util.ToPointer("Message"), + Message: util.ToPointer("message"), } statusStatus := broadcasts.STATUS_STATUS_ENQUEUED summary := broadcasts.Summary{ - Failures: util.ToPointer(int64(123)), - Total: util.ToPointer(int64(123)), + Failures: util.ToPointer(int64(8)), + Total: util.ToPointer(int64(8)), } broadcastStatus := broadcasts.BroadcastStatus{ @@ -175,17 +181,17 @@ broadcastStatus := broadcasts.BroadcastStatus{ } request := broadcasts.Broadcast{ - ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "ActionUrl" }), - Category: util.ToPointer(util.Nullable[string]{ Value: "Category" }), - Content: util.ToPointer(util.Nullable[string]{ Value: "Content" }), - CreatedAt: util.ToPointer("CreatedAt"), + ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "action_url" }), + Category: util.ToPointer(util.Nullable[string]{ Value: "category" }), + Content: util.ToPointer(util.Nullable[string]{ Value: "content" }), + CreatedAt: util.ToPointer("created_at"), CustomAttributes: []byte{}, - Id: util.ToPointer("Id"), + Id: util.ToPointer("id"), Overrides: &overrides, Recipients: []shared.User{user}, Status: &broadcastStatus, - Title: util.ToPointer("Title"), - Topic: util.ToPointer(util.Nullable[string]{ Value: "Topic" }), + Title: util.ToPointer("title"), + Topic: util.ToPointer(util.Nullable[string]{ Value: "topic" }), } response, err := client.Broadcasts.CreateBroadcast(context.Background(), request) @@ -220,15 +226,17 @@ Retrieves detailed information about a specific broadcast by its ID. Includes th import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Broadcasts.FetchBroadcast(context.Background(), "broadcastId") +response, err := client.Broadcasts.FetchBroadcast(context.Background(), "broadcast_id") if err != nil { panic(err) } diff --git a/docs/project-client/services/channels_service.md b/docs/project-client/services/channels_service.md index c49d966..30d6d9b 100644 --- a/docs/project-client/services/channels_service.md +++ b/docs/project-client/services/channels_service.md @@ -2,31 +2,34 @@ A list of all methods in the `ChannelsService` service. Click on the method name to view detailed information about that method. -| Methods | Description | -| :------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| [SaveChannelsConfig](#savechannelsconfig) | Save the channels configuration for a given key. | -| [FetchChannelsConfig](#fetchchannelsconfig) | Fetches the channels config for a given key. | -| [ListUserInboxTokens](#listuserinboxtokens) | Lists all Inbox tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | -| [FetchUserInboxToken](#fetchuserinboxtoken) | Fetches a specific Inbox token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | -| [DeleteUserInboxToken](#deleteuserinboxtoken) | Deletes a specific user's Inbox token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | -| [ListUserApnsTokens](#listuserapnstokens) | Lists all APNs tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | -| [FetchUserApnsToken](#fetchuserapnstoken) | Fetches a specific APNs token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | -| [DeleteUserApnsToken](#deleteuserapnstoken) | Deletes a specific user's APNs token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | -| [ListUserExpoTokens](#listuserexpotokens) | Lists all Expo tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | -| [FetchUserExpoToken](#fetchuserexpotoken) | Fetches a specific Expo token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | -| [DeleteUserExpoToken](#deleteuserexpotoken) | Deletes a specific user's Expo token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | -| [ListUserFcmTokens](#listuserfcmtokens) | Lists all FCM tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | -| [FetchUserFcmToken](#fetchuserfcmtoken) | Fetches a specific FCM token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | -| [DeleteUserFcmToken](#deleteuserfcmtoken) | Deletes a specific user's FCM token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | -| [ListUserSlackTokens](#listuserslacktokens) | Lists all Slack tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | -| [FetchUserSlackToken](#fetchuserslacktoken) | Fetches a specific Slack token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | -| [DeleteUserSlackToken](#deleteuserslacktoken) | Deletes a specific user's Slack token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | -| [ListUserTeamsTokens](#listuserteamstokens) | Lists all Teams tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | -| [FetchUserTeamsToken](#fetchuserteamstoken) | Fetches a specific Teams token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | -| [DeleteUserTeamsToken](#deleteuserteamstoken) | Deletes a specific user's Teams token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | -| [ListUserWebPushTokens](#listuserwebpushtokens) | Lists all Web Push tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | -| [FetchUserWebPushToken](#fetchuserwebpushtoken) | Fetches a specific Web Push token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | -| [DeleteUserWebPushToken](#deleteuserwebpushtoken) | Deletes a specific user's Web Push token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | +| Methods | Description | +| :-------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [SaveChannelsConfig](#savechannelsconfig) | Save the channels configuration for a given key. | +| [FetchChannelsConfig](#fetchchannelsconfig) | Fetches the channels config for a given key. | +| [ListUserInboxTokens](#listuserinboxtokens) | Lists all Inbox tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | +| [FetchUserInboxToken](#fetchuserinboxtoken) | Fetches a specific Inbox token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | +| [DeleteUserInboxToken](#deleteuserinboxtoken) | Deletes a specific user's Inbox token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | +| [ListUserApnsTokens](#listuserapnstokens) | Lists all APNs tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | +| [FetchUserApnsToken](#fetchuserapnstoken) | Fetches a specific APNs token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | +| [DeleteUserApnsToken](#deleteuserapnstoken) | Deletes a specific user's APNs token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | +| [ListUserExpoTokens](#listuserexpotokens) | Lists all Expo tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | +| [FetchUserExpoToken](#fetchuserexpotoken) | Fetches a specific Expo token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | +| [DeleteUserExpoToken](#deleteuserexpotoken) | Deletes a specific user's Expo token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | +| [ListUserFcmTokens](#listuserfcmtokens) | Lists all FCM tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | +| [FetchUserFcmToken](#fetchuserfcmtoken) | Fetches a specific FCM token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | +| [DeleteUserFcmToken](#deleteuserfcmtoken) | Deletes a specific user's FCM token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | +| [ListUserMagicbellSlackbotTokens](#listusermagicbellslackbottokens) | Lists all MagicBell SlackBot tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | +| [FetchUserMagicbellSlackbotToken](#fetchusermagicbellslackbottoken) | Fetches a specific MagicBell SlackBot token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | +| [DeleteUserMagicbellSlackbotToken](#deleteusermagicbellslackbottoken) | Deletes a specific user's MagicBell SlackBot token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | +| [ListUserSlackTokens](#listuserslacktokens) | Lists all Slack tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | +| [FetchUserSlackToken](#fetchuserslacktoken) | Fetches a specific Slack token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | +| [DeleteUserSlackToken](#deleteuserslacktoken) | Deletes a specific user's Slack token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | +| [ListUserTeamsTokens](#listuserteamstokens) | Lists all Teams tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | +| [FetchUserTeamsToken](#fetchuserteamstoken) | Fetches a specific Teams token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | +| [DeleteUserTeamsToken](#deleteuserteamstoken) | Deletes a specific user's Teams token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | +| [ListUserWebPushTokens](#listuserwebpushtokens) | Lists all Web Push tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. | +| [FetchUserWebPushToken](#fetchuserwebpushtoken) | Fetches a specific Web Push token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. | +| [DeleteUserWebPushToken](#deleteuserwebpushtoken) | Deletes a specific user's Web Push token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. | ## SaveChannelsConfig @@ -52,6 +55,7 @@ Save the channels configuration for a given key. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -59,20 +63,21 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) channel := channels.CHANNEL_IN_APP categoryDeliveryConfigChannels := channels.CategoryDeliveryConfigChannels{ Channel: &channel, - Delay: util.ToPointer(int64(123)), - If_: util.ToPointer(util.Nullable[string]{ Value: "If_" }), + Delay: util.ToPointer(int64(8)), + If_: util.ToPointer(util.Nullable[string]{ Value: "if" }), } request := channels.CategoryDeliveryConfig{ Channels: []channels.CategoryDeliveryConfigChannels{categoryDeliveryConfigChannels}, Disabled: util.ToPointer(true), - Key: util.ToPointer("Key"), + Key: util.ToPointer("key"), } response, err := client.Channels.SaveChannelsConfig(context.Background(), request) @@ -107,12 +112,14 @@ Fetches the channels config for a given key. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Channels.FetchChannelsConfig(context.Background(), "key") @@ -148,21 +155,25 @@ Lists all Inbox tokens associated with a specific user. This endpoint is availab import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/channels" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := channels.ListUserInboxTokensRequestParams{ - + Limit: util.ToPointer(int64(3)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } -response, err := client.Channels.ListUserInboxTokens(context.Background(), "userId", params) +response, err := client.Channels.ListUserInboxTokens(context.Background(), "user_id", params) if err != nil { panic(err) } @@ -195,15 +206,17 @@ Fetches a specific Inbox token by its ID for a given user. This endpoint is avai import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.FetchUserInboxToken(context.Background(), "userId", "tokenId") +response, err := client.Channels.FetchUserInboxToken(context.Background(), "user_id", "token_id") if err != nil { panic(err) } @@ -236,15 +249,17 @@ Deletes a specific user's Inbox token. This endpoint is available to project adm import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.DeleteUserInboxToken(context.Background(), "userId", "tokenId") +response, err := client.Channels.DeleteUserInboxToken(context.Background(), "user_id", "token_id") if err != nil { panic(err) } @@ -277,21 +292,25 @@ Lists all APNs tokens associated with a specific user. This endpoint is availabl import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/channels" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := channels.ListUserApnsTokensRequestParams{ - + Limit: util.ToPointer(int64(2)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } -response, err := client.Channels.ListUserApnsTokens(context.Background(), "userId", params) +response, err := client.Channels.ListUserApnsTokens(context.Background(), "user_id", params) if err != nil { panic(err) } @@ -324,15 +343,17 @@ Fetches a specific APNs token by its ID for a given user. This endpoint is avail import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.FetchUserApnsToken(context.Background(), "userId", "tokenId") +response, err := client.Channels.FetchUserApnsToken(context.Background(), "user_id", "token_id") if err != nil { panic(err) } @@ -365,15 +386,17 @@ Deletes a specific user's APNs token. This endpoint is available to project admi import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.DeleteUserApnsToken(context.Background(), "userId", "tokenId") +response, err := client.Channels.DeleteUserApnsToken(context.Background(), "user_id", "token_id") if err != nil { panic(err) } @@ -406,21 +429,25 @@ Lists all Expo tokens associated with a specific user. This endpoint is availabl import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/channels" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := channels.ListUserExpoTokensRequestParams{ - + Limit: util.ToPointer(int64(1)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } -response, err := client.Channels.ListUserExpoTokens(context.Background(), "userId", params) +response, err := client.Channels.ListUserExpoTokens(context.Background(), "user_id", params) if err != nil { panic(err) } @@ -453,15 +480,17 @@ Fetches a specific Expo token by its ID for a given user. This endpoint is avail import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.FetchUserExpoToken(context.Background(), "userId", "tokenId") +response, err := client.Channels.FetchUserExpoToken(context.Background(), "user_id", "token_id") if err != nil { panic(err) } @@ -494,15 +523,17 @@ Deletes a specific user's Expo token. This endpoint is available to project admi import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.DeleteUserExpoToken(context.Background(), "userId", "tokenId") +response, err := client.Channels.DeleteUserExpoToken(context.Background(), "user_id", "token_id") if err != nil { panic(err) } @@ -535,21 +566,25 @@ Lists all FCM tokens associated with a specific user. This endpoint is available import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/channels" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := channels.ListUserFcmTokensRequestParams{ - + Limit: util.ToPointer(int64(1)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } -response, err := client.Channels.ListUserFcmTokens(context.Background(), "userId", params) +response, err := client.Channels.ListUserFcmTokens(context.Background(), "user_id", params) if err != nil { panic(err) } @@ -582,15 +617,17 @@ Fetches a specific FCM token by its ID for a given user. This endpoint is availa import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.FetchUserFcmToken(context.Background(), "userId", "tokenId") +response, err := client.Channels.FetchUserFcmToken(context.Background(), "user_id", "token_id") if err != nil { panic(err) } @@ -623,15 +660,154 @@ Deletes a specific user's FCM token. This endpoint is available to project admin import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + +response, err := client.Channels.DeleteUserFcmToken(context.Background(), "user_id", "token_id") +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## ListUserMagicbellSlackbotTokens + +Lists all MagicBell SlackBot tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. + +- HTTP Method: `GET` +- Endpoint: `/users/{user_id}/channels/slack/magicbell_slackbot/tokens` + +**Parameters** + +| Name | Type | Required | Description | +| :----- | :------------------------------------------- | :------- | :---------------------------- | +| ctx | Context | ✅ | Default go language context | +| userId | string | ✅ | | +| params | ListUserMagicbellSlackbotTokensRequestParams | ✅ | Additional request parameters | + +**Return Type** + +`SlackTokenCollection` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + "github.com/magicbell/magicbell-go/pkg/project-client/util" + "github.com/magicbell/magicbell-go/pkg/project-client/channels" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.DeleteUserFcmToken(context.Background(), "userId", "tokenId") + +params := channels.ListUserMagicbellSlackbotTokensRequestParams{ + Limit: util.ToPointer(int64(6)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), +} + +response, err := client.Channels.ListUserMagicbellSlackbotTokens(context.Background(), "user_id", params) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## FetchUserMagicbellSlackbotToken + +Fetches a specific MagicBell SlackBot token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. + +- HTTP Method: `GET` +- Endpoint: `/users/{user_id}/channels/slack/magicbell_slackbot/tokens/{token_id}` + +**Parameters** + +| Name | Type | Required | Description | +| :------ | :------ | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| userId | string | ✅ | | +| tokenId | string | ✅ | | + +**Return Type** + +`SlackToken` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + +response, err := client.Channels.FetchUserMagicbellSlackbotToken(context.Background(), "user_id", "token_id") +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## DeleteUserMagicbellSlackbotToken + +Deletes a specific user's MagicBell SlackBot token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. + +- HTTP Method: `DELETE` +- Endpoint: `/users/{user_id}/channels/slack/magicbell_slackbot/tokens/{token_id}` + +**Parameters** + +| Name | Type | Required | Description | +| :------ | :------ | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| userId | string | ✅ | | +| tokenId | string | ✅ | | + +**Return Type** + +`DiscardResult` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + +response, err := client.Channels.DeleteUserMagicbellSlackbotToken(context.Background(), "user_id", "token_id") if err != nil { panic(err) } @@ -664,21 +840,25 @@ Lists all Slack tokens associated with a specific user. This endpoint is availab import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/channels" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := channels.ListUserSlackTokensRequestParams{ - + Limit: util.ToPointer(int64(4)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } -response, err := client.Channels.ListUserSlackTokens(context.Background(), "userId", params) +response, err := client.Channels.ListUserSlackTokens(context.Background(), "user_id", params) if err != nil { panic(err) } @@ -711,15 +891,17 @@ Fetches a specific Slack token by its ID for a given user. This endpoint is avai import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.FetchUserSlackToken(context.Background(), "userId", "tokenId") +response, err := client.Channels.FetchUserSlackToken(context.Background(), "user_id", "token_id") if err != nil { panic(err) } @@ -752,15 +934,17 @@ Deletes a specific user's Slack token. This endpoint is available to project adm import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.DeleteUserSlackToken(context.Background(), "userId", "tokenId") +response, err := client.Channels.DeleteUserSlackToken(context.Background(), "user_id", "token_id") if err != nil { panic(err) } @@ -793,21 +977,25 @@ Lists all Teams tokens associated with a specific user. This endpoint is availab import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/channels" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := channels.ListUserTeamsTokensRequestParams{ - + Limit: util.ToPointer(int64(6)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } -response, err := client.Channels.ListUserTeamsTokens(context.Background(), "userId", params) +response, err := client.Channels.ListUserTeamsTokens(context.Background(), "user_id", params) if err != nil { panic(err) } @@ -840,15 +1028,17 @@ Fetches a specific Teams token by its ID for a given user. This endpoint is avai import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.FetchUserTeamsToken(context.Background(), "userId", "tokenId") +response, err := client.Channels.FetchUserTeamsToken(context.Background(), "user_id", "token_id") if err != nil { panic(err) } @@ -881,15 +1071,17 @@ Deletes a specific user's Teams token. This endpoint is available to project adm import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.DeleteUserTeamsToken(context.Background(), "userId", "tokenId") +response, err := client.Channels.DeleteUserTeamsToken(context.Background(), "user_id", "token_id") if err != nil { panic(err) } @@ -922,21 +1114,25 @@ Lists all Web Push tokens associated with a specific user. This endpoint is avai import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/channels" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := channels.ListUserWebPushTokensRequestParams{ - + Limit: util.ToPointer(int64(5)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } -response, err := client.Channels.ListUserWebPushTokens(context.Background(), "userId", params) +response, err := client.Channels.ListUserWebPushTokens(context.Background(), "user_id", params) if err != nil { panic(err) } @@ -969,15 +1165,17 @@ Fetches a specific Web Push token by its ID for a given user. This endpoint is a import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.FetchUserWebPushToken(context.Background(), "userId", "tokenId") +response, err := client.Channels.FetchUserWebPushToken(context.Background(), "user_id", "token_id") if err != nil { panic(err) } @@ -1010,15 +1208,17 @@ Deletes a specific user's Web Push token. This endpoint is available to project import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.DeleteUserWebPushToken(context.Background(), "userId", "tokenId") +response, err := client.Channels.DeleteUserWebPushToken(context.Background(), "user_id", "token_id") if err != nil { panic(err) } diff --git a/docs/project-client/services/events_service.md b/docs/project-client/services/events_service.md index bb2ba10..4196f1d 100644 --- a/docs/project-client/services/events_service.md +++ b/docs/project-client/services/events_service.md @@ -31,18 +31,22 @@ Retrieves a paginated list of events for the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/events" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := events.ListEventsRequestParams{ - + Limit: util.ToPointer(int64(5)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } response, err := client.Events.ListEvents(context.Background(), params) @@ -77,15 +81,17 @@ Fetches a project event by its ID. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Events.FetchEvent(context.Background(), "eventId") +response, err := client.Events.FetchEvent(context.Background(), "event_id") if err != nil { panic(err) } diff --git a/docs/project-client/services/integrations_service.md b/docs/project-client/services/integrations_service.md index 333d044..a71999f 100644 --- a/docs/project-client/services/integrations_service.md +++ b/docs/project-client/services/integrations_service.md @@ -2,48 +2,57 @@ A list of all methods in the `IntegrationsService` service. Click on the method name to view detailed information about that method. -| Methods | Description | -| :-------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [ListIntegrations](#listintegrations) | Lists all available and configured integrations for the project. Returns a summary of each integration including its type, status, and basic configuration information. | -| [ListApnsIntegrations](#listapnsintegrations) | Retrieves the current APNs integration configurations for a specific integration type in the project. Returns configuration details and status information. | -| [SaveApnsIntegration](#saveapnsintegration) | Updates or creates the APNs integration for the project. | -| [DeleteApnsIntegration](#deleteapnsintegration) | Deletes the APNs integration configuration from the project. This will disable the integration's functionality within the project. | -| [ListExpoIntegrations](#listexpointegrations) | Retrieves the current Expo integration configurations for a specific integration type in the project. Returns configuration details and status information. | -| [SaveExpoIntegration](#saveexpointegration) | Updates or creates the Expo integration for the project. | -| [DeleteExpoIntegration](#deleteexpointegration) | Deletes the Expo integration configuration from the project. This will disable the integration's functionality within the project. | -| [ListFcmIntegrations](#listfcmintegrations) | Retrieves the current FCM integration configurations for a specific integration type in the project. Returns configuration details and status information. | -| [SaveFcmIntegration](#savefcmintegration) | Updates or creates the FCM integration for the project. | -| [DeleteFcmIntegration](#deletefcmintegration) | Deletes the FCM integration configuration from the project. This will disable the integration's functionality within the project. | -| [ListGithubIntegrations](#listgithubintegrations) | Retrieves the current GitHub integration configurations for a specific integration type in the project. Returns configuration details and status information. | -| [SaveGithubIntegration](#savegithubintegration) | Updates or creates the GitHub integration for the project. | -| [DeleteGithubIntegration](#deletegithubintegration) | Deletes the GitHub integration configuration from the project. This will disable the integration's functionality within the project. | -| [ListInboxIntegrations](#listinboxintegrations) | Retrieves the current Inbox integration configurations for a specific integration type in the project. Returns configuration details and status information. | -| [SaveInboxIntegration](#saveinboxintegration) | Updates or creates the Inbox integration for the project. | -| [DeleteInboxIntegration](#deleteinboxintegration) | Deletes the Inbox integration configuration from the project. This will disable the integration's functionality within the project. | -| [ListMailgunIntegrations](#listmailgunintegrations) | Retrieves the current Mailgun integration configurations for a specific integration type in the project. Returns configuration details and status information. | -| [SaveMailgunIntegration](#savemailgunintegration) | Updates or creates the Mailgun integration for the project. | -| [DeleteMailgunIntegration](#deletemailgunintegration) | Deletes the Mailgun integration configuration from the project. This will disable the integration's functionality within the project. | -| [ListPingEmailIntegrations](#listpingemailintegrations) | Retrieves the current Ping Email integration configurations for a specific integration type in the project. Returns configuration details and status information. | -| [SavePingEmailIntegration](#savepingemailintegration) | Updates or creates the Ping Email integration for the project. | -| [DeletePingEmailIntegration](#deletepingemailintegration) | Deletes the Ping Email integration configuration from the project. This will disable the integration's functionality within the project. | -| [ListSendgridIntegrations](#listsendgridintegrations) | Retrieves the current SendGrid integration configurations for a specific integration type in the project. Returns configuration details and status information. | -| [SaveSendgridIntegration](#savesendgridintegration) | Updates or creates the SendGrid integration for the project. | -| [DeleteSendgridIntegration](#deletesendgridintegration) | Deletes the SendGrid integration configuration from the project. This will disable the integration's functionality within the project. | -| [ListSesIntegrations](#listsesintegrations) | Retrieves the current Amazon SES integration configurations for a specific integration type in the project. Returns configuration details and status information. | -| [SaveSesIntegration](#savesesintegration) | Updates or creates the Amazon SES integration for the project. | -| [DeleteSesIntegration](#deletesesintegration) | Deletes the Amazon SES integration configuration from the project. This will disable the integration's functionality within the project. | -| [ListSlackIntegrations](#listslackintegrations) | Retrieves the current Slack integration configurations for a specific integration type in the project. Returns configuration details and status information. | -| [SaveSlackIntegration](#saveslackintegration) | Updates or creates the Slack integration for the project. | -| [DeleteSlackIntegration](#deleteslackintegration) | Deletes the Slack integration configuration from the project. This will disable the integration's functionality within the project. | -| [ListStripeIntegrations](#liststripeintegrations) | Retrieves the current Stripe integration configurations for a specific integration type in the project. Returns configuration details and status information. | -| [SaveStripeIntegration](#savestripeintegration) | Updates or creates the Stripe integration for the project. | -| [DeleteStripeIntegration](#deletestripeintegration) | Deletes the Stripe integration configuration from the project. This will disable the integration's functionality within the project. | -| [ListTwilioIntegrations](#listtwiliointegrations) | Retrieves the current Twilio integration configurations for a specific integration type in the project. Returns configuration details and status information. | -| [SaveTwilioIntegration](#savetwiliointegration) | Updates or creates the Twilio integration for the project. | -| [DeleteTwilioIntegration](#deletetwiliointegration) | Deletes the Twilio integration configuration from the project. This will disable the integration's functionality within the project. | -| [ListWebPushIntegrations](#listwebpushintegrations) | Retrieves the current Web Push integration configurations for a specific integration type in the project. Returns configuration details and status information. | -| [SaveWebPushIntegration](#savewebpushintegration) | Updates or creates the Web Push integration for the project. | -| [DeleteWebPushIntegration](#deletewebpushintegration) | Deletes the Web Push integration configuration from the project. This will disable the integration's functionality within the project. | +| Methods | Description | +| :------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [ListIntegrations](#listintegrations) | Lists all available and configured integrations for the project. Returns a summary of each integration including its type, status, and basic configuration information. | +| [ListApnsIntegrations](#listapnsintegrations) | Retrieves the current APNs integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveApnsIntegration](#saveapnsintegration) | Updates or creates the APNs integration for the project. | +| [DeleteApnsIntegration](#deleteapnsintegration) | Deletes the APNs integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListEventsourceIntegrations](#listeventsourceintegrations) | Retrieves the current EventSource integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveEventsourceIntegration](#saveeventsourceintegration) | Updates or creates the EventSource integration for the project. | +| [DeleteEventsourceIntegration](#deleteeventsourceintegration) | Deletes the EventSource integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListExpoIntegrations](#listexpointegrations) | Retrieves the current Expo integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveExpoIntegration](#saveexpointegration) | Updates or creates the Expo integration for the project. | +| [DeleteExpoIntegration](#deleteexpointegration) | Deletes the Expo integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListFcmIntegrations](#listfcmintegrations) | Retrieves the current FCM integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveFcmIntegration](#savefcmintegration) | Updates or creates the FCM integration for the project. | +| [DeleteFcmIntegration](#deletefcmintegration) | Deletes the FCM integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListGithubIntegrations](#listgithubintegrations) | Retrieves the current GitHub integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveGithubIntegration](#savegithubintegration) | Updates or creates the GitHub integration for the project. | +| [DeleteGithubIntegration](#deletegithubintegration) | Deletes the GitHub integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListInboxIntegrations](#listinboxintegrations) | Retrieves the current Inbox integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveInboxIntegration](#saveinboxintegration) | Updates or creates the Inbox integration for the project. | +| [DeleteInboxIntegration](#deleteinboxintegration) | Deletes the Inbox integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListMagicbellSlackbotIntegrations](#listmagicbellslackbotintegrations) | Retrieves the current MagicBell SlackBot integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveMagicbellSlackbotIntegration](#savemagicbellslackbotintegration) | Updates or creates the MagicBell SlackBot integration for the project. | +| [DeleteMagicbellSlackbotIntegration](#deletemagicbellslackbotintegration) | Deletes the MagicBell SlackBot integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListMailgunIntegrations](#listmailgunintegrations) | Retrieves the current Mailgun integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveMailgunIntegration](#savemailgunintegration) | Updates or creates the Mailgun integration for the project. | +| [DeleteMailgunIntegration](#deletemailgunintegration) | Deletes the Mailgun integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListPingEmailIntegrations](#listpingemailintegrations) | Retrieves the current Ping Email integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SavePingEmailIntegration](#savepingemailintegration) | Updates or creates the Ping Email integration for the project. | +| [DeletePingEmailIntegration](#deletepingemailintegration) | Deletes the Ping Email integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListSendgridIntegrations](#listsendgridintegrations) | Retrieves the current SendGrid integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveSendgridIntegration](#savesendgridintegration) | Updates or creates the SendGrid integration for the project. | +| [DeleteSendgridIntegration](#deletesendgridintegration) | Deletes the SendGrid integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListSesIntegrations](#listsesintegrations) | Retrieves the current Amazon SES integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveSesIntegration](#savesesintegration) | Updates or creates the Amazon SES integration for the project. | +| [DeleteSesIntegration](#deletesesintegration) | Deletes the Amazon SES integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListSlackIntegrations](#listslackintegrations) | Retrieves the current Slack integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveSlackIntegration](#saveslackintegration) | Updates or creates the Slack integration for the project. | +| [DeleteSlackIntegration](#deleteslackintegration) | Deletes the Slack integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListSmtpIntegrations](#listsmtpintegrations) | Retrieves the current SMTP integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveSmtpIntegration](#savesmtpintegration) | Updates or creates the SMTP integration for the project. | +| [DeleteSmtpIntegration](#deletesmtpintegration) | Deletes the SMTP integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListStripeIntegrations](#liststripeintegrations) | Retrieves the current Stripe integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveStripeIntegration](#savestripeintegration) | Updates or creates the Stripe integration for the project. | +| [DeleteStripeIntegration](#deletestripeintegration) | Deletes the Stripe integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListTwilioIntegrations](#listtwiliointegrations) | Retrieves the current Twilio integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveTwilioIntegration](#savetwiliointegration) | Updates or creates the Twilio integration for the project. | +| [DeleteTwilioIntegration](#deletetwiliointegration) | Deletes the Twilio integration configuration from the project. This will disable the integration's functionality within the project. | +| [ListWebPushIntegrations](#listwebpushintegrations) | Retrieves the current Web Push integration configurations for a specific integration type in the project. Returns configuration details and status information. | +| [SaveWebPushIntegration](#savewebpushintegration) | Updates or creates the Web Push integration for the project. | +| [DeleteWebPushIntegration](#deletewebpushintegration) | Deletes the Web Push integration configuration from the project. This will disable the integration's functionality within the project. | ## ListIntegrations @@ -69,18 +78,22 @@ Lists all available and configured integrations for the project. Returns a summa import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := integrations.ListIntegrationsRequestParams{ - + Limit: util.ToPointer(int64(3)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } response, err := client.Integrations.ListIntegrations(context.Background(), params) @@ -114,12 +127,14 @@ Retrieves the current APNs integration configurations for a specific integration import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.ListApnsIntegrations(context.Background()) @@ -154,6 +169,7 @@ Updates or creates the APNs integration for the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -161,6 +177,7 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) badge := integrations.BADGE_UNREAD @@ -168,12 +185,14 @@ badge := integrations.BADGE_UNREAD payloadVersion := integrations.PAYLOAD_VERSION_1 request := integrations.ApnsConfigPayload{ - AppId: util.ToPointer("AppId"), + AppId: util.ToPointer("app_id"), Badge: &badge, - Certificate: util.ToPointer("Certificate"), - KeyId: util.ToPointer("KeyId"), + Certificate: util.ToPointer("BEGIN PRIVATE KEY-------- +tahhm84591o= +----------END PRIVATE KEYYYYYY-------"), + KeyId: util.ToPointer("sintdolor "), PayloadVersion: &payloadVersion, - TeamId: util.ToPointer("TeamId"), + TeamId: util.ToPointer("laborumiru"), } response, err := client.Integrations.SaveApnsIntegration(context.Background(), request) @@ -208,18 +227,20 @@ Deletes the APNs integration configuration from the project. This will disable t import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := integrations.DeleteApnsIntegrationRequestParams{ - + Id: util.ToPointer("id"), } response, err := client.Integrations.DeleteApnsIntegration(context.Background(), params) @@ -230,6 +251,143 @@ if err != nil { fmt.Println(response) ``` +## ListEventsourceIntegrations + +Retrieves the current EventSource integration configurations for a specific integration type in the project. Returns configuration details and status information. + +- HTTP Method: `GET` +- Endpoint: `/integrations/eventsource` + +**Parameters** + +| Name | Type | Required | Description | +| :--- | :------ | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | + +**Return Type** + +`EventSourceConfigCollection` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + +response, err := client.Integrations.ListEventsourceIntegrations(context.Background()) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## SaveEventsourceIntegration + +Updates or creates the EventSource integration for the project. + +- HTTP Method: `PUT` +- Endpoint: `/integrations/eventsource` + +**Parameters** + +| Name | Type | Required | Description | +| :----------------------- | :----------------------- | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| eventSourceConfigPayload | EventSourceConfigPayload | ✅ | | + +**Return Type** + +`EventSourceConfigPayload` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + "github.com/magicbell/magicbell-go/pkg/project-client/util" + "github.com/magicbell/magicbell-go/pkg/project-client/integrations" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +request := integrations.EventSourceConfigPayload{ + Source: util.ToPointer("source"), +} + +response, err := client.Integrations.SaveEventsourceIntegration(context.Background(), request) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## DeleteEventsourceIntegration + +Deletes the EventSource integration configuration from the project. This will disable the integration's functionality within the project. + +- HTTP Method: `DELETE` +- Endpoint: `/integrations/eventsource` + +**Parameters** + +| Name | Type | Required | Description | +| :----- | :---------------------------------------- | :------- | :---------------------------- | +| ctx | Context | ✅ | Default go language context | +| params | DeleteEventsourceIntegrationRequestParams | ✅ | Additional request parameters | + +**Return Type** + +`any` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + "github.com/magicbell/magicbell-go/pkg/project-client/util" + "github.com/magicbell/magicbell-go/pkg/project-client/integrations" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +params := integrations.DeleteEventsourceIntegrationRequestParams{ + Id: util.ToPointer("id"), +} + +response, err := client.Integrations.DeleteEventsourceIntegration(context.Background(), params) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + ## ListExpoIntegrations Retrieves the current Expo integration configurations for a specific integration type in the project. Returns configuration details and status information. @@ -253,12 +411,14 @@ Retrieves the current Expo integration configurations for a specific integration import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.ListExpoIntegrations(context.Background()) @@ -293,6 +453,7 @@ Updates or creates the Expo integration for the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -300,11 +461,12 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) request := integrations.ExpoConfigPayload{ - AccessToken: util.ToPointer("AccessToken"), + AccessToken: util.ToPointer("access_token"), } response, err := client.Integrations.SaveExpoIntegration(context.Background(), request) @@ -339,18 +501,20 @@ Deletes the Expo integration configuration from the project. This will disable t import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := integrations.DeleteExpoIntegrationRequestParams{ - + Id: util.ToPointer("id"), } response, err := client.Integrations.DeleteExpoIntegration(context.Background(), params) @@ -384,12 +548,14 @@ Retrieves the current FCM integration configurations for a specific integration import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.ListFcmIntegrations(context.Background()) @@ -424,6 +590,7 @@ Updates or creates the FCM integration for the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -431,22 +598,25 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) type_ := integrations.TYPE_SERVICE_ACCOUNT request := integrations.FcmConfigPayload{ - AuthProviderX509CertUrl: util.ToPointer("AuthProviderX509CertUrl"), - AuthUri: util.ToPointer("AuthUri"), - ClientEmail: util.ToPointer("ClientEmail"), - ClientId: util.ToPointer("ClientId"), - ClientX509CertUrl: util.ToPointer("ClientX509CertUrl"), - PrivateKey: util.ToPointer("PrivateKey"), - PrivateKeyId: util.ToPointer("PrivateKeyId"), - ProjectId: util.ToPointer("ProjectId"), - TokenUri: util.ToPointer("TokenUri"), + AuthProviderX509CertUrl: util.ToPointer("auth_provider_x509_cert_url"), + AuthUri: util.ToPointer("auth_uri"), + ClientEmail: util.ToPointer("client_email"), + ClientId: util.ToPointer("client_id"), + ClientX509CertUrl: util.ToPointer("client_x509_cert_url"), + PrivateKey: util.ToPointer(" BEGINNNHB-------- +BRMn2Y= +--- ENDUZSZ-----------"), + PrivateKeyId: util.ToPointer("private_key_id"), + ProjectId: util.ToPointer("project_id"), + TokenUri: util.ToPointer("token_uri"), Type_: &type_, - UniverseDomain: util.ToPointer("UniverseDomain"), + UniverseDomain: util.ToPointer("universe_domain"), } response, err := client.Integrations.SaveFcmIntegration(context.Background(), request) @@ -481,18 +651,20 @@ Deletes the FCM integration configuration from the project. This will disable th import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := integrations.DeleteFcmIntegrationRequestParams{ - + Id: util.ToPointer("id"), } response, err := client.Integrations.DeleteFcmIntegration(context.Background(), params) @@ -526,12 +698,14 @@ Retrieves the current GitHub integration configurations for a specific integrati import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.ListGithubIntegrations(context.Background()) @@ -566,6 +740,7 @@ Updates or creates the GitHub integration for the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -573,11 +748,12 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) request := integrations.GithubConfigPayload{ - WebhookSigningSecret: util.ToPointer("WebhookSigningSecret"), + WebhookSigningSecret: util.ToPointer("webhook_signing_secret"), } response, err := client.Integrations.SaveGithubIntegration(context.Background(), request) @@ -612,18 +788,20 @@ Deletes the GitHub integration configuration from the project. This will disable import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := integrations.DeleteGithubIntegrationRequestParams{ - + Id: util.ToPointer("id"), } response, err := client.Integrations.DeleteGithubIntegration(context.Background(), params) @@ -657,12 +835,14 @@ Retrieves the current Inbox integration configurations for a specific integratio import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.ListInboxIntegrations(context.Background()) @@ -697,6 +877,7 @@ Updates or creates the Inbox integration for the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -704,104 +885,105 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) images := integrations.Images{ - EmptyInboxUrl: util.ToPointer("EmptyInboxUrl"), + EmptyInboxUrl: util.ToPointer("emptyInboxUrl"), } banner := integrations.Banner{ - BackgroundColor: util.ToPointer("BackgroundColor"), - BackgroundOpacity: util.ToPointer(float64(123)), - FontSize: util.ToPointer("FontSize"), - TextColor: util.ToPointer("TextColor"), + BackgroundColor: util.ToPointer("backgroundColor"), + BackgroundOpacity: util.ToPointer(float64(0.65)), + FontSize: util.ToPointer("fontSize"), + TextColor: util.ToPointer("textColor"), } dialog := integrations.Dialog{ - AccentColor: util.ToPointer("AccentColor"), - BackgroundColor: util.ToPointer("BackgroundColor"), - TextColor: util.ToPointer("TextColor"), + AccentColor: util.ToPointer("accentColor"), + BackgroundColor: util.ToPointer("backgroundColor"), + TextColor: util.ToPointer("textColor"), } footer := integrations.Footer{ - BackgroundColor: util.ToPointer("BackgroundColor"), - BorderRadius: util.ToPointer("BorderRadius"), - FontSize: util.ToPointer("FontSize"), - TextColor: util.ToPointer("TextColor"), + BackgroundColor: util.ToPointer("backgroundColor"), + BorderRadius: util.ToPointer("borderRadius"), + FontSize: util.ToPointer("fontSize"), + TextColor: util.ToPointer("textColor"), } header := integrations.Header{ - BackgroundColor: util.ToPointer("BackgroundColor"), - BorderRadius: util.ToPointer("BorderRadius"), - FontFamily: util.ToPointer("FontFamily"), - FontSize: util.ToPointer("FontSize"), - TextColor: util.ToPointer("TextColor"), + BackgroundColor: util.ToPointer("backgroundColor"), + BorderRadius: util.ToPointer("borderRadius"), + FontFamily: util.ToPointer("fontFamily"), + FontSize: util.ToPointer("fontSize"), + TextColor: util.ToPointer("textColor"), } icon := integrations.Icon{ - BorderColor: util.ToPointer("BorderColor"), - Width: util.ToPointer("Width"), + BorderColor: util.ToPointer("borderColor"), + Width: util.ToPointer("width"), } defaultHover := integrations.DefaultHover{ - BackgroundColor: util.ToPointer("BackgroundColor"), + BackgroundColor: util.ToPointer("backgroundColor"), } defaultState := integrations.DefaultState{ - Color: util.ToPointer("Color"), + Color: util.ToPointer("color"), } default_ := integrations.Default_{ - BackgroundColor: util.ToPointer("BackgroundColor"), - BorderRadius: util.ToPointer("BorderRadius"), - FontFamily: util.ToPointer("FontFamily"), - FontSize: util.ToPointer("FontSize"), + BackgroundColor: util.ToPointer("backgroundColor"), + BorderRadius: util.ToPointer("borderRadius"), + FontFamily: util.ToPointer("fontFamily"), + FontSize: util.ToPointer("fontSize"), Hover: &defaultHover, - Margin: util.ToPointer("Margin"), + Margin: util.ToPointer("margin"), State: &defaultState, - TextColor: util.ToPointer("TextColor"), + TextColor: util.ToPointer("textColor"), } unreadHover := integrations.UnreadHover{ - BackgroundColor: util.ToPointer("BackgroundColor"), + BackgroundColor: util.ToPointer("backgroundColor"), } unreadState := integrations.UnreadState{ - Color: util.ToPointer("Color"), + Color: util.ToPointer("color"), } unread := integrations.Unread{ - BackgroundColor: util.ToPointer("BackgroundColor"), + BackgroundColor: util.ToPointer("backgroundColor"), Hover: &unreadHover, State: &unreadState, - TextColor: util.ToPointer("TextColor"), + TextColor: util.ToPointer("textColor"), } unseenHover := integrations.UnseenHover{ - BackgroundColor: util.ToPointer("BackgroundColor"), + BackgroundColor: util.ToPointer("backgroundColor"), } unseenState := integrations.UnseenState{ - Color: util.ToPointer("Color"), + Color: util.ToPointer("color"), } unseen := integrations.Unseen{ - BackgroundColor: util.ToPointer("BackgroundColor"), + BackgroundColor: util.ToPointer("backgroundColor"), Hover: &unseenHover, State: &unseenState, - TextColor: util.ToPointer("TextColor"), + TextColor: util.ToPointer("textColor"), } notification := integrations.Notification{ @@ -812,7 +994,7 @@ notification := integrations.Notification{ unseenBadge := integrations.UnseenBadge{ - BackgroundColor: util.ToPointer("BackgroundColor"), + BackgroundColor: util.ToPointer("backgroundColor"), } theme := integrations.Theme{ @@ -827,7 +1009,7 @@ theme := integrations.Theme{ request := integrations.InboxConfigPayload{ Images: &images, - Locale: util.ToPointer(util.Nullable[string]{ Value: "Locale" }), + Locale: util.ToPointer(util.Nullable[string]{ Value: "locale" }), Theme: &theme, } @@ -863,18 +1045,20 @@ Deletes the Inbox integration configuration from the project. This will disable import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := integrations.DeleteInboxIntegrationRequestParams{ - + Id: util.ToPointer("id"), } response, err := client.Integrations.DeleteInboxIntegration(context.Background(), params) @@ -885,6 +1069,143 @@ if err != nil { fmt.Println(response) ``` +## ListMagicbellSlackbotIntegrations + +Retrieves the current MagicBell SlackBot integration configurations for a specific integration type in the project. Returns configuration details and status information. + +- HTTP Method: `GET` +- Endpoint: `/integrations/magicbell_slackbot` + +**Parameters** + +| Name | Type | Required | Description | +| :--- | :------ | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | + +**Return Type** + +`SlackBotConfigCollection` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + +response, err := client.Integrations.ListMagicbellSlackbotIntegrations(context.Background()) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## SaveMagicbellSlackbotIntegration + +Updates or creates the MagicBell SlackBot integration for the project. + +- HTTP Method: `PUT` +- Endpoint: `/integrations/magicbell_slackbot` + +**Parameters** + +| Name | Type | Required | Description | +| :-------------------- | :-------------------- | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| slackBotConfigPayload | SlackBotConfigPayload | ✅ | | + +**Return Type** + +`SlackBotConfigPayload` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + "github.com/magicbell/magicbell-go/pkg/project-client/util" + "github.com/magicbell/magicbell-go/pkg/project-client/integrations" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +request := integrations.SlackBotConfigPayload{ + Enabled: util.ToPointer(true), +} + +response, err := client.Integrations.SaveMagicbellSlackbotIntegration(context.Background(), request) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## DeleteMagicbellSlackbotIntegration + +Deletes the MagicBell SlackBot integration configuration from the project. This will disable the integration's functionality within the project. + +- HTTP Method: `DELETE` +- Endpoint: `/integrations/magicbell_slackbot` + +**Parameters** + +| Name | Type | Required | Description | +| :----- | :---------------------------------------------- | :------- | :---------------------------- | +| ctx | Context | ✅ | Default go language context | +| params | DeleteMagicbellSlackbotIntegrationRequestParams | ✅ | Additional request parameters | + +**Return Type** + +`any` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + "github.com/magicbell/magicbell-go/pkg/project-client/util" + "github.com/magicbell/magicbell-go/pkg/project-client/integrations" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +params := integrations.DeleteMagicbellSlackbotIntegrationRequestParams{ + Id: util.ToPointer("id"), +} + +response, err := client.Integrations.DeleteMagicbellSlackbotIntegration(context.Background(), params) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + ## ListMailgunIntegrations Retrieves the current Mailgun integration configurations for a specific integration type in the project. Returns configuration details and status information. @@ -908,12 +1229,14 @@ Retrieves the current Mailgun integration configurations for a specific integrat import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.ListMailgunIntegrations(context.Background()) @@ -948,6 +1271,7 @@ Updates or creates the Mailgun integration for the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -955,19 +1279,20 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) mailgunConfigPayloadFrom := integrations.MailgunConfigPayloadFrom{ - Email: util.ToPointer("Email"), - Name: util.ToPointer(util.Nullable[string]{ Value: "Name" }), + Email: util.ToPointer("email"), + Name: util.ToPointer(util.Nullable[string]{ Value: "name" }), } region := integrations.REGION_US request := integrations.MailgunConfigPayload{ - ApiKey: util.ToPointer("ApiKey"), - Domain: util.ToPointer("Domain"), + ApiKey: util.ToPointer("api_key"), + Domain: util.ToPointer("domain"), From: &mailgunConfigPayloadFrom, Region: ®ion, } @@ -1004,18 +1329,20 @@ Deletes the Mailgun integration configuration from the project. This will disabl import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := integrations.DeleteMailgunIntegrationRequestParams{ - + Id: util.ToPointer("id"), } response, err := client.Integrations.DeleteMailgunIntegration(context.Background(), params) @@ -1049,12 +1376,14 @@ Retrieves the current Ping Email integration configurations for a specific integ import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.ListPingEmailIntegrations(context.Background()) @@ -1089,6 +1418,7 @@ Updates or creates the Ping Email integration for the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -1096,11 +1426,12 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) request := integrations.PingConfigPayload{ - Url: util.ToPointer("Url"), + Url: util.ToPointer("url"), } response, err := client.Integrations.SavePingEmailIntegration(context.Background(), request) @@ -1135,18 +1466,20 @@ Deletes the Ping Email integration configuration from the project. This will dis import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := integrations.DeletePingEmailIntegrationRequestParams{ - + Id: util.ToPointer("id"), } response, err := client.Integrations.DeletePingEmailIntegration(context.Background(), params) @@ -1180,12 +1513,14 @@ Retrieves the current SendGrid integration configurations for a specific integra import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.ListSendgridIntegrations(context.Background()) @@ -1220,6 +1555,7 @@ Updates or creates the SendGrid integration for the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -1227,24 +1563,25 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) sendgridConfigPayloadFrom := integrations.SendgridConfigPayloadFrom{ - Email: util.ToPointer("Email"), - Name: util.ToPointer(util.Nullable[string]{ Value: "Name" }), + Email: util.ToPointer("email"), + Name: util.ToPointer(util.Nullable[string]{ Value: "name" }), } -replyTo := integrations.ReplyTo{ - Email: util.ToPointer("Email"), - Name: util.ToPointer(util.Nullable[string]{ Value: "Name" }), +sendgridConfigPayloadReplyTo := integrations.SendgridConfigPayloadReplyTo{ + Email: util.ToPointer("email"), + Name: util.ToPointer(util.Nullable[string]{ Value: "name" }), } request := integrations.SendgridConfigPayload{ - ApiKey: util.ToPointer("ApiKey"), + ApiKey: util.ToPointer("api_key"), From: &sendgridConfigPayloadFrom, - ReplyTo: &replyTo, + ReplyTo: &sendgridConfigPayloadReplyTo, } response, err := client.Integrations.SaveSendgridIntegration(context.Background(), request) @@ -1279,18 +1616,20 @@ Deletes the SendGrid integration configuration from the project. This will disab import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := integrations.DeleteSendgridIntegrationRequestParams{ - + Id: util.ToPointer("id"), } response, err := client.Integrations.DeleteSendgridIntegration(context.Background(), params) @@ -1324,12 +1663,14 @@ Retrieves the current Amazon SES integration configurations for a specific integ import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.ListSesIntegrations(context.Background()) @@ -1364,6 +1705,7 @@ Updates or creates the Amazon SES integration for the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -1371,19 +1713,20 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) sesConfigPayloadFrom := integrations.SesConfigPayloadFrom{ - Email: util.ToPointer("Email"), - Name: util.ToPointer(util.Nullable[string]{ Value: "Name" }), + Email: util.ToPointer("email"), + Name: util.ToPointer(util.Nullable[string]{ Value: "name" }), } request := integrations.SesConfigPayload{ From: &sesConfigPayloadFrom, - KeyId: util.ToPointer("KeyId"), - Region: util.ToPointer("Region"), - SecretKey: util.ToPointer("SecretKey"), + KeyId: util.ToPointer("key_id"), + Region: util.ToPointer("region"), + SecretKey: util.ToPointer("secret_key"), } response, err := client.Integrations.SaveSesIntegration(context.Background(), request) @@ -1418,18 +1761,20 @@ Deletes the Amazon SES integration configuration from the project. This will dis import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := integrations.DeleteSesIntegrationRequestParams{ - + Id: util.ToPointer("id"), } response, err := client.Integrations.DeleteSesIntegration(context.Background(), params) @@ -1463,12 +1808,14 @@ Retrieves the current Slack integration configurations for a specific integratio import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.ListSlackIntegrations(context.Background()) @@ -1503,6 +1850,7 @@ Updates or creates the Slack integration for the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -1510,14 +1858,15 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) request := integrations.SlackConfigPayload{ - AppId: util.ToPointer("AppId"), - ClientId: util.ToPointer("ClientId"), - ClientSecret: util.ToPointer("ClientSecret"), - SigningSecret: util.ToPointer("SigningSecret"), + AppId: util.ToPointer("N"), + ClientId: util.ToPointer("26.63"), + ClientSecret: util.ToPointer("irure proidentincididunt exsit E"), + SigningSecret: util.ToPointer("incididunt laborisculpa magna al"), } response, err := client.Integrations.SaveSlackIntegration(context.Background(), request) @@ -1552,18 +1901,20 @@ Deletes the Slack integration configuration from the project. This will disable import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := integrations.DeleteSlackIntegrationRequestParams{ - + Id: util.ToPointer("id"), } response, err := client.Integrations.DeleteSlackIntegration(context.Background(), params) @@ -1574,6 +1925,162 @@ if err != nil { fmt.Println(response) ``` +## ListSmtpIntegrations + +Retrieves the current SMTP integration configurations for a specific integration type in the project. Returns configuration details and status information. + +- HTTP Method: `GET` +- Endpoint: `/integrations/smtp` + +**Parameters** + +| Name | Type | Required | Description | +| :--- | :------ | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | + +**Return Type** + +`SmtpConfigObjectCollection` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + +response, err := client.Integrations.ListSmtpIntegrations(context.Background()) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## SaveSmtpIntegration + +Updates or creates the SMTP integration for the project. + +- HTTP Method: `PUT` +- Endpoint: `/integrations/smtp` + +**Parameters** + +| Name | Type | Required | Description | +| :--------- | :--------- | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| smtpConfig | SmtpConfig | ✅ | | + +**Return Type** + +`SmtpConfig` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + "github.com/magicbell/magicbell-go/pkg/project-client/util" + "github.com/magicbell/magicbell-go/pkg/project-client/integrations" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +smtpConfigFrom := integrations.SmtpConfigFrom{ + Email: util.ToPointer("email"), + Name: util.ToPointer("name"), +} + + +smtpConfigReplyTo := integrations.SmtpConfigReplyTo{ + Email: util.ToPointer("email"), + Name: util.ToPointer("name"), +} + +security := integrations.SECURITY_NONE + +request := integrations.SmtpConfig{ + From: &smtpConfigFrom, + Host: util.ToPointer("smtp.gmail.com"), + Password: util.ToPointer("password"), + Port: util.ToPointer(int64(25)), + ReplyTo: &smtpConfigReplyTo, + Security: &security, + Username: util.ToPointer("username"), +} + +response, err := client.Integrations.SaveSmtpIntegration(context.Background(), request) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## DeleteSmtpIntegration + +Deletes the SMTP integration configuration from the project. This will disable the integration's functionality within the project. + +- HTTP Method: `DELETE` +- Endpoint: `/integrations/smtp` + +**Parameters** + +| Name | Type | Required | Description | +| :----- | :--------------------------------- | :------- | :---------------------------- | +| ctx | Context | ✅ | Default go language context | +| params | DeleteSmtpIntegrationRequestParams | ✅ | Additional request parameters | + +**Return Type** + +`any` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + "github.com/magicbell/magicbell-go/pkg/project-client/util" + "github.com/magicbell/magicbell-go/pkg/project-client/integrations" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +params := integrations.DeleteSmtpIntegrationRequestParams{ + Id: util.ToPointer("id"), +} + +response, err := client.Integrations.DeleteSmtpIntegration(context.Background(), params) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + ## ListStripeIntegrations Retrieves the current Stripe integration configurations for a specific integration type in the project. Returns configuration details and status information. @@ -1597,12 +2104,14 @@ Retrieves the current Stripe integration configurations for a specific integrati import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.ListStripeIntegrations(context.Background()) @@ -1637,6 +2146,7 @@ Updates or creates the Stripe integration for the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -1644,11 +2154,13 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) request := integrations.StripeConfigPayload{ - WebhookSigningSecret: util.ToPointer("WebhookSigningSecret"), + Id: util.ToPointer("id"), + WebhookSigningSecret: util.ToPointer("webhook_signing_secret"), } response, err := client.Integrations.SaveStripeIntegration(context.Background(), request) @@ -1683,18 +2195,20 @@ Deletes the Stripe integration configuration from the project. This will disable import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := integrations.DeleteStripeIntegrationRequestParams{ - + Id: util.ToPointer("id"), } response, err := client.Integrations.DeleteStripeIntegration(context.Background(), params) @@ -1728,12 +2242,14 @@ Retrieves the current Twilio integration configurations for a specific integrati import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.ListTwilioIntegrations(context.Background()) @@ -1768,6 +2284,7 @@ Updates or creates the Twilio integration for the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -1775,14 +2292,15 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) request := integrations.TwilioConfigPayload{ - AccountSid: util.ToPointer("AccountSid"), - ApiKey: util.ToPointer("ApiKey"), - ApiSecret: util.ToPointer("ApiSecret"), - From: util.ToPointer("From"), + AccountSid: util.ToPointer("account_sid"), + ApiKey: util.ToPointer("api_key"), + ApiSecret: util.ToPointer("api_secret"), + From: util.ToPointer("+8547811425211"), } response, err := client.Integrations.SaveTwilioIntegration(context.Background(), request) @@ -1817,18 +2335,20 @@ Deletes the Twilio integration configuration from the project. This will disable import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := integrations.DeleteTwilioIntegrationRequestParams{ - + Id: util.ToPointer("id"), } response, err := client.Integrations.DeleteTwilioIntegration(context.Background(), params) @@ -1862,12 +2382,14 @@ Retrieves the current Web Push integration configurations for a specific integra import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.ListWebPushIntegrations(context.Background()) @@ -1902,6 +2424,7 @@ Updates or creates the Web Push integration for the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -1909,12 +2432,13 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) request := integrations.WebpushConfigPayload{ - PrivateKey: util.ToPointer("PrivateKey"), - PublicKey: util.ToPointer("PublicKey"), + PrivateKey: util.ToPointer("private_key"), + PublicKey: util.ToPointer("public_key"), } response, err := client.Integrations.SaveWebPushIntegration(context.Background(), request) @@ -1949,18 +2473,20 @@ Deletes the Web Push integration configuration from the project. This will disab import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := integrations.DeleteWebPushIntegrationRequestParams{ - + Id: util.ToPointer("id"), } response, err := client.Integrations.DeleteWebPushIntegration(context.Background(), params) diff --git a/docs/project-client/services/users_service.md b/docs/project-client/services/users_service.md index c22c913..8ef28dd 100644 --- a/docs/project-client/services/users_service.md +++ b/docs/project-client/services/users_service.md @@ -32,18 +32,23 @@ Lists all users in the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" - + "github.com/magicbell/magicbell-go/pkg/project-client/util" "github.com/magicbell/magicbell-go/pkg/project-client/users" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := users.ListUsersRequestParams{ - + Limit: util.ToPointer(int64(2)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), + Query: util.ToPointer("query"), } response, err := client.Users.ListUsers(context.Background(), params) @@ -78,6 +83,7 @@ Creates or updates a user with the provided details. The user will be associated import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" "github.com/magicbell/magicbell-go/pkg/project-client/util" @@ -85,20 +91,21 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) request := shared.User{ - CreatedAt: util.ToPointer(util.Nullable[string]{ Value: "CreatedAt" }), + CreatedAt: util.ToPointer(util.Nullable[string]{ Value: "created_at" }), CustomAttributes: []byte{}, - Email: util.ToPointer(util.Nullable[string]{ Value: "Email" }), - ExternalId: util.ToPointer(util.Nullable[string]{ Value: "ExternalId" }), - FirstName: util.ToPointer(util.Nullable[string]{ Value: "FirstName" }), - Id: util.ToPointer("Id"), - LastName: util.ToPointer(util.Nullable[string]{ Value: "LastName" }), - LastNotifiedAt: util.ToPointer(util.Nullable[string]{ Value: "LastNotifiedAt" }), - LastSeenAt: util.ToPointer(util.Nullable[string]{ Value: "LastSeenAt" }), - UpdatedAt: util.ToPointer(util.Nullable[string]{ Value: "UpdatedAt" }), + Email: util.ToPointer(util.Nullable[string]{ Value: "email" }), + ExternalId: util.ToPointer(util.Nullable[string]{ Value: "external_id" }), + FirstName: util.ToPointer(util.Nullable[string]{ Value: "first_name" }), + Id: util.ToPointer("id"), + LastName: util.ToPointer(util.Nullable[string]{ Value: "last_name" }), + LastNotifiedAt: util.ToPointer(util.Nullable[string]{ Value: "last_notified_at" }), + LastSeenAt: util.ToPointer(util.Nullable[string]{ Value: "last_seen_at" }), + UpdatedAt: util.ToPointer(util.Nullable[string]{ Value: "updated_at" }), } response, err := client.Users.SaveUser(context.Background(), request) @@ -133,15 +140,17 @@ Removes a user and all associated data from the project. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/project-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Users.DeleteUser(context.Background(), "userId") +response, err := client.Users.DeleteUser(context.Background(), "user_id") if err != nil { panic(err) } diff --git a/docs/project-client/services/workflows_service.md b/docs/project-client/services/workflows_service.md new file mode 100644 index 0000000..baa06a9 --- /dev/null +++ b/docs/project-client/services/workflows_service.md @@ -0,0 +1,283 @@ +# WorkflowsService + +A list of all methods in the `WorkflowsService` service. Click on the method name to view detailed information about that method. + +| Methods | Description | +| :-------------------------------------- | :------------------------------------------------------- | +| [FetchWorkflows](#fetchworkflows) | Retrieves all workflow definitions for the project | +| [SaveWorkflow](#saveworkflow) | Creates or updates a workflow definition for the project | +| [FetchWorkflow](#fetchworkflow) | Retrieves a workflow definition by key | +| [CreateWorkflowRun](#createworkflowrun) | Executes a workflow with the provided input parameters | +| [FetchWorkflowRun](#fetchworkflowrun) | Retrieves the status and details of a workflow run | +| [ListWorkflowRuns](#listworkflowruns) | Retrieves all runs for a specific workflow | + +## FetchWorkflows + +Retrieves all workflow definitions for the project + +- HTTP Method: `GET` +- Endpoint: `/workflows` + +**Parameters** + +| Name | Type | Required | Description | +| :--- | :------ | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | + +**Return Type** + +`WorkflowList` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + +response, err := client.Workflows.FetchWorkflows(context.Background()) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## SaveWorkflow + +Creates or updates a workflow definition for the project + +- HTTP Method: `PUT` +- Endpoint: `/workflows` + +**Parameters** + +| Name | Type | Required | Description | +| :----------------- | :----------------- | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| workflowDefinition | WorkflowDefinition | ✅ | | + +**Return Type** + +`WorkflowDefinition` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + "github.com/magicbell/magicbell-go/pkg/project-client/util" + "github.com/magicbell/magicbell-go/pkg/project-client/workflows" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +workflowDefinitionSteps := workflows.WorkflowDefinitionSteps{ + Command: util.ToPointer("command"), + If_: util.ToPointer(util.Nullable[string]{ Value: "if" }), + Input: []byte{}, +} + +request := workflows.WorkflowDefinition{ + Disabled: util.ToPointer(true), + Key: util.ToPointer("key"), + Steps: []workflows.WorkflowDefinitionSteps{workflowDefinitionSteps}, +} + +response, err := client.Workflows.SaveWorkflow(context.Background(), request) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## FetchWorkflow + +Retrieves a workflow definition by key + +- HTTP Method: `GET` +- Endpoint: `/workflows/*` + +**Parameters** + +| Name | Type | Required | Description | +| :--- | :------ | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | + +**Return Type** + +`WorkflowDefinition` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + +response, err := client.Workflows.FetchWorkflow(context.Background()) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## CreateWorkflowRun + +Executes a workflow with the provided input parameters + +- HTTP Method: `POST` +- Endpoint: `/workflows/runs` + +**Parameters** + +| Name | Type | Required | Description | +| :--------------------- | :--------------------- | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| executeWorkflowRequest | ExecuteWorkflowRequest | ✅ | | + +**Return Type** + +`CreateRunResponse` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + "github.com/magicbell/magicbell-go/pkg/project-client/util" + "github.com/magicbell/magicbell-go/pkg/project-client/workflows" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +request := workflows.ExecuteWorkflowRequest{ + Input: []byte{}, + Key: util.ToPointer("key"), +} + +response, err := client.Workflows.CreateWorkflowRun(context.Background(), request) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## FetchWorkflowRun + +Retrieves the status and details of a workflow run + +- HTTP Method: `GET` +- Endpoint: `/workflows/runs/{run_id}` + +**Parameters** + +| Name | Type | Required | Description | +| :---- | :------ | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| runId | string | ✅ | | + +**Return Type** + +`GetRunResponse` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + +response, err := client.Workflows.FetchWorkflowRun(context.Background(), "run_id") +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## ListWorkflowRuns + +Retrieves all runs for a specific workflow + +- HTTP Method: `GET` +- Endpoint: `/workflows/{workflow_key}/runs` + +**Parameters** + +| Name | Type | Required | Description | +| :---------- | :------ | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| workflowKey | string | ✅ | | + +**Return Type** + +`WorkflowRunCollection` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/client" + +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + +response, err := client.Workflows.ListWorkflowRuns(context.Background(), "workflow_key") +if err != nil { + panic(err) +} + +fmt.Println(response) +``` diff --git a/docs/project-client/snippets/snippets.json b/docs/project-client/snippets/snippets.json index 7cb4b77..7d479c6 100644 --- a/docs/project-client/snippets/snippets.json +++ b/docs/project-client/snippets/snippets.json @@ -1,149 +1,188 @@ { "endpoints": { "/broadcasts": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/broadcasts\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := broadcasts.ListBroadcastsRequestParams{\n\n}\n\nresponse, err := client.Broadcasts.ListBroadcasts(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/broadcasts\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nemail := broadcasts.Email{\n ActionUrl: util.ToPointer(util.Nullable[string]{ Value: \"ActionUrl\" }),\n Content: util.ToPointer(\"Content\"),\n Title: util.ToPointer(\"Title\"),\n}\n\n\ninApp := broadcasts.InApp{\n ActionUrl: util.ToPointer(util.Nullable[string]{ Value: \"ActionUrl\" }),\n Content: util.ToPointer(\"Content\"),\n Title: util.ToPointer(\"Title\"),\n}\n\n\nmobilePush := broadcasts.MobilePush{\n ActionUrl: util.ToPointer(util.Nullable[string]{ Value: \"ActionUrl\" }),\n Content: util.ToPointer(\"Content\"),\n Title: util.ToPointer(\"Title\"),\n}\n\n\nsms := broadcasts.Sms{\n ActionUrl: util.ToPointer(util.Nullable[string]{ Value: \"ActionUrl\" }),\n Content: util.ToPointer(\"Content\"),\n Title: util.ToPointer(\"Title\"),\n}\n\noverridesChannels := broadcasts.OverridesChannels{\n Email: &email,\n InApp: &inApp,\n MobilePush: &mobilePush,\n Sms: &sms,\n}\n\n\nproviders := broadcasts.Providers{\n Apns: []byte{},\n Expo: []byte{},\n Fcm: []byte{},\n Mailgun: []byte{},\n Sendgrid: []byte{},\n Ses: []byte{},\n Slack: []byte{},\n Teams: []byte{},\n Twilio: []byte{},\n WebPush: []byte{},\n}\n\noverrides := broadcasts.Overrides{\n Channels: &overridesChannels,\n Providers: &providers,\n}\n\n\nuser := shared.User{\n CreatedAt: util.ToPointer(util.Nullable[string]{ Value: \"CreatedAt\" }),\n CustomAttributes: []byte{},\n Email: util.ToPointer(util.Nullable[string]{ Value: \"Email\" }),\n ExternalId: util.ToPointer(util.Nullable[string]{ Value: \"ExternalId\" }),\n FirstName: util.ToPointer(util.Nullable[string]{ Value: \"FirstName\" }),\n Id: util.ToPointer(\"Id\"),\n LastName: util.ToPointer(util.Nullable[string]{ Value: \"LastName\" }),\n LastNotifiedAt: util.ToPointer(util.Nullable[string]{ Value: \"LastNotifiedAt\" }),\n LastSeenAt: util.ToPointer(util.Nullable[string]{ Value: \"LastSeenAt\" }),\n UpdatedAt: util.ToPointer(util.Nullable[string]{ Value: \"UpdatedAt\" }),\n}\n\n\nerrors := broadcasts.Errors{\n Message: util.ToPointer(\"Message\"),\n}\n\nstatusStatus := broadcasts.STATUS_STATUS_ENQUEUED\n\n\nsummary := broadcasts.Summary{\n Failures: util.ToPointer(int64(123)),\n Total: util.ToPointer(int64(123)),\n}\n\nbroadcastStatus := broadcasts.BroadcastStatus{\n Errors: []broadcasts.Errors{errors},\n Status: &statusStatus,\n Summary: &summary,\n}\n\nrequest := broadcasts.Broadcast{\n ActionUrl: util.ToPointer(util.Nullable[string]{ Value: \"ActionUrl\" }),\n Category: util.ToPointer(util.Nullable[string]{ Value: \"Category\" }),\n Content: util.ToPointer(util.Nullable[string]{ Value: \"Content\" }),\n CreatedAt: util.ToPointer(\"CreatedAt\"),\n CustomAttributes: []byte{},\n Id: util.ToPointer(\"Id\"),\n Overrides: &overrides,\n Recipients: []shared.User{user},\n Status: &broadcastStatus,\n Title: util.ToPointer(\"Title\"),\n Topic: util.ToPointer(util.Nullable[string]{ Value: \"Topic\" }),\n}\n\nresponse, err := client.Broadcasts.CreateBroadcast(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/broadcasts\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := broadcasts.ListBroadcastsRequestParams{\n Limit: util.ToPointer(int64(0)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Broadcasts.ListBroadcasts(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/broadcasts\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nemail := broadcasts.Email{\n ActionUrl: util.ToPointer(util.Nullable[string]{ Value: \"action_url\" }),\n Content: util.ToPointer(\"content\"),\n Title: util.ToPointer(\"title\"),\n}\n\n\ninApp := broadcasts.InApp{\n ActionUrl: util.ToPointer(util.Nullable[string]{ Value: \"action_url\" }),\n Content: util.ToPointer(\"content\"),\n Title: util.ToPointer(\"title\"),\n}\n\n\nmobilePush := broadcasts.MobilePush{\n ActionUrl: util.ToPointer(util.Nullable[string]{ Value: \"action_url\" }),\n Content: util.ToPointer(\"content\"),\n Title: util.ToPointer(\"title\"),\n}\n\n\nsms := broadcasts.Sms{\n ActionUrl: util.ToPointer(util.Nullable[string]{ Value: \"action_url\" }),\n Content: util.ToPointer(\"content\"),\n Title: util.ToPointer(\"title\"),\n}\n\noverridesChannels := broadcasts.OverridesChannels{\n Email: &email,\n InApp: &inApp,\n MobilePush: &mobilePush,\n Sms: &sms,\n}\n\n\nproviders := broadcasts.Providers{\n Apns: []byte{},\n Expo: []byte{},\n Fcm: []byte{},\n Mailgun: []byte{},\n Sendgrid: []byte{},\n Ses: []byte{},\n Slack: []byte{},\n Teams: []byte{},\n Twilio: []byte{},\n WebPush: []byte{},\n}\n\noverrides := broadcasts.Overrides{\n Channels: &overridesChannels,\n Providers: &providers,\n}\n\n\nuser := shared.User{\n CreatedAt: util.ToPointer(util.Nullable[string]{ Value: \"created_at\" }),\n CustomAttributes: []byte{},\n Email: util.ToPointer(util.Nullable[string]{ Value: \"email\" }),\n ExternalId: util.ToPointer(util.Nullable[string]{ Value: \"external_id\" }),\n FirstName: util.ToPointer(util.Nullable[string]{ Value: \"first_name\" }),\n Id: util.ToPointer(\"id\"),\n LastName: util.ToPointer(util.Nullable[string]{ Value: \"last_name\" }),\n LastNotifiedAt: util.ToPointer(util.Nullable[string]{ Value: \"last_notified_at\" }),\n LastSeenAt: util.ToPointer(util.Nullable[string]{ Value: \"last_seen_at\" }),\n UpdatedAt: util.ToPointer(util.Nullable[string]{ Value: \"updated_at\" }),\n}\n\n\nerrors := broadcasts.Errors{\n Message: util.ToPointer(\"message\"),\n}\n\nstatusStatus := broadcasts.STATUS_STATUS_ENQUEUED\n\n\nsummary := broadcasts.Summary{\n Failures: util.ToPointer(int64(8)),\n Total: util.ToPointer(int64(8)),\n}\n\nbroadcastStatus := broadcasts.BroadcastStatus{\n Errors: []broadcasts.Errors{errors},\n Status: &statusStatus,\n Summary: &summary,\n}\n\nrequest := broadcasts.Broadcast{\n ActionUrl: util.ToPointer(util.Nullable[string]{ Value: \"action_url\" }),\n Category: util.ToPointer(util.Nullable[string]{ Value: \"category\" }),\n Content: util.ToPointer(util.Nullable[string]{ Value: \"content\" }),\n CreatedAt: util.ToPointer(\"created_at\"),\n CustomAttributes: []byte{},\n Id: util.ToPointer(\"id\"),\n Overrides: &overrides,\n Recipients: []shared.User{user},\n Status: &broadcastStatus,\n Title: util.ToPointer(\"title\"),\n Topic: util.ToPointer(util.Nullable[string]{ Value: \"topic\" }),\n}\n\nresponse, err := client.Broadcasts.CreateBroadcast(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/broadcasts/{broadcast_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Broadcasts.FetchBroadcast(context.Background(), \"broadcastId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Broadcasts.FetchBroadcast(context.Background(), \"broadcast_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels": { - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nchannel := channels.CHANNEL_IN_APP\n\ncategoryDeliveryConfigChannels := channels.CategoryDeliveryConfigChannels{\n Channel: &channel,\n Delay: util.ToPointer(int64(123)),\n If_: util.ToPointer(util.Nullable[string]{ Value: \"If_\" }),\n}\n\nrequest := channels.CategoryDeliveryConfig{\n Channels: []channels.CategoryDeliveryConfigChannels{categoryDeliveryConfigChannels},\n Disabled: util.ToPointer(true),\n Key: util.ToPointer(\"Key\"),\n}\n\nresponse, err := client.Channels.SaveChannelsConfig(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nchannel := channels.CHANNEL_IN_APP\n\ncategoryDeliveryConfigChannels := channels.CategoryDeliveryConfigChannels{\n Channel: &channel,\n Delay: util.ToPointer(int64(8)),\n If_: util.ToPointer(util.Nullable[string]{ Value: \"if\" }),\n}\n\nrequest := channels.CategoryDeliveryConfig{\n Channels: []channels.CategoryDeliveryConfigChannels{categoryDeliveryConfigChannels},\n Disabled: util.ToPointer(true),\n Key: util.ToPointer(\"key\"),\n}\n\nresponse, err := client.Channels.SaveChannelsConfig(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels/{key}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchChannelsConfig(context.Background(), \"key\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchChannelsConfig(context.Background(), \"key\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}/channels/in_app/inbox/tokens": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserInboxTokensRequestParams{\n\n}\n\nresponse, err := client.Channels.ListUserInboxTokens(context.Background(), \"userId\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserInboxTokensRequestParams{\n Limit: util.ToPointer(int64(3)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListUserInboxTokens(context.Background(), \"user_id\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}/channels/in_app/inbox/tokens/{token_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserInboxToken(context.Background(), \"userId\", \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserInboxToken(context.Background(), \"userId\", \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserInboxToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserInboxToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}/channels/mobile_push/apns/tokens": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserApnsTokensRequestParams{\n\n}\n\nresponse, err := client.Channels.ListUserApnsTokens(context.Background(), \"userId\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserApnsTokensRequestParams{\n Limit: util.ToPointer(int64(2)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListUserApnsTokens(context.Background(), \"user_id\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}/channels/mobile_push/apns/tokens/{token_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserApnsToken(context.Background(), \"userId\", \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserApnsToken(context.Background(), \"userId\", \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserApnsToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserApnsToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}/channels/mobile_push/expo/tokens": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserExpoTokensRequestParams{\n\n}\n\nresponse, err := client.Channels.ListUserExpoTokens(context.Background(), \"userId\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserExpoTokensRequestParams{\n Limit: util.ToPointer(int64(1)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListUserExpoTokens(context.Background(), \"user_id\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}/channels/mobile_push/expo/tokens/{token_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserExpoToken(context.Background(), \"userId\", \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserExpoToken(context.Background(), \"userId\", \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserExpoToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserExpoToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}/channels/mobile_push/fcm/tokens": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserFcmTokensRequestParams{\n\n}\n\nresponse, err := client.Channels.ListUserFcmTokens(context.Background(), \"userId\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserFcmTokensRequestParams{\n Limit: util.ToPointer(int64(1)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListUserFcmTokens(context.Background(), \"user_id\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}/channels/mobile_push/fcm/tokens/{token_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserFcmToken(context.Background(), \"userId\", \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserFcmToken(context.Background(), \"userId\", \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserFcmToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserFcmToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/users/{user_id}/channels/slack/magicbell_slackbot/tokens": { + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserMagicbellSlackbotTokensRequestParams{\n Limit: util.ToPointer(int64(6)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListUserMagicbellSlackbotTokens(context.Background(), \"user_id\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/users/{user_id}/channels/slack/magicbell_slackbot/tokens/{token_id}": { + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserMagicbellSlackbotToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserMagicbellSlackbotToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}/channels/slack/tokens": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserSlackTokensRequestParams{\n\n}\n\nresponse, err := client.Channels.ListUserSlackTokens(context.Background(), \"userId\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserSlackTokensRequestParams{\n Limit: util.ToPointer(int64(4)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListUserSlackTokens(context.Background(), \"user_id\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}/channels/slack/tokens/{token_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserSlackToken(context.Background(), \"userId\", \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserSlackToken(context.Background(), \"userId\", \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserSlackToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserSlackToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}/channels/teams/tokens": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserTeamsTokensRequestParams{\n\n}\n\nresponse, err := client.Channels.ListUserTeamsTokens(context.Background(), \"userId\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserTeamsTokensRequestParams{\n Limit: util.ToPointer(int64(6)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListUserTeamsTokens(context.Background(), \"user_id\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}/channels/teams/tokens/{token_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserTeamsToken(context.Background(), \"userId\", \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserTeamsToken(context.Background(), \"userId\", \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserTeamsToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserTeamsToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}/channels/web_push/tokens": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserWebPushTokensRequestParams{\n\n}\n\nresponse, err := client.Channels.ListUserWebPushTokens(context.Background(), \"userId\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListUserWebPushTokensRequestParams{\n Limit: util.ToPointer(int64(5)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListUserWebPushTokens(context.Background(), \"user_id\", params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}/channels/web_push/tokens/{token_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserWebPushToken(context.Background(), \"userId\", \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserWebPushToken(context.Background(), \"userId\", \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserWebPushToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteUserWebPushToken(context.Background(), \"user_id\", \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/events": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/events\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := events.ListEventsRequestParams{\n\n}\n\nresponse, err := client.Events.ListEvents(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/events\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := events.ListEventsRequestParams{\n Limit: util.ToPointer(int64(5)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Events.ListEvents(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/events/{event_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Events.FetchEvent(context.Background(), \"eventId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Events.FetchEvent(context.Background(), \"event_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := integrations.ListIntegrationsRequestParams{\n\n}\n\nresponse, err := client.Integrations.ListIntegrations(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.ListIntegrationsRequestParams{\n Limit: util.ToPointer(int64(3)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Integrations.ListIntegrations(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/apns": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListApnsIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nbadge := integrations.BADGE_UNREAD\n\npayloadVersion := integrations.PAYLOAD_VERSION_1\n\nrequest := integrations.ApnsConfigPayload{\n AppId: util.ToPointer(\"AppId\"),\n Badge: &badge,\n Certificate: util.ToPointer(\"Certificate\"),\n KeyId: util.ToPointer(\"KeyId\"),\n PayloadVersion: &payloadVersion,\n TeamId: util.ToPointer(\"TeamId\"),\n}\n\nresponse, err := client.Integrations.SaveApnsIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteApnsIntegrationRequestParams{\n\n}\n\nresponse, err := client.Integrations.DeleteApnsIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListApnsIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nbadge := integrations.BADGE_UNREAD\n\npayloadVersion := integrations.PAYLOAD_VERSION_1\n\nrequest := integrations.ApnsConfigPayload{\n AppId: util.ToPointer(\"app_id\"),\n Badge: &badge,\n Certificate: util.ToPointer(\"BEGIN PRIVATE KEY--------\ntahhm84591o=\n----------END PRIVATE KEYYYYYY-------\"),\n KeyId: util.ToPointer(\"sintdolor \"),\n PayloadVersion: &payloadVersion,\n TeamId: util.ToPointer(\"laborumiru\"),\n}\n\nresponse, err := client.Integrations.SaveApnsIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteApnsIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteApnsIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/integrations/eventsource": { + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListEventsourceIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := integrations.EventSourceConfigPayload{\n Source: util.ToPointer(\"source\"),\n}\n\nresponse, err := client.Integrations.SaveEventsourceIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteEventsourceIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteEventsourceIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/expo": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListExpoIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nrequest := integrations.ExpoConfigPayload{\n AccessToken: util.ToPointer(\"AccessToken\"),\n}\n\nresponse, err := client.Integrations.SaveExpoIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteExpoIntegrationRequestParams{\n\n}\n\nresponse, err := client.Integrations.DeleteExpoIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListExpoIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := integrations.ExpoConfigPayload{\n AccessToken: util.ToPointer(\"access_token\"),\n}\n\nresponse, err := client.Integrations.SaveExpoIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteExpoIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteExpoIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/fcm": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListFcmIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\ntype_ := integrations.TYPE_SERVICE_ACCOUNT\n\nrequest := integrations.FcmConfigPayload{\n AuthProviderX509CertUrl: util.ToPointer(\"AuthProviderX509CertUrl\"),\n AuthUri: util.ToPointer(\"AuthUri\"),\n ClientEmail: util.ToPointer(\"ClientEmail\"),\n ClientId: util.ToPointer(\"ClientId\"),\n ClientX509CertUrl: util.ToPointer(\"ClientX509CertUrl\"),\n PrivateKey: util.ToPointer(\"PrivateKey\"),\n PrivateKeyId: util.ToPointer(\"PrivateKeyId\"),\n ProjectId: util.ToPointer(\"ProjectId\"),\n TokenUri: util.ToPointer(\"TokenUri\"),\n Type_: &type_,\n UniverseDomain: util.ToPointer(\"UniverseDomain\"),\n}\n\nresponse, err := client.Integrations.SaveFcmIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteFcmIntegrationRequestParams{\n\n}\n\nresponse, err := client.Integrations.DeleteFcmIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListFcmIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\ntype_ := integrations.TYPE_SERVICE_ACCOUNT\n\nrequest := integrations.FcmConfigPayload{\n AuthProviderX509CertUrl: util.ToPointer(\"auth_provider_x509_cert_url\"),\n AuthUri: util.ToPointer(\"auth_uri\"),\n ClientEmail: util.ToPointer(\"client_email\"),\n ClientId: util.ToPointer(\"client_id\"),\n ClientX509CertUrl: util.ToPointer(\"client_x509_cert_url\"),\n PrivateKey: util.ToPointer(\" BEGINNNHB--------\nBRMn2Y=\n--- ENDUZSZ-----------\"),\n PrivateKeyId: util.ToPointer(\"private_key_id\"),\n ProjectId: util.ToPointer(\"project_id\"),\n TokenUri: util.ToPointer(\"token_uri\"),\n Type_: &type_,\n UniverseDomain: util.ToPointer(\"universe_domain\"),\n}\n\nresponse, err := client.Integrations.SaveFcmIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteFcmIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteFcmIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/github": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListGithubIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nrequest := integrations.GithubConfigPayload{\n WebhookSigningSecret: util.ToPointer(\"WebhookSigningSecret\"),\n}\n\nresponse, err := client.Integrations.SaveGithubIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteGithubIntegrationRequestParams{\n\n}\n\nresponse, err := client.Integrations.DeleteGithubIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListGithubIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := integrations.GithubConfigPayload{\n WebhookSigningSecret: util.ToPointer(\"webhook_signing_secret\"),\n}\n\nresponse, err := client.Integrations.SaveGithubIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteGithubIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteGithubIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/inbox": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListInboxIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nimages := integrations.Images{\n EmptyInboxUrl: util.ToPointer(\"EmptyInboxUrl\"),\n}\n\n\nbanner := integrations.Banner{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n BackgroundOpacity: util.ToPointer(float64(123)),\n FontSize: util.ToPointer(\"FontSize\"),\n TextColor: util.ToPointer(\"TextColor\"),\n}\n\n\ndialog := integrations.Dialog{\n AccentColor: util.ToPointer(\"AccentColor\"),\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n TextColor: util.ToPointer(\"TextColor\"),\n}\n\n\nfooter := integrations.Footer{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n BorderRadius: util.ToPointer(\"BorderRadius\"),\n FontSize: util.ToPointer(\"FontSize\"),\n TextColor: util.ToPointer(\"TextColor\"),\n}\n\n\nheader := integrations.Header{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n BorderRadius: util.ToPointer(\"BorderRadius\"),\n FontFamily: util.ToPointer(\"FontFamily\"),\n FontSize: util.ToPointer(\"FontSize\"),\n TextColor: util.ToPointer(\"TextColor\"),\n}\n\n\nicon := integrations.Icon{\n BorderColor: util.ToPointer(\"BorderColor\"),\n Width: util.ToPointer(\"Width\"),\n}\n\n\ndefaultHover := integrations.DefaultHover{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n}\n\n\ndefaultState := integrations.DefaultState{\n Color: util.ToPointer(\"Color\"),\n}\n\ndefault_ := integrations.Default_{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n BorderRadius: util.ToPointer(\"BorderRadius\"),\n FontFamily: util.ToPointer(\"FontFamily\"),\n FontSize: util.ToPointer(\"FontSize\"),\n Hover: &defaultHover,\n Margin: util.ToPointer(\"Margin\"),\n State: &defaultState,\n TextColor: util.ToPointer(\"TextColor\"),\n}\n\n\nunreadHover := integrations.UnreadHover{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n}\n\n\nunreadState := integrations.UnreadState{\n Color: util.ToPointer(\"Color\"),\n}\n\nunread := integrations.Unread{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n Hover: &unreadHover,\n State: &unreadState,\n TextColor: util.ToPointer(\"TextColor\"),\n}\n\n\nunseenHover := integrations.UnseenHover{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n}\n\n\nunseenState := integrations.UnseenState{\n Color: util.ToPointer(\"Color\"),\n}\n\nunseen := integrations.Unseen{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n Hover: &unseenHover,\n State: &unseenState,\n TextColor: util.ToPointer(\"TextColor\"),\n}\n\nnotification := integrations.Notification{\n Default_: &default_,\n Unread: &unread,\n Unseen: &unseen,\n}\n\n\nunseenBadge := integrations.UnseenBadge{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n}\n\ntheme := integrations.Theme{\n Banner: &banner,\n Dialog: &dialog,\n Footer: &footer,\n Header: &header,\n Icon: &icon,\n Notification: ¬ification,\n UnseenBadge: &unseenBadge,\n}\n\nrequest := integrations.InboxConfigPayload{\n Images: &images,\n Locale: util.ToPointer(util.Nullable[string]{ Value: \"Locale\" }),\n Theme: &theme,\n}\n\nresponse, err := client.Integrations.SaveInboxIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteInboxIntegrationRequestParams{\n\n}\n\nresponse, err := client.Integrations.DeleteInboxIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListInboxIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nimages := integrations.Images{\n EmptyInboxUrl: util.ToPointer(\"emptyInboxUrl\"),\n}\n\n\nbanner := integrations.Banner{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n BackgroundOpacity: util.ToPointer(float64(0.65)),\n FontSize: util.ToPointer(\"fontSize\"),\n TextColor: util.ToPointer(\"textColor\"),\n}\n\n\ndialog := integrations.Dialog{\n AccentColor: util.ToPointer(\"accentColor\"),\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n TextColor: util.ToPointer(\"textColor\"),\n}\n\n\nfooter := integrations.Footer{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n BorderRadius: util.ToPointer(\"borderRadius\"),\n FontSize: util.ToPointer(\"fontSize\"),\n TextColor: util.ToPointer(\"textColor\"),\n}\n\n\nheader := integrations.Header{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n BorderRadius: util.ToPointer(\"borderRadius\"),\n FontFamily: util.ToPointer(\"fontFamily\"),\n FontSize: util.ToPointer(\"fontSize\"),\n TextColor: util.ToPointer(\"textColor\"),\n}\n\n\nicon := integrations.Icon{\n BorderColor: util.ToPointer(\"borderColor\"),\n Width: util.ToPointer(\"width\"),\n}\n\n\ndefaultHover := integrations.DefaultHover{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n}\n\n\ndefaultState := integrations.DefaultState{\n Color: util.ToPointer(\"color\"),\n}\n\ndefault_ := integrations.Default_{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n BorderRadius: util.ToPointer(\"borderRadius\"),\n FontFamily: util.ToPointer(\"fontFamily\"),\n FontSize: util.ToPointer(\"fontSize\"),\n Hover: &defaultHover,\n Margin: util.ToPointer(\"margin\"),\n State: &defaultState,\n TextColor: util.ToPointer(\"textColor\"),\n}\n\n\nunreadHover := integrations.UnreadHover{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n}\n\n\nunreadState := integrations.UnreadState{\n Color: util.ToPointer(\"color\"),\n}\n\nunread := integrations.Unread{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n Hover: &unreadHover,\n State: &unreadState,\n TextColor: util.ToPointer(\"textColor\"),\n}\n\n\nunseenHover := integrations.UnseenHover{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n}\n\n\nunseenState := integrations.UnseenState{\n Color: util.ToPointer(\"color\"),\n}\n\nunseen := integrations.Unseen{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n Hover: &unseenHover,\n State: &unseenState,\n TextColor: util.ToPointer(\"textColor\"),\n}\n\nnotification := integrations.Notification{\n Default_: &default_,\n Unread: &unread,\n Unseen: &unseen,\n}\n\n\nunseenBadge := integrations.UnseenBadge{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n}\n\ntheme := integrations.Theme{\n Banner: &banner,\n Dialog: &dialog,\n Footer: &footer,\n Header: &header,\n Icon: &icon,\n Notification: ¬ification,\n UnseenBadge: &unseenBadge,\n}\n\nrequest := integrations.InboxConfigPayload{\n Images: &images,\n Locale: util.ToPointer(util.Nullable[string]{ Value: \"locale\" }),\n Theme: &theme,\n}\n\nresponse, err := client.Integrations.SaveInboxIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteInboxIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteInboxIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/integrations/magicbell_slackbot": { + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListMagicbellSlackbotIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := integrations.SlackBotConfigPayload{\n Enabled: util.ToPointer(true),\n}\n\nresponse, err := client.Integrations.SaveMagicbellSlackbotIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteMagicbellSlackbotIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteMagicbellSlackbotIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/mailgun": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListMailgunIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nmailgunConfigPayloadFrom := integrations.MailgunConfigPayloadFrom{\n Email: util.ToPointer(\"Email\"),\n Name: util.ToPointer(util.Nullable[string]{ Value: \"Name\" }),\n}\n\nregion := integrations.REGION_US\n\nrequest := integrations.MailgunConfigPayload{\n ApiKey: util.ToPointer(\"ApiKey\"),\n Domain: util.ToPointer(\"Domain\"),\n From: &mailgunConfigPayloadFrom,\n Region: ®ion,\n}\n\nresponse, err := client.Integrations.SaveMailgunIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteMailgunIntegrationRequestParams{\n\n}\n\nresponse, err := client.Integrations.DeleteMailgunIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListMailgunIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nmailgunConfigPayloadFrom := integrations.MailgunConfigPayloadFrom{\n Email: util.ToPointer(\"email\"),\n Name: util.ToPointer(util.Nullable[string]{ Value: \"name\" }),\n}\n\nregion := integrations.REGION_US\n\nrequest := integrations.MailgunConfigPayload{\n ApiKey: util.ToPointer(\"api_key\"),\n Domain: util.ToPointer(\"domain\"),\n From: &mailgunConfigPayloadFrom,\n Region: ®ion,\n}\n\nresponse, err := client.Integrations.SaveMailgunIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteMailgunIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteMailgunIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/ping_email": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListPingEmailIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nrequest := integrations.PingConfigPayload{\n Url: util.ToPointer(\"Url\"),\n}\n\nresponse, err := client.Integrations.SavePingEmailIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := integrations.DeletePingEmailIntegrationRequestParams{\n\n}\n\nresponse, err := client.Integrations.DeletePingEmailIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListPingEmailIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := integrations.PingConfigPayload{\n Url: util.ToPointer(\"url\"),\n}\n\nresponse, err := client.Integrations.SavePingEmailIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeletePingEmailIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeletePingEmailIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/sendgrid": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListSendgridIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nsendgridConfigPayloadFrom := integrations.SendgridConfigPayloadFrom{\n Email: util.ToPointer(\"Email\"),\n Name: util.ToPointer(util.Nullable[string]{ Value: \"Name\" }),\n}\n\n\nreplyTo := integrations.ReplyTo{\n Email: util.ToPointer(\"Email\"),\n Name: util.ToPointer(util.Nullable[string]{ Value: \"Name\" }),\n}\n\nrequest := integrations.SendgridConfigPayload{\n ApiKey: util.ToPointer(\"ApiKey\"),\n From: &sendgridConfigPayloadFrom,\n ReplyTo: &replyTo,\n}\n\nresponse, err := client.Integrations.SaveSendgridIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteSendgridIntegrationRequestParams{\n\n}\n\nresponse, err := client.Integrations.DeleteSendgridIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListSendgridIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nsendgridConfigPayloadFrom := integrations.SendgridConfigPayloadFrom{\n Email: util.ToPointer(\"email\"),\n Name: util.ToPointer(util.Nullable[string]{ Value: \"name\" }),\n}\n\n\nsendgridConfigPayloadReplyTo := integrations.SendgridConfigPayloadReplyTo{\n Email: util.ToPointer(\"email\"),\n Name: util.ToPointer(util.Nullable[string]{ Value: \"name\" }),\n}\n\nrequest := integrations.SendgridConfigPayload{\n ApiKey: util.ToPointer(\"api_key\"),\n From: &sendgridConfigPayloadFrom,\n ReplyTo: &sendgridConfigPayloadReplyTo,\n}\n\nresponse, err := client.Integrations.SaveSendgridIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteSendgridIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteSendgridIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/ses": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListSesIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nsesConfigPayloadFrom := integrations.SesConfigPayloadFrom{\n Email: util.ToPointer(\"Email\"),\n Name: util.ToPointer(util.Nullable[string]{ Value: \"Name\" }),\n}\n\nrequest := integrations.SesConfigPayload{\n From: &sesConfigPayloadFrom,\n KeyId: util.ToPointer(\"KeyId\"),\n Region: util.ToPointer(\"Region\"),\n SecretKey: util.ToPointer(\"SecretKey\"),\n}\n\nresponse, err := client.Integrations.SaveSesIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteSesIntegrationRequestParams{\n\n}\n\nresponse, err := client.Integrations.DeleteSesIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListSesIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nsesConfigPayloadFrom := integrations.SesConfigPayloadFrom{\n Email: util.ToPointer(\"email\"),\n Name: util.ToPointer(util.Nullable[string]{ Value: \"name\" }),\n}\n\nrequest := integrations.SesConfigPayload{\n From: &sesConfigPayloadFrom,\n KeyId: util.ToPointer(\"key_id\"),\n Region: util.ToPointer(\"region\"),\n SecretKey: util.ToPointer(\"secret_key\"),\n}\n\nresponse, err := client.Integrations.SaveSesIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteSesIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteSesIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/slack": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListSlackIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nrequest := integrations.SlackConfigPayload{\n AppId: util.ToPointer(\"AppId\"),\n ClientId: util.ToPointer(\"ClientId\"),\n ClientSecret: util.ToPointer(\"ClientSecret\"),\n SigningSecret: util.ToPointer(\"SigningSecret\"),\n}\n\nresponse, err := client.Integrations.SaveSlackIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteSlackIntegrationRequestParams{\n\n}\n\nresponse, err := client.Integrations.DeleteSlackIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListSlackIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := integrations.SlackConfigPayload{\n AppId: util.ToPointer(\"N\"),\n ClientId: util.ToPointer(\"26.63\"),\n ClientSecret: util.ToPointer(\"irure proidentincididunt exsit E\"),\n SigningSecret: util.ToPointer(\"incididunt laborisculpa magna al\"),\n}\n\nresponse, err := client.Integrations.SaveSlackIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteSlackIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteSlackIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/integrations/smtp": { + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListSmtpIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nsmtpConfigFrom := integrations.SmtpConfigFrom{\n Email: util.ToPointer(\"email\"),\n Name: util.ToPointer(\"name\"),\n}\n\n\nsmtpConfigReplyTo := integrations.SmtpConfigReplyTo{\n Email: util.ToPointer(\"email\"),\n Name: util.ToPointer(\"name\"),\n}\n\nsecurity := integrations.SECURITY_NONE\n\nrequest := integrations.SmtpConfig{\n From: &smtpConfigFrom,\n Host: util.ToPointer(\"smtp.gmail.com\"),\n Password: util.ToPointer(\"password\"),\n Port: util.ToPointer(int64(25)),\n ReplyTo: &smtpConfigReplyTo,\n Security: &security,\n Username: util.ToPointer(\"username\"),\n}\n\nresponse, err := client.Integrations.SaveSmtpIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteSmtpIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteSmtpIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/stripe": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListStripeIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nrequest := integrations.StripeConfigPayload{\n WebhookSigningSecret: util.ToPointer(\"WebhookSigningSecret\"),\n}\n\nresponse, err := client.Integrations.SaveStripeIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteStripeIntegrationRequestParams{\n\n}\n\nresponse, err := client.Integrations.DeleteStripeIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListStripeIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := integrations.StripeConfigPayload{\n Id: util.ToPointer(\"id\"),\n WebhookSigningSecret: util.ToPointer(\"webhook_signing_secret\"),\n}\n\nresponse, err := client.Integrations.SaveStripeIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteStripeIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteStripeIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/twilio": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListTwilioIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nrequest := integrations.TwilioConfigPayload{\n AccountSid: util.ToPointer(\"AccountSid\"),\n ApiKey: util.ToPointer(\"ApiKey\"),\n ApiSecret: util.ToPointer(\"ApiSecret\"),\n From: util.ToPointer(\"From\"),\n}\n\nresponse, err := client.Integrations.SaveTwilioIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteTwilioIntegrationRequestParams{\n\n}\n\nresponse, err := client.Integrations.DeleteTwilioIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListTwilioIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := integrations.TwilioConfigPayload{\n AccountSid: util.ToPointer(\"account_sid\"),\n ApiKey: util.ToPointer(\"api_key\"),\n ApiSecret: util.ToPointer(\"api_secret\"),\n From: util.ToPointer(\"+8547811425211\"),\n}\n\nresponse, err := client.Integrations.SaveTwilioIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteTwilioIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteTwilioIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/web_push": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListWebPushIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nrequest := integrations.WebpushConfigPayload{\n PrivateKey: util.ToPointer(\"PrivateKey\"),\n PublicKey: util.ToPointer(\"PublicKey\"),\n}\n\nresponse, err := client.Integrations.SaveWebPushIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteWebPushIntegrationRequestParams{\n\n}\n\nresponse, err := client.Integrations.DeleteWebPushIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.ListWebPushIntegrations(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := integrations.WebpushConfigPayload{\n PrivateKey: util.ToPointer(\"private_key\"),\n PublicKey: util.ToPointer(\"public_key\"),\n}\n\nresponse, err := client.Integrations.SaveWebPushIntegration(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := integrations.DeleteWebPushIntegrationRequestParams{\n Id: util.ToPointer(\"id\"),\n}\n\nresponse, err := client.Integrations.DeleteWebPushIntegration(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/project-client/users\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := users.ListUsersRequestParams{\n\n}\n\nresponse, err := client.Users.ListUsers(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/shared\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nrequest := shared.User{\n CreatedAt: util.ToPointer(util.Nullable[string]{ Value: \"CreatedAt\" }),\n CustomAttributes: []byte{},\n Email: util.ToPointer(util.Nullable[string]{ Value: \"Email\" }),\n ExternalId: util.ToPointer(util.Nullable[string]{ Value: \"ExternalId\" }),\n FirstName: util.ToPointer(util.Nullable[string]{ Value: \"FirstName\" }),\n Id: util.ToPointer(\"Id\"),\n LastName: util.ToPointer(util.Nullable[string]{ Value: \"LastName\" }),\n LastNotifiedAt: util.ToPointer(util.Nullable[string]{ Value: \"LastNotifiedAt\" }),\n LastSeenAt: util.ToPointer(util.Nullable[string]{ Value: \"LastSeenAt\" }),\n UpdatedAt: util.ToPointer(util.Nullable[string]{ Value: \"UpdatedAt\" }),\n}\n\nresponse, err := client.Users.SaveUser(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/users\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := users.ListUsersRequestParams{\n Limit: util.ToPointer(int64(2)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n Query: util.ToPointer(\"query\"),\n}\n\nresponse, err := client.Users.ListUsers(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/shared\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := shared.User{\n CreatedAt: util.ToPointer(util.Nullable[string]{ Value: \"created_at\" }),\n CustomAttributes: []byte{},\n Email: util.ToPointer(util.Nullable[string]{ Value: \"email\" }),\n ExternalId: util.ToPointer(util.Nullable[string]{ Value: \"external_id\" }),\n FirstName: util.ToPointer(util.Nullable[string]{ Value: \"first_name\" }),\n Id: util.ToPointer(\"id\"),\n LastName: util.ToPointer(util.Nullable[string]{ Value: \"last_name\" }),\n LastNotifiedAt: util.ToPointer(util.Nullable[string]{ Value: \"last_notified_at\" }),\n LastSeenAt: util.ToPointer(util.Nullable[string]{ Value: \"last_seen_at\" }),\n UpdatedAt: util.ToPointer(util.Nullable[string]{ Value: \"updated_at\" }),\n}\n\nresponse, err := client.Users.SaveUser(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/users/{user_id}": { - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Users.DeleteUser(context.Background(), \"userId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Users.DeleteUser(context.Background(), \"user_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/workflows": { + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Workflows.FetchWorkflows(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/workflows\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nworkflowDefinitionSteps := workflows.WorkflowDefinitionSteps{\n Command: util.ToPointer(\"command\"),\n If_: util.ToPointer(util.Nullable[string]{ Value: \"if\" }),\n Input: []byte{},\n}\n\nrequest := workflows.WorkflowDefinition{\n Disabled: util.ToPointer(true),\n Key: util.ToPointer(\"key\"),\n Steps: []workflows.WorkflowDefinitionSteps{workflowDefinitionSteps},\n}\n\nresponse, err := client.Workflows.SaveWorkflow(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/workflows/*": { + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Workflows.FetchWorkflow(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/workflows/runs": { + "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/workflows\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := workflows.ExecuteWorkflowRequest{\n Input: []byte{},\n Key: util.ToPointer(\"key\"),\n}\n\nresponse, err := client.Workflows.CreateWorkflowRun(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/workflows/runs/{run_id}": { + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Workflows.FetchWorkflowRun(context.Background(), \"run_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/workflows/{workflow_key}/runs": { + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Workflows.ListWorkflowRuns(context.Background(), \"workflow_key\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" } }, + "example": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/broadcasts\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := broadcasts.ListBroadcastsRequestParams{\n Limit: util.ToPointer(int64(0)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Broadcasts.ListBroadcasts(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", "authentication": { "bearer": { "constructor": "import (\n \"github.com/magicbell/magicbell-go/pkg/project-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig\"\n )\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"YOUR-TOKEN\")\n\nsdk := client.NewClient(config)", diff --git a/docs/user-client/README.md b/docs/user-client/README.md index e63a129..107aef6 100644 --- a/docs/user-client/README.md +++ b/docs/user-client/README.md @@ -8,6 +8,14 @@ title: "user-client" This SDK is compatible with the following versions: `Go >= 1.19.0` +## Installation + +To get started with the SDK, we recommend installing using `go get`: + +```bash +go get client +``` + ## Authentication ### Access Token Authentication @@ -46,11 +54,60 @@ sdk := client.NewClient(config) sdk.SetAccessToken("YOUR-TOKEN") ``` +## Setting a Custom Timeout + +You can set a custom timeout for the SDK's HTTP requests as follows: + +```go +import "time" + +config := clientconfig.NewConfig() + +sdk := client.NewClient(config) + +sdk.SetTimeout(10 * time.Second) +``` + +# Sample Usage + +Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint: + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/user-client/client" + "github.com/magicbell/magicbell-go/pkg/user-client/util" + "github.com/magicbell/magicbell-go/pkg/user-client/channels" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +params := channels.ListInboxTokensRequestParams{ + Limit: util.ToPointer(int64(8)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), +} + +response, err := client.Channels.ListInboxTokens(context.Background(), params) +if err != nil { + panic(err) +} + +fmt.Println(response) + +``` + ## Services The SDK provides various services to interact with the API. -
+
Below is a list of all available services with links to their detailed documentation: | Name | @@ -79,15 +136,16 @@ This response wrapper is used to return the response data from the API. It conta | Data | `T` | The body of the API response | | Metadata | `ClientResponseMetadata` | Status code and headers returned by the API | -#### `ClientError` +#### `ClientError[T]` This response wrapper is used to return an error. It contains the following fields: -| Name | Type | Description | -| :------- | :----------------------- | :------------------------------------------ | -| Err | `error` | The error that occurred | -| Body | `T` | The body of the API response | -| Metadata | `ClientResponseMetadata` | Status code and headers returned by the API | +| Name | Type | Description | +| :------- | :-------------------- | :---------------------------------------------------------------- | +| Err | `error` | The error that occurred | +| Data | `*T` | The deserialized error response data (nil if unmarshaling failed) | +| Body | `[]byte` | The raw body of the API response | +| Metadata | `ClientErrorMetadata` | Status code and headers returned by the API | #### `ClientResponseMetadata` @@ -104,41 +162,45 @@ This struct is shared by both response wrappers and contains the following field The SDK includes several models that represent the data structures used in API requests and responses. These models help in organizing and managing the data efficiently. -
+
Below is a list of all available models with links to their detailed documentation: | Name | Description | | :----------------------------------------------------------------------------------------------- | :---------- | | [InboxTokenResponseCollection](models/inbox_token_response_collection.md) | | -| [InboxToken](models/inbox_token.md) | | | [InboxTokenResponse](models/inbox_token_response.md) | | +| [Links](models/links.md) | | +| [InboxToken](models/inbox_token.md) | | | [DiscardResult](models/discard_result.md) | | | [ApnsTokenCollection](models/apns_token_collection.md) | | -| [ApnsTokenPayload](models/apns_token_payload.md) | | | [ApnsToken](models/apns_token.md) | | +| [ApnsTokenPayload](models/apns_token_payload.md) | | | [ExpoTokenCollection](models/expo_token_collection.md) | | -| [ExpoTokenPayload](models/expo_token_payload.md) | | | [ExpoToken](models/expo_token.md) | | +| [ExpoTokenPayload](models/expo_token_payload.md) | | | [FcmTokenCollection](models/fcm_token_collection.md) | | -| [FcmTokenPayload](models/fcm_token_payload.md) | | | [FcmToken](models/fcm_token.md) | | +| [FcmTokenPayload](models/fcm_token_payload.md) | | | [SlackTokenCollection](models/slack_token_collection.md) | | -| [SlackTokenPayload](models/slack_token_payload.md) | | | [SlackToken](models/slack_token.md) | | +| [SlackTokenPayload](models/slack_token_payload.md) | | | [TeamsTokenCollection](models/teams_token_collection.md) | | -| [TeamsTokenPayload](models/teams_token_payload.md) | | | [TeamsToken](models/teams_token.md) | | +| [TeamsTokenPayload](models/teams_token_payload.md) | | +| [UserPreferences](models/user_preferences.md) | | | [WebPushTokenCollection](models/web_push_token_collection.md) | | -| [WebPushTokenPayload](models/web_push_token_payload.md) | | | [WebPushToken](models/web_push_token.md) | | +| [WebPushTokenPayload](models/web_push_token_payload.md) | | | [InboxConfigPayload](models/inbox_config_payload.md) | | | [SlackInstallation](models/slack_installation.md) | | | [SlackFinishInstallResponse](models/slack_finish_install_response.md) | | -| [SlackStartInstall](models/slack_start_install.md) | | | [SlackStartInstallResponseContent](models/slack_start_install_response_content.md) | | +| [SlackStartInstall](models/slack_start_install.md) | | +| [WebPushTokenPayload](models/web_push_token_payload.md) | | | [WebPushStartInstallationResponse](models/web_push_start_installation_response.md) | | | [NotificationCollection](models/notification_collection.md) | | | [Notification](models/notification.md) | | | [Links](models/links.md) | | +| [CountResponse](models/count_response.md) | |
diff --git a/docs/user-client/models/apns_token.md b/docs/user-client/models/apns_token.md index 3b649d8..6c6b6ae 100644 --- a/docs/user-client/models/apns_token.md +++ b/docs/user-client/models/apns_token.md @@ -2,23 +2,23 @@ **Properties** -| Name | Type | Required | Description | -| :------------- | :------------------------------- | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| CreatedAt | string | ✅ | | -| DeviceToken | string | ✅ | | -| Id | string | ✅ | | -| AppId | string | ❌ | (Optional) The bundle identifier of the application that is registering this token. Use this field to override the default identifier specified in the projects APNs integration. | -| DiscardedAt | string | ❌ | | -| InstallationId | channels.ApnsTokenInstallationId | ❌ | (Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in `production`. | -| UpdatedAt | string | ❌ | | +| Name | Type | Required | Description | +| :------------- | :------------------------------- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------- | +| CreatedAt | string | ✅ | The timestamp when the token was created. | +| DeviceToken | string | ✅ | The APNs device token to register with MagicBell. | +| Id | string | ✅ | The unique identifier for the token. | +| AppId | string | ❌ | The bundle identifier of the application registering this token. Use this to override the default identifier configured on the APNs integration. | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded, if applicable. | +| InstallationId | channels.ApnsTokenInstallationId | ❌ | The APNs environment this token belongs to. If omitted we assume it targets `production`. | +| UpdatedAt | string | ❌ | The timestamp when the token metadata last changed. | # ApnsTokenInstallationId -(Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in `production`. +The APNs environment this token belongs to. If omitted we assume it targets `production`. **Properties** | Name | Type | Required | Description | | :---------- | :----- | :------- | :------------ | -| development | string | ✅ | "development" | -| production | string | ✅ | "production" | +| Development | string | ✅ | "development" | +| Production | string | ✅ | "production" | diff --git a/docs/user-client/models/apns_token_collection.md b/docs/user-client/models/apns_token_collection.md index 0b26eb2..b8638ba 100644 --- a/docs/user-client/models/apns_token_collection.md +++ b/docs/user-client/models/apns_token_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :------------------- | :------- | :---------- | -| Data | []channels.ApnsToken | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------------------ | :------- | :---------- | +| Data | [][channels.ApnsToken](apns_token.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/user-client/models/apns_token_payload.md b/docs/user-client/models/apns_token_payload.md index eed0627..d04abff 100644 --- a/docs/user-client/models/apns_token_payload.md +++ b/docs/user-client/models/apns_token_payload.md @@ -2,19 +2,19 @@ **Properties** -| Name | Type | Required | Description | -| :------------- | :-------------------------------------- | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| DeviceToken | string | ✅ | | -| AppId | string | ❌ | (Optional) The bundle identifier of the application that is registering this token. Use this field to override the default identifier specified in the projects APNs integration. | -| InstallationId | channels.ApnsTokenPayloadInstallationId | ❌ | (Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in `production`. | +| Name | Type | Required | Description | +| :------------- | :-------------------------------------- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------- | +| DeviceToken | string | ✅ | The APNs device token to register with MagicBell. | +| AppId | string | ❌ | The bundle identifier of the application registering this token. Use this to override the default identifier configured on the APNs integration. | +| InstallationId | channels.ApnsTokenPayloadInstallationId | ❌ | The APNs environment this token belongs to. If omitted we assume it targets `production`. | # ApnsTokenPayloadInstallationId -(Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in `production`. +The APNs environment this token belongs to. If omitted we assume it targets `production`. **Properties** | Name | Type | Required | Description | | :---------- | :----- | :------- | :------------ | -| development | string | ✅ | "development" | -| production | string | ✅ | "production" | +| Development | string | ✅ | "development" | +| Production | string | ✅ | "production" | diff --git a/docs/user-client/models/count_response.md b/docs/user-client/models/count_response.md new file mode 100644 index 0000000..985bc6a --- /dev/null +++ b/docs/user-client/models/count_response.md @@ -0,0 +1,7 @@ +# CountResponse + +**Properties** + +| Name | Type | Required | Description | +| :---- | :---- | :------- | :--------------------------------------------- | +| Count | int64 | ✅ | The count of notifications matching the query. | diff --git a/docs/user-client/models/discard_result.md b/docs/user-client/models/discard_result.md index 6b66395..0fa1bb7 100644 --- a/docs/user-client/models/discard_result.md +++ b/docs/user-client/models/discard_result.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---------- | :----- | :------- | :---------- | -| DiscardedAt | string | ❌ | | -| Id | string | ❌ | | +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :--------------------------------------------- | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded. | +| Id | string | ❌ | The unique identifier for the discarded token. | diff --git a/docs/user-client/models/expo_token.md b/docs/user-client/models/expo_token.md index 18362a4..ac79d94 100644 --- a/docs/user-client/models/expo_token.md +++ b/docs/user-client/models/expo_token.md @@ -2,10 +2,10 @@ **Properties** -| Name | Type | Required | Description | -| :---------- | :----- | :------- | :---------- | -| CreatedAt | string | ✅ | | -| DeviceToken | string | ✅ | | -| Id | string | ✅ | | -| DiscardedAt | string | ❌ | | -| UpdatedAt | string | ❌ | | +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :--------------------------------------------------------- | +| CreatedAt | string | ✅ | The timestamp when the token was created. | +| DeviceToken | string | ✅ | The Expo push token returned by the Expo client. | +| Id | string | ✅ | The unique identifier for the token. | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded, if applicable. | +| UpdatedAt | string | ❌ | The timestamp when the token metadata last changed. | diff --git a/docs/user-client/models/expo_token_collection.md b/docs/user-client/models/expo_token_collection.md index 016b17e..86aa56b 100644 --- a/docs/user-client/models/expo_token_collection.md +++ b/docs/user-client/models/expo_token_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :------------------- | :------- | :---------- | -| Data | []channels.ExpoToken | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------------------ | :------- | :---------- | +| Data | [][channels.ExpoToken](expo_token.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/user-client/models/expo_token_payload.md b/docs/user-client/models/expo_token_payload.md index b3035ec..044b74d 100644 --- a/docs/user-client/models/expo_token_payload.md +++ b/docs/user-client/models/expo_token_payload.md @@ -2,6 +2,6 @@ **Properties** -| Name | Type | Required | Description | -| :---------- | :----- | :------- | :---------- | -| DeviceToken | string | ✅ | | +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :----------------------------------------------- | +| DeviceToken | string | ✅ | The Expo push token returned by the Expo client. | diff --git a/docs/user-client/models/fcm_token.md b/docs/user-client/models/fcm_token.md index 159a1df..cb90fcf 100644 --- a/docs/user-client/models/fcm_token.md +++ b/docs/user-client/models/fcm_token.md @@ -2,20 +2,10 @@ **Properties** -| Name | Type | Required | Description | -| :------------- | :------------------------------ | :------- | :---------- | -| CreatedAt | string | ✅ | | -| DeviceToken | string | ✅ | | -| Id | string | ✅ | | -| DiscardedAt | string | ❌ | | -| InstallationId | channels.FcmTokenInstallationId | ❌ | | -| UpdatedAt | string | ❌ | | - -# FcmTokenInstallationId - -**Properties** - -| Name | Type | Required | Description | -| :---------- | :----- | :------- | :------------ | -| development | string | ✅ | "development" | -| production | string | ✅ | "production" | +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :--------------------------------------------------------------------------------- | +| CreatedAt | string | ✅ | The timestamp when the token was created. | +| DeviceToken | string | ✅ | The Firebase Cloud Messaging device registration token to associate with the user. | +| Id | string | ✅ | The unique identifier for the token. | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded, if applicable. | +| UpdatedAt | string | ❌ | The timestamp when the token metadata last changed. | diff --git a/docs/user-client/models/fcm_token_collection.md b/docs/user-client/models/fcm_token_collection.md index 234da3f..0a2f5cd 100644 --- a/docs/user-client/models/fcm_token_collection.md +++ b/docs/user-client/models/fcm_token_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :------------------ | :------- | :---------- | -| Data | []channels.FcmToken | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :---------------------------------- | :------- | :---------- | +| Data | [][channels.FcmToken](fcm_token.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/user-client/models/fcm_token_payload.md b/docs/user-client/models/fcm_token_payload.md index 2ed01f1..3c9b9b1 100644 --- a/docs/user-client/models/fcm_token_payload.md +++ b/docs/user-client/models/fcm_token_payload.md @@ -2,16 +2,6 @@ **Properties** -| Name | Type | Required | Description | -| :------------- | :------------------------------------- | :------- | :---------- | -| DeviceToken | string | ✅ | | -| InstallationId | channels.FcmTokenPayloadInstallationId | ❌ | | - -# FcmTokenPayloadInstallationId - -**Properties** - -| Name | Type | Required | Description | -| :---------- | :----- | :------- | :------------ | -| development | string | ✅ | "development" | -| production | string | ✅ | "production" | +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :--------------------------------------------------------------------------------- | +| DeviceToken | string | ✅ | The Firebase Cloud Messaging device registration token to associate with the user. | diff --git a/docs/user-client/models/inbox_config_payload.md b/docs/user-client/models/inbox_config_payload.md index 85312aa..d299f5a 100644 --- a/docs/user-client/models/inbox_config_payload.md +++ b/docs/user-client/models/inbox_config_payload.md @@ -2,186 +2,222 @@ **Properties** -| Name | Type | Required | Description | -| :----- | :------------------ | :------- | :---------- | -| Images | integrations.Images | ✅ | | -| Locale | string | ✅ | | -| Theme | integrations.Theme | ✅ | | +| Name | Type | Required | Description | +| :----- | :------------------ | :------- | :---------------------------------------------------------------- | +| Images | integrations.Images | ✅ | Image overrides for assets used in the inbox UI. | +| Locale | string | ✅ | Locale code (ISO language tag) used to localize built-in strings. | +| Theme | integrations.Theme | ✅ | Visual customization options for the hosted inbox widget. | # Images +Image overrides for assets used in the inbox UI. + **Properties** -| Name | Type | Required | Description | -| :------------ | :----- | :------- | :---------- | -| EmptyInboxUrl | string | ✅ | | +| Name | Type | Required | Description | +| :------------ | :----- | :------- | :------------------------------------------------------ | +| EmptyInboxUrl | string | ✅ | URL for the illustration shown when the inbox is empty. | # Theme +Visual customization options for the hosted inbox widget. + **Properties** -| Name | Type | Required | Description | -| :----------- | :----------------------------- | :------- | :---------- | -| Banner | integrations.Banner | ❌ | | -| Dialog | integrations.Dialog | ❌ | | -| Footer | integrations.Footer | ❌ | | -| Header | integrations.Header | ❌ | | -| Icon | integrations.Icon | ❌ | | -| Notification | integrations.ThemeNotification | ❌ | | -| UnseenBadge | integrations.UnseenBadge | ❌ | | +| Name | Type | Required | Description | +| :----------- | :----------------------------- | :------- | :--------------------------------------------- | +| Banner | integrations.Banner | ❌ | Top banner styling options. | +| Dialog | integrations.Dialog | ❌ | Styling for confirmation and action dialogs. | +| Footer | integrations.Footer | ❌ | Footer styling for the inbox modal. | +| Header | integrations.Header | ❌ | Header styling for the inbox modal. | +| Icon | integrations.Icon | ❌ | Launcher icon styling overrides. | +| Notification | integrations.ThemeNotification | ❌ | Styling overrides for notification list items. | +| UnseenBadge | integrations.UnseenBadge | ❌ | Badge styling for unseen notification counts. | # Banner +Top banner styling options. + **Properties** -| Name | Type | Required | Description | -| :---------------- | :------ | :------- | :---------- | -| BackgroundColor | string | ✅ | | -| FontSize | string | ✅ | | -| TextColor | string | ✅ | | -| BackgroundOpacity | float64 | ❌ | | +| Name | Type | Required | Description | +| :---------------- | :------ | :------- | :---------------------------------------- | +| BackgroundColor | string | ✅ | Banner background color. | +| FontSize | string | ✅ | Font size for banner text. | +| TextColor | string | ✅ | Banner text color. | +| BackgroundOpacity | float64 | ❌ | Opacity applied to the banner background. | # Dialog +Styling for confirmation and action dialogs. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------- | -| AccentColor | string | ✅ | | -| BackgroundColor | string | ✅ | | -| TextColor | string | ✅ | | +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :---------------------------------------------- | +| AccentColor | string | ✅ | Accent color for dialog buttons and highlights. | +| BackgroundColor | string | ✅ | Dialog background color. | +| TextColor | string | ✅ | Dialog text color. | # Footer +Footer styling for the inbox modal. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------- | -| BackgroundColor | string | ✅ | | -| BorderRadius | string | ✅ | | -| FontSize | string | ✅ | | -| TextColor | string | ✅ | | +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :--------------------------------------------- | +| BackgroundColor | string | ✅ | Footer background color. | +| BorderRadius | string | ✅ | Border radius applied to the footer container. | +| FontSize | string | ✅ | Font size used in the footer. | +| TextColor | string | ✅ | Footer text color. | # Header +Header styling for the inbox modal. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------- | -| BackgroundColor | string | ✅ | | -| BorderRadius | string | ✅ | | -| FontFamily | string | ✅ | | -| FontSize | string | ✅ | | -| TextColor | string | ✅ | | +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :--------------------------------------------- | +| BackgroundColor | string | ✅ | Header background color. | +| BorderRadius | string | ✅ | Border radius applied to the header container. | +| FontFamily | string | ✅ | CSS font family for the header title. | +| FontSize | string | ✅ | Font size used in the header. | +| TextColor | string | ✅ | Header text color. | # Icon +Launcher icon styling overrides. + **Properties** -| Name | Type | Required | Description | -| :---------- | :----- | :------- | :---------- | -| BorderColor | string | ✅ | | -| Width | string | ✅ | | +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :------------------------------------------- | +| BorderColor | string | ✅ | CSS color used for the icon border. | +| Width | string | ✅ | Width of the launcher icon (any CSS length). | # ThemeNotification +Styling overrides for notification list items. + **Properties** -| Name | Type | Required | Description | -| :-------- | :--------------------- | :------- | :---------- | -| Default\_ | integrations.Default\_ | ✅ | | -| Unread | integrations.Unread | ✅ | | -| Unseen | integrations.Unseen | ✅ | | +| Name | Type | Required | Description | +| :-------- | :--------------------- | :------- | :---------------------------------------------- | +| Default\_ | integrations.Default\_ | ✅ | Base styles applied to every notification item. | +| Unread | integrations.Unread | ✅ | Overrides for unread notifications. | +| Unseen | integrations.Unseen | ✅ | Overrides for unseen notifications. | # Default\_ +Base styles applied to every notification item. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :------------------------ | :------- | :---------- | -| BackgroundColor | string | ✅ | | -| BorderRadius | string | ✅ | | -| FontFamily | string | ✅ | | -| FontSize | string | ✅ | | -| Margin | string | ✅ | | -| TextColor | string | ✅ | | -| Hover | integrations.DefaultHover | ❌ | | -| State | integrations.DefaultState | ❌ | | +| Name | Type | Required | Description | +| :-------------- | :------------------------ | :------- | :--------------------------------------------------------- | +| BackgroundColor | string | ✅ | Background color for notifications in their default state. | +| BorderRadius | string | ✅ | Border radius applied to each notification card. | +| FontFamily | string | ✅ | Font family for notification text. | +| FontSize | string | ✅ | Font size for notification text. | +| Margin | string | ✅ | CSS margin applied around each notification card. | +| TextColor | string | ✅ | Default text color for notifications. | +| Hover | integrations.DefaultHover | ❌ | Styles applied when a notification is hovered. | +| State | integrations.DefaultState | ❌ | Accent colors for notification state indicators. | # DefaultHover +Styles applied when a notification is hovered. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------- | -| BackgroundColor | string | ✅ | | +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :------------------------- | +| BackgroundColor | string | ✅ | Background color on hover. | # DefaultState +Accent colors for notification state indicators. + **Properties** -| Name | Type | Required | Description | -| :---- | :----- | :------- | :---------- | -| Color | string | ✅ | | +| Name | Type | Required | Description | +| :---- | :----- | :------- | :---------------------------------- | +| Color | string | ✅ | Color used for the state indicator. | # Unread +Overrides for unread notifications. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----------------------- | :------- | :---------- | -| BackgroundColor | string | ✅ | | -| TextColor | string | ✅ | | -| Hover | integrations.UnreadHover | ❌ | | -| State | integrations.UnreadState | ❌ | | +| Name | Type | Required | Description | +| :-------------- | :----------------------- | :------- | :------------------------------------------------ | +| BackgroundColor | string | ✅ | Background color applied to unread notifications. | +| TextColor | string | ✅ | Text color used when a notification is unread. | +| Hover | integrations.UnreadHover | ❌ | Hover styles for unread notifications. | +| State | integrations.UnreadState | ❌ | State indicator styling for unread notifications. | # UnreadHover +Hover styles for unread notifications. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------- | -| BackgroundColor | string | ✅ | | +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :-------------------------------------------------- | +| BackgroundColor | string | ✅ | Background color on hover for unread notifications. | # UnreadState +State indicator styling for unread notifications. + **Properties** -| Name | Type | Required | Description | -| :---- | :----- | :------- | :---------- | -| Color | string | ✅ | | +| Name | Type | Required | Description | +| :---- | :----- | :------- | :------------------------------------ | +| Color | string | ✅ | Color for the unread state indicator. | # Unseen +Overrides for unseen notifications. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----------------------- | :------- | :---------- | -| BackgroundColor | string | ✅ | | -| TextColor | string | ✅ | | -| Hover | integrations.UnseenHover | ❌ | | -| State | integrations.UnseenState | ❌ | | +| Name | Type | Required | Description | +| :-------------- | :----------------------- | :------- | :------------------------------------------------ | +| BackgroundColor | string | ✅ | Background color applied to unseen notifications. | +| TextColor | string | ✅ | Text color used when a notification is unseen. | +| Hover | integrations.UnseenHover | ❌ | Hover styles for unseen notifications. | +| State | integrations.UnseenState | ❌ | State indicator styling for unseen notifications. | # UnseenHover +Hover styles for unseen notifications. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------- | -| BackgroundColor | string | ✅ | | +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :-------------------------------------------------- | +| BackgroundColor | string | ✅ | Background color on hover for unseen notifications. | # UnseenState +State indicator styling for unseen notifications. + **Properties** -| Name | Type | Required | Description | -| :---- | :----- | :------- | :---------- | -| Color | string | ✅ | | +| Name | Type | Required | Description | +| :---- | :----- | :------- | :------------------------------------ | +| Color | string | ✅ | Color for the unseen state indicator. | # UnseenBadge +Badge styling for unseen notification counts. + **Properties** -| Name | Type | Required | Description | -| :-------------- | :----- | :------- | :---------- | -| BackgroundColor | string | ✅ | | +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :---------------------- | +| BackgroundColor | string | ✅ | Badge background color. | diff --git a/docs/user-client/models/inbox_token.md b/docs/user-client/models/inbox_token.md index 8820dce..72e7cb4 100644 --- a/docs/user-client/models/inbox_token.md +++ b/docs/user-client/models/inbox_token.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :----------- | :----- | :------- | :---------- | -| Token | string | ✅ | | -| ConnectionId | string | ❌ | | +| Name | Type | Required | Description | +| :----------- | :----- | :------- | :------------------------------------------------------------------------- | +| Token | string | ✅ | The in-app inbox token generated for this user. | +| ConnectionId | string | ❌ | Realtime connection ID to restrict delivery to a specific Ably connection. | diff --git a/docs/user-client/models/inbox_token_response.md b/docs/user-client/models/inbox_token_response.md index f932e3c..27f6a36 100644 --- a/docs/user-client/models/inbox_token_response.md +++ b/docs/user-client/models/inbox_token_response.md @@ -2,11 +2,11 @@ **Properties** -| Name | Type | Required | Description | -| :----------- | :----- | :------- | :---------- | -| CreatedAt | string | ✅ | | -| Id | string | ✅ | | -| Token | string | ✅ | | -| ConnectionId | string | ❌ | | -| DiscardedAt | string | ❌ | | -| UpdatedAt | string | ❌ | | +| Name | Type | Required | Description | +| :----------- | :----- | :------- | :------------------------------------------------------------------------- | +| CreatedAt | string | ✅ | The timestamp when the token was created. | +| Id | string | ✅ | The unique identifier for the token. | +| Token | string | ✅ | The in-app inbox token generated for this user. | +| ConnectionId | string | ❌ | Realtime connection ID to restrict delivery to a specific Ably connection. | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded, if applicable. | +| UpdatedAt | string | ❌ | The timestamp when the token metadata last changed. | diff --git a/docs/user-client/models/inbox_token_response_collection.md b/docs/user-client/models/inbox_token_response_collection.md index b3bb125..cf5a84b 100644 --- a/docs/user-client/models/inbox_token_response_collection.md +++ b/docs/user-client/models/inbox_token_response_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :---------------------------- | :------- | :---------- | -| Data | []channels.InboxTokenResponse | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------------------------------------- | :------- | :---------- | +| Data | [][channels.InboxTokenResponse](inbox_token_response.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/user-client/models/notification.md b/docs/user-client/models/notification.md index 629873a..c79769a 100644 --- a/docs/user-client/models/notification.md +++ b/docs/user-client/models/notification.md @@ -2,20 +2,20 @@ **Properties** -| Name | Type | Required | Description | -| :--------------- | :----- | :------- | :---------- | -| CreatedAt | string | ✅ | | -| Id | string | ✅ | | -| Title | string | ✅ | | -| UpdatedAt | string | ✅ | | -| UserId | string | ✅ | | -| ActionUrl | string | ❌ | | -| ArchivedAt | string | ❌ | | -| Category | string | ❌ | | -| Content | string | ❌ | | -| CustomAttributes | any | ❌ | | -| DiscardedAt | string | ❌ | | -| ReadAt | string | ❌ | | -| SeenAt | string | ❌ | | -| SentAt | string | ❌ | | -| Topic | string | ❌ | | +| Name | Type | Required | Description | +| :--------------- | :----- | :------- | :------------------------------------------------------ | +| CreatedAt | string | ✅ | The timestamp when the notification was created. | +| Id | string | ✅ | The unique identifier for the notification. | +| Title | string | ✅ | The title that is displayed to recipients. | +| UpdatedAt | string | ✅ | The timestamp when the notification was last updated. | +| UserId | string | ✅ | The user that should receive the notification. | +| ActionUrl | string | ❌ | The link associated with the notification. | +| ArchivedAt | string | ❌ | The timestamp when the notification was archived. | +| Category | string | ❌ | The category grouping for the notification. | +| Content | string | ❌ | The body content of the notification. | +| CustomAttributes | any | ❌ | The custom data stored with the notification. | +| DiscardedAt | string | ❌ | The timestamp when the notification was discarded. | +| ReadAt | string | ❌ | The timestamp when the notification was marked as read. | +| SeenAt | string | ❌ | The timestamp when the notification was seen. | +| SentAt | string | ❌ | The timestamp when the notification was sent. | +| Topic | string | ❌ | The topic for additional classification. | diff --git a/docs/user-client/models/notification_collection.md b/docs/user-client/models/notification_collection.md index 8946557..fd1698e 100644 --- a/docs/user-client/models/notification_collection.md +++ b/docs/user-client/models/notification_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :--------------------------- | :------- | :---------- | -| Data | []notifications.Notification | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :---------------------------------------------- | :------- | :---------- | +| Data | [][notifications.Notification](notification.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/user-client/models/slack_installation.md b/docs/user-client/models/slack_installation.md index e007a55..7abcf21 100644 --- a/docs/user-client/models/slack_installation.md +++ b/docs/user-client/models/slack_installation.md @@ -2,59 +2,59 @@ **Properties** -| Name | Type | Required | Description | -| :------------------ | :--------------------------- | :------- | :---------- | -| AccessToken | string | ✅ | | -| AppId | string | ✅ | | -| AuthedUser | integrations.AuthedUser | ✅ | | -| Team | integrations.Team | ✅ | | -| BotUserId | string | ❌ | | -| Enterprise | integrations.Enterprise | ❌ | | -| ExpiresIn | int64 | ❌ | | -| Id | string | ❌ | | -| IncomingWebhook | integrations.IncomingWebhook | ❌ | | -| IsEnterpriseInstall | bool | ❌ | | -| RefreshToken | string | ❌ | | -| Scope | string | ❌ | | -| TokenType | string | ❌ | | +| Name | Type | Required | Description | +| :------------------ | :--------------------------- | :------- | :----------------------------------------------------------------- | +| AccessToken | string | ✅ | Bot token returned from the Slack OAuth exchange. | +| AppId | string | ✅ | Slack app identifier for the installed app. | +| AuthedUser | integrations.AuthedUser | ✅ | | +| Team | integrations.Team | ✅ | | +| BotUserId | string | ❌ | Slack user ID of the installed bot. | +| Enterprise | integrations.Enterprise | ❌ | | +| ExpiresIn | int64 | ❌ | Seconds until the bot access token expires. | +| Id | string | ❌ | Unique identifier MagicBell assigns to the Slack installation. | +| IncomingWebhook | integrations.IncomingWebhook | ❌ | | +| IsEnterpriseInstall | bool | ❌ | Indicates whether the installation occurred on an enterprise grid. | +| RefreshToken | string | ❌ | Refresh token for regenerating the bot access token. | +| Scope | string | ❌ | Space-delimited OAuth scopes granted to the bot token. | +| TokenType | string | ❌ | Type of bot token returned by Slack. | # AuthedUser **Properties** -| Name | Type | Required | Description | -| :----------- | :----- | :------- | :---------- | -| Id | string | ✅ | | -| AccessToken | string | ❌ | | -| ExpiresIn | int64 | ❌ | | -| RefreshToken | string | ❌ | | -| Scope | string | ❌ | | -| TokenType | string | ❌ | | +| Name | Type | Required | Description | +| :----------- | :----- | :------- | :------------------------------------------------------ | +| Id | string | ✅ | Slack user ID for the installer. | +| AccessToken | string | ❌ | User token returned from the OAuth exchange. | +| ExpiresIn | int64 | ❌ | Seconds until the user token expires. | +| RefreshToken | string | ❌ | Refresh token for the authed user. | +| Scope | string | ❌ | Space-delimited OAuth scopes granted to the user token. | +| TokenType | string | ❌ | Token type value provided by Slack. | # Team **Properties** -| Name | Type | Required | Description | -| :--- | :----- | :------- | :---------- | -| Id | string | ✅ | | -| Name | string | ❌ | | +| Name | Type | Required | Description | +| :--- | :----- | :------- | :------------------------------------------ | +| Id | string | ✅ | Workspace ID where the app was installed. | +| Name | string | ❌ | Workspace name where the app was installed. | # Enterprise **Properties** -| Name | Type | Required | Description | -| :--- | :----- | :------- | :---------- | -| Id | string | ✅ | | -| Name | string | ✅ | | +| Name | Type | Required | Description | +| :--- | :----- | :------- | :-------------------------- | +| Id | string | ✅ | Enterprise grid identifier. | +| Name | string | ✅ | Enterprise grid name. | # IncomingWebhook **Properties** -| Name | Type | Required | Description | -| :--------------- | :----- | :------- | :---------- | -| Channel | string | ✅ | | -| ConfigurationUrl | string | ✅ | | -| Url | string | ✅ | | +| Name | Type | Required | Description | +| :--------------- | :----- | :------- | :------------------------------------------- | +| Channel | string | ✅ | Human readable name for the webhook channel. | +| ConfigurationUrl | string | ✅ | URL users can visit to manage the webhook. | +| Url | string | ✅ | Webhook URL that Slack posts events to. | diff --git a/docs/user-client/models/slack_start_install.md b/docs/user-client/models/slack_start_install.md index 1d76bbf..7bcbe4b 100644 --- a/docs/user-client/models/slack_start_install.md +++ b/docs/user-client/models/slack_start_install.md @@ -2,9 +2,9 @@ **Properties** -| Name | Type | Required | Description | -| :---------- | :------- | :------- | :---------- | -| AppId | string | ✅ | | -| AuthUrl | string | ❌ | | -| ExtraScopes | []string | ❌ | | -| RedirectUrl | string | ❌ | | +| Name | Type | Required | Description | +| :---------- | :------- | :------- | :------------------------------------------------------------------ | +| AppId | string | ✅ | Slack app ID that the installation flow should use. | +| AuthUrl | string | ❌ | Optional override for the authorization URL returned to the client. | +| ExtraScopes | []string | ❌ | Additional OAuth scopes to request during installation. | +| RedirectUrl | string | ❌ | Custom redirect URL to use after OAuth completes. | diff --git a/docs/user-client/models/slack_token.md b/docs/user-client/models/slack_token.md index 90e0325..d94c472 100644 --- a/docs/user-client/models/slack_token.md +++ b/docs/user-client/models/slack_token.md @@ -4,22 +4,22 @@ | Name | Type | Required | Description | | :---------- | :------------------------- | :------- | :-------------------------------------------------------------------------------------------------- | -| CreatedAt | string | ✅ | | -| Id | string | ✅ | | -| DiscardedAt | string | ❌ | | +| CreatedAt | string | ✅ | The timestamp when the token was created. | +| Id | string | ✅ | The unique identifier for the token. | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded, if applicable. | | Oauth | channels.SlackTokenOauth | ❌ | | -| UpdatedAt | string | ❌ | | +| UpdatedAt | string | ❌ | The timestamp when the token metadata last changed. | | Webhook | channels.SlackTokenWebhook | ❌ | Obtained directly from the incoming_webhook object in the installation response from the Slack API. | # SlackTokenOauth **Properties** -| Name | Type | Required | Description | -| :------------- | :----- | :------- | :---------- | -| ChannelId | string | ✅ | | -| InstallationId | string | ✅ | | -| Scope | string | ❌ | | +| Name | Type | Required | Description | +| :------------- | :----- | :------- | :--------------------------------------------------------------- | +| ChannelId | string | ✅ | The ID of the Slack channel this installation is associated with | +| InstallationId | string | ✅ | A unique identifier for this Slack workspace installation | +| Scope | string | ❌ | The OAuth scope granted during installation | # SlackTokenWebhook @@ -27,6 +27,6 @@ Obtained directly from the incoming_webhook object in the installation response **Properties** -| Name | Type | Required | Description | -| :--- | :----- | :------- | :---------- | -| Url | string | ✅ | | +| Name | Type | Required | Description | +| :--- | :----- | :------- | :------------------------------------------ | +| Url | string | ✅ | The URL for the incoming webhook from Slack | diff --git a/docs/user-client/models/slack_token_collection.md b/docs/user-client/models/slack_token_collection.md index f8d5581..cb50f05 100644 --- a/docs/user-client/models/slack_token_collection.md +++ b/docs/user-client/models/slack_token_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :-------------------- | :------- | :---------- | -| Data | []channels.SlackToken | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :-------------------------------------- | :------- | :---------- | +| Data | [][channels.SlackToken](slack_token.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/user-client/models/slack_token_payload.md b/docs/user-client/models/slack_token_payload.md index 430fa05..b583c83 100644 --- a/docs/user-client/models/slack_token_payload.md +++ b/docs/user-client/models/slack_token_payload.md @@ -11,11 +11,11 @@ **Properties** -| Name | Type | Required | Description | -| :------------- | :----- | :------- | :---------- | -| ChannelId | string | ✅ | | -| InstallationId | string | ✅ | | -| Scope | string | ❌ | | +| Name | Type | Required | Description | +| :------------- | :----- | :------- | :--------------------------------------------------------------- | +| ChannelId | string | ✅ | The ID of the Slack channel this installation is associated with | +| InstallationId | string | ✅ | A unique identifier for this Slack workspace installation | +| Scope | string | ❌ | The OAuth scope granted during installation | # SlackTokenPayloadWebhook @@ -23,6 +23,6 @@ Obtained directly from the incoming_webhook object in the installation response **Properties** -| Name | Type | Required | Description | -| :--- | :----- | :------- | :---------- | -| Url | string | ✅ | | +| Name | Type | Required | Description | +| :--- | :----- | :------- | :------------------------------------------ | +| Url | string | ✅ | The URL for the incoming webhook from Slack | diff --git a/docs/user-client/models/teams_token.md b/docs/user-client/models/teams_token.md index 0ab10d7..6a5620d 100644 --- a/docs/user-client/models/teams_token.md +++ b/docs/user-client/models/teams_token.md @@ -2,13 +2,13 @@ **Properties** -| Name | Type | Required | Description | -| :---------- | :------------------------- | :------- | :---------- | -| CreatedAt | string | ✅ | | -| Id | string | ✅ | | -| DiscardedAt | string | ❌ | | -| UpdatedAt | string | ❌ | | -| Webhook | channels.TeamsTokenWebhook | ❌ | | +| Name | Type | Required | Description | +| :---------- | :------------------------- | :------- | :--------------------------------------------------------- | +| CreatedAt | string | ✅ | The timestamp when the token was created. | +| Id | string | ✅ | The unique identifier for the token. | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded, if applicable. | +| UpdatedAt | string | ❌ | The timestamp when the token metadata last changed. | +| Webhook | channels.TeamsTokenWebhook | ❌ | | # TeamsTokenWebhook diff --git a/docs/user-client/models/teams_token_collection.md b/docs/user-client/models/teams_token_collection.md index 1ca3537..b837dca 100644 --- a/docs/user-client/models/teams_token_collection.md +++ b/docs/user-client/models/teams_token_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :-------------------- | :------- | :---------- | -| Data | []channels.TeamsToken | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :-------------------------------------- | :------- | :---------- | +| Data | [][channels.TeamsToken](teams_token.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/user-client/models/user_preferences.md b/docs/user-client/models/user_preferences.md new file mode 100644 index 0000000..82a699a --- /dev/null +++ b/docs/user-client/models/user_preferences.md @@ -0,0 +1,26 @@ +# UserPreferences + +**Properties** + +| Name | Type | Required | Description | +| :--------- | :-------------------- | :------- | :---------- | +| Categories | []channels.Categories | ❌ | | + +# Categories + +**Properties** + +| Name | Type | Required | Description | +| :------- | :------------------ | :------- | :---------- | +| Channels | []channels.Channels | ❌ | | +| Key | string | ❌ | | +| Label | string | ❌ | | + +# Channels + +**Properties** + +| Name | Type | Required | Description | +| :------ | :----- | :------- | :---------- | +| Enabled | bool | ❌ | | +| Name | string | ❌ | | diff --git a/docs/user-client/models/web_push_start_installation_response.md b/docs/user-client/models/web_push_start_installation_response.md index bcc50ef..32730da 100644 --- a/docs/user-client/models/web_push_start_installation_response.md +++ b/docs/user-client/models/web_push_start_installation_response.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :-------- | :----- | :------- | :---------- | -| AuthToken | string | ✅ | | -| PublicKey | string | ✅ | | +| Name | Type | Required | Description | +| :-------- | :----- | :------- | :--------------------------------------------------------- | +| AuthToken | string | ✅ | Auth secret returned from PushSubscription.getKey('auth'). | +| PublicKey | string | ✅ | VAPID public key generated for this web push installation. | diff --git a/docs/user-client/models/web_push_token.md b/docs/user-client/models/web_push_token.md index a8aaa83..0e4171c 100644 --- a/docs/user-client/models/web_push_token.md +++ b/docs/user-client/models/web_push_token.md @@ -4,12 +4,12 @@ | Name | Type | Required | Description | | :---------- | :------------------------ | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| CreatedAt | string | ✅ | | +| CreatedAt | string | ✅ | The timestamp when the token was created. | | Endpoint | string | ✅ | The push subscription URL obtained from PushSubscription.endpoint after calling registration.pushManager.subscribe(). This is the unique URL for this device that push messages will be sent to. | -| Id | string | ✅ | | +| Id | string | ✅ | The unique identifier for the token. | | Keys | channels.WebPushTokenKeys | ✅ | The encryption keys from the PushSubscription.getKey() method, needed to encrypt push messages for this subscription. | -| DiscardedAt | string | ❌ | | -| UpdatedAt | string | ❌ | | +| DiscardedAt | string | ❌ | The timestamp when the token was discarded, if applicable. | +| UpdatedAt | string | ❌ | The timestamp when the token metadata last changed. | # WebPushTokenKeys diff --git a/docs/user-client/models/web_push_token_collection.md b/docs/user-client/models/web_push_token_collection.md index ed16554..6446fe5 100644 --- a/docs/user-client/models/web_push_token_collection.md +++ b/docs/user-client/models/web_push_token_collection.md @@ -2,7 +2,7 @@ **Properties** -| Name | Type | Required | Description | -| :---- | :---------------------- | :------- | :---------- | -| Data | []channels.WebPushToken | ❌ | | -| Links | shared.Links | ❌ | | +| Name | Type | Required | Description | +| :---- | :------------------------------------------- | :------- | :---------- | +| Data | [][channels.WebPushToken](web_push_token.md) | ❌ | | +| Links | [shared.Links](links.md) | ❌ | | diff --git a/docs/user-client/services/channels_service.md b/docs/user-client/services/channels_service.md index 433fa2f..011f4d2 100644 --- a/docs/user-client/services/channels_service.md +++ b/docs/user-client/services/channels_service.md @@ -2,36 +2,42 @@ A list of all methods in the `ChannelsService` service. Click on the method name to view detailed information about that method. -| Methods | Description | -| :---------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [ListInboxTokens](#listinboxtokens) | Lists all Inbox tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | -| [SaveInboxToken](#saveinboxtoken) | Saves the Inbox token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | -| [FetchInboxToken](#fetchinboxtoken) | Fetches details of a specific Inbox token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | -| [DeleteInboxToken](#deleteinboxtoken) | Deletes one of the authenticated user's Inbox tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | -| [ListApnsTokens](#listapnstokens) | Lists all APNs tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | -| [SaveApnsToken](#saveapnstoken) | Saves the APNs token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | -| [FetchApnsToken](#fetchapnstoken) | Fetches details of a specific APNs token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | -| [DeleteApnsToken](#deleteapnstoken) | Deletes one of the authenticated user's APNs tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | -| [ListExpoTokens](#listexpotokens) | Lists all Expo tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | -| [SaveExpoToken](#saveexpotoken) | Saves the Expo token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | -| [FetchExpoToken](#fetchexpotoken) | Fetches details of a specific Expo token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | -| [DeleteExpoToken](#deleteexpotoken) | Deletes one of the authenticated user's Expo tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | -| [ListFcmTokens](#listfcmtokens) | Lists all FCM tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | -| [SaveFcmToken](#savefcmtoken) | Saves the FCM token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | -| [FetchFcmToken](#fetchfcmtoken) | Fetches details of a specific FCM token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | -| [DeleteFcmToken](#deletefcmtoken) | Deletes one of the authenticated user's FCM tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | -| [ListSlackTokens](#listslacktokens) | Lists all Slack tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | -| [SaveSlackToken](#saveslacktoken) | Saves the Slack token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | -| [FetchSlackToken](#fetchslacktoken) | Fetches details of a specific Slack token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | -| [DeleteSlackToken](#deleteslacktoken) | Deletes one of the authenticated user's Slack tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | -| [ListTeamsTokens](#listteamstokens) | Lists all Teams tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | -| [SaveTeamsToken](#saveteamstoken) | Saves the Teams token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | -| [FetchTeamsToken](#fetchteamstoken) | Fetches details of a specific Teams token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | -| [DeleteTeamsToken](#deleteteamstoken) | Deletes one of the authenticated user's Teams tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | -| [ListWebPushTokens](#listwebpushtokens) | Lists all Web Push tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | -| [SaveWebPushToken](#savewebpushtoken) | Saves the Web Push token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | -| [FetchWebPushToken](#fetchwebpushtoken) | Fetches details of a specific Web Push token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | -| [DeleteWebPushToken](#deletewebpushtoken) | Deletes one of the authenticated user's Web Push tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | +| Methods | Description | +| :------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [ListInboxTokens](#listinboxtokens) | Lists all Inbox tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | +| [SaveInboxToken](#saveinboxtoken) | Saves the Inbox token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | +| [FetchInboxToken](#fetchinboxtoken) | Fetches details of a specific Inbox token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | +| [DeleteInboxToken](#deleteinboxtoken) | Deletes one of the authenticated user's Inbox tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | +| [ListApnsTokens](#listapnstokens) | Lists all APNs tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | +| [SaveApnsToken](#saveapnstoken) | Saves the APNs token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | +| [FetchApnsToken](#fetchapnstoken) | Fetches details of a specific APNs token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | +| [DeleteApnsToken](#deleteapnstoken) | Deletes one of the authenticated user's APNs tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | +| [ListExpoTokens](#listexpotokens) | Lists all Expo tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | +| [SaveExpoToken](#saveexpotoken) | Saves the Expo token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | +| [FetchExpoToken](#fetchexpotoken) | Fetches details of a specific Expo token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | +| [DeleteExpoToken](#deleteexpotoken) | Deletes one of the authenticated user's Expo tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | +| [ListFcmTokens](#listfcmtokens) | Lists all FCM tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | +| [SaveFcmToken](#savefcmtoken) | Saves the FCM token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | +| [FetchFcmToken](#fetchfcmtoken) | Fetches details of a specific FCM token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | +| [DeleteFcmToken](#deletefcmtoken) | Deletes one of the authenticated user's FCM tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | +| [ListMagicbellSlackbotTokens](#listmagicbellslackbottokens) | Lists all MagicBell SlackBot tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | +| [SaveMagicbellSlackbotToken](#savemagicbellslackbottoken) | Saves the MagicBell SlackBot token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | +| [FetchMagicbellSlackbotToken](#fetchmagicbellslackbottoken) | Fetches details of a specific MagicBell SlackBot token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | +| [DeleteMagicbellSlackbotToken](#deletemagicbellslackbottoken) | Deletes one of the authenticated user's MagicBell SlackBot tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | +| [ListSlackTokens](#listslacktokens) | Lists all Slack tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | +| [SaveSlackToken](#saveslacktoken) | Saves the Slack token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | +| [FetchSlackToken](#fetchslacktoken) | Fetches details of a specific Slack token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | +| [DeleteSlackToken](#deleteslacktoken) | Deletes one of the authenticated user's Slack tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | +| [ListTeamsTokens](#listteamstokens) | Lists all Teams tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | +| [SaveTeamsToken](#saveteamstoken) | Saves the Teams token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | +| [FetchTeamsToken](#fetchteamstoken) | Fetches details of a specific Teams token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | +| [DeleteTeamsToken](#deleteteamstoken) | Deletes one of the authenticated user's Teams tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | +| [FetchUserPreferences](#fetchuserpreferences) | Fetch a user's channel delivery preferences. | +| [SaveUserPreferences](#saveuserpreferences) | Save a user's channel preferences. | +| [ListWebPushTokens](#listwebpushtokens) | Lists all Web Push tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. | +| [SaveWebPushToken](#savewebpushtoken) | Saves the Web Push token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. | +| [FetchWebPushToken](#fetchwebpushtoken) | Fetches details of a specific Web Push token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. | +| [DeleteWebPushToken](#deletewebpushtoken) | Deletes one of the authenticated user's Web Push tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. | ## ListInboxTokens @@ -57,18 +63,22 @@ Lists all Inbox tokens belonging to the authenticated user. Returns a paginated import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" - + "github.com/magicbell/magicbell-go/pkg/user-client/util" "github.com/magicbell/magicbell-go/pkg/user-client/channels" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := channels.ListInboxTokensRequestParams{ - + Limit: util.ToPointer(int64(8)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } response, err := client.Channels.ListInboxTokens(context.Background(), params) @@ -103,6 +113,7 @@ Saves the Inbox token for the authenticated user. This token serves as a credent import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" "github.com/magicbell/magicbell-go/pkg/user-client/util" @@ -110,12 +121,13 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) request := channels.InboxToken{ - ConnectionId: util.ToPointer(util.Nullable[string]{ Value: "ConnectionId" }), - Token: util.ToPointer("Token"), + ConnectionId: util.ToPointer(util.Nullable[string]{ Value: "connection_id" }), + Token: util.ToPointer("ipsum nulla mag"), } response, err := client.Channels.SaveInboxToken(context.Background(), request) @@ -150,15 +162,17 @@ Fetches details of a specific Inbox token belonging to the authenticated user. R import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.FetchInboxToken(context.Background(), "tokenId") +response, err := client.Channels.FetchInboxToken(context.Background(), "token_id") if err != nil { panic(err) } @@ -190,15 +204,17 @@ Deletes one of the authenticated user's Inbox tokens. This permanently invalidat import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.DeleteInboxToken(context.Background(), "tokenId") +response, err := client.Channels.DeleteInboxToken(context.Background(), "token_id") if err != nil { panic(err) } @@ -230,18 +246,22 @@ Lists all APNs tokens belonging to the authenticated user. Returns a paginated l import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" - + "github.com/magicbell/magicbell-go/pkg/user-client/util" "github.com/magicbell/magicbell-go/pkg/user-client/channels" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := channels.ListApnsTokensRequestParams{ - + Limit: util.ToPointer(int64(7)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } response, err := client.Channels.ListApnsTokens(context.Background(), params) @@ -276,6 +296,7 @@ Saves the APNs token for the authenticated user. This token serves as a credenti import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" "github.com/magicbell/magicbell-go/pkg/user-client/util" @@ -283,13 +304,14 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) apnsTokenPayloadInstallationId := channels.APNS_TOKEN_PAYLOAD_INSTALLATION_ID_DEVELOPMENT request := channels.ApnsTokenPayload{ - AppId: util.ToPointer("AppId"), - DeviceToken: util.ToPointer("DeviceToken"), + AppId: util.ToPointer("app_id"), + DeviceToken: util.ToPointer("sit culpa incid"), InstallationId: &apnsTokenPayloadInstallationId, } @@ -325,15 +347,17 @@ Fetches details of a specific APNs token belonging to the authenticated user. Re import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.FetchApnsToken(context.Background(), "tokenId") +response, err := client.Channels.FetchApnsToken(context.Background(), "token_id") if err != nil { panic(err) } @@ -365,15 +389,17 @@ Deletes one of the authenticated user's APNs tokens. This permanently invalidate import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.DeleteApnsToken(context.Background(), "tokenId") +response, err := client.Channels.DeleteApnsToken(context.Background(), "token_id") if err != nil { panic(err) } @@ -405,18 +431,22 @@ Lists all Expo tokens belonging to the authenticated user. Returns a paginated l import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" - + "github.com/magicbell/magicbell-go/pkg/user-client/util" "github.com/magicbell/magicbell-go/pkg/user-client/channels" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := channels.ListExpoTokensRequestParams{ - + Limit: util.ToPointer(int64(8)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } response, err := client.Channels.ListExpoTokens(context.Background(), params) @@ -451,6 +481,7 @@ Saves the Expo token for the authenticated user. This token serves as a credenti import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" "github.com/magicbell/magicbell-go/pkg/user-client/util" @@ -458,11 +489,12 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) request := channels.ExpoTokenPayload{ - DeviceToken: util.ToPointer("DeviceToken"), + DeviceToken: util.ToPointer("device_token"), } response, err := client.Channels.SaveExpoToken(context.Background(), request) @@ -497,15 +529,17 @@ Fetches details of a specific Expo token belonging to the authenticated user. Re import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.FetchExpoToken(context.Background(), "tokenId") +response, err := client.Channels.FetchExpoToken(context.Background(), "token_id") if err != nil { panic(err) } @@ -537,15 +571,17 @@ Deletes one of the authenticated user's Expo tokens. This permanently invalidate import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.DeleteExpoToken(context.Background(), "tokenId") +response, err := client.Channels.DeleteExpoToken(context.Background(), "token_id") if err != nil { panic(err) } @@ -577,18 +613,22 @@ Lists all FCM tokens belonging to the authenticated user. Returns a paginated li import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" - + "github.com/magicbell/magicbell-go/pkg/user-client/util" "github.com/magicbell/magicbell-go/pkg/user-client/channels" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := channels.ListFcmTokensRequestParams{ - + Limit: util.ToPointer(int64(6)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } response, err := client.Channels.ListFcmTokens(context.Background(), params) @@ -623,6 +663,7 @@ Saves the FCM token for the authenticated user. This token serves as a credentia import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" "github.com/magicbell/magicbell-go/pkg/user-client/util" @@ -630,13 +671,12 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -fcmTokenPayloadInstallationId := channels.FCM_TOKEN_PAYLOAD_INSTALLATION_ID_DEVELOPMENT request := channels.FcmTokenPayload{ - DeviceToken: util.ToPointer("DeviceToken"), - InstallationId: &fcmTokenPayloadInstallationId, + DeviceToken: util.ToPointer("estminim adipis"), } response, err := client.Channels.SaveFcmToken(context.Background(), request) @@ -671,15 +711,17 @@ Fetches details of a specific FCM token belonging to the authenticated user. Ret import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.FetchFcmToken(context.Background(), "tokenId") +response, err := client.Channels.FetchFcmToken(context.Background(), "token_id") if err != nil { panic(err) } @@ -711,15 +753,211 @@ Deletes one of the authenticated user's FCM tokens. This permanently invalidates import ( "fmt" "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/user-client/client" + +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + +response, err := client.Channels.DeleteFcmToken(context.Background(), "token_id") +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## ListMagicbellSlackbotTokens + +Lists all MagicBell SlackBot tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. + +- HTTP Method: `GET` +- Endpoint: `/channels/slack/magicbell_slackbot/tokens` + +**Parameters** + +| Name | Type | Required | Description | +| :----- | :--------------------------------------- | :------- | :---------------------------- | +| ctx | Context | ✅ | Default go language context | +| params | ListMagicbellSlackbotTokensRequestParams | ✅ | Additional request parameters | + +**Return Type** + +`SlackTokenCollection` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/user-client/client" + "github.com/magicbell/magicbell-go/pkg/user-client/util" + "github.com/magicbell/magicbell-go/pkg/user-client/channels" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +params := channels.ListMagicbellSlackbotTokensRequestParams{ + Limit: util.ToPointer(int64(7)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), +} + +response, err := client.Channels.ListMagicbellSlackbotTokens(context.Background(), params) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## SaveMagicbellSlackbotToken + +Saves the MagicBell SlackBot token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. + +- HTTP Method: `PUT` +- Endpoint: `/channels/slack/magicbell_slackbot/tokens` + +**Parameters** + +| Name | Type | Required | Description | +| :---------------- | :---------------- | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| slackTokenPayload | SlackTokenPayload | ✅ | | + +**Return Type** + +`SlackTokenPayload` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/user-client/client" + "github.com/magicbell/magicbell-go/pkg/user-client/util" + "github.com/magicbell/magicbell-go/pkg/user-client/channels" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +slackTokenPayloadOauth := channels.SlackTokenPayloadOauth{ + ChannelId: util.ToPointer("channel_id"), + InstallationId: util.ToPointer("installation_id"), + Scope: util.ToPointer("scope"), +} + + +slackTokenPayloadWebhook := channels.SlackTokenPayloadWebhook{ + Url: util.ToPointer("url"), +} + +request := channels.SlackTokenPayload{ + Oauth: &slackTokenPayloadOauth, + Webhook: &slackTokenPayloadWebhook, +} + +response, err := client.Channels.SaveMagicbellSlackbotToken(context.Background(), request) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## FetchMagicbellSlackbotToken + +Fetches details of a specific MagicBell SlackBot token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. + +- HTTP Method: `GET` +- Endpoint: `/channels/slack/magicbell_slackbot/tokens/{token_id}` + +**Parameters** + +| Name | Type | Required | Description | +| :------ | :------ | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| tokenId | string | ✅ | | + +**Return Type** + +`SlackToken` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/user-client/client" + +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + +response, err := client.Channels.FetchMagicbellSlackbotToken(context.Background(), "token_id") +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## DeleteMagicbellSlackbotToken + +Deletes one of the authenticated user's MagicBell SlackBot tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. + +- HTTP Method: `DELETE` +- Endpoint: `/channels/slack/magicbell_slackbot/tokens/{token_id}` + +**Parameters** + +| Name | Type | Required | Description | +| :------ | :------ | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| tokenId | string | ✅ | | + +**Return Type** + +`DiscardResult` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.DeleteFcmToken(context.Background(), "tokenId") +response, err := client.Channels.DeleteMagicbellSlackbotToken(context.Background(), "token_id") if err != nil { panic(err) } @@ -751,18 +989,22 @@ Lists all Slack tokens belonging to the authenticated user. Returns a paginated import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" - + "github.com/magicbell/magicbell-go/pkg/user-client/util" "github.com/magicbell/magicbell-go/pkg/user-client/channels" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := channels.ListSlackTokensRequestParams{ - + Limit: util.ToPointer(int64(2)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } response, err := client.Channels.ListSlackTokens(context.Background(), params) @@ -797,6 +1039,7 @@ Saves the Slack token for the authenticated user. This token serves as a credent import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" "github.com/magicbell/magicbell-go/pkg/user-client/util" @@ -804,18 +1047,19 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) slackTokenPayloadOauth := channels.SlackTokenPayloadOauth{ - ChannelId: util.ToPointer("ChannelId"), - InstallationId: util.ToPointer("InstallationId"), - Scope: util.ToPointer("Scope"), + ChannelId: util.ToPointer("channel_id"), + InstallationId: util.ToPointer("installation_id"), + Scope: util.ToPointer("scope"), } slackTokenPayloadWebhook := channels.SlackTokenPayloadWebhook{ - Url: util.ToPointer("Url"), + Url: util.ToPointer("url"), } request := channels.SlackTokenPayload{ @@ -855,15 +1099,17 @@ Fetches details of a specific Slack token belonging to the authenticated user. R import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.FetchSlackToken(context.Background(), "tokenId") +response, err := client.Channels.FetchSlackToken(context.Background(), "token_id") if err != nil { panic(err) } @@ -895,15 +1141,17 @@ Deletes one of the authenticated user's Slack tokens. This permanently invalidat import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.DeleteSlackToken(context.Background(), "tokenId") +response, err := client.Channels.DeleteSlackToken(context.Background(), "token_id") if err != nil { panic(err) } @@ -935,18 +1183,22 @@ Lists all Teams tokens belonging to the authenticated user. Returns a paginated import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" - + "github.com/magicbell/magicbell-go/pkg/user-client/util" "github.com/magicbell/magicbell-go/pkg/user-client/channels" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := channels.ListTeamsTokensRequestParams{ - + Limit: util.ToPointer(int64(4)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } response, err := client.Channels.ListTeamsTokens(context.Background(), params) @@ -981,6 +1233,7 @@ Saves the Teams token for the authenticated user. This token serves as a credent import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" "github.com/magicbell/magicbell-go/pkg/user-client/util" @@ -988,11 +1241,12 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) teamsTokenPayloadWebhook := channels.TeamsTokenPayloadWebhook{ - Url: util.ToPointer("Url"), + Url: util.ToPointer("url"), } request := channels.TeamsTokenPayload{ @@ -1031,15 +1285,17 @@ Fetches details of a specific Teams token belonging to the authenticated user. R import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.FetchTeamsToken(context.Background(), "tokenId") +response, err := client.Channels.FetchTeamsToken(context.Background(), "token_id") if err != nil { panic(err) } @@ -1071,15 +1327,117 @@ Deletes one of the authenticated user's Teams tokens. This permanently invalidat import ( "fmt" "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/user-client/client" + +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + +response, err := client.Channels.DeleteTeamsToken(context.Background(), "token_id") +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## FetchUserPreferences + +Fetch a user's channel delivery preferences. + +- HTTP Method: `GET` +- Endpoint: `/channels/user_preferences` + +**Parameters** + +| Name | Type | Required | Description | +| :--- | :------ | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | + +**Return Type** + +`UserPreferences` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.DeleteTeamsToken(context.Background(), "tokenId") +response, err := client.Channels.FetchUserPreferences(context.Background()) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## SaveUserPreferences + +Save a user's channel preferences. + +- HTTP Method: `PUT` +- Endpoint: `/channels/user_preferences` + +**Parameters** + +| Name | Type | Required | Description | +| :-------------- | :-------------- | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| userPreferences | UserPreferences | ✅ | | + +**Return Type** + +`any` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/user-client/client" + "github.com/magicbell/magicbell-go/pkg/user-client/util" + "github.com/magicbell/magicbell-go/pkg/user-client/channels" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +channels := channels.Channels{ + Enabled: util.ToPointer(true), + Name: util.ToPointer("name"), +} + +categories := channels.Categories{ + Channels: []channels.Channels{channels}, + Key: util.ToPointer("key"), + Label: util.ToPointer(util.Nullable[string]{ Value: "label" }), +} + +request := channels.UserPreferences{ + Categories: []channels.Categories{categories}, +} + +response, err := client.Channels.SaveUserPreferences(context.Background(), request) if err != nil { panic(err) } @@ -1111,18 +1469,22 @@ Lists all Web Push tokens belonging to the authenticated user. Returns a paginat import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" - + "github.com/magicbell/magicbell-go/pkg/user-client/util" "github.com/magicbell/magicbell-go/pkg/user-client/channels" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := channels.ListWebPushTokensRequestParams{ - + Limit: util.ToPointer(int64(9)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), } response, err := client.Channels.ListWebPushTokens(context.Background(), params) @@ -1157,6 +1519,7 @@ Saves the Web Push token for the authenticated user. This token serves as a cred import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" "github.com/magicbell/magicbell-go/pkg/user-client/util" @@ -1164,16 +1527,17 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) webPushTokenPayloadKeys := shared.WebPushTokenPayloadKeys{ - Auth: util.ToPointer("Auth"), - P256dh: util.ToPointer("P256dh"), + Auth: util.ToPointer("auth"), + P256dh: util.ToPointer("p256dh"), } request := shared.WebPushTokenPayload{ - Endpoint: util.ToPointer("Endpoint"), + Endpoint: util.ToPointer("endpoint"), Keys: &webPushTokenPayloadKeys, } @@ -1209,15 +1573,17 @@ Fetches details of a specific Web Push token belonging to the authenticated user import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.FetchWebPushToken(context.Background(), "tokenId") +response, err := client.Channels.FetchWebPushToken(context.Background(), "token_id") if err != nil { panic(err) } @@ -1249,15 +1615,17 @@ Deletes one of the authenticated user's Web Push tokens. This permanently invali import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Channels.DeleteWebPushToken(context.Background(), "tokenId") +response, err := client.Channels.DeleteWebPushToken(context.Background(), "token_id") if err != nil { panic(err) } diff --git a/docs/user-client/services/integrations_service.md b/docs/user-client/services/integrations_service.md index 64b2b2b..8873a3e 100644 --- a/docs/user-client/services/integrations_service.md +++ b/docs/user-client/services/integrations_service.md @@ -2,15 +2,18 @@ A list of all methods in the `IntegrationsService` service. Click on the method name to view detailed information about that method. -| Methods | Description | -| :---------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [SaveInboxInstallation](#saveinboxinstallation) | Creates a new installation of a Inbox integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration. | -| [StartInboxInstallation](#startinboxinstallation) | Initiates the installation flow for an Inbox integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required. | -| [SaveSlackInstallation](#saveslackinstallation) | Creates a new installation of a Slack integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration. | -| [FinishSlackInstallation](#finishslackinstallation) | Completes the installation flow for the Slack integration. This endpoint is typically called after the user has completed any required authorization steps with Slack. | -| [StartSlackInstallation](#startslackinstallation) | Initiates the installation flow for a Slack integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required. | -| [SaveWebPushInstallation](#savewebpushinstallation) | Creates a new installation of a Web Push integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration. | -| [StartWebPushInstallation](#startwebpushinstallation) | Initiates the installation flow for a Web Push integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required. | +| Methods | Description | +| :-------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [SaveInboxInstallation](#saveinboxinstallation) | Creates a new installation of a Inbox integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration. | +| [StartInboxInstallation](#startinboxinstallation) | Initiates the installation flow for an Inbox integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required. | +| [SaveMagicbellSlackbotInstallation](#savemagicbellslackbotinstallation) | Creates a new installation of a MagicBell SlackBot integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration. | +| [FinishMagicbellSlackbotInstallation](#finishmagicbellslackbotinstallation) | Completes the installation flow for the MagicBell SlackBot integration. This endpoint is typically called after the user has completed any required authorization steps with MagicBell SlackBot. | +| [StartMagicbellSlackbotInstallation](#startmagicbellslackbotinstallation) | Initiates the installation flow for a MagicBell SlackBot integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required. | +| [SaveSlackInstallation](#saveslackinstallation) | Creates a new installation of a Slack integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration. | +| [FinishSlackInstallation](#finishslackinstallation) | Completes the installation flow for the Slack integration. This endpoint is typically called after the user has completed any required authorization steps with Slack. | +| [StartSlackInstallation](#startslackinstallation) | Initiates the installation flow for a Slack integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required. | +| [SaveWebPushInstallation](#savewebpushinstallation) | Creates a new installation of a Web Push integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration. | +| [StartWebPushInstallation](#startwebpushinstallation) | Initiates the installation flow for a Web Push integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required. | ## SaveInboxInstallation @@ -36,6 +39,7 @@ Creates a new installation of a Inbox integration for a user. This endpoint is u import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" "github.com/magicbell/magicbell-go/pkg/user-client/util" @@ -43,104 +47,105 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) images := integrations.Images{ - EmptyInboxUrl: util.ToPointer("EmptyInboxUrl"), + EmptyInboxUrl: util.ToPointer("emptyInboxUrl"), } banner := integrations.Banner{ - BackgroundColor: util.ToPointer("BackgroundColor"), - BackgroundOpacity: util.ToPointer(float64(123)), - FontSize: util.ToPointer("FontSize"), - TextColor: util.ToPointer("TextColor"), + BackgroundColor: util.ToPointer("backgroundColor"), + BackgroundOpacity: util.ToPointer(float64(6.42)), + FontSize: util.ToPointer("fontSize"), + TextColor: util.ToPointer("textColor"), } dialog := integrations.Dialog{ - AccentColor: util.ToPointer("AccentColor"), - BackgroundColor: util.ToPointer("BackgroundColor"), - TextColor: util.ToPointer("TextColor"), + AccentColor: util.ToPointer("accentColor"), + BackgroundColor: util.ToPointer("backgroundColor"), + TextColor: util.ToPointer("textColor"), } footer := integrations.Footer{ - BackgroundColor: util.ToPointer("BackgroundColor"), - BorderRadius: util.ToPointer("BorderRadius"), - FontSize: util.ToPointer("FontSize"), - TextColor: util.ToPointer("TextColor"), + BackgroundColor: util.ToPointer("backgroundColor"), + BorderRadius: util.ToPointer("borderRadius"), + FontSize: util.ToPointer("fontSize"), + TextColor: util.ToPointer("textColor"), } header := integrations.Header{ - BackgroundColor: util.ToPointer("BackgroundColor"), - BorderRadius: util.ToPointer("BorderRadius"), - FontFamily: util.ToPointer("FontFamily"), - FontSize: util.ToPointer("FontSize"), - TextColor: util.ToPointer("TextColor"), + BackgroundColor: util.ToPointer("backgroundColor"), + BorderRadius: util.ToPointer("borderRadius"), + FontFamily: util.ToPointer("fontFamily"), + FontSize: util.ToPointer("fontSize"), + TextColor: util.ToPointer("textColor"), } icon := integrations.Icon{ - BorderColor: util.ToPointer("BorderColor"), - Width: util.ToPointer("Width"), + BorderColor: util.ToPointer("borderColor"), + Width: util.ToPointer("width"), } defaultHover := integrations.DefaultHover{ - BackgroundColor: util.ToPointer("BackgroundColor"), + BackgroundColor: util.ToPointer("backgroundColor"), } defaultState := integrations.DefaultState{ - Color: util.ToPointer("Color"), + Color: util.ToPointer("color"), } default_ := integrations.Default_{ - BackgroundColor: util.ToPointer("BackgroundColor"), - BorderRadius: util.ToPointer("BorderRadius"), - FontFamily: util.ToPointer("FontFamily"), - FontSize: util.ToPointer("FontSize"), + BackgroundColor: util.ToPointer("backgroundColor"), + BorderRadius: util.ToPointer("borderRadius"), + FontFamily: util.ToPointer("fontFamily"), + FontSize: util.ToPointer("fontSize"), Hover: &defaultHover, - Margin: util.ToPointer("Margin"), + Margin: util.ToPointer("margin"), State: &defaultState, - TextColor: util.ToPointer("TextColor"), + TextColor: util.ToPointer("textColor"), } unreadHover := integrations.UnreadHover{ - BackgroundColor: util.ToPointer("BackgroundColor"), + BackgroundColor: util.ToPointer("backgroundColor"), } unreadState := integrations.UnreadState{ - Color: util.ToPointer("Color"), + Color: util.ToPointer("color"), } unread := integrations.Unread{ - BackgroundColor: util.ToPointer("BackgroundColor"), + BackgroundColor: util.ToPointer("backgroundColor"), Hover: &unreadHover, State: &unreadState, - TextColor: util.ToPointer("TextColor"), + TextColor: util.ToPointer("textColor"), } unseenHover := integrations.UnseenHover{ - BackgroundColor: util.ToPointer("BackgroundColor"), + BackgroundColor: util.ToPointer("backgroundColor"), } unseenState := integrations.UnseenState{ - Color: util.ToPointer("Color"), + Color: util.ToPointer("color"), } unseen := integrations.Unseen{ - BackgroundColor: util.ToPointer("BackgroundColor"), + BackgroundColor: util.ToPointer("backgroundColor"), Hover: &unseenHover, State: &unseenState, - TextColor: util.ToPointer("TextColor"), + TextColor: util.ToPointer("textColor"), } themeNotification := integrations.ThemeNotification{ @@ -151,7 +156,7 @@ themeNotification := integrations.ThemeNotification{ unseenBadge := integrations.UnseenBadge{ - BackgroundColor: util.ToPointer("BackgroundColor"), + BackgroundColor: util.ToPointer("backgroundColor"), } theme := integrations.Theme{ @@ -166,7 +171,7 @@ theme := integrations.Theme{ request := integrations.InboxConfigPayload{ Images: &images, - Locale: util.ToPointer(util.Nullable[string]{ Value: "Locale" }), + Locale: util.ToPointer(util.Nullable[string]{ Value: "locale" }), Theme: &theme, } @@ -201,12 +206,14 @@ Initiates the installation flow for an Inbox integration. This is the first step import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.StartInboxInstallation(context.Background()) @@ -217,6 +224,195 @@ if err != nil { fmt.Println(response) ``` +## SaveMagicbellSlackbotInstallation + +Creates a new installation of a MagicBell SlackBot integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration. + +- HTTP Method: `PUT` +- Endpoint: `/integrations/magicbell_slackbot/installations` + +**Parameters** + +| Name | Type | Required | Description | +| :---------------- | :---------------- | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| slackInstallation | SlackInstallation | ✅ | | + +**Return Type** + +`SlackInstallation` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/user-client/client" + "github.com/magicbell/magicbell-go/pkg/user-client/util" + "github.com/magicbell/magicbell-go/pkg/user-client/integrations" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +authedUser := integrations.AuthedUser{ + AccessToken: util.ToPointer("access_token"), + ExpiresIn: util.ToPointer(int64(1)), + Id: util.ToPointer("id"), + RefreshToken: util.ToPointer("refresh_token"), + Scope: util.ToPointer("scope"), + TokenType: util.ToPointer("token_type"), +} + + +enterprise := integrations.Enterprise{ + Id: util.ToPointer("id"), + Name: util.ToPointer("name"), +} + + +incomingWebhook := integrations.IncomingWebhook{ + Channel: util.ToPointer("channel"), + ConfigurationUrl: util.ToPointer("configuration_url"), + Url: util.ToPointer("url"), +} + + +team := integrations.Team{ + Id: util.ToPointer("id"), + Name: util.ToPointer("name"), +} + +request := integrations.SlackInstallation{ + AccessToken: util.ToPointer("access_token"), + AppId: util.ToPointer("app_id"), + AuthedUser: &authedUser, + BotUserId: util.ToPointer("bot_user_id"), + Enterprise: &enterprise, + ExpiresIn: util.ToPointer(int64(2)), + Id: util.ToPointer("318-g~J]11"), + IncomingWebhook: &incomingWebhook, + IsEnterpriseInstall: util.ToPointer(true), + RefreshToken: util.ToPointer("refresh_token"), + Scope: util.ToPointer("scope"), + Team: &team, + TokenType: util.ToPointer("token_type"), +} + +response, err := client.Integrations.SaveMagicbellSlackbotInstallation(context.Background(), request) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## FinishMagicbellSlackbotInstallation + +Completes the installation flow for the MagicBell SlackBot integration. This endpoint is typically called after the user has completed any required authorization steps with MagicBell SlackBot. + +- HTTP Method: `POST` +- Endpoint: `/integrations/magicbell_slackbot/installations/finish` + +**Parameters** + +| Name | Type | Required | Description | +| :------------------------- | :------------------------- | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| slackFinishInstallResponse | SlackFinishInstallResponse | ✅ | | + +**Return Type** + +`SlackInstallation` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/user-client/client" + "github.com/magicbell/magicbell-go/pkg/user-client/util" + "github.com/magicbell/magicbell-go/pkg/user-client/integrations" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +request := integrations.SlackFinishInstallResponse{ + AppId: util.ToPointer("app_id"), + Code: util.ToPointer("code"), + RedirectUrl: util.ToPointer("redirect_url"), +} + +response, err := client.Integrations.FinishMagicbellSlackbotInstallation(context.Background(), request) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + +## StartMagicbellSlackbotInstallation + +Initiates the installation flow for a MagicBell SlackBot integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required. + +- HTTP Method: `POST` +- Endpoint: `/integrations/magicbell_slackbot/installations/start` + +**Parameters** + +| Name | Type | Required | Description | +| :---------------- | :---------------- | :------- | :-------------------------- | +| ctx | Context | ✅ | Default go language context | +| slackStartInstall | SlackStartInstall | ✅ | | + +**Return Type** + +`SlackStartInstallResponseContent` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/user-client/client" + "github.com/magicbell/magicbell-go/pkg/user-client/util" + "github.com/magicbell/magicbell-go/pkg/user-client/integrations" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +request := integrations.SlackStartInstall{ + AppId: util.ToPointer("app_id"), + AuthUrl: util.ToPointer("auth_url"), + ExtraScopes: []string{}, + RedirectUrl: util.ToPointer("redirect_url"), +} + +response, err := client.Integrations.StartMagicbellSlackbotInstallation(context.Background(), request) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + ## SaveSlackInstallation Creates a new installation of a Slack integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration. @@ -241,6 +437,7 @@ Creates a new installation of a Slack integration for a user. This endpoint is u import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" "github.com/magicbell/magicbell-go/pkg/user-client/util" @@ -248,51 +445,52 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) authedUser := integrations.AuthedUser{ - AccessToken: util.ToPointer("AccessToken"), - ExpiresIn: util.ToPointer(int64(123)), - Id: util.ToPointer("Id"), - RefreshToken: util.ToPointer("RefreshToken"), - Scope: util.ToPointer("Scope"), - TokenType: util.ToPointer("TokenType"), + AccessToken: util.ToPointer("access_token"), + ExpiresIn: util.ToPointer(int64(1)), + Id: util.ToPointer("id"), + RefreshToken: util.ToPointer("refresh_token"), + Scope: util.ToPointer("scope"), + TokenType: util.ToPointer("token_type"), } enterprise := integrations.Enterprise{ - Id: util.ToPointer("Id"), - Name: util.ToPointer("Name"), + Id: util.ToPointer("id"), + Name: util.ToPointer("name"), } incomingWebhook := integrations.IncomingWebhook{ - Channel: util.ToPointer("Channel"), - ConfigurationUrl: util.ToPointer("ConfigurationUrl"), - Url: util.ToPointer("Url"), + Channel: util.ToPointer("channel"), + ConfigurationUrl: util.ToPointer("configuration_url"), + Url: util.ToPointer("url"), } team := integrations.Team{ - Id: util.ToPointer("Id"), - Name: util.ToPointer("Name"), + Id: util.ToPointer("id"), + Name: util.ToPointer("name"), } request := integrations.SlackInstallation{ - AccessToken: util.ToPointer("AccessToken"), - AppId: util.ToPointer("AppId"), + AccessToken: util.ToPointer("access_token"), + AppId: util.ToPointer("app_id"), AuthedUser: &authedUser, - BotUserId: util.ToPointer("BotUserId"), + BotUserId: util.ToPointer("bot_user_id"), Enterprise: &enterprise, - ExpiresIn: util.ToPointer(int64(123)), - Id: util.ToPointer("Id"), + ExpiresIn: util.ToPointer(int64(2)), + Id: util.ToPointer("318-g~J]11"), IncomingWebhook: &incomingWebhook, IsEnterpriseInstall: util.ToPointer(true), - RefreshToken: util.ToPointer("RefreshToken"), - Scope: util.ToPointer("Scope"), + RefreshToken: util.ToPointer("refresh_token"), + Scope: util.ToPointer("scope"), Team: &team, - TokenType: util.ToPointer("TokenType"), + TokenType: util.ToPointer("token_type"), } response, err := client.Integrations.SaveSlackInstallation(context.Background(), request) @@ -327,6 +525,7 @@ Completes the installation flow for the Slack integration. This endpoint is typi import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" "github.com/magicbell/magicbell-go/pkg/user-client/util" @@ -334,13 +533,14 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) request := integrations.SlackFinishInstallResponse{ - AppId: util.ToPointer("AppId"), - Code: util.ToPointer("Code"), - RedirectUrl: util.ToPointer("RedirectUrl"), + AppId: util.ToPointer("app_id"), + Code: util.ToPointer("code"), + RedirectUrl: util.ToPointer("redirect_url"), } response, err := client.Integrations.FinishSlackInstallation(context.Background(), request) @@ -375,6 +575,7 @@ Initiates the installation flow for a Slack integration. This is the first step import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" "github.com/magicbell/magicbell-go/pkg/user-client/util" @@ -382,14 +583,15 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) request := integrations.SlackStartInstall{ - AppId: util.ToPointer("AppId"), - AuthUrl: util.ToPointer("AuthUrl"), + AppId: util.ToPointer("app_id"), + AuthUrl: util.ToPointer("auth_url"), ExtraScopes: []string{}, - RedirectUrl: util.ToPointer("RedirectUrl"), + RedirectUrl: util.ToPointer("redirect_url"), } response, err := client.Integrations.StartSlackInstallation(context.Background(), request) @@ -424,6 +626,7 @@ Creates a new installation of a Web Push integration for a user. This endpoint i import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" "github.com/magicbell/magicbell-go/pkg/user-client/util" @@ -431,16 +634,17 @@ import ( ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) webPushTokenPayloadKeys := shared.WebPushTokenPayloadKeys{ - Auth: util.ToPointer("Auth"), - P256dh: util.ToPointer("P256dh"), + Auth: util.ToPointer("auth"), + P256dh: util.ToPointer("p256dh"), } request := shared.WebPushTokenPayload{ - Endpoint: util.ToPointer("Endpoint"), + Endpoint: util.ToPointer("endpoint"), Keys: &webPushTokenPayloadKeys, } @@ -475,12 +679,14 @@ Initiates the installation flow for a Web Push integration. This is the first st import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) response, err := client.Integrations.StartWebPushInstallation(context.Background()) diff --git a/docs/user-client/services/notifications_service.md b/docs/user-client/services/notifications_service.md index db7e969..0fa7831 100644 --- a/docs/user-client/services/notifications_service.md +++ b/docs/user-client/services/notifications_service.md @@ -2,16 +2,17 @@ A list of all methods in the `NotificationsService` service. Click on the method name to view detailed information about that method. -| Methods | Description | -| :---------------------------------------------------- | :---------------------------------- | -| [ListNotifications](#listnotifications) | Lists all notifications for a user. | -| [ArchiveAllNotifications](#archiveallnotifications) | Archive all notifications. | -| [MarkAllNotificationsRead](#markallnotificationsread) | Marks all notifications as read. | -| [FetchNotification](#fetchnotification) | Gets a notification by ID. | -| [ArchiveNotification](#archivenotification) | Archive a notification. | -| [MarkNotificationRead](#marknotificationread) | Marks a notification as read. | -| [UnarchiveNotification](#unarchivenotification) | Unarchives a notification. | -| [MarkNotificationUnread](#marknotificationunread) | Marks a notification as unread. | +| Methods | Description | +| :-------------------------------------------------------------- | :---------------------------------------------------------------------------------------------- | +| [ListNotifications](#listnotifications) | Lists all notifications for a user. | +| [ArchiveAllNotifications](#archiveallnotifications) | Archive all notifications. | +| [MarkAllNotificationsRead](#markallnotificationsread) | Marks all notifications as read. | +| [FetchUnreadNotificationsCount](#fetchunreadnotificationscount) | Returns the count of unread notifications for a user. Supports filtering by category and topic. | +| [FetchNotification](#fetchnotification) | Gets a notification by ID. | +| [ArchiveNotification](#archivenotification) | Archive a notification. | +| [MarkNotificationRead](#marknotificationread) | Marks a notification as read. | +| [UnarchiveNotification](#unarchivenotification) | Unarchives a notification. | +| [MarkNotificationUnread](#marknotificationunread) | Marks a notification as unread. | ## ListNotifications @@ -37,18 +38,25 @@ Lists all notifications for a user. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" - + "github.com/magicbell/magicbell-go/pkg/user-client/util" "github.com/magicbell/magicbell-go/pkg/user-client/notifications" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := notifications.ListNotificationsRequestParams{ - + Limit: util.ToPointer(int64(5)), + StartingAfter: util.ToPointer("starting_after"), + EndingBefore: util.ToPointer("ending_before"), + Status: util.ToPointer("status"), + Category: util.ToPointer("category"), + Topic: util.ToPointer("topic"), } response, err := client.Notifications.ListNotifications(context.Background(), params) @@ -83,18 +91,21 @@ Archive all notifications. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" - + "github.com/magicbell/magicbell-go/pkg/user-client/util" "github.com/magicbell/magicbell-go/pkg/user-client/notifications" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := notifications.ArchiveAllNotificationsRequestParams{ - + Category: util.ToPointer("category"), + Topic: util.ToPointer("topic"), } response, err := client.Notifications.ArchiveAllNotifications(context.Background(), params) @@ -129,18 +140,21 @@ Marks all notifications as read. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" - + "github.com/magicbell/magicbell-go/pkg/user-client/util" "github.com/magicbell/magicbell-go/pkg/user-client/notifications" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) params := notifications.MarkAllNotificationsReadRequestParams{ - + Category: util.ToPointer("category"), + Topic: util.ToPointer("topic"), } response, err := client.Notifications.MarkAllNotificationsRead(context.Background(), params) @@ -151,6 +165,55 @@ if err != nil { fmt.Println(response) ``` +## FetchUnreadNotificationsCount + +Returns the count of unread notifications for a user. Supports filtering by category and topic. + +- HTTP Method: `GET` +- Endpoint: `/notifications/unread/count` + +**Parameters** + +| Name | Type | Required | Description | +| :----- | :----------------------------------------- | :------- | :---------------------------- | +| ctx | Context | ✅ | Default go language context | +| params | FetchUnreadNotificationsCountRequestParams | ✅ | Additional request parameters | + +**Return Type** + +`CountResponse` + +**Example Usage Code Snippet** + +```go +import ( + "fmt" + "encoding/json" + "context" + "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/user-client/client" + "github.com/magicbell/magicbell-go/pkg/user-client/util" + "github.com/magicbell/magicbell-go/pkg/user-client/notifications" +) + +config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") +client := client.NewClient(config) + + +params := notifications.FetchUnreadNotificationsCountRequestParams{ + Category: util.ToPointer("category"), + Topic: util.ToPointer("topic"), +} + +response, err := client.Notifications.FetchUnreadNotificationsCount(context.Background(), params) +if err != nil { + panic(err) +} + +fmt.Println(response) +``` + ## FetchNotification Gets a notification by ID. @@ -175,15 +238,17 @@ Gets a notification by ID. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Notifications.FetchNotification(context.Background(), "notificationId") +response, err := client.Notifications.FetchNotification(context.Background(), "notification_id") if err != nil { panic(err) } @@ -215,15 +280,17 @@ Archive a notification. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Notifications.ArchiveNotification(context.Background(), "notificationId") +response, err := client.Notifications.ArchiveNotification(context.Background(), "notification_id") if err != nil { panic(err) } @@ -255,15 +322,17 @@ Marks a notification as read. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Notifications.MarkNotificationRead(context.Background(), "notificationId") +response, err := client.Notifications.MarkNotificationRead(context.Background(), "notification_id") if err != nil { panic(err) } @@ -295,15 +364,17 @@ Unarchives a notification. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Notifications.UnarchiveNotification(context.Background(), "notificationId") +response, err := client.Notifications.UnarchiveNotification(context.Background(), "notification_id") if err != nil { panic(err) } @@ -335,15 +406,17 @@ Marks a notification as unread. import ( "fmt" "encoding/json" + "context" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" "github.com/magicbell/magicbell-go/pkg/user-client/client" ) config := clientconfig.NewConfig() +config.SetAccessToken("ACCESS_TOKEN") client := client.NewClient(config) -response, err := client.Notifications.MarkNotificationUnread(context.Background(), "notificationId") +response, err := client.Notifications.MarkNotificationUnread(context.Background(), "notification_id") if err != nil { panic(err) } diff --git a/docs/user-client/snippets/snippets.json b/docs/user-client/snippets/snippets.json index c260450..df57806 100644 --- a/docs/user-client/snippets/snippets.json +++ b/docs/user-client/snippets/snippets.json @@ -1,107 +1,132 @@ { "endpoints": { "/channels/in_app/inbox/tokens": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := channels.ListInboxTokensRequestParams{\n\n}\n\nresponse, err := client.Channels.ListInboxTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nrequest := channels.InboxToken{\n ConnectionId: util.ToPointer(util.Nullable[string]{ Value: \"ConnectionId\" }),\n Token: util.ToPointer(\"Token\"),\n}\n\nresponse, err := client.Channels.SaveInboxToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListInboxTokensRequestParams{\n Limit: util.ToPointer(int64(8)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListInboxTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := channels.InboxToken{\n ConnectionId: util.ToPointer(util.Nullable[string]{ Value: \"connection_id\" }),\n Token: util.ToPointer(\"ipsum nulla mag\"),\n}\n\nresponse, err := client.Channels.SaveInboxToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels/in_app/inbox/tokens/{token_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchInboxToken(context.Background(), \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteInboxToken(context.Background(), \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchInboxToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteInboxToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels/mobile_push/apns/tokens": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := channels.ListApnsTokensRequestParams{\n\n}\n\nresponse, err := client.Channels.ListApnsTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\napnsTokenPayloadInstallationId := channels.APNS_TOKEN_PAYLOAD_INSTALLATION_ID_DEVELOPMENT\n\nrequest := channels.ApnsTokenPayload{\n AppId: util.ToPointer(\"AppId\"),\n DeviceToken: util.ToPointer(\"DeviceToken\"),\n InstallationId: &apnsTokenPayloadInstallationId,\n}\n\nresponse, err := client.Channels.SaveApnsToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListApnsTokensRequestParams{\n Limit: util.ToPointer(int64(7)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListApnsTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\napnsTokenPayloadInstallationId := channels.APNS_TOKEN_PAYLOAD_INSTALLATION_ID_DEVELOPMENT\n\nrequest := channels.ApnsTokenPayload{\n AppId: util.ToPointer(\"app_id\"),\n DeviceToken: util.ToPointer(\"sit culpa incid\"),\n InstallationId: &apnsTokenPayloadInstallationId,\n}\n\nresponse, err := client.Channels.SaveApnsToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels/mobile_push/apns/tokens/{token_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchApnsToken(context.Background(), \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteApnsToken(context.Background(), \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchApnsToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteApnsToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels/mobile_push/expo/tokens": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := channels.ListExpoTokensRequestParams{\n\n}\n\nresponse, err := client.Channels.ListExpoTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nrequest := channels.ExpoTokenPayload{\n DeviceToken: util.ToPointer(\"DeviceToken\"),\n}\n\nresponse, err := client.Channels.SaveExpoToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListExpoTokensRequestParams{\n Limit: util.ToPointer(int64(8)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListExpoTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := channels.ExpoTokenPayload{\n DeviceToken: util.ToPointer(\"device_token\"),\n}\n\nresponse, err := client.Channels.SaveExpoToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels/mobile_push/expo/tokens/{token_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchExpoToken(context.Background(), \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteExpoToken(context.Background(), \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchExpoToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteExpoToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels/mobile_push/fcm/tokens": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := channels.ListFcmTokensRequestParams{\n\n}\n\nresponse, err := client.Channels.ListFcmTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nfcmTokenPayloadInstallationId := channels.FCM_TOKEN_PAYLOAD_INSTALLATION_ID_DEVELOPMENT\n\nrequest := channels.FcmTokenPayload{\n DeviceToken: util.ToPointer(\"DeviceToken\"),\n InstallationId: &fcmTokenPayloadInstallationId,\n}\n\nresponse, err := client.Channels.SaveFcmToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListFcmTokensRequestParams{\n Limit: util.ToPointer(int64(6)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListFcmTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := channels.FcmTokenPayload{\n DeviceToken: util.ToPointer(\"estminim adipis\"),\n}\n\nresponse, err := client.Channels.SaveFcmToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels/mobile_push/fcm/tokens/{token_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchFcmToken(context.Background(), \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteFcmToken(context.Background(), \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchFcmToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteFcmToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/channels/slack/magicbell_slackbot/tokens": { + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListMagicbellSlackbotTokensRequestParams{\n Limit: util.ToPointer(int64(7)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListMagicbellSlackbotTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nslackTokenPayloadOauth := channels.SlackTokenPayloadOauth{\n ChannelId: util.ToPointer(\"channel_id\"),\n InstallationId: util.ToPointer(\"installation_id\"),\n Scope: util.ToPointer(\"scope\"),\n}\n\n\nslackTokenPayloadWebhook := channels.SlackTokenPayloadWebhook{\n Url: util.ToPointer(\"url\"),\n}\n\nrequest := channels.SlackTokenPayload{\n Oauth: &slackTokenPayloadOauth,\n Webhook: &slackTokenPayloadWebhook,\n}\n\nresponse, err := client.Channels.SaveMagicbellSlackbotToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/channels/slack/magicbell_slackbot/tokens/{token_id}": { + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchMagicbellSlackbotToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteMagicbellSlackbotToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels/slack/tokens": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := channels.ListSlackTokensRequestParams{\n\n}\n\nresponse, err := client.Channels.ListSlackTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nslackTokenPayloadOauth := channels.SlackTokenPayloadOauth{\n ChannelId: util.ToPointer(\"ChannelId\"),\n InstallationId: util.ToPointer(\"InstallationId\"),\n Scope: util.ToPointer(\"Scope\"),\n}\n\n\nslackTokenPayloadWebhook := channels.SlackTokenPayloadWebhook{\n Url: util.ToPointer(\"Url\"),\n}\n\nrequest := channels.SlackTokenPayload{\n Oauth: &slackTokenPayloadOauth,\n Webhook: &slackTokenPayloadWebhook,\n}\n\nresponse, err := client.Channels.SaveSlackToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListSlackTokensRequestParams{\n Limit: util.ToPointer(int64(2)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListSlackTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nslackTokenPayloadOauth := channels.SlackTokenPayloadOauth{\n ChannelId: util.ToPointer(\"channel_id\"),\n InstallationId: util.ToPointer(\"installation_id\"),\n Scope: util.ToPointer(\"scope\"),\n}\n\n\nslackTokenPayloadWebhook := channels.SlackTokenPayloadWebhook{\n Url: util.ToPointer(\"url\"),\n}\n\nrequest := channels.SlackTokenPayload{\n Oauth: &slackTokenPayloadOauth,\n Webhook: &slackTokenPayloadWebhook,\n}\n\nresponse, err := client.Channels.SaveSlackToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels/slack/tokens/{token_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchSlackToken(context.Background(), \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteSlackToken(context.Background(), \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchSlackToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteSlackToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels/teams/tokens": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := channels.ListTeamsTokensRequestParams{\n\n}\n\nresponse, err := client.Channels.ListTeamsTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nteamsTokenPayloadWebhook := channels.TeamsTokenPayloadWebhook{\n Url: util.ToPointer(\"Url\"),\n}\n\nrequest := channels.TeamsTokenPayload{\n Webhook: &teamsTokenPayloadWebhook,\n}\n\nresponse, err := client.Channels.SaveTeamsToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListTeamsTokensRequestParams{\n Limit: util.ToPointer(int64(4)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListTeamsTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nteamsTokenPayloadWebhook := channels.TeamsTokenPayloadWebhook{\n Url: util.ToPointer(\"url\"),\n}\n\nrequest := channels.TeamsTokenPayload{\n Webhook: &teamsTokenPayloadWebhook,\n}\n\nresponse, err := client.Channels.SaveTeamsToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels/teams/tokens/{token_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchTeamsToken(context.Background(), \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteTeamsToken(context.Background(), \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchTeamsToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteTeamsToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/channels/user_preferences": { + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchUserPreferences(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nchannels := channels.Channels{\n Enabled: util.ToPointer(true),\n Name: util.ToPointer(\"name\"),\n}\n\ncategories := channels.Categories{\n Channels: []channels.Channels{channels},\n Key: util.ToPointer(\"key\"),\n Label: util.ToPointer(util.Nullable[string]{ Value: \"label\" }),\n}\n\nrequest := channels.UserPreferences{\n Categories: []channels.Categories{categories},\n}\n\nresponse, err := client.Channels.SaveUserPreferences(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels/web_push/tokens": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := channels.ListWebPushTokensRequestParams{\n\n}\n\nresponse, err := client.Channels.ListWebPushTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/shared\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nwebPushTokenPayloadKeys := shared.WebPushTokenPayloadKeys{\n Auth: util.ToPointer(\"Auth\"),\n P256dh: util.ToPointer(\"P256dh\"),\n}\n\nrequest := shared.WebPushTokenPayload{\n Endpoint: util.ToPointer(\"Endpoint\"),\n Keys: &webPushTokenPayloadKeys,\n}\n\nresponse, err := client.Channels.SaveWebPushToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListWebPushTokensRequestParams{\n Limit: util.ToPointer(int64(9)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListWebPushTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/shared\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nwebPushTokenPayloadKeys := shared.WebPushTokenPayloadKeys{\n Auth: util.ToPointer(\"auth\"),\n P256dh: util.ToPointer(\"p256dh\"),\n}\n\nrequest := shared.WebPushTokenPayload{\n Endpoint: util.ToPointer(\"endpoint\"),\n Keys: &webPushTokenPayloadKeys,\n}\n\nresponse, err := client.Channels.SaveWebPushToken(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/channels/web_push/tokens/{token_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchWebPushToken(context.Background(), \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", - "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteWebPushToken(context.Background(), \"tokenId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.FetchWebPushToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", + "delete": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Channels.DeleteWebPushToken(context.Background(), \"token_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/inbox/installations": { - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nimages := integrations.Images{\n EmptyInboxUrl: util.ToPointer(\"EmptyInboxUrl\"),\n}\n\n\nbanner := integrations.Banner{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n BackgroundOpacity: util.ToPointer(float64(123)),\n FontSize: util.ToPointer(\"FontSize\"),\n TextColor: util.ToPointer(\"TextColor\"),\n}\n\n\ndialog := integrations.Dialog{\n AccentColor: util.ToPointer(\"AccentColor\"),\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n TextColor: util.ToPointer(\"TextColor\"),\n}\n\n\nfooter := integrations.Footer{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n BorderRadius: util.ToPointer(\"BorderRadius\"),\n FontSize: util.ToPointer(\"FontSize\"),\n TextColor: util.ToPointer(\"TextColor\"),\n}\n\n\nheader := integrations.Header{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n BorderRadius: util.ToPointer(\"BorderRadius\"),\n FontFamily: util.ToPointer(\"FontFamily\"),\n FontSize: util.ToPointer(\"FontSize\"),\n TextColor: util.ToPointer(\"TextColor\"),\n}\n\n\nicon := integrations.Icon{\n BorderColor: util.ToPointer(\"BorderColor\"),\n Width: util.ToPointer(\"Width\"),\n}\n\n\ndefaultHover := integrations.DefaultHover{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n}\n\n\ndefaultState := integrations.DefaultState{\n Color: util.ToPointer(\"Color\"),\n}\n\ndefault_ := integrations.Default_{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n BorderRadius: util.ToPointer(\"BorderRadius\"),\n FontFamily: util.ToPointer(\"FontFamily\"),\n FontSize: util.ToPointer(\"FontSize\"),\n Hover: &defaultHover,\n Margin: util.ToPointer(\"Margin\"),\n State: &defaultState,\n TextColor: util.ToPointer(\"TextColor\"),\n}\n\n\nunreadHover := integrations.UnreadHover{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n}\n\n\nunreadState := integrations.UnreadState{\n Color: util.ToPointer(\"Color\"),\n}\n\nunread := integrations.Unread{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n Hover: &unreadHover,\n State: &unreadState,\n TextColor: util.ToPointer(\"TextColor\"),\n}\n\n\nunseenHover := integrations.UnseenHover{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n}\n\n\nunseenState := integrations.UnseenState{\n Color: util.ToPointer(\"Color\"),\n}\n\nunseen := integrations.Unseen{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n Hover: &unseenHover,\n State: &unseenState,\n TextColor: util.ToPointer(\"TextColor\"),\n}\n\nthemeNotification := integrations.ThemeNotification{\n Default_: &default_,\n Unread: &unread,\n Unseen: &unseen,\n}\n\n\nunseenBadge := integrations.UnseenBadge{\n BackgroundColor: util.ToPointer(\"BackgroundColor\"),\n}\n\ntheme := integrations.Theme{\n Banner: &banner,\n Dialog: &dialog,\n Footer: &footer,\n Header: &header,\n Icon: &icon,\n Notification: &themeNotification,\n UnseenBadge: &unseenBadge,\n}\n\nrequest := integrations.InboxConfigPayload{\n Images: &images,\n Locale: util.ToPointer(util.Nullable[string]{ Value: \"Locale\" }),\n Theme: &theme,\n}\n\nresponse, err := client.Integrations.SaveInboxInstallation(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nimages := integrations.Images{\n EmptyInboxUrl: util.ToPointer(\"emptyInboxUrl\"),\n}\n\n\nbanner := integrations.Banner{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n BackgroundOpacity: util.ToPointer(float64(6.42)),\n FontSize: util.ToPointer(\"fontSize\"),\n TextColor: util.ToPointer(\"textColor\"),\n}\n\n\ndialog := integrations.Dialog{\n AccentColor: util.ToPointer(\"accentColor\"),\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n TextColor: util.ToPointer(\"textColor\"),\n}\n\n\nfooter := integrations.Footer{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n BorderRadius: util.ToPointer(\"borderRadius\"),\n FontSize: util.ToPointer(\"fontSize\"),\n TextColor: util.ToPointer(\"textColor\"),\n}\n\n\nheader := integrations.Header{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n BorderRadius: util.ToPointer(\"borderRadius\"),\n FontFamily: util.ToPointer(\"fontFamily\"),\n FontSize: util.ToPointer(\"fontSize\"),\n TextColor: util.ToPointer(\"textColor\"),\n}\n\n\nicon := integrations.Icon{\n BorderColor: util.ToPointer(\"borderColor\"),\n Width: util.ToPointer(\"width\"),\n}\n\n\ndefaultHover := integrations.DefaultHover{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n}\n\n\ndefaultState := integrations.DefaultState{\n Color: util.ToPointer(\"color\"),\n}\n\ndefault_ := integrations.Default_{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n BorderRadius: util.ToPointer(\"borderRadius\"),\n FontFamily: util.ToPointer(\"fontFamily\"),\n FontSize: util.ToPointer(\"fontSize\"),\n Hover: &defaultHover,\n Margin: util.ToPointer(\"margin\"),\n State: &defaultState,\n TextColor: util.ToPointer(\"textColor\"),\n}\n\n\nunreadHover := integrations.UnreadHover{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n}\n\n\nunreadState := integrations.UnreadState{\n Color: util.ToPointer(\"color\"),\n}\n\nunread := integrations.Unread{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n Hover: &unreadHover,\n State: &unreadState,\n TextColor: util.ToPointer(\"textColor\"),\n}\n\n\nunseenHover := integrations.UnseenHover{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n}\n\n\nunseenState := integrations.UnseenState{\n Color: util.ToPointer(\"color\"),\n}\n\nunseen := integrations.Unseen{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n Hover: &unseenHover,\n State: &unseenState,\n TextColor: util.ToPointer(\"textColor\"),\n}\n\nthemeNotification := integrations.ThemeNotification{\n Default_: &default_,\n Unread: &unread,\n Unseen: &unseen,\n}\n\n\nunseenBadge := integrations.UnseenBadge{\n BackgroundColor: util.ToPointer(\"backgroundColor\"),\n}\n\ntheme := integrations.Theme{\n Banner: &banner,\n Dialog: &dialog,\n Footer: &footer,\n Header: &header,\n Icon: &icon,\n Notification: &themeNotification,\n UnseenBadge: &unseenBadge,\n}\n\nrequest := integrations.InboxConfigPayload{\n Images: &images,\n Locale: util.ToPointer(util.Nullable[string]{ Value: \"locale\" }),\n Theme: &theme,\n}\n\nresponse, err := client.Integrations.SaveInboxInstallation(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/inbox/installations/start": { - "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.StartInboxInstallation(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.StartInboxInstallation(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/integrations/magicbell_slackbot/installations": { + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nauthedUser := integrations.AuthedUser{\n AccessToken: util.ToPointer(\"access_token\"),\n ExpiresIn: util.ToPointer(int64(1)),\n Id: util.ToPointer(\"id\"),\n RefreshToken: util.ToPointer(\"refresh_token\"),\n Scope: util.ToPointer(\"scope\"),\n TokenType: util.ToPointer(\"token_type\"),\n}\n\n\nenterprise := integrations.Enterprise{\n Id: util.ToPointer(\"id\"),\n Name: util.ToPointer(\"name\"),\n}\n\n\nincomingWebhook := integrations.IncomingWebhook{\n Channel: util.ToPointer(\"channel\"),\n ConfigurationUrl: util.ToPointer(\"configuration_url\"),\n Url: util.ToPointer(\"url\"),\n}\n\n\nteam := integrations.Team{\n Id: util.ToPointer(\"id\"),\n Name: util.ToPointer(\"name\"),\n}\n\nrequest := integrations.SlackInstallation{\n AccessToken: util.ToPointer(\"access_token\"),\n AppId: util.ToPointer(\"app_id\"),\n AuthedUser: &authedUser,\n BotUserId: util.ToPointer(\"bot_user_id\"),\n Enterprise: &enterprise,\n ExpiresIn: util.ToPointer(int64(2)),\n Id: util.ToPointer(\"318-g~J]11\"),\n IncomingWebhook: &incomingWebhook,\n IsEnterpriseInstall: util.ToPointer(true),\n RefreshToken: util.ToPointer(\"refresh_token\"),\n Scope: util.ToPointer(\"scope\"),\n Team: &team,\n TokenType: util.ToPointer(\"token_type\"),\n}\n\nresponse, err := client.Integrations.SaveMagicbellSlackbotInstallation(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/integrations/magicbell_slackbot/installations/finish": { + "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := integrations.SlackFinishInstallResponse{\n AppId: util.ToPointer(\"app_id\"),\n Code: util.ToPointer(\"code\"),\n RedirectUrl: util.ToPointer(\"redirect_url\"),\n}\n\nresponse, err := client.Integrations.FinishMagicbellSlackbotInstallation(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/integrations/magicbell_slackbot/installations/start": { + "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := integrations.SlackStartInstall{\n AppId: util.ToPointer(\"app_id\"),\n AuthUrl: util.ToPointer(\"auth_url\"),\n ExtraScopes: []string{},\n RedirectUrl: util.ToPointer(\"redirect_url\"),\n}\n\nresponse, err := client.Integrations.StartMagicbellSlackbotInstallation(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/slack/installations": { - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nauthedUser := integrations.AuthedUser{\n AccessToken: util.ToPointer(\"AccessToken\"),\n ExpiresIn: util.ToPointer(int64(123)),\n Id: util.ToPointer(\"Id\"),\n RefreshToken: util.ToPointer(\"RefreshToken\"),\n Scope: util.ToPointer(\"Scope\"),\n TokenType: util.ToPointer(\"TokenType\"),\n}\n\n\nenterprise := integrations.Enterprise{\n Id: util.ToPointer(\"Id\"),\n Name: util.ToPointer(\"Name\"),\n}\n\n\nincomingWebhook := integrations.IncomingWebhook{\n Channel: util.ToPointer(\"Channel\"),\n ConfigurationUrl: util.ToPointer(\"ConfigurationUrl\"),\n Url: util.ToPointer(\"Url\"),\n}\n\n\nteam := integrations.Team{\n Id: util.ToPointer(\"Id\"),\n Name: util.ToPointer(\"Name\"),\n}\n\nrequest := integrations.SlackInstallation{\n AccessToken: util.ToPointer(\"AccessToken\"),\n AppId: util.ToPointer(\"AppId\"),\n AuthedUser: &authedUser,\n BotUserId: util.ToPointer(\"BotUserId\"),\n Enterprise: &enterprise,\n ExpiresIn: util.ToPointer(int64(123)),\n Id: util.ToPointer(\"Id\"),\n IncomingWebhook: &incomingWebhook,\n IsEnterpriseInstall: util.ToPointer(true),\n RefreshToken: util.ToPointer(\"RefreshToken\"),\n Scope: util.ToPointer(\"Scope\"),\n Team: &team,\n TokenType: util.ToPointer(\"TokenType\"),\n}\n\nresponse, err := client.Integrations.SaveSlackInstallation(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nauthedUser := integrations.AuthedUser{\n AccessToken: util.ToPointer(\"access_token\"),\n ExpiresIn: util.ToPointer(int64(1)),\n Id: util.ToPointer(\"id\"),\n RefreshToken: util.ToPointer(\"refresh_token\"),\n Scope: util.ToPointer(\"scope\"),\n TokenType: util.ToPointer(\"token_type\"),\n}\n\n\nenterprise := integrations.Enterprise{\n Id: util.ToPointer(\"id\"),\n Name: util.ToPointer(\"name\"),\n}\n\n\nincomingWebhook := integrations.IncomingWebhook{\n Channel: util.ToPointer(\"channel\"),\n ConfigurationUrl: util.ToPointer(\"configuration_url\"),\n Url: util.ToPointer(\"url\"),\n}\n\n\nteam := integrations.Team{\n Id: util.ToPointer(\"id\"),\n Name: util.ToPointer(\"name\"),\n}\n\nrequest := integrations.SlackInstallation{\n AccessToken: util.ToPointer(\"access_token\"),\n AppId: util.ToPointer(\"app_id\"),\n AuthedUser: &authedUser,\n BotUserId: util.ToPointer(\"bot_user_id\"),\n Enterprise: &enterprise,\n ExpiresIn: util.ToPointer(int64(2)),\n Id: util.ToPointer(\"318-g~J]11\"),\n IncomingWebhook: &incomingWebhook,\n IsEnterpriseInstall: util.ToPointer(true),\n RefreshToken: util.ToPointer(\"refresh_token\"),\n Scope: util.ToPointer(\"scope\"),\n Team: &team,\n TokenType: util.ToPointer(\"token_type\"),\n}\n\nresponse, err := client.Integrations.SaveSlackInstallation(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/slack/installations/finish": { - "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nrequest := integrations.SlackFinishInstallResponse{\n AppId: util.ToPointer(\"AppId\"),\n Code: util.ToPointer(\"Code\"),\n RedirectUrl: util.ToPointer(\"RedirectUrl\"),\n}\n\nresponse, err := client.Integrations.FinishSlackInstallation(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := integrations.SlackFinishInstallResponse{\n AppId: util.ToPointer(\"app_id\"),\n Code: util.ToPointer(\"code\"),\n RedirectUrl: util.ToPointer(\"redirect_url\"),\n}\n\nresponse, err := client.Integrations.FinishSlackInstallation(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/slack/installations/start": { - "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nrequest := integrations.SlackStartInstall{\n AppId: util.ToPointer(\"AppId\"),\n AuthUrl: util.ToPointer(\"AuthUrl\"),\n ExtraScopes: []string{},\n RedirectUrl: util.ToPointer(\"RedirectUrl\"),\n}\n\nresponse, err := client.Integrations.StartSlackInstallation(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/integrations\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nrequest := integrations.SlackStartInstall{\n AppId: util.ToPointer(\"app_id\"),\n AuthUrl: util.ToPointer(\"auth_url\"),\n ExtraScopes: []string{},\n RedirectUrl: util.ToPointer(\"redirect_url\"),\n}\n\nresponse, err := client.Integrations.StartSlackInstallation(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/web_push/installations": { - "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/shared\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nwebPushTokenPayloadKeys := shared.WebPushTokenPayloadKeys{\n Auth: util.ToPointer(\"Auth\"),\n P256dh: util.ToPointer(\"P256dh\"),\n}\n\nrequest := shared.WebPushTokenPayload{\n Endpoint: util.ToPointer(\"Endpoint\"),\n Keys: &webPushTokenPayloadKeys,\n}\n\nresponse, err := client.Integrations.SaveWebPushInstallation(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "put": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/shared\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nwebPushTokenPayloadKeys := shared.WebPushTokenPayloadKeys{\n Auth: util.ToPointer(\"auth\"),\n P256dh: util.ToPointer(\"p256dh\"),\n}\n\nrequest := shared.WebPushTokenPayload{\n Endpoint: util.ToPointer(\"endpoint\"),\n Keys: &webPushTokenPayloadKeys,\n}\n\nresponse, err := client.Integrations.SaveWebPushInstallation(context.Background(), request)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/integrations/web_push/installations/start": { - "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.StartWebPushInstallation(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Integrations.StartWebPushInstallation(context.Background())\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/notifications": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/user-client/notifications\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := notifications.ListNotificationsRequestParams{\n\n}\n\nresponse, err := client.Notifications.ListNotifications(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/notifications\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := notifications.ListNotificationsRequestParams{\n Limit: util.ToPointer(int64(5)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n Status: util.ToPointer(\"status\"),\n Category: util.ToPointer(\"category\"),\n Topic: util.ToPointer(\"topic\"),\n}\n\nresponse, err := client.Notifications.ListNotifications(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/notifications/archive": { - "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/user-client/notifications\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := notifications.ArchiveAllNotificationsRequestParams{\n\n}\n\nresponse, err := client.Notifications.ArchiveAllNotifications(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/notifications\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := notifications.ArchiveAllNotificationsRequestParams{\n Category: util.ToPointer(\"category\"),\n Topic: util.ToPointer(\"topic\"),\n}\n\nresponse, err := client.Notifications.ArchiveAllNotifications(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/notifications/read": { - "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n \"github.com/magicbell/magicbell-go/pkg/user-client/notifications\"\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\n\nparams := notifications.MarkAllNotificationsReadRequestParams{\n\n}\n\nresponse, err := client.Notifications.MarkAllNotificationsRead(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/notifications\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := notifications.MarkAllNotificationsReadRequestParams{\n Category: util.ToPointer(\"category\"),\n Topic: util.ToPointer(\"topic\"),\n}\n\nresponse, err := client.Notifications.MarkAllNotificationsRead(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + }, + "/notifications/unread/count": { + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/notifications\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := notifications.FetchUnreadNotificationsCountRequestParams{\n Category: util.ToPointer(\"category\"),\n Topic: util.ToPointer(\"topic\"),\n}\n\nresponse, err := client.Notifications.FetchUnreadNotificationsCount(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/notifications/{notification_id}": { - "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Notifications.FetchNotification(context.Background(), \"notificationId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "get": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Notifications.FetchNotification(context.Background(), \"notification_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/notifications/{notification_id}/archive": { - "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Notifications.ArchiveNotification(context.Background(), \"notificationId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Notifications.ArchiveNotification(context.Background(), \"notification_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/notifications/{notification_id}/read": { - "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Notifications.MarkNotificationRead(context.Background(), \"notificationId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Notifications.MarkNotificationRead(context.Background(), \"notification_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/notifications/{notification_id}/unarchive": { - "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Notifications.UnarchiveNotification(context.Background(), \"notificationId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Notifications.UnarchiveNotification(context.Background(), \"notification_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" }, "/notifications/{notification_id}/unread": { - "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nclient := client.NewClient(config)\n\nresponse, err := client.Notifications.MarkNotificationUnread(context.Background(), \"notificationId\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" + "post": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\nresponse, err := client.Notifications.MarkNotificationUnread(context.Background(), \"notification_id\")\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n" } }, + "example": "import (\n \"fmt\"\n \"encoding/json\"\n \"context\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/util\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/channels\"\n)\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"ACCESS_TOKEN\")\nclient := client.NewClient(config)\n\n\nparams := channels.ListInboxTokensRequestParams{\n Limit: util.ToPointer(int64(8)),\n StartingAfter: util.ToPointer(\"starting_after\"),\n EndingBefore: util.ToPointer(\"ending_before\"),\n}\n\nresponse, err := client.Channels.ListInboxTokens(context.Background(), params)\nif err != nil {\n panic(err)\n}\n\nfmt.Println(response)\n", "authentication": { "bearer": { "constructor": "import (\n \"github.com/magicbell/magicbell-go/pkg/user-client/client\"\n \"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig\"\n )\n\nconfig := clientconfig.NewConfig()\nconfig.SetAccessToken(\"YOUR-TOKEN\")\n\nsdk := client.NewClient(config)", diff --git a/pkg/project-client/broadcasts/broadcast.go b/pkg/project-client/broadcasts/broadcast.go index eb1d15a..816b13c 100644 --- a/pkg/project-client/broadcasts/broadcast.go +++ b/pkg/project-client/broadcasts/broadcast.go @@ -8,19 +8,28 @@ import ( ) type Broadcast struct { + // The URL recipients will be directed to when interacting with the broadcast. ActionUrl *util.Nullable[string] `json:"action_url,omitempty" maxLength:"2048"` - Category *util.Nullable[string] `json:"category,omitempty" maxLength:"255" pattern:"^[A-Za-z0-9_\.\-/:]+$"` - Content *util.Nullable[string] `json:"content,omitempty" maxLength:"10485760"` + // The label used to group broadcasts. + Category *util.Nullable[string] `json:"category,omitempty" maxLength:"255" pattern:"^[A-Za-z0-9_\.\-/:]+$"` + // The body content delivered with the broadcast. + Content *util.Nullable[string] `json:"content,omitempty" maxLength:"10485760"` // The timestamp when the broadcast was created. - CreatedAt *string `json:"created_at,omitempty"` + CreatedAt *string `json:"created_at,omitempty"` + // Arbitrary custom data associated with the broadcast. CustomAttributes *util.Nullable[any] `json:"custom_attributes,omitempty"` // The unique id for this broadcast. - Id *string `json:"id,omitempty"` - Overrides *util.Nullable[Overrides] `json:"overrides,omitempty"` + Id *string `json:"id,omitempty"` + // Channel- or provider-specific values that override the defaults. + Overrides *util.Nullable[Overrides] `json:"overrides,omitempty"` + // A collection of users or filters that determine who receives the broadcast. Recipients *util.Nullable[[]shared.User] `json:"recipients,omitempty" required:"true" minItems:"1" maxItems:"1000"` - Status *BroadcastStatus `json:"status,omitempty"` - Title *string `json:"title,omitempty" required:"true" maxLength:"255" minLength:"1"` - Topic *util.Nullable[string] `json:"topic,omitempty" maxLength:"255" pattern:"^[A-Za-z0-9_\.\-/:]+$"` + // The runtime state of the broadcast execution. + Status *BroadcastStatus `json:"status,omitempty"` + // The subject or headline that will be shown to recipients. + Title *string `json:"title,omitempty" required:"true" maxLength:"255" minLength:"1"` + // The topic that further classifies the broadcast. + Topic *util.Nullable[string] `json:"topic,omitempty" maxLength:"255" pattern:"^[A-Za-z0-9_\.\-/:]+$"` } func (b *Broadcast) GetActionUrl() *util.Nullable[string] { @@ -183,571 +192,3 @@ func (b Broadcast) String() string { func (b *Broadcast) UnmarshalJSON(data []byte) error { return unmarshal.UnmarshalNullable(data, b) } - -type Overrides struct { - Channels *OverridesChannels `json:"channels,omitempty"` - Providers *Providers `json:"providers,omitempty"` -} - -func (o *Overrides) GetChannels() *OverridesChannels { - if o == nil { - return nil - } - return o.Channels -} - -func (o *Overrides) SetChannels(channels OverridesChannels) { - o.Channels = &channels -} - -func (o *Overrides) GetProviders() *Providers { - if o == nil { - return nil - } - return o.Providers -} - -func (o *Overrides) SetProviders(providers Providers) { - o.Providers = &providers -} - -func (o Overrides) String() string { - jsonData, err := json.MarshalIndent(o, "", " ") - if err != nil { - return "error converting struct: Overrides to string" - } - return string(jsonData) -} - -type OverridesChannels struct { - Email *Email `json:"email,omitempty"` - InApp *InApp `json:"in_app,omitempty"` - MobilePush *MobilePush `json:"mobile_push,omitempty"` - Sms *Sms `json:"sms,omitempty"` -} - -func (o *OverridesChannels) GetEmail() *Email { - if o == nil { - return nil - } - return o.Email -} - -func (o *OverridesChannels) SetEmail(email Email) { - o.Email = &email -} - -func (o *OverridesChannels) GetInApp() *InApp { - if o == nil { - return nil - } - return o.InApp -} - -func (o *OverridesChannels) SetInApp(inApp InApp) { - o.InApp = &inApp -} - -func (o *OverridesChannels) GetMobilePush() *MobilePush { - if o == nil { - return nil - } - return o.MobilePush -} - -func (o *OverridesChannels) SetMobilePush(mobilePush MobilePush) { - o.MobilePush = &mobilePush -} - -func (o *OverridesChannels) GetSms() *Sms { - if o == nil { - return nil - } - return o.Sms -} - -func (o *OverridesChannels) SetSms(sms Sms) { - o.Sms = &sms -} - -func (o OverridesChannels) String() string { - jsonData, err := json.MarshalIndent(o, "", " ") - if err != nil { - return "error converting struct: OverridesChannels to string" - } - return string(jsonData) -} - -type Email struct { - ActionUrl *util.Nullable[string] `json:"action_url,omitempty" maxLength:"2048"` - Content *string `json:"content,omitempty" maxLength:"1048576"` - Title *string `json:"title,omitempty" maxLength:"255" minLength:"1"` -} - -func (e *Email) GetActionUrl() *util.Nullable[string] { - if e == nil { - return nil - } - return e.ActionUrl -} - -func (e *Email) SetActionUrl(actionUrl util.Nullable[string]) { - e.ActionUrl = &actionUrl -} - -func (e *Email) SetActionUrlNull() { - e.ActionUrl = &util.Nullable[string]{IsNull: true} -} - -func (e *Email) GetContent() *string { - if e == nil { - return nil - } - return e.Content -} - -func (e *Email) SetContent(content string) { - e.Content = &content -} - -func (e *Email) GetTitle() *string { - if e == nil { - return nil - } - return e.Title -} - -func (e *Email) SetTitle(title string) { - e.Title = &title -} - -func (e Email) String() string { - jsonData, err := json.MarshalIndent(e, "", " ") - if err != nil { - return "error converting struct: Email to string" - } - return string(jsonData) -} - -func (e *Email) UnmarshalJSON(data []byte) error { - return unmarshal.UnmarshalNullable(data, e) -} - -type InApp struct { - ActionUrl *util.Nullable[string] `json:"action_url,omitempty" maxLength:"2048"` - Content *string `json:"content,omitempty" maxLength:"1048576"` - Title *string `json:"title,omitempty" maxLength:"255" minLength:"1"` -} - -func (i *InApp) GetActionUrl() *util.Nullable[string] { - if i == nil { - return nil - } - return i.ActionUrl -} - -func (i *InApp) SetActionUrl(actionUrl util.Nullable[string]) { - i.ActionUrl = &actionUrl -} - -func (i *InApp) SetActionUrlNull() { - i.ActionUrl = &util.Nullable[string]{IsNull: true} -} - -func (i *InApp) GetContent() *string { - if i == nil { - return nil - } - return i.Content -} - -func (i *InApp) SetContent(content string) { - i.Content = &content -} - -func (i *InApp) GetTitle() *string { - if i == nil { - return nil - } - return i.Title -} - -func (i *InApp) SetTitle(title string) { - i.Title = &title -} - -func (i InApp) String() string { - jsonData, err := json.MarshalIndent(i, "", " ") - if err != nil { - return "error converting struct: InApp to string" - } - return string(jsonData) -} - -func (i *InApp) UnmarshalJSON(data []byte) error { - return unmarshal.UnmarshalNullable(data, i) -} - -type MobilePush struct { - ActionUrl *util.Nullable[string] `json:"action_url,omitempty" maxLength:"2048"` - Content *string `json:"content,omitempty" maxLength:"1048576"` - Title *string `json:"title,omitempty" maxLength:"255" minLength:"1"` -} - -func (m *MobilePush) GetActionUrl() *util.Nullable[string] { - if m == nil { - return nil - } - return m.ActionUrl -} - -func (m *MobilePush) SetActionUrl(actionUrl util.Nullable[string]) { - m.ActionUrl = &actionUrl -} - -func (m *MobilePush) SetActionUrlNull() { - m.ActionUrl = &util.Nullable[string]{IsNull: true} -} - -func (m *MobilePush) GetContent() *string { - if m == nil { - return nil - } - return m.Content -} - -func (m *MobilePush) SetContent(content string) { - m.Content = &content -} - -func (m *MobilePush) GetTitle() *string { - if m == nil { - return nil - } - return m.Title -} - -func (m *MobilePush) SetTitle(title string) { - m.Title = &title -} - -func (m MobilePush) String() string { - jsonData, err := json.MarshalIndent(m, "", " ") - if err != nil { - return "error converting struct: MobilePush to string" - } - return string(jsonData) -} - -func (m *MobilePush) UnmarshalJSON(data []byte) error { - return unmarshal.UnmarshalNullable(data, m) -} - -type Sms struct { - ActionUrl *util.Nullable[string] `json:"action_url,omitempty" maxLength:"2048"` - Content *string `json:"content,omitempty" maxLength:"1048576"` - Title *string `json:"title,omitempty" maxLength:"255" minLength:"1"` -} - -func (s *Sms) GetActionUrl() *util.Nullable[string] { - if s == nil { - return nil - } - return s.ActionUrl -} - -func (s *Sms) SetActionUrl(actionUrl util.Nullable[string]) { - s.ActionUrl = &actionUrl -} - -func (s *Sms) SetActionUrlNull() { - s.ActionUrl = &util.Nullable[string]{IsNull: true} -} - -func (s *Sms) GetContent() *string { - if s == nil { - return nil - } - return s.Content -} - -func (s *Sms) SetContent(content string) { - s.Content = &content -} - -func (s *Sms) GetTitle() *string { - if s == nil { - return nil - } - return s.Title -} - -func (s *Sms) SetTitle(title string) { - s.Title = &title -} - -func (s Sms) String() string { - jsonData, err := json.MarshalIndent(s, "", " ") - if err != nil { - return "error converting struct: Sms to string" - } - return string(jsonData) -} - -func (s *Sms) UnmarshalJSON(data []byte) error { - return unmarshal.UnmarshalNullable(data, s) -} - -type Providers struct { - Apns any `json:"apns,omitempty"` - Expo any `json:"expo,omitempty"` - Fcm any `json:"fcm,omitempty"` - Mailgun any `json:"mailgun,omitempty"` - Sendgrid any `json:"sendgrid,omitempty"` - Ses any `json:"ses,omitempty"` - Slack any `json:"slack,omitempty"` - Teams any `json:"teams,omitempty"` - Twilio any `json:"twilio,omitempty"` - WebPush any `json:"web_push,omitempty"` -} - -func (p *Providers) GetApns() any { - if p == nil { - return nil - } - return p.Apns -} - -func (p *Providers) SetApns(apns any) { - p.Apns = &apns -} - -func (p *Providers) GetExpo() any { - if p == nil { - return nil - } - return p.Expo -} - -func (p *Providers) SetExpo(expo any) { - p.Expo = &expo -} - -func (p *Providers) GetFcm() any { - if p == nil { - return nil - } - return p.Fcm -} - -func (p *Providers) SetFcm(fcm any) { - p.Fcm = &fcm -} - -func (p *Providers) GetMailgun() any { - if p == nil { - return nil - } - return p.Mailgun -} - -func (p *Providers) SetMailgun(mailgun any) { - p.Mailgun = &mailgun -} - -func (p *Providers) GetSendgrid() any { - if p == nil { - return nil - } - return p.Sendgrid -} - -func (p *Providers) SetSendgrid(sendgrid any) { - p.Sendgrid = &sendgrid -} - -func (p *Providers) GetSes() any { - if p == nil { - return nil - } - return p.Ses -} - -func (p *Providers) SetSes(ses any) { - p.Ses = &ses -} - -func (p *Providers) GetSlack() any { - if p == nil { - return nil - } - return p.Slack -} - -func (p *Providers) SetSlack(slack any) { - p.Slack = &slack -} - -func (p *Providers) GetTeams() any { - if p == nil { - return nil - } - return p.Teams -} - -func (p *Providers) SetTeams(teams any) { - p.Teams = &teams -} - -func (p *Providers) GetTwilio() any { - if p == nil { - return nil - } - return p.Twilio -} - -func (p *Providers) SetTwilio(twilio any) { - p.Twilio = &twilio -} - -func (p *Providers) GetWebPush() any { - if p == nil { - return nil - } - return p.WebPush -} - -func (p *Providers) SetWebPush(webPush any) { - p.WebPush = &webPush -} - -func (p Providers) String() string { - jsonData, err := json.MarshalIndent(p, "", " ") - if err != nil { - return "error converting struct: Providers to string" - } - return string(jsonData) -} - -type BroadcastStatus struct { - Errors *util.Nullable[[]Errors] `json:"errors,omitempty" required:"true"` - Status *StatusStatus `json:"status,omitempty" required:"true"` - Summary *Summary `json:"summary,omitempty" required:"true"` -} - -func (b *BroadcastStatus) GetErrors() *util.Nullable[[]Errors] { - if b == nil { - return nil - } - return b.Errors -} - -func (b *BroadcastStatus) SetErrors(errors util.Nullable[[]Errors]) { - b.Errors = &errors -} - -func (b *BroadcastStatus) SetErrorsNull() { - b.Errors = &util.Nullable[[]Errors]{IsNull: true} -} - -func (b *BroadcastStatus) GetStatus() *StatusStatus { - if b == nil { - return nil - } - return b.Status -} - -func (b *BroadcastStatus) SetStatus(status StatusStatus) { - b.Status = &status -} - -func (b *BroadcastStatus) GetSummary() *Summary { - if b == nil { - return nil - } - return b.Summary -} - -func (b *BroadcastStatus) SetSummary(summary Summary) { - b.Summary = &summary -} - -func (b BroadcastStatus) String() string { - jsonData, err := json.MarshalIndent(b, "", " ") - if err != nil { - return "error converting struct: BroadcastStatus to string" - } - return string(jsonData) -} - -func (b *BroadcastStatus) UnmarshalJSON(data []byte) error { - return unmarshal.UnmarshalNullable(data, b) -} - -type Errors struct { - Message *string `json:"message,omitempty"` -} - -func (e *Errors) GetMessage() *string { - if e == nil { - return nil - } - return e.Message -} - -func (e *Errors) SetMessage(message string) { - e.Message = &message -} - -func (e Errors) String() string { - jsonData, err := json.MarshalIndent(e, "", " ") - if err != nil { - return "error converting struct: Errors to string" - } - return string(jsonData) -} - -type StatusStatus string - -const ( - STATUS_STATUS_ENQUEUED StatusStatus = "enqueued" - STATUS_STATUS_PROCESSING StatusStatus = "processing" - STATUS_STATUS_PROCESSED StatusStatus = "processed" -) - -type Summary struct { - // The number of failures while processing the broadcast. - Failures *int64 `json:"failures,omitempty" required:"true"` - // The number of recipients that the broadcast was sent to. - Total *int64 `json:"total,omitempty" required:"true"` -} - -func (s *Summary) GetFailures() *int64 { - if s == nil { - return nil - } - return s.Failures -} - -func (s *Summary) SetFailures(failures int64) { - s.Failures = &failures -} - -func (s *Summary) GetTotal() *int64 { - if s == nil { - return nil - } - return s.Total -} - -func (s *Summary) SetTotal(total int64) { - s.Total = &total -} - -func (s Summary) String() string { - jsonData, err := json.MarshalIndent(s, "", " ") - if err != nil { - return "error converting struct: Summary to string" - } - return string(jsonData) -} diff --git a/pkg/project-client/broadcasts/broadcast_status.go b/pkg/project-client/broadcasts/broadcast_status.go new file mode 100644 index 0000000..44c8e5c --- /dev/null +++ b/pkg/project-client/broadcasts/broadcast_status.go @@ -0,0 +1,66 @@ +package broadcasts + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" + "github.com/magicbell/magicbell-go/pkg/project-client/util" +) + +// The runtime state of the broadcast execution. +type BroadcastStatus struct { + // A list of errors encountered while processing the broadcast. + Errors *util.Nullable[[]Errors] `json:"errors,omitempty" required:"true"` + // The overall processing status of the broadcast. + Status *StatusStatus `json:"status,omitempty" required:"true"` + // The summary counts for total recipients and failures. + Summary *Summary `json:"summary,omitempty" required:"true"` +} + +func (b *BroadcastStatus) GetErrors() *util.Nullable[[]Errors] { + if b == nil { + return nil + } + return b.Errors +} + +func (b *BroadcastStatus) SetErrors(errors util.Nullable[[]Errors]) { + b.Errors = &errors +} + +func (b *BroadcastStatus) SetErrorsNull() { + b.Errors = &util.Nullable[[]Errors]{IsNull: true} +} + +func (b *BroadcastStatus) GetStatus() *StatusStatus { + if b == nil { + return nil + } + return b.Status +} + +func (b *BroadcastStatus) SetStatus(status StatusStatus) { + b.Status = &status +} + +func (b *BroadcastStatus) GetSummary() *Summary { + if b == nil { + return nil + } + return b.Summary +} + +func (b *BroadcastStatus) SetSummary(summary Summary) { + b.Summary = &summary +} + +func (b BroadcastStatus) String() string { + jsonData, err := json.MarshalIndent(b, "", " ") + if err != nil { + return "error converting struct: BroadcastStatus to string" + } + return string(jsonData) +} + +func (b *BroadcastStatus) UnmarshalJSON(data []byte) error { + return unmarshal.UnmarshalNullable(data, b) +} diff --git a/pkg/project-client/broadcasts/broadcasts_service.go b/pkg/project-client/broadcasts/broadcasts_service.go index 30849cb..ef1e60d 100644 --- a/pkg/project-client/broadcasts/broadcasts_service.go +++ b/pkg/project-client/broadcasts/broadcasts_service.go @@ -3,6 +3,7 @@ package broadcasts import ( "context" restClient "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/hooks" "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/httptransport" "github.com/magicbell/magicbell-go/pkg/project-client/internal/configmanager" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" @@ -10,8 +11,11 @@ import ( "time" ) +// BroadcastsService provides methods to interact with BroadcastsService-related API endpoints. +// It uses a configuration manager for settings and supports custom hooks for request/response interception. type BroadcastsService struct { manager *configmanager.ConfigManager + hook hooks.Hook } func NewBroadcastsService() *BroadcastsService { @@ -20,15 +24,28 @@ func NewBroadcastsService() *BroadcastsService { } } +// WithConfigManager sets the configuration manager for this service. +// Returns the service instance for method chaining. func (api *BroadcastsService) WithConfigManager(manager *configmanager.ConfigManager) *BroadcastsService { api.manager = manager return api } +// WithHook sets a custom hook for request/response interception. +// Returns the service instance for method chaining. +func (api *BroadcastsService) WithHook(hook hooks.Hook) *BroadcastsService { + api.hook = hook + return api +} + func (api *BroadcastsService) getConfig() *clientconfig.Config { return api.manager.GetBroadcasts() } +func (api *BroadcastsService) getHook() hooks.Hook { + return api.hook +} + func (api *BroadcastsService) SetBaseUrl(baseUrl string) { config := api.getConfig() config.SetBaseUrl(baseUrl) @@ -45,7 +62,7 @@ func (api *BroadcastsService) SetAccessToken(accessToken string) { } // Retrieves a paginated list of broadcasts for the project. Returns basic information about each broadcast including its creation time and status. -func (api *BroadcastsService) ListBroadcasts(ctx context.Context, params ListBroadcastsRequestParams) (*shared.ClientResponse[BroadcastCollection], *shared.ClientError) { +func (api *BroadcastsService) ListBroadcasts(ctx context.Context, params ListBroadcastsRequestParams) (*shared.ClientResponse[BroadcastCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -57,17 +74,17 @@ func (api *BroadcastsService) ListBroadcasts(ctx context.Context, params ListBro WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[BroadcastCollection](config) + client := restClient.NewRestClient[BroadcastCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[BroadcastCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[BroadcastCollection](resp), nil } // Creates a new broadcast. When a broadcast is created, it generates individual notifications for relevant users within the project. -func (api *BroadcastsService) CreateBroadcast(ctx context.Context, broadcast Broadcast) (*shared.ClientResponse[Broadcast], *shared.ClientError) { +func (api *BroadcastsService) CreateBroadcast(ctx context.Context, broadcast Broadcast) (*shared.ClientResponse[Broadcast], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -80,17 +97,17 @@ func (api *BroadcastsService) CreateBroadcast(ctx context.Context, broadcast Bro WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[Broadcast](config) + client := restClient.NewRestClient[Broadcast, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[Broadcast](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[Broadcast](resp), nil } // Retrieves detailed information about a specific broadcast by its ID. Includes the broadcast's configuration and current status. -func (api *BroadcastsService) FetchBroadcast(ctx context.Context, broadcastId string) (*shared.ClientResponse[Broadcast], *shared.ClientError) { +func (api *BroadcastsService) FetchBroadcast(ctx context.Context, broadcastId string) (*shared.ClientResponse[Broadcast], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -102,10 +119,10 @@ func (api *BroadcastsService) FetchBroadcast(ctx context.Context, broadcastId st WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[Broadcast](config) + client := restClient.NewRestClient[Broadcast, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[Broadcast](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[Broadcast](resp), nil diff --git a/pkg/project-client/broadcasts/email.go b/pkg/project-client/broadcasts/email.go new file mode 100644 index 0000000..fa18641 --- /dev/null +++ b/pkg/project-client/broadcasts/email.go @@ -0,0 +1,66 @@ +package broadcasts + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" + "github.com/magicbell/magicbell-go/pkg/project-client/util" +) + +// Overrides for email notifications. +type Email struct { + // The link associated with the channel-specific notification. + ActionUrl *util.Nullable[string] `json:"action_url,omitempty" maxLength:"2048"` + // The channel-specific content. + Content *string `json:"content,omitempty" maxLength:"1048576"` + // The channel-specific title. + Title *string `json:"title,omitempty" maxLength:"255" minLength:"1"` +} + +func (e *Email) GetActionUrl() *util.Nullable[string] { + if e == nil { + return nil + } + return e.ActionUrl +} + +func (e *Email) SetActionUrl(actionUrl util.Nullable[string]) { + e.ActionUrl = &actionUrl +} + +func (e *Email) SetActionUrlNull() { + e.ActionUrl = &util.Nullable[string]{IsNull: true} +} + +func (e *Email) GetContent() *string { + if e == nil { + return nil + } + return e.Content +} + +func (e *Email) SetContent(content string) { + e.Content = &content +} + +func (e *Email) GetTitle() *string { + if e == nil { + return nil + } + return e.Title +} + +func (e *Email) SetTitle(title string) { + e.Title = &title +} + +func (e Email) String() string { + jsonData, err := json.MarshalIndent(e, "", " ") + if err != nil { + return "error converting struct: Email to string" + } + return string(jsonData) +} + +func (e *Email) UnmarshalJSON(data []byte) error { + return unmarshal.UnmarshalNullable(data, e) +} diff --git a/pkg/project-client/broadcasts/errors.go b/pkg/project-client/broadcasts/errors.go new file mode 100644 index 0000000..dda9fb1 --- /dev/null +++ b/pkg/project-client/broadcasts/errors.go @@ -0,0 +1,27 @@ +package broadcasts + +import "encoding/json" + +type Errors struct { + // The details about the processing error. + Message *string `json:"message,omitempty"` +} + +func (e *Errors) GetMessage() *string { + if e == nil { + return nil + } + return e.Message +} + +func (e *Errors) SetMessage(message string) { + e.Message = &message +} + +func (e Errors) String() string { + jsonData, err := json.MarshalIndent(e, "", " ") + if err != nil { + return "error converting struct: Errors to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/broadcasts/in_app.go b/pkg/project-client/broadcasts/in_app.go new file mode 100644 index 0000000..0d9782f --- /dev/null +++ b/pkg/project-client/broadcasts/in_app.go @@ -0,0 +1,66 @@ +package broadcasts + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" + "github.com/magicbell/magicbell-go/pkg/project-client/util" +) + +// Overrides for in-app notifications. +type InApp struct { + // The link associated with the channel-specific notification. + ActionUrl *util.Nullable[string] `json:"action_url,omitempty" maxLength:"2048"` + // The channel-specific content. + Content *string `json:"content,omitempty" maxLength:"1048576"` + // The channel-specific title. + Title *string `json:"title,omitempty" maxLength:"255" minLength:"1"` +} + +func (i *InApp) GetActionUrl() *util.Nullable[string] { + if i == nil { + return nil + } + return i.ActionUrl +} + +func (i *InApp) SetActionUrl(actionUrl util.Nullable[string]) { + i.ActionUrl = &actionUrl +} + +func (i *InApp) SetActionUrlNull() { + i.ActionUrl = &util.Nullable[string]{IsNull: true} +} + +func (i *InApp) GetContent() *string { + if i == nil { + return nil + } + return i.Content +} + +func (i *InApp) SetContent(content string) { + i.Content = &content +} + +func (i *InApp) GetTitle() *string { + if i == nil { + return nil + } + return i.Title +} + +func (i *InApp) SetTitle(title string) { + i.Title = &title +} + +func (i InApp) String() string { + jsonData, err := json.MarshalIndent(i, "", " ") + if err != nil { + return "error converting struct: InApp to string" + } + return string(jsonData) +} + +func (i *InApp) UnmarshalJSON(data []byte) error { + return unmarshal.UnmarshalNullable(data, i) +} diff --git a/pkg/project-client/broadcasts/mobile_push.go b/pkg/project-client/broadcasts/mobile_push.go new file mode 100644 index 0000000..2a36ec6 --- /dev/null +++ b/pkg/project-client/broadcasts/mobile_push.go @@ -0,0 +1,66 @@ +package broadcasts + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" + "github.com/magicbell/magicbell-go/pkg/project-client/util" +) + +// Overrides for mobile push notifications. +type MobilePush struct { + // The link associated with the channel-specific notification. + ActionUrl *util.Nullable[string] `json:"action_url,omitempty" maxLength:"2048"` + // The channel-specific content. + Content *string `json:"content,omitempty" maxLength:"1048576"` + // The channel-specific title. + Title *string `json:"title,omitempty" maxLength:"255" minLength:"1"` +} + +func (m *MobilePush) GetActionUrl() *util.Nullable[string] { + if m == nil { + return nil + } + return m.ActionUrl +} + +func (m *MobilePush) SetActionUrl(actionUrl util.Nullable[string]) { + m.ActionUrl = &actionUrl +} + +func (m *MobilePush) SetActionUrlNull() { + m.ActionUrl = &util.Nullable[string]{IsNull: true} +} + +func (m *MobilePush) GetContent() *string { + if m == nil { + return nil + } + return m.Content +} + +func (m *MobilePush) SetContent(content string) { + m.Content = &content +} + +func (m *MobilePush) GetTitle() *string { + if m == nil { + return nil + } + return m.Title +} + +func (m *MobilePush) SetTitle(title string) { + m.Title = &title +} + +func (m MobilePush) String() string { + jsonData, err := json.MarshalIndent(m, "", " ") + if err != nil { + return "error converting struct: MobilePush to string" + } + return string(jsonData) +} + +func (m *MobilePush) UnmarshalJSON(data []byte) error { + return unmarshal.UnmarshalNullable(data, m) +} diff --git a/pkg/project-client/broadcasts/overrides.go b/pkg/project-client/broadcasts/overrides.go new file mode 100644 index 0000000..2f1202c --- /dev/null +++ b/pkg/project-client/broadcasts/overrides.go @@ -0,0 +1,41 @@ +package broadcasts + +import "encoding/json" + +// Channel- or provider-specific values that override the defaults. +type Overrides struct { + // Overrides that are scoped to individual delivery channels. + Channels *OverridesChannels `json:"channels,omitempty"` + // Overrides that are scoped to specific providers for a channel. + Providers *Providers `json:"providers,omitempty"` +} + +func (o *Overrides) GetChannels() *OverridesChannels { + if o == nil { + return nil + } + return o.Channels +} + +func (o *Overrides) SetChannels(channels OverridesChannels) { + o.Channels = &channels +} + +func (o *Overrides) GetProviders() *Providers { + if o == nil { + return nil + } + return o.Providers +} + +func (o *Overrides) SetProviders(providers Providers) { + o.Providers = &providers +} + +func (o Overrides) String() string { + jsonData, err := json.MarshalIndent(o, "", " ") + if err != nil { + return "error converting struct: Overrides to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/broadcasts/overrides_channels.go b/pkg/project-client/broadcasts/overrides_channels.go new file mode 100644 index 0000000..b9be267 --- /dev/null +++ b/pkg/project-client/broadcasts/overrides_channels.go @@ -0,0 +1,67 @@ +package broadcasts + +import "encoding/json" + +// Overrides that are scoped to individual delivery channels. +type OverridesChannels struct { + // Overrides for email notifications. + Email *Email `json:"email,omitempty"` + // Overrides for in-app notifications. + InApp *InApp `json:"in_app,omitempty"` + // Overrides for mobile push notifications. + MobilePush *MobilePush `json:"mobile_push,omitempty"` + // Overrides for SMS notifications. + Sms *Sms `json:"sms,omitempty"` +} + +func (o *OverridesChannels) GetEmail() *Email { + if o == nil { + return nil + } + return o.Email +} + +func (o *OverridesChannels) SetEmail(email Email) { + o.Email = &email +} + +func (o *OverridesChannels) GetInApp() *InApp { + if o == nil { + return nil + } + return o.InApp +} + +func (o *OverridesChannels) SetInApp(inApp InApp) { + o.InApp = &inApp +} + +func (o *OverridesChannels) GetMobilePush() *MobilePush { + if o == nil { + return nil + } + return o.MobilePush +} + +func (o *OverridesChannels) SetMobilePush(mobilePush MobilePush) { + o.MobilePush = &mobilePush +} + +func (o *OverridesChannels) GetSms() *Sms { + if o == nil { + return nil + } + return o.Sms +} + +func (o *OverridesChannels) SetSms(sms Sms) { + o.Sms = &sms +} + +func (o OverridesChannels) String() string { + jsonData, err := json.MarshalIndent(o, "", " ") + if err != nil { + return "error converting struct: OverridesChannels to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/broadcasts/providers.go b/pkg/project-client/broadcasts/providers.go new file mode 100644 index 0000000..869d0a6 --- /dev/null +++ b/pkg/project-client/broadcasts/providers.go @@ -0,0 +1,145 @@ +package broadcasts + +import "encoding/json" + +// Overrides that are scoped to specific providers for a channel. +type Providers struct { + // Provider-specific overrides for Apple Push Notification service. + Apns any `json:"apns,omitempty"` + // Provider-specific overrides for Expo push notifications. + Expo any `json:"expo,omitempty"` + // Provider-specific overrides for Firebase Cloud Messaging. + Fcm any `json:"fcm,omitempty"` + // Provider-specific overrides for Mailgun. + Mailgun any `json:"mailgun,omitempty"` + // Provider-specific overrides for Sendgrid. + Sendgrid any `json:"sendgrid,omitempty"` + // Provider-specific overrides for AWS SES. + Ses any `json:"ses,omitempty"` + // Provider-specific overrides for Slack. + Slack any `json:"slack,omitempty"` + // Provider-specific overrides for Microsoft Teams. + Teams any `json:"teams,omitempty"` + // Provider-specific overrides for Twilio. + Twilio any `json:"twilio,omitempty"` + // Provider-specific overrides for the web push provider. + WebPush any `json:"web_push,omitempty"` +} + +func (p *Providers) GetApns() any { + if p == nil { + return nil + } + return p.Apns +} + +func (p *Providers) SetApns(apns any) { + p.Apns = &apns +} + +func (p *Providers) GetExpo() any { + if p == nil { + return nil + } + return p.Expo +} + +func (p *Providers) SetExpo(expo any) { + p.Expo = &expo +} + +func (p *Providers) GetFcm() any { + if p == nil { + return nil + } + return p.Fcm +} + +func (p *Providers) SetFcm(fcm any) { + p.Fcm = &fcm +} + +func (p *Providers) GetMailgun() any { + if p == nil { + return nil + } + return p.Mailgun +} + +func (p *Providers) SetMailgun(mailgun any) { + p.Mailgun = &mailgun +} + +func (p *Providers) GetSendgrid() any { + if p == nil { + return nil + } + return p.Sendgrid +} + +func (p *Providers) SetSendgrid(sendgrid any) { + p.Sendgrid = &sendgrid +} + +func (p *Providers) GetSes() any { + if p == nil { + return nil + } + return p.Ses +} + +func (p *Providers) SetSes(ses any) { + p.Ses = &ses +} + +func (p *Providers) GetSlack() any { + if p == nil { + return nil + } + return p.Slack +} + +func (p *Providers) SetSlack(slack any) { + p.Slack = &slack +} + +func (p *Providers) GetTeams() any { + if p == nil { + return nil + } + return p.Teams +} + +func (p *Providers) SetTeams(teams any) { + p.Teams = &teams +} + +func (p *Providers) GetTwilio() any { + if p == nil { + return nil + } + return p.Twilio +} + +func (p *Providers) SetTwilio(twilio any) { + p.Twilio = &twilio +} + +func (p *Providers) GetWebPush() any { + if p == nil { + return nil + } + return p.WebPush +} + +func (p *Providers) SetWebPush(webPush any) { + p.WebPush = &webPush +} + +func (p Providers) String() string { + jsonData, err := json.MarshalIndent(p, "", " ") + if err != nil { + return "error converting struct: Providers to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/broadcasts/request_params.go b/pkg/project-client/broadcasts/request_params.go index 8724273..f570d24 100644 --- a/pkg/project-client/broadcasts/request_params.go +++ b/pkg/project-client/broadcasts/request_params.go @@ -1,17 +1,24 @@ package broadcasts +// ListBroadcastsRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListBroadcastsRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListBroadcastsRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListBroadcastsRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListBroadcastsRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } diff --git a/pkg/project-client/broadcasts/sms.go b/pkg/project-client/broadcasts/sms.go new file mode 100644 index 0000000..f73db9b --- /dev/null +++ b/pkg/project-client/broadcasts/sms.go @@ -0,0 +1,66 @@ +package broadcasts + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" + "github.com/magicbell/magicbell-go/pkg/project-client/util" +) + +// Overrides for SMS notifications. +type Sms struct { + // The link associated with the channel-specific notification. + ActionUrl *util.Nullable[string] `json:"action_url,omitempty" maxLength:"2048"` + // The channel-specific content. + Content *string `json:"content,omitempty" maxLength:"1048576"` + // The channel-specific title. + Title *string `json:"title,omitempty" maxLength:"255" minLength:"1"` +} + +func (s *Sms) GetActionUrl() *util.Nullable[string] { + if s == nil { + return nil + } + return s.ActionUrl +} + +func (s *Sms) SetActionUrl(actionUrl util.Nullable[string]) { + s.ActionUrl = &actionUrl +} + +func (s *Sms) SetActionUrlNull() { + s.ActionUrl = &util.Nullable[string]{IsNull: true} +} + +func (s *Sms) GetContent() *string { + if s == nil { + return nil + } + return s.Content +} + +func (s *Sms) SetContent(content string) { + s.Content = &content +} + +func (s *Sms) GetTitle() *string { + if s == nil { + return nil + } + return s.Title +} + +func (s *Sms) SetTitle(title string) { + s.Title = &title +} + +func (s Sms) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: Sms to string" + } + return string(jsonData) +} + +func (s *Sms) UnmarshalJSON(data []byte) error { + return unmarshal.UnmarshalNullable(data, s) +} diff --git a/pkg/project-client/broadcasts/status_status.go b/pkg/project-client/broadcasts/status_status.go new file mode 100644 index 0000000..a687b7f --- /dev/null +++ b/pkg/project-client/broadcasts/status_status.go @@ -0,0 +1,10 @@ +package broadcasts + +// The overall processing status of the broadcast. +type StatusStatus string + +const ( + STATUS_STATUS_ENQUEUED StatusStatus = "enqueued" + STATUS_STATUS_PROCESSING StatusStatus = "processing" + STATUS_STATUS_PROCESSED StatusStatus = "processed" +) diff --git a/pkg/project-client/broadcasts/summary.go b/pkg/project-client/broadcasts/summary.go new file mode 100644 index 0000000..70d728a --- /dev/null +++ b/pkg/project-client/broadcasts/summary.go @@ -0,0 +1,41 @@ +package broadcasts + +import "encoding/json" + +// The summary counts for total recipients and failures. +type Summary struct { + // The number of failures while processing the broadcast. + Failures *int64 `json:"failures,omitempty" required:"true"` + // The number of recipients that the broadcast was sent to. + Total *int64 `json:"total,omitempty" required:"true"` +} + +func (s *Summary) GetFailures() *int64 { + if s == nil { + return nil + } + return s.Failures +} + +func (s *Summary) SetFailures(failures int64) { + s.Failures = &failures +} + +func (s *Summary) GetTotal() *int64 { + if s == nil { + return nil + } + return s.Total +} + +func (s *Summary) SetTotal(total int64) { + s.Total = &total +} + +func (s Summary) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: Summary to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/channels/apns_token.go b/pkg/project-client/channels/apns_token.go index cf9a4f9..0ac2256 100644 --- a/pkg/project-client/channels/apns_token.go +++ b/pkg/project-client/channels/apns_token.go @@ -7,15 +7,20 @@ import ( ) type ApnsToken struct { - // (Optional) The bundle identifier of the application that is registering this token. Use this field to override the default identifier specified in the projects APNs integration. - AppId *string `json:"app_id,omitempty" pattern:"^[a-zA-Z0-9]+(.[a-zA-Z0-9]+)*$"` - CreatedAt *string `json:"created_at,omitempty" required:"true"` - DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"64"` + // The bundle identifier of the application registering this token. Use this to override the default identifier configured on the APNs integration. + AppId *string `json:"app_id,omitempty" pattern:"^[a-zA-Z0-9]+(.[a-zA-Z0-9]+)*$"` + // The timestamp when the token was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The APNs device token to register with MagicBell. + DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"64"` + // The timestamp when the token was discarded, if applicable. DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - // (Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in `production`. - InstallationId *ApnsTokenInstallationId `json:"installation_id,omitempty"` - UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` + // The unique identifier for the token. + Id *string `json:"id,omitempty" required:"true"` + // The APNs environment this token belongs to. If omitted we assume it targets `production`. + InstallationId *InstallationId `json:"installation_id,omitempty"` + // The timestamp when the token metadata last changed. + UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` } func (a *ApnsToken) GetAppId() *string { @@ -77,14 +82,14 @@ func (a *ApnsToken) SetId(id string) { a.Id = &id } -func (a *ApnsToken) GetInstallationId() *ApnsTokenInstallationId { +func (a *ApnsToken) GetInstallationId() *InstallationId { if a == nil { return nil } return a.InstallationId } -func (a *ApnsToken) SetInstallationId(installationId ApnsTokenInstallationId) { +func (a *ApnsToken) SetInstallationId(installationId InstallationId) { a.InstallationId = &installationId } @@ -114,11 +119,3 @@ func (a ApnsToken) String() string { func (a *ApnsToken) UnmarshalJSON(data []byte) error { return unmarshal.UnmarshalNullable(data, a) } - -// (Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in `production`. -type ApnsTokenInstallationId string - -const ( - APNS_TOKEN_INSTALLATION_ID_DEVELOPMENT ApnsTokenInstallationId = "development" - APNS_TOKEN_INSTALLATION_ID_PRODUCTION ApnsTokenInstallationId = "production" -) diff --git a/pkg/project-client/channels/category_delivery_config.go b/pkg/project-client/channels/category_delivery_config.go index 993b187..7bbe175 100644 --- a/pkg/project-client/channels/category_delivery_config.go +++ b/pkg/project-client/channels/category_delivery_config.go @@ -1,15 +1,14 @@ package channels -import ( - "encoding/json" - "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" - "github.com/magicbell/magicbell-go/pkg/project-client/util" -) +import "encoding/json" type CategoryDeliveryConfig struct { + // Ordered channel steps the delivery planner should execute. Channels []CategoryDeliveryConfigChannels `json:"channels,omitempty" required:"true"` - Disabled *bool `json:"disabled,omitempty"` - Key *string `json:"key,omitempty" required:"true" minLength:"3" pattern:"^[A-Za-z0-9_.\-:/]+$"` + // Disables the plan so it cannot be executed. + Disabled *bool `json:"disabled,omitempty"` + // Unique identifier for this delivery plan. + Key *string `json:"key,omitempty" required:"true" minLength:"3" pattern:"^[A-Za-z0-9_.\-:/]+$"` } func (c *CategoryDeliveryConfig) GetChannels() []CategoryDeliveryConfigChannels { @@ -52,70 +51,3 @@ func (c CategoryDeliveryConfig) String() string { } return string(jsonData) } - -type CategoryDeliveryConfigChannels struct { - Channel *Channel `json:"channel,omitempty" required:"true"` - Delay *int64 `json:"delay,omitempty" min:"0"` - If_ *util.Nullable[string] `json:"if,omitempty"` -} - -func (c *CategoryDeliveryConfigChannels) GetChannel() *Channel { - if c == nil { - return nil - } - return c.Channel -} - -func (c *CategoryDeliveryConfigChannels) SetChannel(channel Channel) { - c.Channel = &channel -} - -func (c *CategoryDeliveryConfigChannels) GetDelay() *int64 { - if c == nil { - return nil - } - return c.Delay -} - -func (c *CategoryDeliveryConfigChannels) SetDelay(delay int64) { - c.Delay = &delay -} - -func (c *CategoryDeliveryConfigChannels) GetIf_() *util.Nullable[string] { - if c == nil { - return nil - } - return c.If_ -} - -func (c *CategoryDeliveryConfigChannels) SetIf_(if_ util.Nullable[string]) { - c.If_ = &if_ -} - -func (c *CategoryDeliveryConfigChannels) SetIf_Null() { - c.If_ = &util.Nullable[string]{IsNull: true} -} - -func (c CategoryDeliveryConfigChannels) String() string { - jsonData, err := json.MarshalIndent(c, "", " ") - if err != nil { - return "error converting struct: CategoryDeliveryConfigChannels to string" - } - return string(jsonData) -} - -func (c *CategoryDeliveryConfigChannels) UnmarshalJSON(data []byte) error { - return unmarshal.UnmarshalNullable(data, c) -} - -type Channel string - -const ( - CHANNEL_IN_APP Channel = "in_app" - CHANNEL_SLACK Channel = "slack" - CHANNEL_WEB_PUSH Channel = "web_push" - CHANNEL_MOBILE_PUSH Channel = "mobile_push" - CHANNEL_TEAMS Channel = "teams" - CHANNEL_EMAIL Channel = "email" - CHANNEL_SMS Channel = "sms" -) diff --git a/pkg/project-client/channels/category_delivery_config_channels.go b/pkg/project-client/channels/category_delivery_config_channels.go new file mode 100644 index 0000000..7e999a9 --- /dev/null +++ b/pkg/project-client/channels/category_delivery_config_channels.go @@ -0,0 +1,65 @@ +package channels + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" + "github.com/magicbell/magicbell-go/pkg/project-client/util" +) + +type CategoryDeliveryConfigChannels struct { + // Name of the channel used for this step. + Channel *Channel `json:"channel,omitempty" required:"true"` + // Delay in seconds to wait after the previous step. + Delay *int64 `json:"delay,omitempty" min:"0"` + // Conditional expression evaluated before running the step. + If_ *util.Nullable[string] `json:"if,omitempty"` +} + +func (c *CategoryDeliveryConfigChannels) GetChannel() *Channel { + if c == nil { + return nil + } + return c.Channel +} + +func (c *CategoryDeliveryConfigChannels) SetChannel(channel Channel) { + c.Channel = &channel +} + +func (c *CategoryDeliveryConfigChannels) GetDelay() *int64 { + if c == nil { + return nil + } + return c.Delay +} + +func (c *CategoryDeliveryConfigChannels) SetDelay(delay int64) { + c.Delay = &delay +} + +func (c *CategoryDeliveryConfigChannels) GetIf_() *util.Nullable[string] { + if c == nil { + return nil + } + return c.If_ +} + +func (c *CategoryDeliveryConfigChannels) SetIf_(if_ util.Nullable[string]) { + c.If_ = &if_ +} + +func (c *CategoryDeliveryConfigChannels) SetIf_Null() { + c.If_ = &util.Nullable[string]{IsNull: true} +} + +func (c CategoryDeliveryConfigChannels) String() string { + jsonData, err := json.MarshalIndent(c, "", " ") + if err != nil { + return "error converting struct: CategoryDeliveryConfigChannels to string" + } + return string(jsonData) +} + +func (c *CategoryDeliveryConfigChannels) UnmarshalJSON(data []byte) error { + return unmarshal.UnmarshalNullable(data, c) +} diff --git a/pkg/project-client/channels/channel.go b/pkg/project-client/channels/channel.go new file mode 100644 index 0000000..4211a0e --- /dev/null +++ b/pkg/project-client/channels/channel.go @@ -0,0 +1,14 @@ +package channels + +// Name of the channel used for this step. +type Channel string + +const ( + CHANNEL_IN_APP Channel = "in_app" + CHANNEL_SLACK Channel = "slack" + CHANNEL_WEB_PUSH Channel = "web_push" + CHANNEL_MOBILE_PUSH Channel = "mobile_push" + CHANNEL_TEAMS Channel = "teams" + CHANNEL_EMAIL Channel = "email" + CHANNEL_SMS Channel = "sms" +) diff --git a/pkg/project-client/channels/channels_service.go b/pkg/project-client/channels/channels_service.go index 5ac1903..2b4e5d9 100644 --- a/pkg/project-client/channels/channels_service.go +++ b/pkg/project-client/channels/channels_service.go @@ -3,6 +3,7 @@ package channels import ( "context" restClient "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/hooks" "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/httptransport" "github.com/magicbell/magicbell-go/pkg/project-client/internal/configmanager" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" @@ -10,8 +11,11 @@ import ( "time" ) +// ChannelsService provides methods to interact with ChannelsService-related API endpoints. +// It uses a configuration manager for settings and supports custom hooks for request/response interception. type ChannelsService struct { manager *configmanager.ConfigManager + hook hooks.Hook } func NewChannelsService() *ChannelsService { @@ -20,15 +24,28 @@ func NewChannelsService() *ChannelsService { } } +// WithConfigManager sets the configuration manager for this service. +// Returns the service instance for method chaining. func (api *ChannelsService) WithConfigManager(manager *configmanager.ConfigManager) *ChannelsService { api.manager = manager return api } +// WithHook sets a custom hook for request/response interception. +// Returns the service instance for method chaining. +func (api *ChannelsService) WithHook(hook hooks.Hook) *ChannelsService { + api.hook = hook + return api +} + func (api *ChannelsService) getConfig() *clientconfig.Config { return api.manager.GetChannels() } +func (api *ChannelsService) getHook() hooks.Hook { + return api.hook +} + func (api *ChannelsService) SetBaseUrl(baseUrl string) { config := api.getConfig() config.SetBaseUrl(baseUrl) @@ -45,7 +62,7 @@ func (api *ChannelsService) SetAccessToken(accessToken string) { } // Save the channels configuration for a given key. -func (api *ChannelsService) SaveChannelsConfig(ctx context.Context, categoryDeliveryConfig CategoryDeliveryConfig) (*shared.ClientResponse[CategoryDeliveryConfig], *shared.ClientError) { +func (api *ChannelsService) SaveChannelsConfig(ctx context.Context, categoryDeliveryConfig CategoryDeliveryConfig) (*shared.ClientResponse[CategoryDeliveryConfig], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -58,17 +75,17 @@ func (api *ChannelsService) SaveChannelsConfig(ctx context.Context, categoryDeli WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[CategoryDeliveryConfig](config) + client := restClient.NewRestClient[CategoryDeliveryConfig, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[CategoryDeliveryConfig](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[CategoryDeliveryConfig](resp), nil } // Fetches the channels config for a given key. -func (api *ChannelsService) FetchChannelsConfig(ctx context.Context, key string) (*shared.ClientResponse[CategoryDeliveryConfig], *shared.ClientError) { +func (api *ChannelsService) FetchChannelsConfig(ctx context.Context, key string) (*shared.ClientResponse[CategoryDeliveryConfig], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -80,17 +97,17 @@ func (api *ChannelsService) FetchChannelsConfig(ctx context.Context, key string) WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[CategoryDeliveryConfig](config) + client := restClient.NewRestClient[CategoryDeliveryConfig, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[CategoryDeliveryConfig](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[CategoryDeliveryConfig](resp), nil } // Lists all Inbox tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. -func (api *ChannelsService) ListUserInboxTokens(ctx context.Context, userId string, params ListUserInboxTokensRequestParams) (*shared.ClientResponse[InboxTokenResponseCollection], *shared.ClientError) { +func (api *ChannelsService) ListUserInboxTokens(ctx context.Context, userId string, params ListUserInboxTokensRequestParams) (*shared.ClientResponse[InboxTokenResponseCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -103,17 +120,17 @@ func (api *ChannelsService) ListUserInboxTokens(ctx context.Context, userId stri WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[InboxTokenResponseCollection](config) + client := restClient.NewRestClient[InboxTokenResponseCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[InboxTokenResponseCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[InboxTokenResponseCollection](resp), nil } // Fetches a specific Inbox token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. -func (api *ChannelsService) FetchUserInboxToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[InboxTokenResponse], *shared.ClientError) { +func (api *ChannelsService) FetchUserInboxToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[InboxTokenResponse], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -126,17 +143,17 @@ func (api *ChannelsService) FetchUserInboxToken(ctx context.Context, userId stri WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[InboxTokenResponse](config) + client := restClient.NewRestClient[InboxTokenResponse, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[InboxTokenResponse](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[InboxTokenResponse](resp), nil } // Deletes a specific user's Inbox token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. -func (api *ChannelsService) DeleteUserInboxToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError) { +func (api *ChannelsService) DeleteUserInboxToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -149,17 +166,17 @@ func (api *ChannelsService) DeleteUserInboxToken(ctx context.Context, userId str WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[DiscardResult](config) + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[DiscardResult](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[DiscardResult](resp), nil } // Lists all APNs tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. -func (api *ChannelsService) ListUserApnsTokens(ctx context.Context, userId string, params ListUserApnsTokensRequestParams) (*shared.ClientResponse[ApnsTokenCollection], *shared.ClientError) { +func (api *ChannelsService) ListUserApnsTokens(ctx context.Context, userId string, params ListUserApnsTokensRequestParams) (*shared.ClientResponse[ApnsTokenCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -172,17 +189,17 @@ func (api *ChannelsService) ListUserApnsTokens(ctx context.Context, userId strin WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[ApnsTokenCollection](config) + client := restClient.NewRestClient[ApnsTokenCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[ApnsTokenCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[ApnsTokenCollection](resp), nil } // Fetches a specific APNs token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. -func (api *ChannelsService) FetchUserApnsToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[ApnsToken], *shared.ClientError) { +func (api *ChannelsService) FetchUserApnsToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[ApnsToken], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -195,17 +212,17 @@ func (api *ChannelsService) FetchUserApnsToken(ctx context.Context, userId strin WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[ApnsToken](config) + client := restClient.NewRestClient[ApnsToken, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[ApnsToken](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[ApnsToken](resp), nil } // Deletes a specific user's APNs token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. -func (api *ChannelsService) DeleteUserApnsToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError) { +func (api *ChannelsService) DeleteUserApnsToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -218,17 +235,17 @@ func (api *ChannelsService) DeleteUserApnsToken(ctx context.Context, userId stri WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[DiscardResult](config) + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[DiscardResult](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[DiscardResult](resp), nil } // Lists all Expo tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. -func (api *ChannelsService) ListUserExpoTokens(ctx context.Context, userId string, params ListUserExpoTokensRequestParams) (*shared.ClientResponse[ExpoTokenCollection], *shared.ClientError) { +func (api *ChannelsService) ListUserExpoTokens(ctx context.Context, userId string, params ListUserExpoTokensRequestParams) (*shared.ClientResponse[ExpoTokenCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -241,17 +258,17 @@ func (api *ChannelsService) ListUserExpoTokens(ctx context.Context, userId strin WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[ExpoTokenCollection](config) + client := restClient.NewRestClient[ExpoTokenCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[ExpoTokenCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[ExpoTokenCollection](resp), nil } // Fetches a specific Expo token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. -func (api *ChannelsService) FetchUserExpoToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[ExpoToken], *shared.ClientError) { +func (api *ChannelsService) FetchUserExpoToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[ExpoToken], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -264,17 +281,17 @@ func (api *ChannelsService) FetchUserExpoToken(ctx context.Context, userId strin WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[ExpoToken](config) + client := restClient.NewRestClient[ExpoToken, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[ExpoToken](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[ExpoToken](resp), nil } // Deletes a specific user's Expo token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. -func (api *ChannelsService) DeleteUserExpoToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError) { +func (api *ChannelsService) DeleteUserExpoToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -287,17 +304,17 @@ func (api *ChannelsService) DeleteUserExpoToken(ctx context.Context, userId stri WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[DiscardResult](config) + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[DiscardResult](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[DiscardResult](resp), nil } // Lists all FCM tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. -func (api *ChannelsService) ListUserFcmTokens(ctx context.Context, userId string, params ListUserFcmTokensRequestParams) (*shared.ClientResponse[FcmTokenCollection], *shared.ClientError) { +func (api *ChannelsService) ListUserFcmTokens(ctx context.Context, userId string, params ListUserFcmTokensRequestParams) (*shared.ClientResponse[FcmTokenCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -310,17 +327,17 @@ func (api *ChannelsService) ListUserFcmTokens(ctx context.Context, userId string WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[FcmTokenCollection](config) + client := restClient.NewRestClient[FcmTokenCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[FcmTokenCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[FcmTokenCollection](resp), nil } // Fetches a specific FCM token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. -func (api *ChannelsService) FetchUserFcmToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[FcmToken], *shared.ClientError) { +func (api *ChannelsService) FetchUserFcmToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[FcmToken], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -333,17 +350,17 @@ func (api *ChannelsService) FetchUserFcmToken(ctx context.Context, userId string WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[FcmToken](config) + client := restClient.NewRestClient[FcmToken, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[FcmToken](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[FcmToken](resp), nil } // Deletes a specific user's FCM token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. -func (api *ChannelsService) DeleteUserFcmToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError) { +func (api *ChannelsService) DeleteUserFcmToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -356,17 +373,86 @@ func (api *ChannelsService) DeleteUserFcmToken(ctx context.Context, userId strin WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[DiscardResult](config) + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[DiscardResult](resp), nil +} + +// Lists all MagicBell SlackBot tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. +func (api *ChannelsService) ListUserMagicbellSlackbotTokens(ctx context.Context, userId string, params ListUserMagicbellSlackbotTokensRequestParams) (*shared.ClientResponse[SlackTokenCollection], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("GET"). + WithPath("/users/{user_id}/channels/slack/magicbell_slackbot/tokens"). + WithConfig(config). + AddPathParam("user_id", userId). + WithOptions(params). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[SlackTokenCollection, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[SlackTokenCollection](resp), nil +} + +// Fetches a specific MagicBell SlackBot token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. +func (api *ChannelsService) FetchUserMagicbellSlackbotToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[SlackToken], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("GET"). + WithPath("/users/{user_id}/channels/slack/magicbell_slackbot/tokens/{token_id}"). + WithConfig(config). + AddPathParam("user_id", userId). + AddPathParam("token_id", tokenId). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[SlackToken, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[SlackToken](resp), nil +} + +// Deletes a specific user's MagicBell SlackBot token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. +func (api *ChannelsService) DeleteUserMagicbellSlackbotToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("DELETE"). + WithPath("/users/{user_id}/channels/slack/magicbell_slackbot/tokens/{token_id}"). + WithConfig(config). + AddPathParam("user_id", userId). + AddPathParam("token_id", tokenId). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[DiscardResult](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[DiscardResult](resp), nil } // Lists all Slack tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. -func (api *ChannelsService) ListUserSlackTokens(ctx context.Context, userId string, params ListUserSlackTokensRequestParams) (*shared.ClientResponse[SlackTokenCollection], *shared.ClientError) { +func (api *ChannelsService) ListUserSlackTokens(ctx context.Context, userId string, params ListUserSlackTokensRequestParams) (*shared.ClientResponse[SlackTokenCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -379,17 +465,17 @@ func (api *ChannelsService) ListUserSlackTokens(ctx context.Context, userId stri WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[SlackTokenCollection](config) + client := restClient.NewRestClient[SlackTokenCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[SlackTokenCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[SlackTokenCollection](resp), nil } // Fetches a specific Slack token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. -func (api *ChannelsService) FetchUserSlackToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[SlackToken], *shared.ClientError) { +func (api *ChannelsService) FetchUserSlackToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[SlackToken], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -402,17 +488,17 @@ func (api *ChannelsService) FetchUserSlackToken(ctx context.Context, userId stri WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[SlackToken](config) + client := restClient.NewRestClient[SlackToken, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[SlackToken](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[SlackToken](resp), nil } // Deletes a specific user's Slack token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. -func (api *ChannelsService) DeleteUserSlackToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError) { +func (api *ChannelsService) DeleteUserSlackToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -425,17 +511,17 @@ func (api *ChannelsService) DeleteUserSlackToken(ctx context.Context, userId str WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[DiscardResult](config) + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[DiscardResult](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[DiscardResult](resp), nil } // Lists all Teams tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. -func (api *ChannelsService) ListUserTeamsTokens(ctx context.Context, userId string, params ListUserTeamsTokensRequestParams) (*shared.ClientResponse[TeamsTokenCollection], *shared.ClientError) { +func (api *ChannelsService) ListUserTeamsTokens(ctx context.Context, userId string, params ListUserTeamsTokensRequestParams) (*shared.ClientResponse[TeamsTokenCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -448,17 +534,17 @@ func (api *ChannelsService) ListUserTeamsTokens(ctx context.Context, userId stri WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[TeamsTokenCollection](config) + client := restClient.NewRestClient[TeamsTokenCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[TeamsTokenCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[TeamsTokenCollection](resp), nil } // Fetches a specific Teams token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. -func (api *ChannelsService) FetchUserTeamsToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[TeamsToken], *shared.ClientError) { +func (api *ChannelsService) FetchUserTeamsToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[TeamsToken], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -471,17 +557,17 @@ func (api *ChannelsService) FetchUserTeamsToken(ctx context.Context, userId stri WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[TeamsToken](config) + client := restClient.NewRestClient[TeamsToken, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[TeamsToken](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[TeamsToken](resp), nil } // Deletes a specific user's Teams token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. -func (api *ChannelsService) DeleteUserTeamsToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError) { +func (api *ChannelsService) DeleteUserTeamsToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -494,17 +580,17 @@ func (api *ChannelsService) DeleteUserTeamsToken(ctx context.Context, userId str WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[DiscardResult](config) + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[DiscardResult](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[DiscardResult](resp), nil } // Lists all Web Push tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. -func (api *ChannelsService) ListUserWebPushTokens(ctx context.Context, userId string, params ListUserWebPushTokensRequestParams) (*shared.ClientResponse[WebPushTokenCollection], *shared.ClientError) { +func (api *ChannelsService) ListUserWebPushTokens(ctx context.Context, userId string, params ListUserWebPushTokensRequestParams) (*shared.ClientResponse[WebPushTokenCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -517,17 +603,17 @@ func (api *ChannelsService) ListUserWebPushTokens(ctx context.Context, userId st WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[WebPushTokenCollection](config) + client := restClient.NewRestClient[WebPushTokenCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[WebPushTokenCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[WebPushTokenCollection](resp), nil } // Fetches a specific Web Push token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. -func (api *ChannelsService) FetchUserWebPushToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[WebPushToken], *shared.ClientError) { +func (api *ChannelsService) FetchUserWebPushToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[WebPushToken], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -540,17 +626,17 @@ func (api *ChannelsService) FetchUserWebPushToken(ctx context.Context, userId st WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[WebPushToken](config) + client := restClient.NewRestClient[WebPushToken, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[WebPushToken](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[WebPushToken](resp), nil } // Deletes a specific user's Web Push token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. -func (api *ChannelsService) DeleteUserWebPushToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError) { +func (api *ChannelsService) DeleteUserWebPushToken(ctx context.Context, userId string, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -563,10 +649,10 @@ func (api *ChannelsService) DeleteUserWebPushToken(ctx context.Context, userId s WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[DiscardResult](config) + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[DiscardResult](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[DiscardResult](resp), nil diff --git a/pkg/project-client/channels/discard_result.go b/pkg/project-client/channels/discard_result.go index 47c1493..fe18ee9 100644 --- a/pkg/project-client/channels/discard_result.go +++ b/pkg/project-client/channels/discard_result.go @@ -3,8 +3,10 @@ package channels import "encoding/json" type DiscardResult struct { + // The timestamp when the token was discarded. DiscardedAt *string `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty"` + // The unique identifier for the discarded token. + Id *string `json:"id,omitempty"` } func (d *DiscardResult) GetDiscardedAt() *string { diff --git a/pkg/project-client/channels/expo_token.go b/pkg/project-client/channels/expo_token.go index 7bf2c85..acdb727 100644 --- a/pkg/project-client/channels/expo_token.go +++ b/pkg/project-client/channels/expo_token.go @@ -7,11 +7,16 @@ import ( ) type ExpoToken struct { - CreatedAt *string `json:"created_at,omitempty" required:"true"` - DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"1"` + // The timestamp when the token was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The Expo push token returned by the Expo client. + DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"1"` + // The timestamp when the token was discarded, if applicable. DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` + // The unique identifier for the token. + Id *string `json:"id,omitempty" required:"true"` + // The timestamp when the token metadata last changed. + UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` } func (e *ExpoToken) GetCreatedAt() *string { diff --git a/pkg/project-client/channels/fcm_token.go b/pkg/project-client/channels/fcm_token.go index dc6d0a6..fe66f85 100644 --- a/pkg/project-client/channels/fcm_token.go +++ b/pkg/project-client/channels/fcm_token.go @@ -7,12 +7,16 @@ import ( ) type FcmToken struct { - CreatedAt *string `json:"created_at,omitempty" required:"true"` - DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"64"` - DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - InstallationId *FcmTokenInstallationId `json:"installation_id,omitempty"` - UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` + // The timestamp when the token was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The Firebase Cloud Messaging device registration token to associate with the user. + DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"64"` + // The timestamp when the token was discarded, if applicable. + DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` + // The unique identifier for the token. + Id *string `json:"id,omitempty" required:"true"` + // The timestamp when the token metadata last changed. + UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` } func (f *FcmToken) GetCreatedAt() *string { @@ -63,17 +67,6 @@ func (f *FcmToken) SetId(id string) { f.Id = &id } -func (f *FcmToken) GetInstallationId() *FcmTokenInstallationId { - if f == nil { - return nil - } - return f.InstallationId -} - -func (f *FcmToken) SetInstallationId(installationId FcmTokenInstallationId) { - f.InstallationId = &installationId -} - func (f *FcmToken) GetUpdatedAt() *util.Nullable[string] { if f == nil { return nil @@ -100,10 +93,3 @@ func (f FcmToken) String() string { func (f *FcmToken) UnmarshalJSON(data []byte) error { return unmarshal.UnmarshalNullable(data, f) } - -type FcmTokenInstallationId string - -const ( - FCM_TOKEN_INSTALLATION_ID_DEVELOPMENT FcmTokenInstallationId = "development" - FCM_TOKEN_INSTALLATION_ID_PRODUCTION FcmTokenInstallationId = "production" -) diff --git a/pkg/project-client/channels/inbox_token_response.go b/pkg/project-client/channels/inbox_token_response.go index 633e8c6..adc962a 100644 --- a/pkg/project-client/channels/inbox_token_response.go +++ b/pkg/project-client/channels/inbox_token_response.go @@ -7,12 +7,18 @@ import ( ) type InboxTokenResponse struct { + // Realtime connection ID to restrict delivery to a specific Ably connection. ConnectionId *util.Nullable[string] `json:"connection_id,omitempty"` - CreatedAt *string `json:"created_at,omitempty" required:"true"` - DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - Token *string `json:"token,omitempty" required:"true" minLength:"64"` - UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` + // The timestamp when the token was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The timestamp when the token was discarded, if applicable. + DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` + // The unique identifier for the token. + Id *string `json:"id,omitempty" required:"true"` + // The in-app inbox token generated for this user. + Token *string `json:"token,omitempty" required:"true" minLength:"64"` + // The timestamp when the token metadata last changed. + UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` } func (i *InboxTokenResponse) GetConnectionId() *util.Nullable[string] { diff --git a/pkg/project-client/channels/installation_id.go b/pkg/project-client/channels/installation_id.go new file mode 100644 index 0000000..2976891 --- /dev/null +++ b/pkg/project-client/channels/installation_id.go @@ -0,0 +1,9 @@ +package channels + +// The APNs environment this token belongs to. If omitted we assume it targets `production`. +type InstallationId string + +const ( + INSTALLATION_ID_DEVELOPMENT InstallationId = "development" + INSTALLATION_ID_PRODUCTION InstallationId = "production" +) diff --git a/pkg/project-client/channels/keys.go b/pkg/project-client/channels/keys.go new file mode 100644 index 0000000..6fed969 --- /dev/null +++ b/pkg/project-client/channels/keys.go @@ -0,0 +1,41 @@ +package channels + +import "encoding/json" + +// The encryption keys from the PushSubscription.getKey() method, needed to encrypt push messages for this subscription. +type Keys struct { + // The authentication secret obtained from PushSubscription.getKey('auth'). Used to encrypt push messages for this subscription. + Auth *string `json:"auth,omitempty" required:"true"` + // The P-256 ECDH public key obtained from PushSubscription.getKey('p256dh'). Used to encrypt push messages for this subscription. + P256dh *string `json:"p256dh,omitempty" required:"true"` +} + +func (k *Keys) GetAuth() *string { + if k == nil { + return nil + } + return k.Auth +} + +func (k *Keys) SetAuth(auth string) { + k.Auth = &auth +} + +func (k *Keys) GetP256dh() *string { + if k == nil { + return nil + } + return k.P256dh +} + +func (k *Keys) SetP256dh(p256dh string) { + k.P256dh = &p256dh +} + +func (k Keys) String() string { + jsonData, err := json.MarshalIndent(k, "", " ") + if err != nil { + return "error converting struct: Keys to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/channels/oauth.go b/pkg/project-client/channels/oauth.go new file mode 100644 index 0000000..c2463dd --- /dev/null +++ b/pkg/project-client/channels/oauth.go @@ -0,0 +1,53 @@ +package channels + +import "encoding/json" + +type Oauth struct { + // The ID of the Slack channel this installation is associated with + ChannelId *string `json:"channel_id,omitempty" required:"true"` + // A unique identifier for this Slack workspace installation + InstallationId *string `json:"installation_id,omitempty" required:"true"` + // The OAuth scope granted during installation + Scope *string `json:"scope,omitempty"` +} + +func (o *Oauth) GetChannelId() *string { + if o == nil { + return nil + } + return o.ChannelId +} + +func (o *Oauth) SetChannelId(channelId string) { + o.ChannelId = &channelId +} + +func (o *Oauth) GetInstallationId() *string { + if o == nil { + return nil + } + return o.InstallationId +} + +func (o *Oauth) SetInstallationId(installationId string) { + o.InstallationId = &installationId +} + +func (o *Oauth) GetScope() *string { + if o == nil { + return nil + } + return o.Scope +} + +func (o *Oauth) SetScope(scope string) { + o.Scope = &scope +} + +func (o Oauth) String() string { + jsonData, err := json.MarshalIndent(o, "", " ") + if err != nil { + return "error converting struct: Oauth to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/channels/request_params.go b/pkg/project-client/channels/request_params.go index c5a7274..194976a 100644 --- a/pkg/project-client/channels/request_params.go +++ b/pkg/project-client/channels/request_params.go @@ -1,113 +1,185 @@ package channels +// ListUserInboxTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListUserInboxTokensRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListUserInboxTokensRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListUserInboxTokensRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListUserInboxTokensRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } +// ListUserApnsTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListUserApnsTokensRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListUserApnsTokensRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListUserApnsTokensRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListUserApnsTokensRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } +// ListUserExpoTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListUserExpoTokensRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListUserExpoTokensRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListUserExpoTokensRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListUserExpoTokensRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } +// ListUserFcmTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListUserFcmTokensRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListUserFcmTokensRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListUserFcmTokensRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListUserFcmTokensRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } +// ListUserMagicbellSlackbotTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. +type ListUserMagicbellSlackbotTokensRequestParams struct { + Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` + StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` + EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` +} + +// SetLimit sets the Limit parameter. +func (params *ListUserMagicbellSlackbotTokensRequestParams) SetLimit(limit int64) { + params.Limit = &limit +} + +// SetStartingAfter sets the StartingAfter parameter. +func (params *ListUserMagicbellSlackbotTokensRequestParams) SetStartingAfter(startingAfter string) { + params.StartingAfter = &startingAfter +} + +// SetEndingBefore sets the EndingBefore parameter. +func (params *ListUserMagicbellSlackbotTokensRequestParams) SetEndingBefore(endingBefore string) { + params.EndingBefore = &endingBefore +} + +// ListUserSlackTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListUserSlackTokensRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListUserSlackTokensRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListUserSlackTokensRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListUserSlackTokensRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } +// ListUserTeamsTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListUserTeamsTokensRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListUserTeamsTokensRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListUserTeamsTokensRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListUserTeamsTokensRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } +// ListUserWebPushTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListUserWebPushTokensRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListUserWebPushTokensRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListUserWebPushTokensRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListUserWebPushTokensRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } diff --git a/pkg/project-client/channels/slack_token.go b/pkg/project-client/channels/slack_token.go index 8bb6fef..9e788dd 100644 --- a/pkg/project-client/channels/slack_token.go +++ b/pkg/project-client/channels/slack_token.go @@ -7,11 +7,15 @@ import ( ) type SlackToken struct { - CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The timestamp when the token was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The timestamp when the token was discarded, if applicable. DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - Oauth *Oauth `json:"oauth,omitempty"` - UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` + // The unique identifier for the token. + Id *string `json:"id,omitempty" required:"true"` + Oauth *Oauth `json:"oauth,omitempty"` + // The timestamp when the token metadata last changed. + UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` // Obtained directly from the incoming_webhook object in the installation response from the Slack API. Webhook *SlackTokenWebhook `json:"webhook,omitempty"` } @@ -101,74 +105,3 @@ func (s SlackToken) String() string { func (s *SlackToken) UnmarshalJSON(data []byte) error { return unmarshal.UnmarshalNullable(data, s) } - -type Oauth struct { - ChannelId *string `json:"channel_id,omitempty" required:"true"` - InstallationId *string `json:"installation_id,omitempty" required:"true"` - Scope *string `json:"scope,omitempty"` -} - -func (o *Oauth) GetChannelId() *string { - if o == nil { - return nil - } - return o.ChannelId -} - -func (o *Oauth) SetChannelId(channelId string) { - o.ChannelId = &channelId -} - -func (o *Oauth) GetInstallationId() *string { - if o == nil { - return nil - } - return o.InstallationId -} - -func (o *Oauth) SetInstallationId(installationId string) { - o.InstallationId = &installationId -} - -func (o *Oauth) GetScope() *string { - if o == nil { - return nil - } - return o.Scope -} - -func (o *Oauth) SetScope(scope string) { - o.Scope = &scope -} - -func (o Oauth) String() string { - jsonData, err := json.MarshalIndent(o, "", " ") - if err != nil { - return "error converting struct: Oauth to string" - } - return string(jsonData) -} - -// Obtained directly from the incoming_webhook object in the installation response from the Slack API. -type SlackTokenWebhook struct { - Url *string `json:"url,omitempty" required:"true" minLength:"1"` -} - -func (s *SlackTokenWebhook) GetUrl() *string { - if s == nil { - return nil - } - return s.Url -} - -func (s *SlackTokenWebhook) SetUrl(url string) { - s.Url = &url -} - -func (s SlackTokenWebhook) String() string { - jsonData, err := json.MarshalIndent(s, "", " ") - if err != nil { - return "error converting struct: SlackTokenWebhook to string" - } - return string(jsonData) -} diff --git a/pkg/project-client/channels/slack_token_webhook.go b/pkg/project-client/channels/slack_token_webhook.go new file mode 100644 index 0000000..28b257a --- /dev/null +++ b/pkg/project-client/channels/slack_token_webhook.go @@ -0,0 +1,28 @@ +package channels + +import "encoding/json" + +// Obtained directly from the incoming_webhook object in the installation response from the Slack API. +type SlackTokenWebhook struct { + // The URL for the incoming webhook from Slack + Url *string `json:"url,omitempty" required:"true" minLength:"1"` +} + +func (s *SlackTokenWebhook) GetUrl() *string { + if s == nil { + return nil + } + return s.Url +} + +func (s *SlackTokenWebhook) SetUrl(url string) { + s.Url = &url +} + +func (s SlackTokenWebhook) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SlackTokenWebhook to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/channels/teams_token.go b/pkg/project-client/channels/teams_token.go index babf384..9be7642 100644 --- a/pkg/project-client/channels/teams_token.go +++ b/pkg/project-client/channels/teams_token.go @@ -7,11 +7,15 @@ import ( ) type TeamsToken struct { - CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The timestamp when the token was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The timestamp when the token was discarded, if applicable. DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` - Webhook *TeamsTokenWebhook `json:"webhook,omitempty"` + // The unique identifier for the token. + Id *string `json:"id,omitempty" required:"true"` + // The timestamp when the token metadata last changed. + UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` + Webhook *TeamsTokenWebhook `json:"webhook,omitempty"` } func (t *TeamsToken) GetCreatedAt() *string { @@ -88,26 +92,3 @@ func (t TeamsToken) String() string { func (t *TeamsToken) UnmarshalJSON(data []byte) error { return unmarshal.UnmarshalNullable(data, t) } - -type TeamsTokenWebhook struct { - Url *string `json:"url,omitempty"` -} - -func (t *TeamsTokenWebhook) GetUrl() *string { - if t == nil { - return nil - } - return t.Url -} - -func (t *TeamsTokenWebhook) SetUrl(url string) { - t.Url = &url -} - -func (t TeamsTokenWebhook) String() string { - jsonData, err := json.MarshalIndent(t, "", " ") - if err != nil { - return "error converting struct: TeamsTokenWebhook to string" - } - return string(jsonData) -} diff --git a/pkg/project-client/channels/teams_token_webhook.go b/pkg/project-client/channels/teams_token_webhook.go new file mode 100644 index 0000000..ce2c616 --- /dev/null +++ b/pkg/project-client/channels/teams_token_webhook.go @@ -0,0 +1,26 @@ +package channels + +import "encoding/json" + +type TeamsTokenWebhook struct { + Url *string `json:"url,omitempty"` +} + +func (t *TeamsTokenWebhook) GetUrl() *string { + if t == nil { + return nil + } + return t.Url +} + +func (t *TeamsTokenWebhook) SetUrl(url string) { + t.Url = &url +} + +func (t TeamsTokenWebhook) String() string { + jsonData, err := json.MarshalIndent(t, "", " ") + if err != nil { + return "error converting struct: TeamsTokenWebhook to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/channels/web_push_token.go b/pkg/project-client/channels/web_push_token.go index 0f917b7..d0b6d93 100644 --- a/pkg/project-client/channels/web_push_token.go +++ b/pkg/project-client/channels/web_push_token.go @@ -7,13 +7,17 @@ import ( ) type WebPushToken struct { - CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The timestamp when the token was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The timestamp when the token was discarded, if applicable. DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` // The push subscription URL obtained from PushSubscription.endpoint after calling registration.pushManager.subscribe(). This is the unique URL for this device that push messages will be sent to. Endpoint *string `json:"endpoint,omitempty" required:"true"` - Id *string `json:"id,omitempty" required:"true"` + // The unique identifier for the token. + Id *string `json:"id,omitempty" required:"true"` // The encryption keys from the PushSubscription.getKey() method, needed to encrypt push messages for this subscription. - Keys *Keys `json:"keys,omitempty" required:"true"` + Keys *Keys `json:"keys,omitempty" required:"true"` + // The timestamp when the token metadata last changed. UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` } @@ -102,41 +106,3 @@ func (w WebPushToken) String() string { func (w *WebPushToken) UnmarshalJSON(data []byte) error { return unmarshal.UnmarshalNullable(data, w) } - -// The encryption keys from the PushSubscription.getKey() method, needed to encrypt push messages for this subscription. -type Keys struct { - // The authentication secret obtained from PushSubscription.getKey('auth'). Used to encrypt push messages for this subscription. - Auth *string `json:"auth,omitempty" required:"true"` - // The P-256 ECDH public key obtained from PushSubscription.getKey('p256dh'). Used to encrypt push messages for this subscription. - P256dh *string `json:"p256dh,omitempty" required:"true"` -} - -func (k *Keys) GetAuth() *string { - if k == nil { - return nil - } - return k.Auth -} - -func (k *Keys) SetAuth(auth string) { - k.Auth = &auth -} - -func (k *Keys) GetP256dh() *string { - if k == nil { - return nil - } - return k.P256dh -} - -func (k *Keys) SetP256dh(p256dh string) { - k.P256dh = &p256dh -} - -func (k Keys) String() string { - jsonData, err := json.MarshalIndent(k, "", " ") - if err != nil { - return "error converting struct: Keys to string" - } - return string(jsonData) -} diff --git a/pkg/project-client/client/client.go b/pkg/project-client/client/client.go index db0b711..81e9fe6 100644 --- a/pkg/project-client/client/client.go +++ b/pkg/project-client/client/client.go @@ -1,6 +1,7 @@ package client import ( + "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/hooks" "github.com/magicbell/magicbell-go/pkg/project-client/internal/configmanager" "github.com/magicbell/magicbell-go/pkg/project-client/broadcasts" "github.com/magicbell/magicbell-go/pkg/project-client/channels" @@ -8,15 +9,19 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/events" "github.com/magicbell/magicbell-go/pkg/project-client/integrations" "github.com/magicbell/magicbell-go/pkg/project-client/users" + "github.com/magicbell/magicbell-go/pkg/project-client/workflows" "time" ) +// Client is the main SDK client that provides access to all service endpoints. +// It manages configuration, authentication, and service instances with centralized settings. type Client struct { Broadcasts *broadcasts.BroadcastsService Channels *channels.ChannelsService Events *events.EventsService Integrations *integrations.IntegrationsService Users *users.UsersService + Workflows *workflows.WorkflowsService manager *configmanager.ConfigManager } @@ -26,13 +31,22 @@ func NewClient(config clientconfig.Config) *Client { events := events.NewEventsService() integrations := integrations.NewIntegrationsService() users := users.NewUsersService() + workflows := workflows.NewWorkflowsService() manager := configmanager.NewConfigManager(config) + hook := hooks.NewDefaultHook() broadcasts.WithConfigManager(manager) channels.WithConfigManager(manager) events.WithConfigManager(manager) integrations.WithConfigManager(manager) users.WithConfigManager(manager) + workflows.WithConfigManager(manager) + broadcasts.WithHook(hook) + channels.WithHook(hook) + events.WithHook(hook) + integrations.WithHook(hook) + users.WithHook(hook) + workflows.WithHook(hook) return &Client{ Broadcasts: broadcasts, @@ -40,6 +54,7 @@ func NewClient(config clientconfig.Config) *Client { Events: events, Integrations: integrations, Users: users, + Workflows: workflows, manager: manager, } } diff --git a/pkg/project-client/clientconfig/config.go b/pkg/project-client/clientconfig/config.go index c98e36e..e105830 100644 --- a/pkg/project-client/clientconfig/config.go +++ b/pkg/project-client/clientconfig/config.go @@ -1,14 +1,23 @@ package clientconfig -import "time" +import ( + "time" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/hooks" +) + +// Config holds all configuration parameters for the SDK client. +// It manages base URL, timeout, authentication credentials, and custom hooks. type Config struct { BaseUrl *string Timeout *time.Duration AccessToken *string HookParams map[string]string + hook hooks.Hook } +// NewConfig creates a new Config instance with default values. +// Sets the base URL to the default environment and timeout to 10 seconds. func NewConfig() Config { baseUrl := DEFAULT_ENVIRONMENT timeout := time.Second * 10 diff --git a/pkg/project-client/clientconfig/environments.go b/pkg/project-client/clientconfig/environments.go index 9993362..10b97cd 100644 --- a/pkg/project-client/clientconfig/environments.go +++ b/pkg/project-client/clientconfig/environments.go @@ -1,5 +1,7 @@ package clientconfig +// Environment constants define the available base URLs for different deployment environments. +// Use these constants when configuring the SDK client. const ( DEFAULT_ENVIRONMENT = "https://api.magicbell.com/v2" ) diff --git a/pkg/project-client/events/event.go b/pkg/project-client/events/event.go index b923832..06837ef 100644 --- a/pkg/project-client/events/event.go +++ b/pkg/project-client/events/event.go @@ -7,13 +7,22 @@ import ( ) type Event struct { - Code *int64 `json:"code,omitempty"` - Context *util.Nullable[any] `json:"context,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - Level *string `json:"level,omitempty"` - Log *util.Nullable[string] `json:"log,omitempty"` - Timestamp *string `json:"timestamp,omitempty" required:"true"` - Type_ *string `json:"type,omitempty" required:"true"` + // The numeric code that categorizes the event. + Code *int64 `json:"code,omitempty"` + // Additional contextual attributes for the event. + Context *util.Nullable[any] `json:"context,omitempty"` + // The unique identifier for the event. + Id *string `json:"id,omitempty" required:"true"` + // The severity level assigned to the event. + Level *string `json:"level,omitempty"` + // A human-readable log message. + Log *util.Nullable[string] `json:"log,omitempty"` + // The raw payload delivered by the event source. + Payload *util.Nullable[any] `json:"payload,omitempty"` + // The time at which the event was recorded. + Timestamp *string `json:"timestamp,omitempty" required:"true"` + // The type of event that occurred. + Type_ *string `json:"type,omitempty" required:"true"` } func (e *Event) GetCode() *int64 { @@ -79,6 +88,21 @@ func (e *Event) SetLogNull() { e.Log = &util.Nullable[string]{IsNull: true} } +func (e *Event) GetPayload() *util.Nullable[any] { + if e == nil { + return nil + } + return e.Payload +} + +func (e *Event) SetPayload(payload util.Nullable[any]) { + e.Payload = &payload +} + +func (e *Event) SetPayloadNull() { + e.Payload = &util.Nullable[any]{IsNull: true} +} + func (e *Event) GetTimestamp() *string { if e == nil { return nil diff --git a/pkg/project-client/events/events_service.go b/pkg/project-client/events/events_service.go index 79e0f19..e4be45d 100644 --- a/pkg/project-client/events/events_service.go +++ b/pkg/project-client/events/events_service.go @@ -3,6 +3,7 @@ package events import ( "context" restClient "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/hooks" "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/httptransport" "github.com/magicbell/magicbell-go/pkg/project-client/internal/configmanager" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" @@ -10,8 +11,11 @@ import ( "time" ) +// EventsService provides methods to interact with EventsService-related API endpoints. +// It uses a configuration manager for settings and supports custom hooks for request/response interception. type EventsService struct { manager *configmanager.ConfigManager + hook hooks.Hook } func NewEventsService() *EventsService { @@ -20,15 +24,28 @@ func NewEventsService() *EventsService { } } +// WithConfigManager sets the configuration manager for this service. +// Returns the service instance for method chaining. func (api *EventsService) WithConfigManager(manager *configmanager.ConfigManager) *EventsService { api.manager = manager return api } +// WithHook sets a custom hook for request/response interception. +// Returns the service instance for method chaining. +func (api *EventsService) WithHook(hook hooks.Hook) *EventsService { + api.hook = hook + return api +} + func (api *EventsService) getConfig() *clientconfig.Config { return api.manager.GetEvents() } +func (api *EventsService) getHook() hooks.Hook { + return api.hook +} + func (api *EventsService) SetBaseUrl(baseUrl string) { config := api.getConfig() config.SetBaseUrl(baseUrl) @@ -45,7 +62,7 @@ func (api *EventsService) SetAccessToken(accessToken string) { } // Retrieves a paginated list of events for the project. -func (api *EventsService) ListEvents(ctx context.Context, params ListEventsRequestParams) (*shared.ClientResponse[EventCollection], *shared.ClientError) { +func (api *EventsService) ListEvents(ctx context.Context, params ListEventsRequestParams) (*shared.ClientResponse[EventCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -57,17 +74,17 @@ func (api *EventsService) ListEvents(ctx context.Context, params ListEventsReque WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[EventCollection](config) + client := restClient.NewRestClient[EventCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[EventCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[EventCollection](resp), nil } // Fetches a project event by its ID. -func (api *EventsService) FetchEvent(ctx context.Context, eventId string) (*shared.ClientResponse[Event], *shared.ClientError) { +func (api *EventsService) FetchEvent(ctx context.Context, eventId string) (*shared.ClientResponse[Event], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -79,10 +96,10 @@ func (api *EventsService) FetchEvent(ctx context.Context, eventId string) (*shar WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[Event](config) + client := restClient.NewRestClient[Event, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[Event](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[Event](resp), nil diff --git a/pkg/project-client/events/request_params.go b/pkg/project-client/events/request_params.go index 0a93249..46113f6 100644 --- a/pkg/project-client/events/request_params.go +++ b/pkg/project-client/events/request_params.go @@ -1,17 +1,24 @@ package events +// ListEventsRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListEventsRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListEventsRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListEventsRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListEventsRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } diff --git a/pkg/project-client/integrations/apns_config_payload.go b/pkg/project-client/integrations/apns_config_payload.go index b30cdae..d751f5f 100644 --- a/pkg/project-client/integrations/apns_config_payload.go +++ b/pkg/project-client/integrations/apns_config_payload.go @@ -5,12 +5,16 @@ import "encoding/json" type ApnsConfigPayload struct { // The default bundle identifier of the application that is configured with this project. It can be overriden on a per token basis, when registering device tokens. AppId *string `json:"app_id,omitempty" required:"true" pattern:"^[a-zA-Z0-9]+(.[a-zA-Z0-9]+)*$"` - Badge *Badge `json:"badge,omitempty" required:"true"` + // Controls whether the app icon badge counts unread or unseen notifications. + Badge *Badge `json:"badge,omitempty" required:"true"` // The APNs certificate in P8 format. Generate it at [developer.apple.com](https://developer.apple.com/account/resources/authkeys/add) with the 'Apple Push Notification service (APNs)' option selected. - Certificate *string `json:"certificate,omitempty" required:"true" pattern:"^-+?\s?BEGIN PRIVATE KEY-+\n([A-Za-z0-9+/\r\n]+={0,2})\n-+\s?END PRIVATE KEY+-+\n?$"` - KeyId *string `json:"key_id,omitempty" required:"true" maxLength:"10" minLength:"10"` + Certificate *string `json:"certificate,omitempty" required:"true" pattern:"^-+?\s?BEGIN PRIVATE KEY-+\n([A-Za-z0-9+/\r\n]+={0,2})\n-+\s?END PRIVATE KEY+-+\n?$"` + // The 10-character Key ID from your Apple Developer account used with the P8 certificate. + KeyId *string `json:"key_id,omitempty" required:"true" maxLength:"10" minLength:"10"` + // Internal payload format version used by MagicBell. PayloadVersion *PayloadVersion `json:"payload_version,omitempty"` - TeamId *string `json:"team_id,omitempty" required:"true" maxLength:"10" minLength:"10"` + // The Apple Developer Team ID that owns the configured key. + TeamId *string `json:"team_id,omitempty" required:"true" maxLength:"10" minLength:"10"` } func (a *ApnsConfigPayload) GetAppId() *string { @@ -86,17 +90,3 @@ func (a ApnsConfigPayload) String() string { } return string(jsonData) } - -type Badge string - -const ( - BADGE_UNREAD Badge = "unread" - BADGE_UNSEEN Badge = "unseen" -) - -type PayloadVersion string - -const ( - PAYLOAD_VERSION_1 PayloadVersion = "1" - PAYLOAD_VERSION_2 PayloadVersion = "2" -) diff --git a/pkg/project-client/integrations/badge.go b/pkg/project-client/integrations/badge.go new file mode 100644 index 0000000..e1c6c96 --- /dev/null +++ b/pkg/project-client/integrations/badge.go @@ -0,0 +1,9 @@ +package integrations + +// Controls whether the app icon badge counts unread or unseen notifications. +type Badge string + +const ( + BADGE_UNREAD Badge = "unread" + BADGE_UNSEEN Badge = "unseen" +) diff --git a/pkg/project-client/integrations/banner.go b/pkg/project-client/integrations/banner.go new file mode 100644 index 0000000..e8209df --- /dev/null +++ b/pkg/project-client/integrations/banner.go @@ -0,0 +1,67 @@ +package integrations + +import "encoding/json" + +// Top banner styling options. +type Banner struct { + // Banner background color. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` + // Opacity applied to the banner background. + BackgroundOpacity *float64 `json:"backgroundOpacity,omitempty"` + // Font size for banner text. + FontSize *string `json:"fontSize,omitempty" required:"true"` + // Banner text color. + TextColor *string `json:"textColor,omitempty" required:"true"` +} + +func (b *Banner) GetBackgroundColor() *string { + if b == nil { + return nil + } + return b.BackgroundColor +} + +func (b *Banner) SetBackgroundColor(backgroundColor string) { + b.BackgroundColor = &backgroundColor +} + +func (b *Banner) GetBackgroundOpacity() *float64 { + if b == nil { + return nil + } + return b.BackgroundOpacity +} + +func (b *Banner) SetBackgroundOpacity(backgroundOpacity float64) { + b.BackgroundOpacity = &backgroundOpacity +} + +func (b *Banner) GetFontSize() *string { + if b == nil { + return nil + } + return b.FontSize +} + +func (b *Banner) SetFontSize(fontSize string) { + b.FontSize = &fontSize +} + +func (b *Banner) GetTextColor() *string { + if b == nil { + return nil + } + return b.TextColor +} + +func (b *Banner) SetTextColor(textColor string) { + b.TextColor = &textColor +} + +func (b Banner) String() string { + jsonData, err := json.MarshalIndent(b, "", " ") + if err != nil { + return "error converting struct: Banner to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/default_.go b/pkg/project-client/integrations/default_.go new file mode 100644 index 0000000..f0a19b3 --- /dev/null +++ b/pkg/project-client/integrations/default_.go @@ -0,0 +1,119 @@ +package integrations + +import "encoding/json" + +// Base styles applied to every notification item. +type Default_ struct { + // Background color for notifications in their default state. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` + // Border radius applied to each notification card. + BorderRadius *string `json:"borderRadius,omitempty" required:"true"` + // Font family for notification text. + FontFamily *string `json:"fontFamily,omitempty" required:"true"` + // Font size for notification text. + FontSize *string `json:"fontSize,omitempty" required:"true"` + // Styles applied when a notification is hovered. + Hover *DefaultHover `json:"hover,omitempty"` + // CSS margin applied around each notification card. + Margin *string `json:"margin,omitempty" required:"true"` + // Accent colors for notification state indicators. + State *DefaultState `json:"state,omitempty"` + // Default text color for notifications. + TextColor *string `json:"textColor,omitempty" required:"true"` +} + +func (d *Default_) GetBackgroundColor() *string { + if d == nil { + return nil + } + return d.BackgroundColor +} + +func (d *Default_) SetBackgroundColor(backgroundColor string) { + d.BackgroundColor = &backgroundColor +} + +func (d *Default_) GetBorderRadius() *string { + if d == nil { + return nil + } + return d.BorderRadius +} + +func (d *Default_) SetBorderRadius(borderRadius string) { + d.BorderRadius = &borderRadius +} + +func (d *Default_) GetFontFamily() *string { + if d == nil { + return nil + } + return d.FontFamily +} + +func (d *Default_) SetFontFamily(fontFamily string) { + d.FontFamily = &fontFamily +} + +func (d *Default_) GetFontSize() *string { + if d == nil { + return nil + } + return d.FontSize +} + +func (d *Default_) SetFontSize(fontSize string) { + d.FontSize = &fontSize +} + +func (d *Default_) GetHover() *DefaultHover { + if d == nil { + return nil + } + return d.Hover +} + +func (d *Default_) SetHover(hover DefaultHover) { + d.Hover = &hover +} + +func (d *Default_) GetMargin() *string { + if d == nil { + return nil + } + return d.Margin +} + +func (d *Default_) SetMargin(margin string) { + d.Margin = &margin +} + +func (d *Default_) GetState() *DefaultState { + if d == nil { + return nil + } + return d.State +} + +func (d *Default_) SetState(state DefaultState) { + d.State = &state +} + +func (d *Default_) GetTextColor() *string { + if d == nil { + return nil + } + return d.TextColor +} + +func (d *Default_) SetTextColor(textColor string) { + d.TextColor = &textColor +} + +func (d Default_) String() string { + jsonData, err := json.MarshalIndent(d, "", " ") + if err != nil { + return "error converting struct: Default_ to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/default_hover.go b/pkg/project-client/integrations/default_hover.go new file mode 100644 index 0000000..ec5f5c4 --- /dev/null +++ b/pkg/project-client/integrations/default_hover.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// Styles applied when a notification is hovered. +type DefaultHover struct { + // Background color on hover. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` +} + +func (d *DefaultHover) GetBackgroundColor() *string { + if d == nil { + return nil + } + return d.BackgroundColor +} + +func (d *DefaultHover) SetBackgroundColor(backgroundColor string) { + d.BackgroundColor = &backgroundColor +} + +func (d DefaultHover) String() string { + jsonData, err := json.MarshalIndent(d, "", " ") + if err != nil { + return "error converting struct: DefaultHover to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/default_state.go b/pkg/project-client/integrations/default_state.go new file mode 100644 index 0000000..85a4ebd --- /dev/null +++ b/pkg/project-client/integrations/default_state.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// Accent colors for notification state indicators. +type DefaultState struct { + // Color used for the state indicator. + Color *string `json:"color,omitempty" required:"true"` +} + +func (d *DefaultState) GetColor() *string { + if d == nil { + return nil + } + return d.Color +} + +func (d *DefaultState) SetColor(color string) { + d.Color = &color +} + +func (d DefaultState) String() string { + jsonData, err := json.MarshalIndent(d, "", " ") + if err != nil { + return "error converting struct: DefaultState to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/dialog.go b/pkg/project-client/integrations/dialog.go new file mode 100644 index 0000000..d76c3f7 --- /dev/null +++ b/pkg/project-client/integrations/dialog.go @@ -0,0 +1,54 @@ +package integrations + +import "encoding/json" + +// Styling for confirmation and action dialogs. +type Dialog struct { + // Accent color for dialog buttons and highlights. + AccentColor *string `json:"accentColor,omitempty" required:"true"` + // Dialog background color. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` + // Dialog text color. + TextColor *string `json:"textColor,omitempty" required:"true"` +} + +func (d *Dialog) GetAccentColor() *string { + if d == nil { + return nil + } + return d.AccentColor +} + +func (d *Dialog) SetAccentColor(accentColor string) { + d.AccentColor = &accentColor +} + +func (d *Dialog) GetBackgroundColor() *string { + if d == nil { + return nil + } + return d.BackgroundColor +} + +func (d *Dialog) SetBackgroundColor(backgroundColor string) { + d.BackgroundColor = &backgroundColor +} + +func (d *Dialog) GetTextColor() *string { + if d == nil { + return nil + } + return d.TextColor +} + +func (d *Dialog) SetTextColor(textColor string) { + d.TextColor = &textColor +} + +func (d Dialog) String() string { + jsonData, err := json.MarshalIndent(d, "", " ") + if err != nil { + return "error converting struct: Dialog to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/event_source_config.go b/pkg/project-client/integrations/event_source_config.go new file mode 100644 index 0000000..990f1e5 --- /dev/null +++ b/pkg/project-client/integrations/event_source_config.go @@ -0,0 +1,50 @@ +package integrations + +import "encoding/json" + +type EventSourceConfig struct { + Config *EventSourceConfigPayload `json:"config,omitempty" required:"true"` + Id *string `json:"id,omitempty" required:"true"` + Name *string `json:"name,omitempty" required:"true"` +} + +func (e *EventSourceConfig) GetConfig() *EventSourceConfigPayload { + if e == nil { + return nil + } + return e.Config +} + +func (e *EventSourceConfig) SetConfig(config EventSourceConfigPayload) { + e.Config = &config +} + +func (e *EventSourceConfig) GetId() *string { + if e == nil { + return nil + } + return e.Id +} + +func (e *EventSourceConfig) SetId(id string) { + e.Id = &id +} + +func (e *EventSourceConfig) GetName() *string { + if e == nil { + return nil + } + return e.Name +} + +func (e *EventSourceConfig) SetName(name string) { + e.Name = &name +} + +func (e EventSourceConfig) String() string { + jsonData, err := json.MarshalIndent(e, "", " ") + if err != nil { + return "error converting struct: EventSourceConfig to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/event_source_config_collection.go b/pkg/project-client/integrations/event_source_config_collection.go new file mode 100644 index 0000000..83f57c6 --- /dev/null +++ b/pkg/project-client/integrations/event_source_config_collection.go @@ -0,0 +1,41 @@ +package integrations + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/shared" +) + +type EventSourceConfigCollection struct { + Data []EventSourceConfig `json:"data,omitempty"` + Links *shared.Links `json:"links,omitempty"` +} + +func (e *EventSourceConfigCollection) GetData() []EventSourceConfig { + if e == nil { + return nil + } + return e.Data +} + +func (e *EventSourceConfigCollection) SetData(data []EventSourceConfig) { + e.Data = data +} + +func (e *EventSourceConfigCollection) GetLinks() *shared.Links { + if e == nil { + return nil + } + return e.Links +} + +func (e *EventSourceConfigCollection) SetLinks(links shared.Links) { + e.Links = &links +} + +func (e EventSourceConfigCollection) String() string { + jsonData, err := json.MarshalIndent(e, "", " ") + if err != nil { + return "error converting struct: EventSourceConfigCollection to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/event_source_config_payload.go b/pkg/project-client/integrations/event_source_config_payload.go new file mode 100644 index 0000000..69840af --- /dev/null +++ b/pkg/project-client/integrations/event_source_config_payload.go @@ -0,0 +1,26 @@ +package integrations + +import "encoding/json" + +type EventSourceConfigPayload struct { + Source *string `json:"source,omitempty" required:"true"` +} + +func (e *EventSourceConfigPayload) GetSource() *string { + if e == nil { + return nil + } + return e.Source +} + +func (e *EventSourceConfigPayload) SetSource(source string) { + e.Source = &source +} + +func (e EventSourceConfigPayload) String() string { + jsonData, err := json.MarshalIndent(e, "", " ") + if err != nil { + return "error converting struct: EventSourceConfigPayload to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/expo_config_payload.go b/pkg/project-client/integrations/expo_config_payload.go index 7575d4e..d97e9fd 100644 --- a/pkg/project-client/integrations/expo_config_payload.go +++ b/pkg/project-client/integrations/expo_config_payload.go @@ -3,6 +3,7 @@ package integrations import "encoding/json" type ExpoConfigPayload struct { + // The Expo access token used to authenticate push notifications. AccessToken *string `json:"access_token,omitempty" required:"true" minLength:"1"` } diff --git a/pkg/project-client/integrations/fcm_config_payload.go b/pkg/project-client/integrations/fcm_config_payload.go index 6facf20..df63ba4 100644 --- a/pkg/project-client/integrations/fcm_config_payload.go +++ b/pkg/project-client/integrations/fcm_config_payload.go @@ -3,17 +3,28 @@ package integrations import "encoding/json" type FcmConfigPayload struct { + // URL for Google's OAuth provider x509 certificates used to validate tokens. AuthProviderX509CertUrl *string `json:"auth_provider_x509_cert_url,omitempty" required:"true"` - AuthUri *string `json:"auth_uri,omitempty" required:"true"` - ClientEmail *string `json:"client_email,omitempty" required:"true"` - ClientId *string `json:"client_id,omitempty" required:"true"` - ClientX509CertUrl *string `json:"client_x509_cert_url,omitempty" required:"true"` - PrivateKey *string `json:"private_key,omitempty" required:"true" pattern:"^-+?\s?BEGIN[A-Z ]+-+\n([A-Za-z0-9+/\r\n]+={0,2})\n-+\s?END[A-Z ]+-+\n?$"` - PrivateKeyId *string `json:"private_key_id,omitempty" required:"true"` - ProjectId *string `json:"project_id,omitempty" required:"true"` - TokenUri *string `json:"token_uri,omitempty" required:"true"` - Type_ *Type_ `json:"type,omitempty" required:"true"` - UniverseDomain *string `json:"universe_domain,omitempty" required:"true"` + // OAuth authorization endpoint used when exchanging Firebase credentials. + AuthUri *string `json:"auth_uri,omitempty" required:"true"` + // The client email address from the Firebase service account. + ClientEmail *string `json:"client_email,omitempty" required:"true"` + // The numeric client identifier for the Firebase service account. + ClientId *string `json:"client_id,omitempty" required:"true"` + // URL to the public x509 certificate for this service account. + ClientX509CertUrl *string `json:"client_x509_cert_url,omitempty" required:"true"` + // The PEM encoded service account private key used to sign Firebase credentials. + PrivateKey *string `json:"private_key,omitempty" required:"true" pattern:"^-+?\s?BEGIN[A-Z ]+-+\n([A-Za-z0-9+/\r\n]+={0,2})\n-+\s?END[A-Z ]+-+\n?$"` + // Identifier of the private key inside the downloaded service account JSON. + PrivateKeyId *string `json:"private_key_id,omitempty" required:"true"` + // The Firebase project ID associated with this service account. + ProjectId *string `json:"project_id,omitempty" required:"true"` + // OAuth token endpoint used to mint access tokens for FCM. + TokenUri *string `json:"token_uri,omitempty" required:"true"` + // Indicates the kind of Google credential. Service accounts always use the `service_account` type. + Type_ *Type_ `json:"type,omitempty" required:"true"` + // The Google Cloud universe domain hosting the Firebase APIs. + UniverseDomain *string `json:"universe_domain,omitempty" required:"true"` } func (f *FcmConfigPayload) GetAuthProviderX509CertUrl() *string { @@ -144,9 +155,3 @@ func (f FcmConfigPayload) String() string { } return string(jsonData) } - -type Type_ string - -const ( - TYPE_SERVICE_ACCOUNT Type_ = "service_account" -) diff --git a/pkg/project-client/integrations/footer.go b/pkg/project-client/integrations/footer.go new file mode 100644 index 0000000..4cce7a5 --- /dev/null +++ b/pkg/project-client/integrations/footer.go @@ -0,0 +1,67 @@ +package integrations + +import "encoding/json" + +// Footer styling for the inbox modal. +type Footer struct { + // Footer background color. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` + // Border radius applied to the footer container. + BorderRadius *string `json:"borderRadius,omitempty" required:"true"` + // Font size used in the footer. + FontSize *string `json:"fontSize,omitempty" required:"true"` + // Footer text color. + TextColor *string `json:"textColor,omitempty" required:"true"` +} + +func (f *Footer) GetBackgroundColor() *string { + if f == nil { + return nil + } + return f.BackgroundColor +} + +func (f *Footer) SetBackgroundColor(backgroundColor string) { + f.BackgroundColor = &backgroundColor +} + +func (f *Footer) GetBorderRadius() *string { + if f == nil { + return nil + } + return f.BorderRadius +} + +func (f *Footer) SetBorderRadius(borderRadius string) { + f.BorderRadius = &borderRadius +} + +func (f *Footer) GetFontSize() *string { + if f == nil { + return nil + } + return f.FontSize +} + +func (f *Footer) SetFontSize(fontSize string) { + f.FontSize = &fontSize +} + +func (f *Footer) GetTextColor() *string { + if f == nil { + return nil + } + return f.TextColor +} + +func (f *Footer) SetTextColor(textColor string) { + f.TextColor = &textColor +} + +func (f Footer) String() string { + jsonData, err := json.MarshalIndent(f, "", " ") + if err != nil { + return "error converting struct: Footer to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/header.go b/pkg/project-client/integrations/header.go new file mode 100644 index 0000000..1105c44 --- /dev/null +++ b/pkg/project-client/integrations/header.go @@ -0,0 +1,80 @@ +package integrations + +import "encoding/json" + +// Header styling for the inbox modal. +type Header struct { + // Header background color. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` + // Border radius applied to the header container. + BorderRadius *string `json:"borderRadius,omitempty" required:"true"` + // CSS font family for the header title. + FontFamily *string `json:"fontFamily,omitempty" required:"true"` + // Font size used in the header. + FontSize *string `json:"fontSize,omitempty" required:"true"` + // Header text color. + TextColor *string `json:"textColor,omitempty" required:"true"` +} + +func (h *Header) GetBackgroundColor() *string { + if h == nil { + return nil + } + return h.BackgroundColor +} + +func (h *Header) SetBackgroundColor(backgroundColor string) { + h.BackgroundColor = &backgroundColor +} + +func (h *Header) GetBorderRadius() *string { + if h == nil { + return nil + } + return h.BorderRadius +} + +func (h *Header) SetBorderRadius(borderRadius string) { + h.BorderRadius = &borderRadius +} + +func (h *Header) GetFontFamily() *string { + if h == nil { + return nil + } + return h.FontFamily +} + +func (h *Header) SetFontFamily(fontFamily string) { + h.FontFamily = &fontFamily +} + +func (h *Header) GetFontSize() *string { + if h == nil { + return nil + } + return h.FontSize +} + +func (h *Header) SetFontSize(fontSize string) { + h.FontSize = &fontSize +} + +func (h *Header) GetTextColor() *string { + if h == nil { + return nil + } + return h.TextColor +} + +func (h *Header) SetTextColor(textColor string) { + h.TextColor = &textColor +} + +func (h Header) String() string { + jsonData, err := json.MarshalIndent(h, "", " ") + if err != nil { + return "error converting struct: Header to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/icon.go b/pkg/project-client/integrations/icon.go new file mode 100644 index 0000000..315ccdf --- /dev/null +++ b/pkg/project-client/integrations/icon.go @@ -0,0 +1,41 @@ +package integrations + +import "encoding/json" + +// Launcher icon styling overrides. +type Icon struct { + // CSS color used for the icon border. + BorderColor *string `json:"borderColor,omitempty" required:"true"` + // Width of the launcher icon (any CSS length). + Width *string `json:"width,omitempty" required:"true"` +} + +func (i *Icon) GetBorderColor() *string { + if i == nil { + return nil + } + return i.BorderColor +} + +func (i *Icon) SetBorderColor(borderColor string) { + i.BorderColor = &borderColor +} + +func (i *Icon) GetWidth() *string { + if i == nil { + return nil + } + return i.Width +} + +func (i *Icon) SetWidth(width string) { + i.Width = &width +} + +func (i Icon) String() string { + jsonData, err := json.MarshalIndent(i, "", " ") + if err != nil { + return "error converting struct: Icon to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/images.go b/pkg/project-client/integrations/images.go new file mode 100644 index 0000000..3b4b07a --- /dev/null +++ b/pkg/project-client/integrations/images.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// Image overrides for assets used in the inbox UI. +type Images struct { + // URL for the illustration shown when the inbox is empty. + EmptyInboxUrl *string `json:"emptyInboxUrl,omitempty" required:"true"` +} + +func (i *Images) GetEmptyInboxUrl() *string { + if i == nil { + return nil + } + return i.EmptyInboxUrl +} + +func (i *Images) SetEmptyInboxUrl(emptyInboxUrl string) { + i.EmptyInboxUrl = &emptyInboxUrl +} + +func (i Images) String() string { + jsonData, err := json.MarshalIndent(i, "", " ") + if err != nil { + return "error converting struct: Images to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/inbox_config_payload.go b/pkg/project-client/integrations/inbox_config_payload.go index f286836..d95cf91 100644 --- a/pkg/project-client/integrations/inbox_config_payload.go +++ b/pkg/project-client/integrations/inbox_config_payload.go @@ -7,9 +7,12 @@ import ( ) type InboxConfigPayload struct { + // Image overrides for assets used in the inbox UI. Images *util.Nullable[Images] `json:"images,omitempty" required:"true"` + // Locale code (ISO language tag) used to localize built-in strings. Locale *util.Nullable[string] `json:"locale,omitempty" required:"true" minLength:"2"` - Theme *util.Nullable[Theme] `json:"theme,omitempty" required:"true"` + // Visual customization options for the hosted inbox widget. + Theme *util.Nullable[Theme] `json:"theme,omitempty" required:"true"` } func (i *InboxConfigPayload) GetImages() *util.Nullable[Images] { @@ -68,825 +71,3 @@ func (i InboxConfigPayload) String() string { func (i *InboxConfigPayload) UnmarshalJSON(data []byte) error { return unmarshal.UnmarshalNullable(data, i) } - -type Images struct { - EmptyInboxUrl *string `json:"emptyInboxUrl,omitempty" required:"true"` -} - -func (i *Images) GetEmptyInboxUrl() *string { - if i == nil { - return nil - } - return i.EmptyInboxUrl -} - -func (i *Images) SetEmptyInboxUrl(emptyInboxUrl string) { - i.EmptyInboxUrl = &emptyInboxUrl -} - -func (i Images) String() string { - jsonData, err := json.MarshalIndent(i, "", " ") - if err != nil { - return "error converting struct: Images to string" - } - return string(jsonData) -} - -type Theme struct { - Banner *Banner `json:"banner,omitempty"` - Dialog *Dialog `json:"dialog,omitempty"` - Footer *Footer `json:"footer,omitempty"` - Header *Header `json:"header,omitempty"` - Icon *Icon `json:"icon,omitempty"` - Notification *Notification `json:"notification,omitempty"` - UnseenBadge *UnseenBadge `json:"unseenBadge,omitempty"` -} - -func (t *Theme) GetBanner() *Banner { - if t == nil { - return nil - } - return t.Banner -} - -func (t *Theme) SetBanner(banner Banner) { - t.Banner = &banner -} - -func (t *Theme) GetDialog() *Dialog { - if t == nil { - return nil - } - return t.Dialog -} - -func (t *Theme) SetDialog(dialog Dialog) { - t.Dialog = &dialog -} - -func (t *Theme) GetFooter() *Footer { - if t == nil { - return nil - } - return t.Footer -} - -func (t *Theme) SetFooter(footer Footer) { - t.Footer = &footer -} - -func (t *Theme) GetHeader() *Header { - if t == nil { - return nil - } - return t.Header -} - -func (t *Theme) SetHeader(header Header) { - t.Header = &header -} - -func (t *Theme) GetIcon() *Icon { - if t == nil { - return nil - } - return t.Icon -} - -func (t *Theme) SetIcon(icon Icon) { - t.Icon = &icon -} - -func (t *Theme) GetNotification() *Notification { - if t == nil { - return nil - } - return t.Notification -} - -func (t *Theme) SetNotification(notification Notification) { - t.Notification = ¬ification -} - -func (t *Theme) GetUnseenBadge() *UnseenBadge { - if t == nil { - return nil - } - return t.UnseenBadge -} - -func (t *Theme) SetUnseenBadge(unseenBadge UnseenBadge) { - t.UnseenBadge = &unseenBadge -} - -func (t Theme) String() string { - jsonData, err := json.MarshalIndent(t, "", " ") - if err != nil { - return "error converting struct: Theme to string" - } - return string(jsonData) -} - -type Banner struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` - BackgroundOpacity *float64 `json:"backgroundOpacity,omitempty"` - FontSize *string `json:"fontSize,omitempty" required:"true"` - TextColor *string `json:"textColor,omitempty" required:"true"` -} - -func (b *Banner) GetBackgroundColor() *string { - if b == nil { - return nil - } - return b.BackgroundColor -} - -func (b *Banner) SetBackgroundColor(backgroundColor string) { - b.BackgroundColor = &backgroundColor -} - -func (b *Banner) GetBackgroundOpacity() *float64 { - if b == nil { - return nil - } - return b.BackgroundOpacity -} - -func (b *Banner) SetBackgroundOpacity(backgroundOpacity float64) { - b.BackgroundOpacity = &backgroundOpacity -} - -func (b *Banner) GetFontSize() *string { - if b == nil { - return nil - } - return b.FontSize -} - -func (b *Banner) SetFontSize(fontSize string) { - b.FontSize = &fontSize -} - -func (b *Banner) GetTextColor() *string { - if b == nil { - return nil - } - return b.TextColor -} - -func (b *Banner) SetTextColor(textColor string) { - b.TextColor = &textColor -} - -func (b Banner) String() string { - jsonData, err := json.MarshalIndent(b, "", " ") - if err != nil { - return "error converting struct: Banner to string" - } - return string(jsonData) -} - -type Dialog struct { - AccentColor *string `json:"accentColor,omitempty" required:"true"` - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` - TextColor *string `json:"textColor,omitempty" required:"true"` -} - -func (d *Dialog) GetAccentColor() *string { - if d == nil { - return nil - } - return d.AccentColor -} - -func (d *Dialog) SetAccentColor(accentColor string) { - d.AccentColor = &accentColor -} - -func (d *Dialog) GetBackgroundColor() *string { - if d == nil { - return nil - } - return d.BackgroundColor -} - -func (d *Dialog) SetBackgroundColor(backgroundColor string) { - d.BackgroundColor = &backgroundColor -} - -func (d *Dialog) GetTextColor() *string { - if d == nil { - return nil - } - return d.TextColor -} - -func (d *Dialog) SetTextColor(textColor string) { - d.TextColor = &textColor -} - -func (d Dialog) String() string { - jsonData, err := json.MarshalIndent(d, "", " ") - if err != nil { - return "error converting struct: Dialog to string" - } - return string(jsonData) -} - -type Footer struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` - BorderRadius *string `json:"borderRadius,omitempty" required:"true"` - FontSize *string `json:"fontSize,omitempty" required:"true"` - TextColor *string `json:"textColor,omitempty" required:"true"` -} - -func (f *Footer) GetBackgroundColor() *string { - if f == nil { - return nil - } - return f.BackgroundColor -} - -func (f *Footer) SetBackgroundColor(backgroundColor string) { - f.BackgroundColor = &backgroundColor -} - -func (f *Footer) GetBorderRadius() *string { - if f == nil { - return nil - } - return f.BorderRadius -} - -func (f *Footer) SetBorderRadius(borderRadius string) { - f.BorderRadius = &borderRadius -} - -func (f *Footer) GetFontSize() *string { - if f == nil { - return nil - } - return f.FontSize -} - -func (f *Footer) SetFontSize(fontSize string) { - f.FontSize = &fontSize -} - -func (f *Footer) GetTextColor() *string { - if f == nil { - return nil - } - return f.TextColor -} - -func (f *Footer) SetTextColor(textColor string) { - f.TextColor = &textColor -} - -func (f Footer) String() string { - jsonData, err := json.MarshalIndent(f, "", " ") - if err != nil { - return "error converting struct: Footer to string" - } - return string(jsonData) -} - -type Header struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` - BorderRadius *string `json:"borderRadius,omitempty" required:"true"` - FontFamily *string `json:"fontFamily,omitempty" required:"true"` - FontSize *string `json:"fontSize,omitempty" required:"true"` - TextColor *string `json:"textColor,omitempty" required:"true"` -} - -func (h *Header) GetBackgroundColor() *string { - if h == nil { - return nil - } - return h.BackgroundColor -} - -func (h *Header) SetBackgroundColor(backgroundColor string) { - h.BackgroundColor = &backgroundColor -} - -func (h *Header) GetBorderRadius() *string { - if h == nil { - return nil - } - return h.BorderRadius -} - -func (h *Header) SetBorderRadius(borderRadius string) { - h.BorderRadius = &borderRadius -} - -func (h *Header) GetFontFamily() *string { - if h == nil { - return nil - } - return h.FontFamily -} - -func (h *Header) SetFontFamily(fontFamily string) { - h.FontFamily = &fontFamily -} - -func (h *Header) GetFontSize() *string { - if h == nil { - return nil - } - return h.FontSize -} - -func (h *Header) SetFontSize(fontSize string) { - h.FontSize = &fontSize -} - -func (h *Header) GetTextColor() *string { - if h == nil { - return nil - } - return h.TextColor -} - -func (h *Header) SetTextColor(textColor string) { - h.TextColor = &textColor -} - -func (h Header) String() string { - jsonData, err := json.MarshalIndent(h, "", " ") - if err != nil { - return "error converting struct: Header to string" - } - return string(jsonData) -} - -type Icon struct { - BorderColor *string `json:"borderColor,omitempty" required:"true"` - Width *string `json:"width,omitempty" required:"true"` -} - -func (i *Icon) GetBorderColor() *string { - if i == nil { - return nil - } - return i.BorderColor -} - -func (i *Icon) SetBorderColor(borderColor string) { - i.BorderColor = &borderColor -} - -func (i *Icon) GetWidth() *string { - if i == nil { - return nil - } - return i.Width -} - -func (i *Icon) SetWidth(width string) { - i.Width = &width -} - -func (i Icon) String() string { - jsonData, err := json.MarshalIndent(i, "", " ") - if err != nil { - return "error converting struct: Icon to string" - } - return string(jsonData) -} - -type Notification struct { - Default_ *Default_ `json:"default,omitempty" required:"true"` - Unread *Unread `json:"unread,omitempty" required:"true"` - Unseen *Unseen `json:"unseen,omitempty" required:"true"` -} - -func (n *Notification) GetDefault_() *Default_ { - if n == nil { - return nil - } - return n.Default_ -} - -func (n *Notification) SetDefault_(default_ Default_) { - n.Default_ = &default_ -} - -func (n *Notification) GetUnread() *Unread { - if n == nil { - return nil - } - return n.Unread -} - -func (n *Notification) SetUnread(unread Unread) { - n.Unread = &unread -} - -func (n *Notification) GetUnseen() *Unseen { - if n == nil { - return nil - } - return n.Unseen -} - -func (n *Notification) SetUnseen(unseen Unseen) { - n.Unseen = &unseen -} - -func (n Notification) String() string { - jsonData, err := json.MarshalIndent(n, "", " ") - if err != nil { - return "error converting struct: Notification to string" - } - return string(jsonData) -} - -type Default_ struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` - BorderRadius *string `json:"borderRadius,omitempty" required:"true"` - FontFamily *string `json:"fontFamily,omitempty" required:"true"` - FontSize *string `json:"fontSize,omitempty" required:"true"` - Hover *DefaultHover `json:"hover,omitempty"` - Margin *string `json:"margin,omitempty" required:"true"` - State *DefaultState `json:"state,omitempty"` - TextColor *string `json:"textColor,omitempty" required:"true"` -} - -func (d *Default_) GetBackgroundColor() *string { - if d == nil { - return nil - } - return d.BackgroundColor -} - -func (d *Default_) SetBackgroundColor(backgroundColor string) { - d.BackgroundColor = &backgroundColor -} - -func (d *Default_) GetBorderRadius() *string { - if d == nil { - return nil - } - return d.BorderRadius -} - -func (d *Default_) SetBorderRadius(borderRadius string) { - d.BorderRadius = &borderRadius -} - -func (d *Default_) GetFontFamily() *string { - if d == nil { - return nil - } - return d.FontFamily -} - -func (d *Default_) SetFontFamily(fontFamily string) { - d.FontFamily = &fontFamily -} - -func (d *Default_) GetFontSize() *string { - if d == nil { - return nil - } - return d.FontSize -} - -func (d *Default_) SetFontSize(fontSize string) { - d.FontSize = &fontSize -} - -func (d *Default_) GetHover() *DefaultHover { - if d == nil { - return nil - } - return d.Hover -} - -func (d *Default_) SetHover(hover DefaultHover) { - d.Hover = &hover -} - -func (d *Default_) GetMargin() *string { - if d == nil { - return nil - } - return d.Margin -} - -func (d *Default_) SetMargin(margin string) { - d.Margin = &margin -} - -func (d *Default_) GetState() *DefaultState { - if d == nil { - return nil - } - return d.State -} - -func (d *Default_) SetState(state DefaultState) { - d.State = &state -} - -func (d *Default_) GetTextColor() *string { - if d == nil { - return nil - } - return d.TextColor -} - -func (d *Default_) SetTextColor(textColor string) { - d.TextColor = &textColor -} - -func (d Default_) String() string { - jsonData, err := json.MarshalIndent(d, "", " ") - if err != nil { - return "error converting struct: Default_ to string" - } - return string(jsonData) -} - -type DefaultHover struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` -} - -func (d *DefaultHover) GetBackgroundColor() *string { - if d == nil { - return nil - } - return d.BackgroundColor -} - -func (d *DefaultHover) SetBackgroundColor(backgroundColor string) { - d.BackgroundColor = &backgroundColor -} - -func (d DefaultHover) String() string { - jsonData, err := json.MarshalIndent(d, "", " ") - if err != nil { - return "error converting struct: DefaultHover to string" - } - return string(jsonData) -} - -type DefaultState struct { - Color *string `json:"color,omitempty" required:"true"` -} - -func (d *DefaultState) GetColor() *string { - if d == nil { - return nil - } - return d.Color -} - -func (d *DefaultState) SetColor(color string) { - d.Color = &color -} - -func (d DefaultState) String() string { - jsonData, err := json.MarshalIndent(d, "", " ") - if err != nil { - return "error converting struct: DefaultState to string" - } - return string(jsonData) -} - -type Unread struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` - Hover *UnreadHover `json:"hover,omitempty"` - State *UnreadState `json:"state,omitempty"` - TextColor *string `json:"textColor,omitempty" required:"true"` -} - -func (u *Unread) GetBackgroundColor() *string { - if u == nil { - return nil - } - return u.BackgroundColor -} - -func (u *Unread) SetBackgroundColor(backgroundColor string) { - u.BackgroundColor = &backgroundColor -} - -func (u *Unread) GetHover() *UnreadHover { - if u == nil { - return nil - } - return u.Hover -} - -func (u *Unread) SetHover(hover UnreadHover) { - u.Hover = &hover -} - -func (u *Unread) GetState() *UnreadState { - if u == nil { - return nil - } - return u.State -} - -func (u *Unread) SetState(state UnreadState) { - u.State = &state -} - -func (u *Unread) GetTextColor() *string { - if u == nil { - return nil - } - return u.TextColor -} - -func (u *Unread) SetTextColor(textColor string) { - u.TextColor = &textColor -} - -func (u Unread) String() string { - jsonData, err := json.MarshalIndent(u, "", " ") - if err != nil { - return "error converting struct: Unread to string" - } - return string(jsonData) -} - -type UnreadHover struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` -} - -func (u *UnreadHover) GetBackgroundColor() *string { - if u == nil { - return nil - } - return u.BackgroundColor -} - -func (u *UnreadHover) SetBackgroundColor(backgroundColor string) { - u.BackgroundColor = &backgroundColor -} - -func (u UnreadHover) String() string { - jsonData, err := json.MarshalIndent(u, "", " ") - if err != nil { - return "error converting struct: UnreadHover to string" - } - return string(jsonData) -} - -type UnreadState struct { - Color *string `json:"color,omitempty" required:"true"` -} - -func (u *UnreadState) GetColor() *string { - if u == nil { - return nil - } - return u.Color -} - -func (u *UnreadState) SetColor(color string) { - u.Color = &color -} - -func (u UnreadState) String() string { - jsonData, err := json.MarshalIndent(u, "", " ") - if err != nil { - return "error converting struct: UnreadState to string" - } - return string(jsonData) -} - -type Unseen struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` - Hover *UnseenHover `json:"hover,omitempty"` - State *UnseenState `json:"state,omitempty"` - TextColor *string `json:"textColor,omitempty" required:"true"` -} - -func (u *Unseen) GetBackgroundColor() *string { - if u == nil { - return nil - } - return u.BackgroundColor -} - -func (u *Unseen) SetBackgroundColor(backgroundColor string) { - u.BackgroundColor = &backgroundColor -} - -func (u *Unseen) GetHover() *UnseenHover { - if u == nil { - return nil - } - return u.Hover -} - -func (u *Unseen) SetHover(hover UnseenHover) { - u.Hover = &hover -} - -func (u *Unseen) GetState() *UnseenState { - if u == nil { - return nil - } - return u.State -} - -func (u *Unseen) SetState(state UnseenState) { - u.State = &state -} - -func (u *Unseen) GetTextColor() *string { - if u == nil { - return nil - } - return u.TextColor -} - -func (u *Unseen) SetTextColor(textColor string) { - u.TextColor = &textColor -} - -func (u Unseen) String() string { - jsonData, err := json.MarshalIndent(u, "", " ") - if err != nil { - return "error converting struct: Unseen to string" - } - return string(jsonData) -} - -type UnseenHover struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` -} - -func (u *UnseenHover) GetBackgroundColor() *string { - if u == nil { - return nil - } - return u.BackgroundColor -} - -func (u *UnseenHover) SetBackgroundColor(backgroundColor string) { - u.BackgroundColor = &backgroundColor -} - -func (u UnseenHover) String() string { - jsonData, err := json.MarshalIndent(u, "", " ") - if err != nil { - return "error converting struct: UnseenHover to string" - } - return string(jsonData) -} - -type UnseenState struct { - Color *string `json:"color,omitempty" required:"true"` -} - -func (u *UnseenState) GetColor() *string { - if u == nil { - return nil - } - return u.Color -} - -func (u *UnseenState) SetColor(color string) { - u.Color = &color -} - -func (u UnseenState) String() string { - jsonData, err := json.MarshalIndent(u, "", " ") - if err != nil { - return "error converting struct: UnseenState to string" - } - return string(jsonData) -} - -type UnseenBadge struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` -} - -func (u *UnseenBadge) GetBackgroundColor() *string { - if u == nil { - return nil - } - return u.BackgroundColor -} - -func (u *UnseenBadge) SetBackgroundColor(backgroundColor string) { - u.BackgroundColor = &backgroundColor -} - -func (u UnseenBadge) String() string { - jsonData, err := json.MarshalIndent(u, "", " ") - if err != nil { - return "error converting struct: UnseenBadge to string" - } - return string(jsonData) -} diff --git a/pkg/project-client/integrations/integrations_service.go b/pkg/project-client/integrations/integrations_service.go index 9284caf..beec3f5 100644 --- a/pkg/project-client/integrations/integrations_service.go +++ b/pkg/project-client/integrations/integrations_service.go @@ -3,6 +3,7 @@ package integrations import ( "context" restClient "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/hooks" "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/httptransport" "github.com/magicbell/magicbell-go/pkg/project-client/internal/configmanager" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" @@ -10,8 +11,11 @@ import ( "time" ) +// IntegrationsService provides methods to interact with IntegrationsService-related API endpoints. +// It uses a configuration manager for settings and supports custom hooks for request/response interception. type IntegrationsService struct { manager *configmanager.ConfigManager + hook hooks.Hook } func NewIntegrationsService() *IntegrationsService { @@ -20,15 +24,28 @@ func NewIntegrationsService() *IntegrationsService { } } +// WithConfigManager sets the configuration manager for this service. +// Returns the service instance for method chaining. func (api *IntegrationsService) WithConfigManager(manager *configmanager.ConfigManager) *IntegrationsService { api.manager = manager return api } +// WithHook sets a custom hook for request/response interception. +// Returns the service instance for method chaining. +func (api *IntegrationsService) WithHook(hook hooks.Hook) *IntegrationsService { + api.hook = hook + return api +} + func (api *IntegrationsService) getConfig() *clientconfig.Config { return api.manager.GetIntegrations() } +func (api *IntegrationsService) getHook() hooks.Hook { + return api.hook +} + func (api *IntegrationsService) SetBaseUrl(baseUrl string) { config := api.getConfig() config.SetBaseUrl(baseUrl) @@ -45,7 +62,7 @@ func (api *IntegrationsService) SetAccessToken(accessToken string) { } // Lists all available and configured integrations for the project. Returns a summary of each integration including its type, status, and basic configuration information. -func (api *IntegrationsService) ListIntegrations(ctx context.Context, params ListIntegrationsRequestParams) (*shared.ClientResponse[IntegrationConfigCollection], *shared.ClientError) { +func (api *IntegrationsService) ListIntegrations(ctx context.Context, params ListIntegrationsRequestParams) (*shared.ClientResponse[IntegrationConfigCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -57,17 +74,17 @@ func (api *IntegrationsService) ListIntegrations(ctx context.Context, params Lis WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[IntegrationConfigCollection](config) + client := restClient.NewRestClient[IntegrationConfigCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[IntegrationConfigCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[IntegrationConfigCollection](resp), nil } // Retrieves the current APNs integration configurations for a specific integration type in the project. Returns configuration details and status information. -func (api *IntegrationsService) ListApnsIntegrations(ctx context.Context) (*shared.ClientResponse[ApnsConfigCollection], *shared.ClientError) { +func (api *IntegrationsService) ListApnsIntegrations(ctx context.Context) (*shared.ClientResponse[ApnsConfigCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -78,17 +95,17 @@ func (api *IntegrationsService) ListApnsIntegrations(ctx context.Context) (*shar WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[ApnsConfigCollection](config) + client := restClient.NewRestClient[ApnsConfigCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[ApnsConfigCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[ApnsConfigCollection](resp), nil } // Updates or creates the APNs integration for the project. -func (api *IntegrationsService) SaveApnsIntegration(ctx context.Context, apnsConfigPayload ApnsConfigPayload) (*shared.ClientResponse[ApnsConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) SaveApnsIntegration(ctx context.Context, apnsConfigPayload ApnsConfigPayload) (*shared.ClientResponse[ApnsConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -101,17 +118,17 @@ func (api *IntegrationsService) SaveApnsIntegration(ctx context.Context, apnsCon WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[ApnsConfigPayload](config) + client := restClient.NewRestClient[ApnsConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[ApnsConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[ApnsConfigPayload](resp), nil } // Deletes the APNs integration configuration from the project. This will disable the integration's functionality within the project. -func (api *IntegrationsService) DeleteApnsIntegration(ctx context.Context, params DeleteApnsIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *IntegrationsService) DeleteApnsIntegration(ctx context.Context, params DeleteApnsIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -123,17 +140,83 @@ func (api *IntegrationsService) DeleteApnsIntegration(ctx context.Context, param WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[any](resp), nil +} + +// Retrieves the current EventSource integration configurations for a specific integration type in the project. Returns configuration details and status information. +func (api *IntegrationsService) ListEventsourceIntegrations(ctx context.Context) (*shared.ClientResponse[EventSourceConfigCollection], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("GET"). + WithPath("/integrations/eventsource"). + WithConfig(config). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[EventSourceConfigCollection, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[EventSourceConfigCollection](resp), nil +} + +// Updates or creates the EventSource integration for the project. +func (api *IntegrationsService) SaveEventsourceIntegration(ctx context.Context, eventSourceConfigPayload EventSourceConfigPayload) (*shared.ClientResponse[EventSourceConfigPayload], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("PUT"). + WithPath("/integrations/eventsource"). + WithConfig(config). + WithBody(eventSourceConfigPayload). + AddHeader("CONTENT-TYPE", "application/json"). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[EventSourceConfigPayload, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[EventSourceConfigPayload](resp), nil +} + +// Deletes the EventSource integration configuration from the project. This will disable the integration's functionality within the project. +func (api *IntegrationsService) DeleteEventsourceIntegration(ctx context.Context, params DeleteEventsourceIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("DELETE"). + WithPath("/integrations/eventsource"). + WithConfig(config). + WithOptions(params). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[any, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Retrieves the current Expo integration configurations for a specific integration type in the project. Returns configuration details and status information. -func (api *IntegrationsService) ListExpoIntegrations(ctx context.Context) (*shared.ClientResponse[ExpoConfigCollection], *shared.ClientError) { +func (api *IntegrationsService) ListExpoIntegrations(ctx context.Context) (*shared.ClientResponse[ExpoConfigCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -144,17 +227,17 @@ func (api *IntegrationsService) ListExpoIntegrations(ctx context.Context) (*shar WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[ExpoConfigCollection](config) + client := restClient.NewRestClient[ExpoConfigCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[ExpoConfigCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[ExpoConfigCollection](resp), nil } // Updates or creates the Expo integration for the project. -func (api *IntegrationsService) SaveExpoIntegration(ctx context.Context, expoConfigPayload ExpoConfigPayload) (*shared.ClientResponse[ExpoConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) SaveExpoIntegration(ctx context.Context, expoConfigPayload ExpoConfigPayload) (*shared.ClientResponse[ExpoConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -167,17 +250,17 @@ func (api *IntegrationsService) SaveExpoIntegration(ctx context.Context, expoCon WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[ExpoConfigPayload](config) + client := restClient.NewRestClient[ExpoConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[ExpoConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[ExpoConfigPayload](resp), nil } // Deletes the Expo integration configuration from the project. This will disable the integration's functionality within the project. -func (api *IntegrationsService) DeleteExpoIntegration(ctx context.Context, params DeleteExpoIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *IntegrationsService) DeleteExpoIntegration(ctx context.Context, params DeleteExpoIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -189,17 +272,17 @@ func (api *IntegrationsService) DeleteExpoIntegration(ctx context.Context, param WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Retrieves the current FCM integration configurations for a specific integration type in the project. Returns configuration details and status information. -func (api *IntegrationsService) ListFcmIntegrations(ctx context.Context) (*shared.ClientResponse[FcmConfigCollection], *shared.ClientError) { +func (api *IntegrationsService) ListFcmIntegrations(ctx context.Context) (*shared.ClientResponse[FcmConfigCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -210,17 +293,17 @@ func (api *IntegrationsService) ListFcmIntegrations(ctx context.Context) (*share WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[FcmConfigCollection](config) + client := restClient.NewRestClient[FcmConfigCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[FcmConfigCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[FcmConfigCollection](resp), nil } // Updates or creates the FCM integration for the project. -func (api *IntegrationsService) SaveFcmIntegration(ctx context.Context, fcmConfigPayload FcmConfigPayload) (*shared.ClientResponse[FcmConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) SaveFcmIntegration(ctx context.Context, fcmConfigPayload FcmConfigPayload) (*shared.ClientResponse[FcmConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -233,17 +316,17 @@ func (api *IntegrationsService) SaveFcmIntegration(ctx context.Context, fcmConfi WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[FcmConfigPayload](config) + client := restClient.NewRestClient[FcmConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[FcmConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[FcmConfigPayload](resp), nil } // Deletes the FCM integration configuration from the project. This will disable the integration's functionality within the project. -func (api *IntegrationsService) DeleteFcmIntegration(ctx context.Context, params DeleteFcmIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *IntegrationsService) DeleteFcmIntegration(ctx context.Context, params DeleteFcmIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -255,17 +338,17 @@ func (api *IntegrationsService) DeleteFcmIntegration(ctx context.Context, params WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Retrieves the current GitHub integration configurations for a specific integration type in the project. Returns configuration details and status information. -func (api *IntegrationsService) ListGithubIntegrations(ctx context.Context) (*shared.ClientResponse[GithubConfigCollection], *shared.ClientError) { +func (api *IntegrationsService) ListGithubIntegrations(ctx context.Context) (*shared.ClientResponse[GithubConfigCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -276,17 +359,17 @@ func (api *IntegrationsService) ListGithubIntegrations(ctx context.Context) (*sh WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[GithubConfigCollection](config) + client := restClient.NewRestClient[GithubConfigCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[GithubConfigCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[GithubConfigCollection](resp), nil } // Updates or creates the GitHub integration for the project. -func (api *IntegrationsService) SaveGithubIntegration(ctx context.Context, githubConfigPayload GithubConfigPayload) (*shared.ClientResponse[GithubConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) SaveGithubIntegration(ctx context.Context, githubConfigPayload GithubConfigPayload) (*shared.ClientResponse[GithubConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -299,17 +382,17 @@ func (api *IntegrationsService) SaveGithubIntegration(ctx context.Context, githu WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[GithubConfigPayload](config) + client := restClient.NewRestClient[GithubConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[GithubConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[GithubConfigPayload](resp), nil } // Deletes the GitHub integration configuration from the project. This will disable the integration's functionality within the project. -func (api *IntegrationsService) DeleteGithubIntegration(ctx context.Context, params DeleteGithubIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *IntegrationsService) DeleteGithubIntegration(ctx context.Context, params DeleteGithubIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -321,17 +404,17 @@ func (api *IntegrationsService) DeleteGithubIntegration(ctx context.Context, par WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Retrieves the current Inbox integration configurations for a specific integration type in the project. Returns configuration details and status information. -func (api *IntegrationsService) ListInboxIntegrations(ctx context.Context) (*shared.ClientResponse[InboxConfigCollection], *shared.ClientError) { +func (api *IntegrationsService) ListInboxIntegrations(ctx context.Context) (*shared.ClientResponse[InboxConfigCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -342,17 +425,17 @@ func (api *IntegrationsService) ListInboxIntegrations(ctx context.Context) (*sha WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[InboxConfigCollection](config) + client := restClient.NewRestClient[InboxConfigCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[InboxConfigCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[InboxConfigCollection](resp), nil } // Updates or creates the Inbox integration for the project. -func (api *IntegrationsService) SaveInboxIntegration(ctx context.Context, inboxConfigPayload InboxConfigPayload) (*shared.ClientResponse[InboxConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) SaveInboxIntegration(ctx context.Context, inboxConfigPayload InboxConfigPayload) (*shared.ClientResponse[InboxConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -365,17 +448,17 @@ func (api *IntegrationsService) SaveInboxIntegration(ctx context.Context, inboxC WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[InboxConfigPayload](config) + client := restClient.NewRestClient[InboxConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[InboxConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[InboxConfigPayload](resp), nil } // Deletes the Inbox integration configuration from the project. This will disable the integration's functionality within the project. -func (api *IntegrationsService) DeleteInboxIntegration(ctx context.Context, params DeleteInboxIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *IntegrationsService) DeleteInboxIntegration(ctx context.Context, params DeleteInboxIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -387,17 +470,83 @@ func (api *IntegrationsService) DeleteInboxIntegration(ctx context.Context, para WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[any](resp), nil +} + +// Retrieves the current MagicBell SlackBot integration configurations for a specific integration type in the project. Returns configuration details and status information. +func (api *IntegrationsService) ListMagicbellSlackbotIntegrations(ctx context.Context) (*shared.ClientResponse[SlackBotConfigCollection], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("GET"). + WithPath("/integrations/magicbell_slackbot"). + WithConfig(config). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[SlackBotConfigCollection, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[SlackBotConfigCollection](resp), nil +} + +// Updates or creates the MagicBell SlackBot integration for the project. +func (api *IntegrationsService) SaveMagicbellSlackbotIntegration(ctx context.Context, slackBotConfigPayload SlackBotConfigPayload) (*shared.ClientResponse[SlackBotConfigPayload], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("PUT"). + WithPath("/integrations/magicbell_slackbot"). + WithConfig(config). + WithBody(slackBotConfigPayload). + AddHeader("CONTENT-TYPE", "application/json"). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[SlackBotConfigPayload, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[SlackBotConfigPayload](resp), nil +} + +// Deletes the MagicBell SlackBot integration configuration from the project. This will disable the integration's functionality within the project. +func (api *IntegrationsService) DeleteMagicbellSlackbotIntegration(ctx context.Context, params DeleteMagicbellSlackbotIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("DELETE"). + WithPath("/integrations/magicbell_slackbot"). + WithConfig(config). + WithOptions(params). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[any, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Retrieves the current Mailgun integration configurations for a specific integration type in the project. Returns configuration details and status information. -func (api *IntegrationsService) ListMailgunIntegrations(ctx context.Context) (*shared.ClientResponse[MailgunConfigCollection], *shared.ClientError) { +func (api *IntegrationsService) ListMailgunIntegrations(ctx context.Context) (*shared.ClientResponse[MailgunConfigCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -408,17 +557,17 @@ func (api *IntegrationsService) ListMailgunIntegrations(ctx context.Context) (*s WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[MailgunConfigCollection](config) + client := restClient.NewRestClient[MailgunConfigCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[MailgunConfigCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[MailgunConfigCollection](resp), nil } // Updates or creates the Mailgun integration for the project. -func (api *IntegrationsService) SaveMailgunIntegration(ctx context.Context, mailgunConfigPayload MailgunConfigPayload) (*shared.ClientResponse[MailgunConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) SaveMailgunIntegration(ctx context.Context, mailgunConfigPayload MailgunConfigPayload) (*shared.ClientResponse[MailgunConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -431,17 +580,17 @@ func (api *IntegrationsService) SaveMailgunIntegration(ctx context.Context, mail WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[MailgunConfigPayload](config) + client := restClient.NewRestClient[MailgunConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[MailgunConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[MailgunConfigPayload](resp), nil } // Deletes the Mailgun integration configuration from the project. This will disable the integration's functionality within the project. -func (api *IntegrationsService) DeleteMailgunIntegration(ctx context.Context, params DeleteMailgunIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *IntegrationsService) DeleteMailgunIntegration(ctx context.Context, params DeleteMailgunIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -453,17 +602,17 @@ func (api *IntegrationsService) DeleteMailgunIntegration(ctx context.Context, pa WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Retrieves the current Ping Email integration configurations for a specific integration type in the project. Returns configuration details and status information. -func (api *IntegrationsService) ListPingEmailIntegrations(ctx context.Context) (*shared.ClientResponse[PingConfigCollection], *shared.ClientError) { +func (api *IntegrationsService) ListPingEmailIntegrations(ctx context.Context) (*shared.ClientResponse[PingConfigCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -474,17 +623,17 @@ func (api *IntegrationsService) ListPingEmailIntegrations(ctx context.Context) ( WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[PingConfigCollection](config) + client := restClient.NewRestClient[PingConfigCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[PingConfigCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[PingConfigCollection](resp), nil } // Updates or creates the Ping Email integration for the project. -func (api *IntegrationsService) SavePingEmailIntegration(ctx context.Context, pingConfigPayload PingConfigPayload) (*shared.ClientResponse[PingConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) SavePingEmailIntegration(ctx context.Context, pingConfigPayload PingConfigPayload) (*shared.ClientResponse[PingConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -497,17 +646,17 @@ func (api *IntegrationsService) SavePingEmailIntegration(ctx context.Context, pi WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[PingConfigPayload](config) + client := restClient.NewRestClient[PingConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[PingConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[PingConfigPayload](resp), nil } // Deletes the Ping Email integration configuration from the project. This will disable the integration's functionality within the project. -func (api *IntegrationsService) DeletePingEmailIntegration(ctx context.Context, params DeletePingEmailIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *IntegrationsService) DeletePingEmailIntegration(ctx context.Context, params DeletePingEmailIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -519,17 +668,17 @@ func (api *IntegrationsService) DeletePingEmailIntegration(ctx context.Context, WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Retrieves the current SendGrid integration configurations for a specific integration type in the project. Returns configuration details and status information. -func (api *IntegrationsService) ListSendgridIntegrations(ctx context.Context) (*shared.ClientResponse[SendgridConfigCollection], *shared.ClientError) { +func (api *IntegrationsService) ListSendgridIntegrations(ctx context.Context) (*shared.ClientResponse[SendgridConfigCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -540,17 +689,17 @@ func (api *IntegrationsService) ListSendgridIntegrations(ctx context.Context) (* WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[SendgridConfigCollection](config) + client := restClient.NewRestClient[SendgridConfigCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[SendgridConfigCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[SendgridConfigCollection](resp), nil } // Updates or creates the SendGrid integration for the project. -func (api *IntegrationsService) SaveSendgridIntegration(ctx context.Context, sendgridConfigPayload SendgridConfigPayload) (*shared.ClientResponse[SendgridConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) SaveSendgridIntegration(ctx context.Context, sendgridConfigPayload SendgridConfigPayload) (*shared.ClientResponse[SendgridConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -563,17 +712,17 @@ func (api *IntegrationsService) SaveSendgridIntegration(ctx context.Context, sen WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[SendgridConfigPayload](config) + client := restClient.NewRestClient[SendgridConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[SendgridConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[SendgridConfigPayload](resp), nil } // Deletes the SendGrid integration configuration from the project. This will disable the integration's functionality within the project. -func (api *IntegrationsService) DeleteSendgridIntegration(ctx context.Context, params DeleteSendgridIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *IntegrationsService) DeleteSendgridIntegration(ctx context.Context, params DeleteSendgridIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -585,17 +734,17 @@ func (api *IntegrationsService) DeleteSendgridIntegration(ctx context.Context, p WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Retrieves the current Amazon SES integration configurations for a specific integration type in the project. Returns configuration details and status information. -func (api *IntegrationsService) ListSesIntegrations(ctx context.Context) (*shared.ClientResponse[SesConfigCollection], *shared.ClientError) { +func (api *IntegrationsService) ListSesIntegrations(ctx context.Context) (*shared.ClientResponse[SesConfigCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -606,17 +755,17 @@ func (api *IntegrationsService) ListSesIntegrations(ctx context.Context) (*share WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[SesConfigCollection](config) + client := restClient.NewRestClient[SesConfigCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[SesConfigCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[SesConfigCollection](resp), nil } // Updates or creates the Amazon SES integration for the project. -func (api *IntegrationsService) SaveSesIntegration(ctx context.Context, sesConfigPayload SesConfigPayload) (*shared.ClientResponse[SesConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) SaveSesIntegration(ctx context.Context, sesConfigPayload SesConfigPayload) (*shared.ClientResponse[SesConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -629,17 +778,17 @@ func (api *IntegrationsService) SaveSesIntegration(ctx context.Context, sesConfi WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[SesConfigPayload](config) + client := restClient.NewRestClient[SesConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[SesConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[SesConfigPayload](resp), nil } // Deletes the Amazon SES integration configuration from the project. This will disable the integration's functionality within the project. -func (api *IntegrationsService) DeleteSesIntegration(ctx context.Context, params DeleteSesIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *IntegrationsService) DeleteSesIntegration(ctx context.Context, params DeleteSesIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -651,17 +800,17 @@ func (api *IntegrationsService) DeleteSesIntegration(ctx context.Context, params WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Retrieves the current Slack integration configurations for a specific integration type in the project. Returns configuration details and status information. -func (api *IntegrationsService) ListSlackIntegrations(ctx context.Context) (*shared.ClientResponse[SlackConfigCollection], *shared.ClientError) { +func (api *IntegrationsService) ListSlackIntegrations(ctx context.Context) (*shared.ClientResponse[SlackConfigCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -672,17 +821,17 @@ func (api *IntegrationsService) ListSlackIntegrations(ctx context.Context) (*sha WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[SlackConfigCollection](config) + client := restClient.NewRestClient[SlackConfigCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[SlackConfigCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[SlackConfigCollection](resp), nil } // Updates or creates the Slack integration for the project. -func (api *IntegrationsService) SaveSlackIntegration(ctx context.Context, slackConfigPayload SlackConfigPayload) (*shared.ClientResponse[SlackConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) SaveSlackIntegration(ctx context.Context, slackConfigPayload SlackConfigPayload) (*shared.ClientResponse[SlackConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -695,17 +844,17 @@ func (api *IntegrationsService) SaveSlackIntegration(ctx context.Context, slackC WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[SlackConfigPayload](config) + client := restClient.NewRestClient[SlackConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[SlackConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[SlackConfigPayload](resp), nil } // Deletes the Slack integration configuration from the project. This will disable the integration's functionality within the project. -func (api *IntegrationsService) DeleteSlackIntegration(ctx context.Context, params DeleteSlackIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *IntegrationsService) DeleteSlackIntegration(ctx context.Context, params DeleteSlackIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -717,17 +866,83 @@ func (api *IntegrationsService) DeleteSlackIntegration(ctx context.Context, para WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[any](resp), nil +} + +// Retrieves the current SMTP integration configurations for a specific integration type in the project. Returns configuration details and status information. +func (api *IntegrationsService) ListSmtpIntegrations(ctx context.Context) (*shared.ClientResponse[SmtpConfigObjectCollection], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("GET"). + WithPath("/integrations/smtp"). + WithConfig(config). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[SmtpConfigObjectCollection, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[SmtpConfigObjectCollection](resp), nil +} + +// Updates or creates the SMTP integration for the project. +func (api *IntegrationsService) SaveSmtpIntegration(ctx context.Context, smtpConfig SmtpConfig) (*shared.ClientResponse[SmtpConfig], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("PUT"). + WithPath("/integrations/smtp"). + WithConfig(config). + WithBody(smtpConfig). + AddHeader("CONTENT-TYPE", "application/json"). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[SmtpConfig, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[SmtpConfig](resp), nil +} + +// Deletes the SMTP integration configuration from the project. This will disable the integration's functionality within the project. +func (api *IntegrationsService) DeleteSmtpIntegration(ctx context.Context, params DeleteSmtpIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("DELETE"). + WithPath("/integrations/smtp"). + WithConfig(config). + WithOptions(params). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Retrieves the current Stripe integration configurations for a specific integration type in the project. Returns configuration details and status information. -func (api *IntegrationsService) ListStripeIntegrations(ctx context.Context) (*shared.ClientResponse[StripeConfigCollection], *shared.ClientError) { +func (api *IntegrationsService) ListStripeIntegrations(ctx context.Context) (*shared.ClientResponse[StripeConfigCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -738,17 +953,17 @@ func (api *IntegrationsService) ListStripeIntegrations(ctx context.Context) (*sh WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[StripeConfigCollection](config) + client := restClient.NewRestClient[StripeConfigCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[StripeConfigCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[StripeConfigCollection](resp), nil } // Updates or creates the Stripe integration for the project. -func (api *IntegrationsService) SaveStripeIntegration(ctx context.Context, stripeConfigPayload StripeConfigPayload) (*shared.ClientResponse[StripeConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) SaveStripeIntegration(ctx context.Context, stripeConfigPayload StripeConfigPayload) (*shared.ClientResponse[StripeConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -761,17 +976,17 @@ func (api *IntegrationsService) SaveStripeIntegration(ctx context.Context, strip WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[StripeConfigPayload](config) + client := restClient.NewRestClient[StripeConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[StripeConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[StripeConfigPayload](resp), nil } // Deletes the Stripe integration configuration from the project. This will disable the integration's functionality within the project. -func (api *IntegrationsService) DeleteStripeIntegration(ctx context.Context, params DeleteStripeIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *IntegrationsService) DeleteStripeIntegration(ctx context.Context, params DeleteStripeIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -783,17 +998,17 @@ func (api *IntegrationsService) DeleteStripeIntegration(ctx context.Context, par WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Retrieves the current Twilio integration configurations for a specific integration type in the project. Returns configuration details and status information. -func (api *IntegrationsService) ListTwilioIntegrations(ctx context.Context) (*shared.ClientResponse[TwilioConfigCollection], *shared.ClientError) { +func (api *IntegrationsService) ListTwilioIntegrations(ctx context.Context) (*shared.ClientResponse[TwilioConfigCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -804,17 +1019,17 @@ func (api *IntegrationsService) ListTwilioIntegrations(ctx context.Context) (*sh WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[TwilioConfigCollection](config) + client := restClient.NewRestClient[TwilioConfigCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[TwilioConfigCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[TwilioConfigCollection](resp), nil } // Updates or creates the Twilio integration for the project. -func (api *IntegrationsService) SaveTwilioIntegration(ctx context.Context, twilioConfigPayload TwilioConfigPayload) (*shared.ClientResponse[TwilioConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) SaveTwilioIntegration(ctx context.Context, twilioConfigPayload TwilioConfigPayload) (*shared.ClientResponse[TwilioConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -827,17 +1042,17 @@ func (api *IntegrationsService) SaveTwilioIntegration(ctx context.Context, twili WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[TwilioConfigPayload](config) + client := restClient.NewRestClient[TwilioConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[TwilioConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[TwilioConfigPayload](resp), nil } // Deletes the Twilio integration configuration from the project. This will disable the integration's functionality within the project. -func (api *IntegrationsService) DeleteTwilioIntegration(ctx context.Context, params DeleteTwilioIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *IntegrationsService) DeleteTwilioIntegration(ctx context.Context, params DeleteTwilioIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -849,17 +1064,17 @@ func (api *IntegrationsService) DeleteTwilioIntegration(ctx context.Context, par WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Retrieves the current Web Push integration configurations for a specific integration type in the project. Returns configuration details and status information. -func (api *IntegrationsService) ListWebPushIntegrations(ctx context.Context) (*shared.ClientResponse[WebpushConfigCollection], *shared.ClientError) { +func (api *IntegrationsService) ListWebPushIntegrations(ctx context.Context) (*shared.ClientResponse[WebpushConfigCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -870,17 +1085,17 @@ func (api *IntegrationsService) ListWebPushIntegrations(ctx context.Context) (*s WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[WebpushConfigCollection](config) + client := restClient.NewRestClient[WebpushConfigCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[WebpushConfigCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[WebpushConfigCollection](resp), nil } // Updates or creates the Web Push integration for the project. -func (api *IntegrationsService) SaveWebPushIntegration(ctx context.Context, webpushConfigPayload WebpushConfigPayload) (*shared.ClientResponse[WebpushConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) SaveWebPushIntegration(ctx context.Context, webpushConfigPayload WebpushConfigPayload) (*shared.ClientResponse[WebpushConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -893,17 +1108,17 @@ func (api *IntegrationsService) SaveWebPushIntegration(ctx context.Context, webp WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[WebpushConfigPayload](config) + client := restClient.NewRestClient[WebpushConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[WebpushConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[WebpushConfigPayload](resp), nil } // Deletes the Web Push integration configuration from the project. This will disable the integration's functionality within the project. -func (api *IntegrationsService) DeleteWebPushIntegration(ctx context.Context, params DeleteWebPushIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *IntegrationsService) DeleteWebPushIntegration(ctx context.Context, params DeleteWebPushIntegrationRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -915,10 +1130,10 @@ func (api *IntegrationsService) DeleteWebPushIntegration(ctx context.Context, pa WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil diff --git a/pkg/project-client/integrations/mailgun_config_payload.go b/pkg/project-client/integrations/mailgun_config_payload.go index 0501153..1dfaf7d 100644 --- a/pkg/project-client/integrations/mailgun_config_payload.go +++ b/pkg/project-client/integrations/mailgun_config_payload.go @@ -1,10 +1,6 @@ package integrations -import ( - "encoding/json" - "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" - "github.com/magicbell/magicbell-go/pkg/project-client/util" -) +import "encoding/json" type MailgunConfigPayload struct { ApiKey *string `json:"api_key,omitempty" required:"true" minLength:"1"` @@ -64,55 +60,3 @@ func (m MailgunConfigPayload) String() string { } return string(jsonData) } - -type MailgunConfigPayloadFrom struct { - // The email address to send from - Email *string `json:"email,omitempty" required:"true"` - // The name to send from - Name *util.Nullable[string] `json:"name,omitempty"` -} - -func (m *MailgunConfigPayloadFrom) GetEmail() *string { - if m == nil { - return nil - } - return m.Email -} - -func (m *MailgunConfigPayloadFrom) SetEmail(email string) { - m.Email = &email -} - -func (m *MailgunConfigPayloadFrom) GetName() *util.Nullable[string] { - if m == nil { - return nil - } - return m.Name -} - -func (m *MailgunConfigPayloadFrom) SetName(name util.Nullable[string]) { - m.Name = &name -} - -func (m *MailgunConfigPayloadFrom) SetNameNull() { - m.Name = &util.Nullable[string]{IsNull: true} -} - -func (m MailgunConfigPayloadFrom) String() string { - jsonData, err := json.MarshalIndent(m, "", " ") - if err != nil { - return "error converting struct: MailgunConfigPayloadFrom to string" - } - return string(jsonData) -} - -func (m *MailgunConfigPayloadFrom) UnmarshalJSON(data []byte) error { - return unmarshal.UnmarshalNullable(data, m) -} - -type Region string - -const ( - REGION_US Region = "us" - REGION_EU Region = "eu" -) diff --git a/pkg/project-client/integrations/mailgun_config_payload_from.go b/pkg/project-client/integrations/mailgun_config_payload_from.go new file mode 100644 index 0000000..977aeae --- /dev/null +++ b/pkg/project-client/integrations/mailgun_config_payload_from.go @@ -0,0 +1,52 @@ +package integrations + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" + "github.com/magicbell/magicbell-go/pkg/project-client/util" +) + +type MailgunConfigPayloadFrom struct { + // The email address to send from + Email *string `json:"email,omitempty" required:"true"` + // The name to send from + Name *util.Nullable[string] `json:"name,omitempty"` +} + +func (m *MailgunConfigPayloadFrom) GetEmail() *string { + if m == nil { + return nil + } + return m.Email +} + +func (m *MailgunConfigPayloadFrom) SetEmail(email string) { + m.Email = &email +} + +func (m *MailgunConfigPayloadFrom) GetName() *util.Nullable[string] { + if m == nil { + return nil + } + return m.Name +} + +func (m *MailgunConfigPayloadFrom) SetName(name util.Nullable[string]) { + m.Name = &name +} + +func (m *MailgunConfigPayloadFrom) SetNameNull() { + m.Name = &util.Nullable[string]{IsNull: true} +} + +func (m MailgunConfigPayloadFrom) String() string { + jsonData, err := json.MarshalIndent(m, "", " ") + if err != nil { + return "error converting struct: MailgunConfigPayloadFrom to string" + } + return string(jsonData) +} + +func (m *MailgunConfigPayloadFrom) UnmarshalJSON(data []byte) error { + return unmarshal.UnmarshalNullable(data, m) +} diff --git a/pkg/project-client/integrations/notification.go b/pkg/project-client/integrations/notification.go new file mode 100644 index 0000000..23cf403 --- /dev/null +++ b/pkg/project-client/integrations/notification.go @@ -0,0 +1,54 @@ +package integrations + +import "encoding/json" + +// Styling overrides for notification list items. +type Notification struct { + // Base styles applied to every notification item. + Default_ *Default_ `json:"default,omitempty" required:"true"` + // Overrides for unread notifications. + Unread *Unread `json:"unread,omitempty" required:"true"` + // Overrides for unseen notifications. + Unseen *Unseen `json:"unseen,omitempty" required:"true"` +} + +func (n *Notification) GetDefault_() *Default_ { + if n == nil { + return nil + } + return n.Default_ +} + +func (n *Notification) SetDefault_(default_ Default_) { + n.Default_ = &default_ +} + +func (n *Notification) GetUnread() *Unread { + if n == nil { + return nil + } + return n.Unread +} + +func (n *Notification) SetUnread(unread Unread) { + n.Unread = &unread +} + +func (n *Notification) GetUnseen() *Unseen { + if n == nil { + return nil + } + return n.Unseen +} + +func (n *Notification) SetUnseen(unseen Unseen) { + n.Unseen = &unseen +} + +func (n Notification) String() string { + jsonData, err := json.MarshalIndent(n, "", " ") + if err != nil { + return "error converting struct: Notification to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/payload_version.go b/pkg/project-client/integrations/payload_version.go new file mode 100644 index 0000000..fb166b0 --- /dev/null +++ b/pkg/project-client/integrations/payload_version.go @@ -0,0 +1,9 @@ +package integrations + +// Internal payload format version used by MagicBell. +type PayloadVersion string + +const ( + PAYLOAD_VERSION_1 PayloadVersion = "1" + PAYLOAD_VERSION_2 PayloadVersion = "2" +) diff --git a/pkg/project-client/integrations/region.go b/pkg/project-client/integrations/region.go new file mode 100644 index 0000000..6b426bc --- /dev/null +++ b/pkg/project-client/integrations/region.go @@ -0,0 +1,8 @@ +package integrations + +type Region string + +const ( + REGION_US Region = "us" + REGION_EU Region = "eu" +) diff --git a/pkg/project-client/integrations/request_params.go b/pkg/project-client/integrations/request_params.go index 3ed1014..4026c8b 100644 --- a/pkg/project-client/integrations/request_params.go +++ b/pkg/project-client/integrations/request_params.go @@ -1,121 +1,200 @@ package integrations +// ListIntegrationsRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListIntegrationsRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListIntegrationsRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListIntegrationsRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListIntegrationsRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } +// DeleteApnsIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type DeleteApnsIntegrationRequestParams struct { Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` } +// SetId sets the Id parameter. func (params *DeleteApnsIntegrationRequestParams) SetId(id string) { params.Id = &id } +// DeleteEventsourceIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. +type DeleteEventsourceIntegrationRequestParams struct { + Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` +} + +// SetId sets the Id parameter. +func (params *DeleteEventsourceIntegrationRequestParams) SetId(id string) { + params.Id = &id +} + +// DeleteExpoIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type DeleteExpoIntegrationRequestParams struct { Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` } +// SetId sets the Id parameter. func (params *DeleteExpoIntegrationRequestParams) SetId(id string) { params.Id = &id } +// DeleteFcmIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type DeleteFcmIntegrationRequestParams struct { Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` } +// SetId sets the Id parameter. func (params *DeleteFcmIntegrationRequestParams) SetId(id string) { params.Id = &id } +// DeleteGithubIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type DeleteGithubIntegrationRequestParams struct { Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` } +// SetId sets the Id parameter. func (params *DeleteGithubIntegrationRequestParams) SetId(id string) { params.Id = &id } +// DeleteInboxIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type DeleteInboxIntegrationRequestParams struct { Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` } +// SetId sets the Id parameter. func (params *DeleteInboxIntegrationRequestParams) SetId(id string) { params.Id = &id } +// DeleteMagicbellSlackbotIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. +type DeleteMagicbellSlackbotIntegrationRequestParams struct { + Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` +} + +// SetId sets the Id parameter. +func (params *DeleteMagicbellSlackbotIntegrationRequestParams) SetId(id string) { + params.Id = &id +} + +// DeleteMailgunIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type DeleteMailgunIntegrationRequestParams struct { Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` } +// SetId sets the Id parameter. func (params *DeleteMailgunIntegrationRequestParams) SetId(id string) { params.Id = &id } +// DeletePingEmailIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type DeletePingEmailIntegrationRequestParams struct { Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` } +// SetId sets the Id parameter. func (params *DeletePingEmailIntegrationRequestParams) SetId(id string) { params.Id = &id } +// DeleteSendgridIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type DeleteSendgridIntegrationRequestParams struct { Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` } +// SetId sets the Id parameter. func (params *DeleteSendgridIntegrationRequestParams) SetId(id string) { params.Id = &id } +// DeleteSesIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type DeleteSesIntegrationRequestParams struct { Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` } +// SetId sets the Id parameter. func (params *DeleteSesIntegrationRequestParams) SetId(id string) { params.Id = &id } +// DeleteSlackIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type DeleteSlackIntegrationRequestParams struct { Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` } +// SetId sets the Id parameter. func (params *DeleteSlackIntegrationRequestParams) SetId(id string) { params.Id = &id } +// DeleteSmtpIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. +type DeleteSmtpIntegrationRequestParams struct { + Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` +} + +// SetId sets the Id parameter. +func (params *DeleteSmtpIntegrationRequestParams) SetId(id string) { + params.Id = &id +} + +// DeleteStripeIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type DeleteStripeIntegrationRequestParams struct { Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` } +// SetId sets the Id parameter. func (params *DeleteStripeIntegrationRequestParams) SetId(id string) { params.Id = &id } +// DeleteTwilioIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type DeleteTwilioIntegrationRequestParams struct { Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` } +// SetId sets the Id parameter. func (params *DeleteTwilioIntegrationRequestParams) SetId(id string) { params.Id = &id } +// DeleteWebPushIntegrationRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type DeleteWebPushIntegrationRequestParams struct { Id *string `explode:"true" serializationStyle:"form" queryParam:"id"` } +// SetId sets the Id parameter. func (params *DeleteWebPushIntegrationRequestParams) SetId(id string) { params.Id = &id } diff --git a/pkg/project-client/integrations/security.go b/pkg/project-client/integrations/security.go new file mode 100644 index 0000000..4ec4e3d --- /dev/null +++ b/pkg/project-client/integrations/security.go @@ -0,0 +1,10 @@ +package integrations + +// SMTP security/encryption method +type Security string + +const ( + SECURITY_NONE Security = "none" + SECURITY_SSL Security = "ssl" + SECURITY_STARTTLS Security = "starttls" +) diff --git a/pkg/project-client/integrations/sendgrid_config_payload.go b/pkg/project-client/integrations/sendgrid_config_payload.go index 7b5719c..e4e8f88 100644 --- a/pkg/project-client/integrations/sendgrid_config_payload.go +++ b/pkg/project-client/integrations/sendgrid_config_payload.go @@ -1,16 +1,12 @@ package integrations -import ( - "encoding/json" - "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" - "github.com/magicbell/magicbell-go/pkg/project-client/util" -) +import "encoding/json" type SendgridConfigPayload struct { // The API key for Sendgrid - ApiKey *string `json:"api_key,omitempty" required:"true"` - From *SendgridConfigPayloadFrom `json:"from,omitempty"` - ReplyTo *ReplyTo `json:"reply_to,omitempty"` + ApiKey *string `json:"api_key,omitempty" required:"true"` + From *SendgridConfigPayloadFrom `json:"from,omitempty"` + ReplyTo *SendgridConfigPayloadReplyTo `json:"reply_to,omitempty"` } func (s *SendgridConfigPayload) GetApiKey() *string { @@ -35,14 +31,14 @@ func (s *SendgridConfigPayload) SetFrom(from SendgridConfigPayloadFrom) { s.From = &from } -func (s *SendgridConfigPayload) GetReplyTo() *ReplyTo { +func (s *SendgridConfigPayload) GetReplyTo() *SendgridConfigPayloadReplyTo { if s == nil { return nil } return s.ReplyTo } -func (s *SendgridConfigPayload) SetReplyTo(replyTo ReplyTo) { +func (s *SendgridConfigPayload) SetReplyTo(replyTo SendgridConfigPayloadReplyTo) { s.ReplyTo = &replyTo } @@ -53,93 +49,3 @@ func (s SendgridConfigPayload) String() string { } return string(jsonData) } - -type SendgridConfigPayloadFrom struct { - // The email address to send from - Email *string `json:"email,omitempty" required:"true"` - // The name to send from - Name *util.Nullable[string] `json:"name,omitempty"` -} - -func (s *SendgridConfigPayloadFrom) GetEmail() *string { - if s == nil { - return nil - } - return s.Email -} - -func (s *SendgridConfigPayloadFrom) SetEmail(email string) { - s.Email = &email -} - -func (s *SendgridConfigPayloadFrom) GetName() *util.Nullable[string] { - if s == nil { - return nil - } - return s.Name -} - -func (s *SendgridConfigPayloadFrom) SetName(name util.Nullable[string]) { - s.Name = &name -} - -func (s *SendgridConfigPayloadFrom) SetNameNull() { - s.Name = &util.Nullable[string]{IsNull: true} -} - -func (s SendgridConfigPayloadFrom) String() string { - jsonData, err := json.MarshalIndent(s, "", " ") - if err != nil { - return "error converting struct: SendgridConfigPayloadFrom to string" - } - return string(jsonData) -} - -func (s *SendgridConfigPayloadFrom) UnmarshalJSON(data []byte) error { - return unmarshal.UnmarshalNullable(data, s) -} - -type ReplyTo struct { - // The email address to reply to - Email *string `json:"email,omitempty" required:"true"` - // The name to reply to - Name *util.Nullable[string] `json:"name,omitempty"` -} - -func (r *ReplyTo) GetEmail() *string { - if r == nil { - return nil - } - return r.Email -} - -func (r *ReplyTo) SetEmail(email string) { - r.Email = &email -} - -func (r *ReplyTo) GetName() *util.Nullable[string] { - if r == nil { - return nil - } - return r.Name -} - -func (r *ReplyTo) SetName(name util.Nullable[string]) { - r.Name = &name -} - -func (r *ReplyTo) SetNameNull() { - r.Name = &util.Nullable[string]{IsNull: true} -} - -func (r ReplyTo) String() string { - jsonData, err := json.MarshalIndent(r, "", " ") - if err != nil { - return "error converting struct: ReplyTo to string" - } - return string(jsonData) -} - -func (r *ReplyTo) UnmarshalJSON(data []byte) error { - return unmarshal.UnmarshalNullable(data, r) -} diff --git a/pkg/project-client/integrations/sendgrid_config_payload_from.go b/pkg/project-client/integrations/sendgrid_config_payload_from.go new file mode 100644 index 0000000..ce382f0 --- /dev/null +++ b/pkg/project-client/integrations/sendgrid_config_payload_from.go @@ -0,0 +1,52 @@ +package integrations + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" + "github.com/magicbell/magicbell-go/pkg/project-client/util" +) + +type SendgridConfigPayloadFrom struct { + // The email address to send from + Email *string `json:"email,omitempty" required:"true"` + // The name to send from + Name *util.Nullable[string] `json:"name,omitempty"` +} + +func (s *SendgridConfigPayloadFrom) GetEmail() *string { + if s == nil { + return nil + } + return s.Email +} + +func (s *SendgridConfigPayloadFrom) SetEmail(email string) { + s.Email = &email +} + +func (s *SendgridConfigPayloadFrom) GetName() *util.Nullable[string] { + if s == nil { + return nil + } + return s.Name +} + +func (s *SendgridConfigPayloadFrom) SetName(name util.Nullable[string]) { + s.Name = &name +} + +func (s *SendgridConfigPayloadFrom) SetNameNull() { + s.Name = &util.Nullable[string]{IsNull: true} +} + +func (s SendgridConfigPayloadFrom) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SendgridConfigPayloadFrom to string" + } + return string(jsonData) +} + +func (s *SendgridConfigPayloadFrom) UnmarshalJSON(data []byte) error { + return unmarshal.UnmarshalNullable(data, s) +} diff --git a/pkg/project-client/integrations/sendgrid_config_payload_reply_to.go b/pkg/project-client/integrations/sendgrid_config_payload_reply_to.go new file mode 100644 index 0000000..6030828 --- /dev/null +++ b/pkg/project-client/integrations/sendgrid_config_payload_reply_to.go @@ -0,0 +1,52 @@ +package integrations + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" + "github.com/magicbell/magicbell-go/pkg/project-client/util" +) + +type SendgridConfigPayloadReplyTo struct { + // The email address to reply to + Email *string `json:"email,omitempty" required:"true"` + // The name to reply to + Name *util.Nullable[string] `json:"name,omitempty"` +} + +func (s *SendgridConfigPayloadReplyTo) GetEmail() *string { + if s == nil { + return nil + } + return s.Email +} + +func (s *SendgridConfigPayloadReplyTo) SetEmail(email string) { + s.Email = &email +} + +func (s *SendgridConfigPayloadReplyTo) GetName() *util.Nullable[string] { + if s == nil { + return nil + } + return s.Name +} + +func (s *SendgridConfigPayloadReplyTo) SetName(name util.Nullable[string]) { + s.Name = &name +} + +func (s *SendgridConfigPayloadReplyTo) SetNameNull() { + s.Name = &util.Nullable[string]{IsNull: true} +} + +func (s SendgridConfigPayloadReplyTo) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SendgridConfigPayloadReplyTo to string" + } + return string(jsonData) +} + +func (s *SendgridConfigPayloadReplyTo) UnmarshalJSON(data []byte) error { + return unmarshal.UnmarshalNullable(data, s) +} diff --git a/pkg/project-client/integrations/ses_config_payload.go b/pkg/project-client/integrations/ses_config_payload.go index d210c1a..8a141a4 100644 --- a/pkg/project-client/integrations/ses_config_payload.go +++ b/pkg/project-client/integrations/ses_config_payload.go @@ -1,10 +1,6 @@ package integrations -import ( - "encoding/json" - "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" - "github.com/magicbell/magicbell-go/pkg/project-client/util" -) +import "encoding/json" type SesConfigPayload struct { From *SesConfigPayloadFrom `json:"from,omitempty"` @@ -67,48 +63,3 @@ func (s SesConfigPayload) String() string { } return string(jsonData) } - -type SesConfigPayloadFrom struct { - // The email address to send from - Email *string `json:"email,omitempty" required:"true"` - // The name to send from - Name *util.Nullable[string] `json:"name,omitempty"` -} - -func (s *SesConfigPayloadFrom) GetEmail() *string { - if s == nil { - return nil - } - return s.Email -} - -func (s *SesConfigPayloadFrom) SetEmail(email string) { - s.Email = &email -} - -func (s *SesConfigPayloadFrom) GetName() *util.Nullable[string] { - if s == nil { - return nil - } - return s.Name -} - -func (s *SesConfigPayloadFrom) SetName(name util.Nullable[string]) { - s.Name = &name -} - -func (s *SesConfigPayloadFrom) SetNameNull() { - s.Name = &util.Nullable[string]{IsNull: true} -} - -func (s SesConfigPayloadFrom) String() string { - jsonData, err := json.MarshalIndent(s, "", " ") - if err != nil { - return "error converting struct: SesConfigPayloadFrom to string" - } - return string(jsonData) -} - -func (s *SesConfigPayloadFrom) UnmarshalJSON(data []byte) error { - return unmarshal.UnmarshalNullable(data, s) -} diff --git a/pkg/project-client/integrations/ses_config_payload_from.go b/pkg/project-client/integrations/ses_config_payload_from.go new file mode 100644 index 0000000..bd7d732 --- /dev/null +++ b/pkg/project-client/integrations/ses_config_payload_from.go @@ -0,0 +1,52 @@ +package integrations + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" + "github.com/magicbell/magicbell-go/pkg/project-client/util" +) + +type SesConfigPayloadFrom struct { + // The email address to send from + Email *string `json:"email,omitempty" required:"true"` + // The name to send from + Name *util.Nullable[string] `json:"name,omitempty"` +} + +func (s *SesConfigPayloadFrom) GetEmail() *string { + if s == nil { + return nil + } + return s.Email +} + +func (s *SesConfigPayloadFrom) SetEmail(email string) { + s.Email = &email +} + +func (s *SesConfigPayloadFrom) GetName() *util.Nullable[string] { + if s == nil { + return nil + } + return s.Name +} + +func (s *SesConfigPayloadFrom) SetName(name util.Nullable[string]) { + s.Name = &name +} + +func (s *SesConfigPayloadFrom) SetNameNull() { + s.Name = &util.Nullable[string]{IsNull: true} +} + +func (s SesConfigPayloadFrom) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SesConfigPayloadFrom to string" + } + return string(jsonData) +} + +func (s *SesConfigPayloadFrom) UnmarshalJSON(data []byte) error { + return unmarshal.UnmarshalNullable(data, s) +} diff --git a/pkg/project-client/integrations/slack_bot_config.go b/pkg/project-client/integrations/slack_bot_config.go new file mode 100644 index 0000000..b675e5c --- /dev/null +++ b/pkg/project-client/integrations/slack_bot_config.go @@ -0,0 +1,50 @@ +package integrations + +import "encoding/json" + +type SlackBotConfig struct { + Config *SlackBotConfigPayload `json:"config,omitempty" required:"true"` + Id *string `json:"id,omitempty" required:"true"` + Name *string `json:"name,omitempty" required:"true"` +} + +func (s *SlackBotConfig) GetConfig() *SlackBotConfigPayload { + if s == nil { + return nil + } + return s.Config +} + +func (s *SlackBotConfig) SetConfig(config SlackBotConfigPayload) { + s.Config = &config +} + +func (s *SlackBotConfig) GetId() *string { + if s == nil { + return nil + } + return s.Id +} + +func (s *SlackBotConfig) SetId(id string) { + s.Id = &id +} + +func (s *SlackBotConfig) GetName() *string { + if s == nil { + return nil + } + return s.Name +} + +func (s *SlackBotConfig) SetName(name string) { + s.Name = &name +} + +func (s SlackBotConfig) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SlackBotConfig to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/slack_bot_config_collection.go b/pkg/project-client/integrations/slack_bot_config_collection.go new file mode 100644 index 0000000..fc1b95e --- /dev/null +++ b/pkg/project-client/integrations/slack_bot_config_collection.go @@ -0,0 +1,41 @@ +package integrations + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/shared" +) + +type SlackBotConfigCollection struct { + Data []SlackBotConfig `json:"data,omitempty"` + Links *shared.Links `json:"links,omitempty"` +} + +func (s *SlackBotConfigCollection) GetData() []SlackBotConfig { + if s == nil { + return nil + } + return s.Data +} + +func (s *SlackBotConfigCollection) SetData(data []SlackBotConfig) { + s.Data = data +} + +func (s *SlackBotConfigCollection) GetLinks() *shared.Links { + if s == nil { + return nil + } + return s.Links +} + +func (s *SlackBotConfigCollection) SetLinks(links shared.Links) { + s.Links = &links +} + +func (s SlackBotConfigCollection) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SlackBotConfigCollection to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/slack_bot_config_payload.go b/pkg/project-client/integrations/slack_bot_config_payload.go new file mode 100644 index 0000000..1f0962d --- /dev/null +++ b/pkg/project-client/integrations/slack_bot_config_payload.go @@ -0,0 +1,26 @@ +package integrations + +import "encoding/json" + +type SlackBotConfigPayload struct { + Enabled *bool `json:"enabled,omitempty" required:"true"` +} + +func (s *SlackBotConfigPayload) GetEnabled() *bool { + if s == nil { + return nil + } + return s.Enabled +} + +func (s *SlackBotConfigPayload) SetEnabled(enabled bool) { + s.Enabled = &enabled +} + +func (s SlackBotConfigPayload) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SlackBotConfigPayload to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/smtp_config.go b/pkg/project-client/integrations/smtp_config.go new file mode 100644 index 0000000..615f9bb --- /dev/null +++ b/pkg/project-client/integrations/smtp_config.go @@ -0,0 +1,105 @@ +package integrations + +import "encoding/json" + +type SmtpConfig struct { + // Default sender email address + From *SmtpConfigFrom `json:"from,omitempty" required:"true"` + // SMTP server hostname + Host *string `json:"host,omitempty" required:"true"` + // SMTP authentication password + Password *string `json:"password,omitempty" required:"true"` + // SMTP server port + Port *int64 `json:"port,omitempty" required:"true" min:"1" max:"65535"` + // Reply-to email address + ReplyTo *SmtpConfigReplyTo `json:"reply_to,omitempty"` + // SMTP security/encryption method + Security *Security `json:"security,omitempty"` + // SMTP authentication username + Username *string `json:"username,omitempty" required:"true"` +} + +func (s *SmtpConfig) GetFrom() *SmtpConfigFrom { + if s == nil { + return nil + } + return s.From +} + +func (s *SmtpConfig) SetFrom(from SmtpConfigFrom) { + s.From = &from +} + +func (s *SmtpConfig) GetHost() *string { + if s == nil { + return nil + } + return s.Host +} + +func (s *SmtpConfig) SetHost(host string) { + s.Host = &host +} + +func (s *SmtpConfig) GetPassword() *string { + if s == nil { + return nil + } + return s.Password +} + +func (s *SmtpConfig) SetPassword(password string) { + s.Password = &password +} + +func (s *SmtpConfig) GetPort() *int64 { + if s == nil { + return nil + } + return s.Port +} + +func (s *SmtpConfig) SetPort(port int64) { + s.Port = &port +} + +func (s *SmtpConfig) GetReplyTo() *SmtpConfigReplyTo { + if s == nil { + return nil + } + return s.ReplyTo +} + +func (s *SmtpConfig) SetReplyTo(replyTo SmtpConfigReplyTo) { + s.ReplyTo = &replyTo +} + +func (s *SmtpConfig) GetSecurity() *Security { + if s == nil { + return nil + } + return s.Security +} + +func (s *SmtpConfig) SetSecurity(security Security) { + s.Security = &security +} + +func (s *SmtpConfig) GetUsername() *string { + if s == nil { + return nil + } + return s.Username +} + +func (s *SmtpConfig) SetUsername(username string) { + s.Username = &username +} + +func (s SmtpConfig) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SmtpConfig to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/smtp_config_from.go b/pkg/project-client/integrations/smtp_config_from.go new file mode 100644 index 0000000..8f496f5 --- /dev/null +++ b/pkg/project-client/integrations/smtp_config_from.go @@ -0,0 +1,41 @@ +package integrations + +import "encoding/json" + +// Default sender email address +type SmtpConfigFrom struct { + // Sender email address + Email *string `json:"email,omitempty" required:"true"` + // Sender name + Name *string `json:"name,omitempty"` +} + +func (s *SmtpConfigFrom) GetEmail() *string { + if s == nil { + return nil + } + return s.Email +} + +func (s *SmtpConfigFrom) SetEmail(email string) { + s.Email = &email +} + +func (s *SmtpConfigFrom) GetName() *string { + if s == nil { + return nil + } + return s.Name +} + +func (s *SmtpConfigFrom) SetName(name string) { + s.Name = &name +} + +func (s SmtpConfigFrom) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SmtpConfigFrom to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/smtp_config_object.go b/pkg/project-client/integrations/smtp_config_object.go new file mode 100644 index 0000000..f047da4 --- /dev/null +++ b/pkg/project-client/integrations/smtp_config_object.go @@ -0,0 +1,50 @@ +package integrations + +import "encoding/json" + +type SmtpConfigObject struct { + Config *SmtpConfig `json:"config,omitempty" required:"true"` + Id *string `json:"id,omitempty" required:"true"` + Name *string `json:"name,omitempty" required:"true"` +} + +func (s *SmtpConfigObject) GetConfig() *SmtpConfig { + if s == nil { + return nil + } + return s.Config +} + +func (s *SmtpConfigObject) SetConfig(config SmtpConfig) { + s.Config = &config +} + +func (s *SmtpConfigObject) GetId() *string { + if s == nil { + return nil + } + return s.Id +} + +func (s *SmtpConfigObject) SetId(id string) { + s.Id = &id +} + +func (s *SmtpConfigObject) GetName() *string { + if s == nil { + return nil + } + return s.Name +} + +func (s *SmtpConfigObject) SetName(name string) { + s.Name = &name +} + +func (s SmtpConfigObject) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SmtpConfigObject to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/smtp_config_object_collection.go b/pkg/project-client/integrations/smtp_config_object_collection.go new file mode 100644 index 0000000..e75f2e3 --- /dev/null +++ b/pkg/project-client/integrations/smtp_config_object_collection.go @@ -0,0 +1,41 @@ +package integrations + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/shared" +) + +type SmtpConfigObjectCollection struct { + Data []SmtpConfigObject `json:"data,omitempty"` + Links *shared.Links `json:"links,omitempty"` +} + +func (s *SmtpConfigObjectCollection) GetData() []SmtpConfigObject { + if s == nil { + return nil + } + return s.Data +} + +func (s *SmtpConfigObjectCollection) SetData(data []SmtpConfigObject) { + s.Data = data +} + +func (s *SmtpConfigObjectCollection) GetLinks() *shared.Links { + if s == nil { + return nil + } + return s.Links +} + +func (s *SmtpConfigObjectCollection) SetLinks(links shared.Links) { + s.Links = &links +} + +func (s SmtpConfigObjectCollection) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SmtpConfigObjectCollection to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/smtp_config_reply_to.go b/pkg/project-client/integrations/smtp_config_reply_to.go new file mode 100644 index 0000000..f430e0a --- /dev/null +++ b/pkg/project-client/integrations/smtp_config_reply_to.go @@ -0,0 +1,41 @@ +package integrations + +import "encoding/json" + +// Reply-to email address +type SmtpConfigReplyTo struct { + // Reply-to email address + Email *string `json:"email,omitempty" required:"true"` + // Reply-to name + Name *string `json:"name,omitempty"` +} + +func (s *SmtpConfigReplyTo) GetEmail() *string { + if s == nil { + return nil + } + return s.Email +} + +func (s *SmtpConfigReplyTo) SetEmail(email string) { + s.Email = &email +} + +func (s *SmtpConfigReplyTo) GetName() *string { + if s == nil { + return nil + } + return s.Name +} + +func (s *SmtpConfigReplyTo) SetName(name string) { + s.Name = &name +} + +func (s SmtpConfigReplyTo) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SmtpConfigReplyTo to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/stripe_config_payload.go b/pkg/project-client/integrations/stripe_config_payload.go index 680eda8..34a2bf2 100644 --- a/pkg/project-client/integrations/stripe_config_payload.go +++ b/pkg/project-client/integrations/stripe_config_payload.go @@ -3,10 +3,23 @@ package integrations import "encoding/json" type StripeConfigPayload struct { + // The unique identifier for this configuration + Id *string `json:"id,omitempty"` // The signing secret to verify incoming requests from Stripe WebhookSigningSecret *string `json:"webhook_signing_secret,omitempty" required:"true" maxLength:"100" minLength:"1"` } +func (s *StripeConfigPayload) GetId() *string { + if s == nil { + return nil + } + return s.Id +} + +func (s *StripeConfigPayload) SetId(id string) { + s.Id = &id +} + func (s *StripeConfigPayload) GetWebhookSigningSecret() *string { if s == nil { return nil diff --git a/pkg/project-client/integrations/theme.go b/pkg/project-client/integrations/theme.go new file mode 100644 index 0000000..7ea63e6 --- /dev/null +++ b/pkg/project-client/integrations/theme.go @@ -0,0 +1,106 @@ +package integrations + +import "encoding/json" + +// Visual customization options for the hosted inbox widget. +type Theme struct { + // Top banner styling options. + Banner *Banner `json:"banner,omitempty"` + // Styling for confirmation and action dialogs. + Dialog *Dialog `json:"dialog,omitempty"` + // Footer styling for the inbox modal. + Footer *Footer `json:"footer,omitempty"` + // Header styling for the inbox modal. + Header *Header `json:"header,omitempty"` + // Launcher icon styling overrides. + Icon *Icon `json:"icon,omitempty"` + // Styling overrides for notification list items. + Notification *Notification `json:"notification,omitempty"` + // Badge styling for unseen notification counts. + UnseenBadge *UnseenBadge `json:"unseenBadge,omitempty"` +} + +func (t *Theme) GetBanner() *Banner { + if t == nil { + return nil + } + return t.Banner +} + +func (t *Theme) SetBanner(banner Banner) { + t.Banner = &banner +} + +func (t *Theme) GetDialog() *Dialog { + if t == nil { + return nil + } + return t.Dialog +} + +func (t *Theme) SetDialog(dialog Dialog) { + t.Dialog = &dialog +} + +func (t *Theme) GetFooter() *Footer { + if t == nil { + return nil + } + return t.Footer +} + +func (t *Theme) SetFooter(footer Footer) { + t.Footer = &footer +} + +func (t *Theme) GetHeader() *Header { + if t == nil { + return nil + } + return t.Header +} + +func (t *Theme) SetHeader(header Header) { + t.Header = &header +} + +func (t *Theme) GetIcon() *Icon { + if t == nil { + return nil + } + return t.Icon +} + +func (t *Theme) SetIcon(icon Icon) { + t.Icon = &icon +} + +func (t *Theme) GetNotification() *Notification { + if t == nil { + return nil + } + return t.Notification +} + +func (t *Theme) SetNotification(notification Notification) { + t.Notification = ¬ification +} + +func (t *Theme) GetUnseenBadge() *UnseenBadge { + if t == nil { + return nil + } + return t.UnseenBadge +} + +func (t *Theme) SetUnseenBadge(unseenBadge UnseenBadge) { + t.UnseenBadge = &unseenBadge +} + +func (t Theme) String() string { + jsonData, err := json.MarshalIndent(t, "", " ") + if err != nil { + return "error converting struct: Theme to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/type_.go b/pkg/project-client/integrations/type_.go new file mode 100644 index 0000000..e4682d8 --- /dev/null +++ b/pkg/project-client/integrations/type_.go @@ -0,0 +1,8 @@ +package integrations + +// Indicates the kind of Google credential. Service accounts always use the `service_account` type. +type Type_ string + +const ( + TYPE_SERVICE_ACCOUNT Type_ = "service_account" +) diff --git a/pkg/project-client/integrations/unread.go b/pkg/project-client/integrations/unread.go new file mode 100644 index 0000000..2555479 --- /dev/null +++ b/pkg/project-client/integrations/unread.go @@ -0,0 +1,67 @@ +package integrations + +import "encoding/json" + +// Overrides for unread notifications. +type Unread struct { + // Background color applied to unread notifications. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` + // Hover styles for unread notifications. + Hover *UnreadHover `json:"hover,omitempty"` + // State indicator styling for unread notifications. + State *UnreadState `json:"state,omitempty"` + // Text color used when a notification is unread. + TextColor *string `json:"textColor,omitempty" required:"true"` +} + +func (u *Unread) GetBackgroundColor() *string { + if u == nil { + return nil + } + return u.BackgroundColor +} + +func (u *Unread) SetBackgroundColor(backgroundColor string) { + u.BackgroundColor = &backgroundColor +} + +func (u *Unread) GetHover() *UnreadHover { + if u == nil { + return nil + } + return u.Hover +} + +func (u *Unread) SetHover(hover UnreadHover) { + u.Hover = &hover +} + +func (u *Unread) GetState() *UnreadState { + if u == nil { + return nil + } + return u.State +} + +func (u *Unread) SetState(state UnreadState) { + u.State = &state +} + +func (u *Unread) GetTextColor() *string { + if u == nil { + return nil + } + return u.TextColor +} + +func (u *Unread) SetTextColor(textColor string) { + u.TextColor = &textColor +} + +func (u Unread) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: Unread to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/unread_hover.go b/pkg/project-client/integrations/unread_hover.go new file mode 100644 index 0000000..cbff9b3 --- /dev/null +++ b/pkg/project-client/integrations/unread_hover.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// Hover styles for unread notifications. +type UnreadHover struct { + // Background color on hover for unread notifications. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` +} + +func (u *UnreadHover) GetBackgroundColor() *string { + if u == nil { + return nil + } + return u.BackgroundColor +} + +func (u *UnreadHover) SetBackgroundColor(backgroundColor string) { + u.BackgroundColor = &backgroundColor +} + +func (u UnreadHover) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: UnreadHover to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/unread_state.go b/pkg/project-client/integrations/unread_state.go new file mode 100644 index 0000000..ce38d9f --- /dev/null +++ b/pkg/project-client/integrations/unread_state.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// State indicator styling for unread notifications. +type UnreadState struct { + // Color for the unread state indicator. + Color *string `json:"color,omitempty" required:"true"` +} + +func (u *UnreadState) GetColor() *string { + if u == nil { + return nil + } + return u.Color +} + +func (u *UnreadState) SetColor(color string) { + u.Color = &color +} + +func (u UnreadState) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: UnreadState to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/unseen.go b/pkg/project-client/integrations/unseen.go new file mode 100644 index 0000000..577d61b --- /dev/null +++ b/pkg/project-client/integrations/unseen.go @@ -0,0 +1,67 @@ +package integrations + +import "encoding/json" + +// Overrides for unseen notifications. +type Unseen struct { + // Background color applied to unseen notifications. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` + // Hover styles for unseen notifications. + Hover *UnseenHover `json:"hover,omitempty"` + // State indicator styling for unseen notifications. + State *UnseenState `json:"state,omitempty"` + // Text color used when a notification is unseen. + TextColor *string `json:"textColor,omitempty" required:"true"` +} + +func (u *Unseen) GetBackgroundColor() *string { + if u == nil { + return nil + } + return u.BackgroundColor +} + +func (u *Unseen) SetBackgroundColor(backgroundColor string) { + u.BackgroundColor = &backgroundColor +} + +func (u *Unseen) GetHover() *UnseenHover { + if u == nil { + return nil + } + return u.Hover +} + +func (u *Unseen) SetHover(hover UnseenHover) { + u.Hover = &hover +} + +func (u *Unseen) GetState() *UnseenState { + if u == nil { + return nil + } + return u.State +} + +func (u *Unseen) SetState(state UnseenState) { + u.State = &state +} + +func (u *Unseen) GetTextColor() *string { + if u == nil { + return nil + } + return u.TextColor +} + +func (u *Unseen) SetTextColor(textColor string) { + u.TextColor = &textColor +} + +func (u Unseen) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: Unseen to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/unseen_badge.go b/pkg/project-client/integrations/unseen_badge.go new file mode 100644 index 0000000..e08fc30 --- /dev/null +++ b/pkg/project-client/integrations/unseen_badge.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// Badge styling for unseen notification counts. +type UnseenBadge struct { + // Badge background color. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` +} + +func (u *UnseenBadge) GetBackgroundColor() *string { + if u == nil { + return nil + } + return u.BackgroundColor +} + +func (u *UnseenBadge) SetBackgroundColor(backgroundColor string) { + u.BackgroundColor = &backgroundColor +} + +func (u UnseenBadge) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: UnseenBadge to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/unseen_hover.go b/pkg/project-client/integrations/unseen_hover.go new file mode 100644 index 0000000..38f4351 --- /dev/null +++ b/pkg/project-client/integrations/unseen_hover.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// Hover styles for unseen notifications. +type UnseenHover struct { + // Background color on hover for unseen notifications. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` +} + +func (u *UnseenHover) GetBackgroundColor() *string { + if u == nil { + return nil + } + return u.BackgroundColor +} + +func (u *UnseenHover) SetBackgroundColor(backgroundColor string) { + u.BackgroundColor = &backgroundColor +} + +func (u UnseenHover) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: UnseenHover to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/unseen_state.go b/pkg/project-client/integrations/unseen_state.go new file mode 100644 index 0000000..3a4e258 --- /dev/null +++ b/pkg/project-client/integrations/unseen_state.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// State indicator styling for unseen notifications. +type UnseenState struct { + // Color for the unseen state indicator. + Color *string `json:"color,omitempty" required:"true"` +} + +func (u *UnseenState) GetColor() *string { + if u == nil { + return nil + } + return u.Color +} + +func (u *UnseenState) SetColor(color string) { + u.Color = &color +} + +func (u UnseenState) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: UnseenState to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/integrations/webpush_config_payload.go b/pkg/project-client/integrations/webpush_config_payload.go index 072bc3d..de1d00c 100644 --- a/pkg/project-client/integrations/webpush_config_payload.go +++ b/pkg/project-client/integrations/webpush_config_payload.go @@ -3,9 +3,9 @@ package integrations import "encoding/json" type WebpushConfigPayload struct { - // VAPID private key - from the pair you generated. + // VAPID private key. PrivateKey *string `json:"private_key,omitempty" required:"true" maxLength:"128" minLength:"8"` - // VAPID public key - generate one at https://tools.reactpwa.com/vapid. + // VAPID public key - read more at https://magicbell.com/tools/vapid-keys. PublicKey *string `json:"public_key,omitempty" required:"true" maxLength:"128" minLength:"8"` } diff --git a/pkg/project-client/internal/clients/rest/client.go b/pkg/project-client/internal/clients/rest/client.go index a2b4b01..629208d 100644 --- a/pkg/project-client/internal/clients/rest/client.go +++ b/pkg/project-client/internal/clients/rest/client.go @@ -7,20 +7,25 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" ) -type RestClient[T any] struct { - handlers *handlers.HandlerChain[T] +// RestClient is a generic HTTP client that handles API requests through a chain of handlers. +// It supports both regular and streaming requests with type-safe response handling. +// T is the response type, E is the error type. +type RestClient[T any, E any] struct { + handlers *handlers.HandlerChain[T, E] } -func NewRestClient[T any](config clientconfig.Config) *RestClient[T] { - retryHandler := handlers.NewRetryHandler[T]() - bearerTokenHandler := handlers.NewAccessTokenHandler[T]() - responseValidationHandler := handlers.NewResponseValidationHandler[T]() - unmarshalHandler := handlers.NewUnmarshalHandler[T]() - requestValidationHandler := handlers.NewRequestValidationHandler[T]() - hookHandler := handlers.NewHookHandler[T](hooks.NewDefaultHook()) - terminatingHandler := handlers.NewTerminatingHandler[T]() +// NewRestClient creates a new REST client with the configured handler chain. +// Initializes all handlers in the correct order for request processing. +func NewRestClient[T any, E any](config clientconfig.Config, hook hooks.Hook) *RestClient[T, E] { + retryHandler := handlers.NewRetryHandler[T, E]() + bearerTokenHandler := handlers.NewAccessTokenHandler[T, E]() + responseValidationHandler := handlers.NewResponseValidationHandler[T, E]() + unmarshalHandler := handlers.NewUnmarshalHandler[T, E]() + requestValidationHandler := handlers.NewRequestValidationHandler[T, E]() + hookHandler := handlers.NewHookHandler[T, E](hook) + terminatingHandler := handlers.NewTerminatingHandler[T, E]() - handlers := handlers.BuildHandlerChain[T](). + handlers := handlers.BuildHandlerChain[T, E](). AddHandler(retryHandler). AddHandler(bearerTokenHandler). AddHandler(responseValidationHandler). @@ -29,11 +34,19 @@ func NewRestClient[T any](config clientconfig.Config) *RestClient[T] { AddHandler(hookHandler). AddHandler(terminatingHandler) - return &RestClient[T]{ + return &RestClient[T, E]{ handlers: handlers, } } -func (client *RestClient[T]) Call(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// Call executes a regular HTTP request through the handler chain. +// Returns the response with deserialized data or an error response. +func (client *RestClient[T, E]) Call(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { return client.handlers.CallApi(request) } + +// Stream executes a streaming HTTP request through the handler chain. +// Returns a stream for consuming response chunks or an error response. +func (client *RestClient[T, E]) Stream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + return client.handlers.StreamApi(request) +} diff --git a/pkg/project-client/internal/clients/rest/handlers/bearer_token_handler.go b/pkg/project-client/internal/clients/rest/handlers/bearer_token_handler.go index 90200a5..c974e67 100644 --- a/pkg/project-client/internal/clients/rest/handlers/bearer_token_handler.go +++ b/pkg/project-client/internal/clients/rest/handlers/bearer_token_handler.go @@ -7,32 +7,59 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/httptransport" ) -type AccessTokenHandler[T any] struct { - nextHandler Handler[T] +// AccessTokenHandler adds a Bearer token to the Authorization header for authentication. +// It injects the configured access token into requests that require token-based auth. +// T is the response type, E is the error type. +type AccessTokenHandler[T any, E any] struct { + nextHandler Handler[T, E] } -func NewAccessTokenHandler[T any]() *AccessTokenHandler[T] { - return &AccessTokenHandler[T]{ +// NewAccessTokenHandler creates a new Bearer token authentication handler. +// Returns a handler that will inject the access token as a Bearer token in the Authorization header. +func NewAccessTokenHandler[T any, E any]() *AccessTokenHandler[T, E] { + return &AccessTokenHandler[T, E]{ nextHandler: nil, } } -func (h *AccessTokenHandler[T]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// prepareRequest clones the request and adds the Bearer token header if configured. +// Formats the token as "Bearer " and sets the Authorization header. +func (h *AccessTokenHandler[T, E]) prepareRequest(request httptransport.Request) (httptransport.Request, error) { if h.nextHandler == nil { - err := errors.New("Handler chain terminated without terminating handler") - return nil, httptransport.NewErrorResponse[T](err, nil) + return httptransport.Request{}, errors.New("Handler chain terminated without terminating handler") } nextRequest := request.Clone() - if request.Config.AccessToken == nil { - return h.nextHandler.Handle(nextRequest) + + if request.Config.AccessToken != nil { + nextRequest.SetHeader("Authorization", fmt.Sprintf("Bearer %s", *request.Config.AccessToken)) } - nextRequest.SetHeader("Authorization", fmt.Sprintf("Bearer %s", *request.Config.AccessToken)) + return nextRequest, nil +} +// Handle processes a regular request by adding the Bearer token if configured. +// Returns the response from the next handler after authentication is applied. +func (h *AccessTokenHandler[T, E]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { + nextRequest, err := h.prepareRequest(request) + if err != nil { + return nil, httptransport.NewErrorResponse[E](err, nil) + } return h.nextHandler.Handle(nextRequest) } -func (h *AccessTokenHandler[T]) SetNext(handler Handler[T]) { +// HandleStream processes a streaming request by adding the Bearer token if configured. +// Returns the stream from the next handler after authentication is applied. +func (h *AccessTokenHandler[T, E]) HandleStream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + nextRequest, err := h.prepareRequest(request) + if err != nil { + return nil, httptransport.NewErrorResponse[E](err, nil) + } + return h.nextHandler.HandleStream(nextRequest) +} + +// SetNext sets the next handler in the chain. +// This method is called during chain construction to link handlers together. +func (h *AccessTokenHandler[T, E]) SetNext(handler Handler[T, E]) { h.nextHandler = handler } diff --git a/pkg/project-client/internal/clients/rest/handlers/handler_chain.go b/pkg/project-client/internal/clients/rest/handlers/handler_chain.go index 27d6d3b..7eef0ff 100644 --- a/pkg/project-client/internal/clients/rest/handlers/handler_chain.go +++ b/pkg/project-client/internal/clients/rest/handlers/handler_chain.go @@ -4,21 +4,31 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/httptransport" ) -type Handler[T any] interface { - Handle(req httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) - SetNext(handler Handler[T]) +// Handler defines the interface for request processing in the handler chain. +// Each handler can process both regular and streaming requests. +// T is the response type, E is the error type. +type Handler[T any, E any] interface { + Handle(req httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) + HandleStream(req httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) + SetNext(handler Handler[T, E]) } -type HandlerChain[T any] struct { - head Handler[T] - tail Handler[T] +// HandlerChain manages a chain of handlers for processing requests. +// Implements the chain of responsibility pattern for request/response processing. +type HandlerChain[T any, E any] struct { + head Handler[T, E] + tail Handler[T, E] } -func BuildHandlerChain[T any]() *HandlerChain[T] { - return &HandlerChain[T]{} +// BuildHandlerChain creates a new empty handler chain. +// Handlers can be added using AddHandler to build the processing pipeline. +func BuildHandlerChain[T any, E any]() *HandlerChain[T, E] { + return &HandlerChain[T, E]{} } -func (chain *HandlerChain[T]) AddHandler(handler Handler[T]) *HandlerChain[T] { +// AddHandler appends a handler to the end of the chain. +// Returns the chain for method chaining. Handlers execute in the order they are added. +func (chain *HandlerChain[T, E]) AddHandler(handler Handler[T, E]) *HandlerChain[T, E] { if chain.head == nil { chain.head = handler chain.tail = handler @@ -31,6 +41,14 @@ func (chain *HandlerChain[T]) AddHandler(handler Handler[T]) *HandlerChain[T] { return chain } -func (chain *HandlerChain[T]) CallApi(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// CallApi processes a regular HTTP request through the handler chain. +// Returns the processed response or an error response. +func (chain *HandlerChain[T, E]) CallApi(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { return chain.head.Handle(request) } + +// StreamApi processes a streaming HTTP request through the handler chain. +// Returns a stream for consuming response chunks or an error response. +func (chain *HandlerChain[T, E]) StreamApi(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + return chain.head.HandleStream(request) +} diff --git a/pkg/project-client/internal/clients/rest/handlers/hook_handler.go b/pkg/project-client/internal/clients/rest/handlers/hook_handler.go index 1ffe5b0..a60d42b 100644 --- a/pkg/project-client/internal/clients/rest/handlers/hook_handler.go +++ b/pkg/project-client/internal/clients/rest/handlers/hook_handler.go @@ -7,22 +7,29 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/httptransport" ) -type HookHandler[T any] struct { - nextHandler Handler[T] +// HookHandler executes custom hook callbacks before and after request processing. +// It allows users to intercept and modify requests, responses, and errors through the hook interface. +// T is the response type, E is the error type. +type HookHandler[T any, E any] struct { + nextHandler Handler[T, E] hook hooks.Hook } -func NewHookHandler[T any](hook hooks.Hook) *HookHandler[T] { - return &HookHandler[T]{ +// NewHookHandler creates a new hook handler with the provided hook implementation. +// Returns a handler that will execute BeforeRequest, AfterResponse, and OnError callbacks. +func NewHookHandler[T any, E any](hook hooks.Hook) *HookHandler[T, E] { + return &HookHandler[T, E]{ hook: hook, nextHandler: nil, } } -func (h *HookHandler[T]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// Handle processes a regular request through the hook lifecycle. +// Executes BeforeRequest, passes the request through the chain, then executes AfterResponse or OnError. +func (h *HookHandler[T, E]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { if h.nextHandler == nil { err := errors.New("Handler chain terminated without terminating handler") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } clonedReq := request.Clone() @@ -31,17 +38,17 @@ func (h *HookHandler[T]) Handle(request httptransport.Request) (*httptransport.R nextRequest, ok := hookReq.(*httptransport.Request) if !ok { err := errors.New("hook returned invalid request") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } response, err := h.nextHandler.Handle(*nextRequest) if err != nil && err.IsHttpError { clonedError := err.Clone() hookError := h.hook.OnError(hookReq, &clonedError, clonedReq.Config.HookParams) - nextError, ok := hookError.(*httptransport.ErrorResponse[T]) + nextError, ok := hookError.(*httptransport.ErrorResponse[E]) if !ok { err := errors.New("hook returned invalid error") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } return nil, nextError @@ -54,12 +61,34 @@ func (h *HookHandler[T]) Handle(request httptransport.Request) (*httptransport.R nextResponse, ok := hookResp.(*httptransport.Response[T]) if !ok { err := errors.New("hook returned invalid response") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } return nextResponse, nil } -func (h *HookHandler[T]) SetNext(handler Handler[T]) { +// HandleStream processes a streaming request by executing the BeforeRequest hook. +// Returns the stream from the next handler after the request hook is applied. +func (h *HookHandler[T, E]) HandleStream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + if h.nextHandler == nil { + err := errors.New("Handler chain terminated without terminating handler") + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + clonedReq := request.Clone() + hookReq := h.hook.BeforeRequest(&clonedReq, clonedReq.Config.HookParams) + + nextRequest, ok := hookReq.(*httptransport.Request) + if !ok { + err := errors.New("hook returned invalid request") + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + return h.nextHandler.HandleStream(*nextRequest) +} + +// SetNext sets the next handler in the chain. +// This method is called during chain construction to link handlers together. +func (h *HookHandler[T, E]) SetNext(handler Handler[T, E]) { h.nextHandler = handler } diff --git a/pkg/project-client/internal/clients/rest/handlers/request_validation_handler.go b/pkg/project-client/internal/clients/rest/handlers/request_validation_handler.go index 852cb99..b06680c 100644 --- a/pkg/project-client/internal/clients/rest/handlers/request_validation_handler.go +++ b/pkg/project-client/internal/clients/rest/handlers/request_validation_handler.go @@ -7,35 +7,65 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/validation" ) -type RequestValidationHandler[T any] struct { - nextHandler Handler[T] +// RequestValidationHandler validates request body and options before sending. +// It ensures that all required fields are present and values meet the specified constraints. +// T is the response type, E is the error type. +type RequestValidationHandler[T any, E any] struct { + nextHandler Handler[T, E] } -func NewRequestValidationHandler[T any]() *RequestValidationHandler[T] { - return &RequestValidationHandler[T]{ +// NewRequestValidationHandler creates a new request validation handler. +// Returns a handler that will validate request body and options against defined schemas. +func NewRequestValidationHandler[T any, E any]() *RequestValidationHandler[T, E] { + return &RequestValidationHandler[T, E]{ nextHandler: nil, } } -func (h *RequestValidationHandler[T]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// Handle validates the request body and options before passing to the next handler. +// Returns a validation error if any constraints are violated, otherwise continues the chain. +func (h *RequestValidationHandler[T, E]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { if h.nextHandler == nil { err := errors.New("Handler chain terminated without terminating handler") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } err := validation.ValidateData(request.Body) if err != nil { - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } err = validation.ValidateData(request.Options) if err != nil { - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } return h.nextHandler.Handle(request) } -func (h *RequestValidationHandler[T]) SetNext(handler Handler[T]) { +// HandleStream validates the request body and options before initiating a stream. +// Returns a validation error if any constraints are violated, otherwise continues the chain. +func (h *RequestValidationHandler[T, E]) HandleStream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + if h.nextHandler == nil { + err := errors.New("Handler chain terminated without terminating handler") + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + err := validation.ValidateData(request.Body) + if err != nil { + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + err = validation.ValidateData(request.Options) + if err != nil { + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + return h.nextHandler.HandleStream(request) +} + +// SetNext sets the next handler in the chain. +// This method is called during chain construction to link handlers together. +func (h *RequestValidationHandler[T, E]) SetNext(handler Handler[T, E]) { h.nextHandler = handler } diff --git a/pkg/project-client/internal/clients/rest/handlers/response_validation_handler.go b/pkg/project-client/internal/clients/rest/handlers/response_validation_handler.go index 06de39b..f7d514c 100644 --- a/pkg/project-client/internal/clients/rest/handlers/response_validation_handler.go +++ b/pkg/project-client/internal/clients/rest/handlers/response_validation_handler.go @@ -7,20 +7,27 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/validation" ) -type ResponseValidationHandler[T any] struct { - nextHandler Handler[T] +// ResponseValidationHandler validates response data after deserialization. +// It ensures that the response data meets the expected schema and constraints. +// T is the response type, E is the error type. +type ResponseValidationHandler[T any, E any] struct { + nextHandler Handler[T, E] } -func NewResponseValidationHandler[T any]() *ResponseValidationHandler[T] { - return &ResponseValidationHandler[T]{ +// NewResponseValidationHandler creates a new response validation handler. +// Returns a handler that will validate response data against defined schemas. +func NewResponseValidationHandler[T any, E any]() *ResponseValidationHandler[T, E] { + return &ResponseValidationHandler[T, E]{ nextHandler: nil, } } -func (h *ResponseValidationHandler[T]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// Handle validates the response data after it's been processed by the handler chain. +// Returns a validation error if the response data doesn't meet the schema, otherwise returns the response. +func (h *ResponseValidationHandler[T, E]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { if h.nextHandler == nil { err := errors.New("Handler chain terminated without terminating handler") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } resp, handlerError := h.nextHandler.Handle(request) @@ -30,12 +37,26 @@ func (h *ResponseValidationHandler[T]) Handle(request httptransport.Request) (*h err := validation.ValidateData(resp.Data) if err != nil { - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } return resp, nil } -func (h *ResponseValidationHandler[T]) SetNext(handler Handler[T]) { +// HandleStream passes through streaming requests without validation. +// Streaming responses are validated as they are consumed by the caller. +func (h *ResponseValidationHandler[T, E]) HandleStream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + if h.nextHandler == nil { + err := errors.New("Handler chain terminated without terminating handler") + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + // Streaming responses are validated as they are consumed, so just pass through + return h.nextHandler.HandleStream(request) +} + +// SetNext sets the next handler in the chain. +// This method is called during chain construction to link handlers together. +func (h *ResponseValidationHandler[T, E]) SetNext(handler Handler[T, E]) { h.nextHandler = handler } diff --git a/pkg/project-client/internal/clients/rest/handlers/retry_handler.go b/pkg/project-client/internal/clients/rest/handlers/retry_handler.go index 7828264..e696cda 100644 --- a/pkg/project-client/internal/clients/rest/handlers/retry_handler.go +++ b/pkg/project-client/internal/clients/rest/handlers/retry_handler.go @@ -12,23 +12,30 @@ const ( retryDelay = 150 * time.Millisecond ) -type RetryHandler[T any] struct { - nextHandler Handler[T] +// RetryHandler automatically retries failed requests with exponential backoff. +// It retries requests that fail or return 4xx/5xx status codes up to maxRetries times. +// T is the response type, E is the error type. +type RetryHandler[T any, E any] struct { + nextHandler Handler[T, E] } -func NewRetryHandler[T any]() *RetryHandler[T] { - return &RetryHandler[T]{ +// NewRetryHandler creates a new retry handler with configured max retries and delay. +// Returns a handler that will automatically retry failed requests with backoff. +func NewRetryHandler[T any, E any]() *RetryHandler[T, E] { + return &RetryHandler[T, E]{ nextHandler: nil, } } -func (h *RetryHandler[T]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// Handle processes a request with automatic retry logic on failures or error status codes. +// Implements exponential backoff between retry attempts. Returns the first successful response or the final error. +func (h *RetryHandler[T, E]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { if h.nextHandler == nil { err := errors.New("Handler chain terminated without terminating handler") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } - var err *httptransport.ErrorResponse[T] + var err *httptransport.ErrorResponse[E] for tryCount := 0; tryCount < maxRetries; tryCount++ { nextRequest := request.Clone() @@ -45,9 +52,39 @@ func (h *RetryHandler[T]) Handle(request httptransport.Request) (*httptransport. backoffDuration := time.Duration(tryCount) * retryDelay time.Sleep(backoffDuration) } - return nil, httptransport.NewErrorResponse[T](err, nil) + if err != nil { + return nil, err + } + return nil, httptransport.NewErrorResponse[E](errors.New("max retries exceeded"), nil) +} + +// HandleStream processes a streaming request with automatic retry logic on failures. +// Retries failed stream connections with exponential backoff. Returns the first successful stream or the final error. +func (h *RetryHandler[T, E]) HandleStream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + if h.nextHandler == nil { + err := errors.New("Handler chain terminated without terminating handler") + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + var errResp *httptransport.ErrorResponse[E] + for tryCount := 0; tryCount < maxRetries; tryCount++ { + nextRequest := request.Clone() + + stream, err := h.nextHandler.HandleStream(nextRequest) + if err == nil { + return stream, nil + } + + errResp = err + + backoffDuration := time.Duration(tryCount) * retryDelay + time.Sleep(backoffDuration) + } + return nil, errResp } -func (h *RetryHandler[T]) SetNext(handler Handler[T]) { +// SetNext sets the next handler in the chain. +// This method is called during chain construction to link handlers together. +func (h *RetryHandler[T, E]) SetNext(handler Handler[T, E]) { h.nextHandler = handler } diff --git a/pkg/project-client/internal/clients/rest/handlers/terminating_handler.go b/pkg/project-client/internal/clients/rest/handlers/terminating_handler.go index b257e79..2114044 100644 --- a/pkg/project-client/internal/clients/rest/handlers/terminating_handler.go +++ b/pkg/project-client/internal/clients/rest/handlers/terminating_handler.go @@ -1,19 +1,27 @@ package handlers import ( + "context" "fmt" "net/http" "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/httptransport" ) -type TerminatingHandler[T any] struct{} +// TerminatingHandler is the final handler in the chain that executes the actual HTTP request. +// It creates an HTTP client, sends the request, and converts the http.Response to a transport response. +// T is the response type, E is the error type. +type TerminatingHandler[T any, E any] struct{} -func NewTerminatingHandler[T any]() *TerminatingHandler[T] { - return &TerminatingHandler[T]{} +// NewTerminatingHandler creates a new terminating handler. +// Returns the handler that will execute HTTP requests and should be the last in the chain. +func NewTerminatingHandler[T any, E any]() *TerminatingHandler[T, E] { + return &TerminatingHandler[T, E]{} } -func (h *TerminatingHandler[T]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// Handle executes the HTTP request using the standard http.Client and returns the response. +// This is the final handler in the chain that performs the actual network call. +func (h *TerminatingHandler[T, E]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { requestClone := request.Clone() client := http.Client{} @@ -23,27 +31,71 @@ func (h *TerminatingHandler[T]) Handle(request httptransport.Request) (*httptran req, err := requestClone.CreateHttpRequest() if err != nil { - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } resp, err := client.Do(req) if err != nil { - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } transportResponse, responseErr := httptransport.NewResponse[T](resp) if responseErr != nil { - return nil, httptransport.NewErrorResponse[T](responseErr, transportResponse) + return nil, httptransport.NewErrorResponse[E](responseErr, nil) } if transportResponse.StatusCode >= 400 { err := fmt.Errorf("HTTP request failed with status code %d", transportResponse.StatusCode) - return nil, httptransport.NewErrorResponse[T](err, transportResponse) + errorResponse := &httptransport.Response[E]{ + StatusCode: transportResponse.StatusCode, + Headers: transportResponse.Headers, + Body: transportResponse.Body, + Raw: transportResponse.Raw, + } + return nil, httptransport.NewErrorResponse[E](err, errorResponse) } return transportResponse, nil } -func (h *TerminatingHandler[T]) SetNext(handler Handler[T]) { +// HandleStream executes a streaming HTTP request and returns a stream for consuming the response. +// Creates an HTTP client, sends the request, and wraps the response body in a stream for chunk-by-chunk processing. +func (h *TerminatingHandler[T, E]) HandleStream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + requestClone := request.Clone() + + client := http.Client{} + if requestClone.Config.Timeout != nil { + client.Timeout = *requestClone.Config.Timeout + } + + req, err := requestClone.CreateHttpRequest() + if err != nil { + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + resp, err := client.Do(req) + if err != nil { + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + if resp.StatusCode >= 400 { + resp.Body.Close() + err := fmt.Errorf("HTTP request failed with status code %d", resp.StatusCode) + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + // Get context from request, or use background if not available + ctx := request.Context + if ctx == nil { + ctx = context.Background() + } + + stream := httptransport.NewStream[T](resp, ctx) + return stream, nil +} + +// SetNext logs a warning as the terminating handler should always be the last in the chain. +// Calling this method indicates a misconfiguration in the handler chain setup. +func (h *TerminatingHandler[T, E]) SetNext(handler Handler[T, E]) { fmt.Println("WARNING: SetNext should not be called on the terminating handler.") } diff --git a/pkg/project-client/internal/clients/rest/handlers/unmarshal_handler.go b/pkg/project-client/internal/clients/rest/handlers/unmarshal_handler.go index 9230275..0b5b1ee 100644 --- a/pkg/project-client/internal/clients/rest/handlers/unmarshal_handler.go +++ b/pkg/project-client/internal/clients/rest/handlers/unmarshal_handler.go @@ -2,70 +2,168 @@ package handlers import ( "errors" + "fmt" + "reflect" "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/httptransport" "github.com/magicbell/magicbell-go/pkg/project-client/internal/contenttypes" ) -type UnmarshalHandler[T any] struct { - nextHandler Handler[T] +// UnmarshalHandler deserializes response bodies based on content type. +// It supports JSON, form data, text, and binary content types, converting raw bytes to typed data. +// T is the response type, E is the error type. +type UnmarshalHandler[T any, E any] struct { + nextHandler Handler[T, E] } -func NewUnmarshalHandler[T any]() *UnmarshalHandler[T] { - return &UnmarshalHandler[T]{ +// NewUnmarshalHandler creates a new unmarshaling handler. +// Returns a handler that will deserialize response bodies according to the requested content type. +func NewUnmarshalHandler[T any, E any]() *UnmarshalHandler[T, E] { + return &UnmarshalHandler[T, E]{ nextHandler: nil, } } -func (h *UnmarshalHandler[T]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// Handle deserializes the response body from the next handler based on the response content type. +// Supports JSON, form-urlencoded, multipart form data, text, and binary formats. +func (h *UnmarshalHandler[T, E]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { if h.nextHandler == nil { err := errors.New("Handler chain terminated without terminating handler") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } resp, handlerError := h.nextHandler.Handle(request) if handlerError != nil { + // Try to unmarshal error response body into the error type E + if handlerError.IsHttpError && len(handlerError.Body) > 0 { + unmarshaledError := h.tryUnmarshalErrorBody(handlerError) + if unmarshaledError != nil { + return nil, unmarshaledError + } + } return nil, handlerError } - target := new(T) - if request.ResponseContentType == httptransport.ContentTypeJson { - err := contenttypes.FromJson(resp.Body, target) - if err != nil { - return nil, httptransport.NewErrorResponse[T](err, resp) - } - } else if request.ResponseContentType == httptransport.ContentTypeFormUrlEncoded { - err := contenttypes.FromFormUrlEncoded(resp.Body, target) - if err != nil { - return nil, httptransport.NewErrorResponse[T](err, resp) - } - } else if request.ResponseContentType == httptransport.ContentTypeMultipartFormData { - err := contenttypes.FromFormData(resp.Body, target) - if err != nil { - return nil, httptransport.NewErrorResponse[T](err, resp) - } - } else if request.ResponseContentType == httptransport.ContentTypeText { - err := contenttypes.FromText[T](resp.Body, target) - if err != nil { - return nil, httptransport.NewErrorResponse[T](err, resp) + if len(resp.Body) == 0 { + var zeroValue T + resp.Data = zeroValue + return resp, nil + } + + contentTypesToTry := []httptransport.ContentType{ + httptransport.ContentTypeJson, + httptransport.ContentTypeMultipartFormData, + httptransport.ContentTypeFormUrlEncoded, + httptransport.ContentTypeText, + httptransport.ContentTypeBinary, + } + + var lastErr error + for _, contentType := range contentTypesToTry { + tempTarget := new(T) + err := unmarshalWithContentType(resp.Body, tempTarget, contentType) + if err == nil { + resp.Data = *tempTarget + return resp, nil } - } else if request.ResponseContentType == httptransport.ContentTypeBinary { - err := contenttypes.FromBinary(resp.Body, target) - if err != nil { - return nil, httptransport.NewErrorResponse[T](err, resp) + lastErr = err + } + + if lastErr == nil { + lastErr = fmt.Errorf("failed to unmarshal response with any content type") + } + + return nil, httptransport.NewErrorResponse[E](lastErr, nil) +} + +// tryUnmarshalErrorBody attempts to unmarshal the error response body into the error type E. +// Returns a new ErrorResponse with unmarshaled data if successful, or nil if unmarshaling fails. +// For []byte error types, FromBinary will handle copying the body directly. +func (h *UnmarshalHandler[T, E]) tryUnmarshalErrorBody(err *httptransport.ErrorResponse[E]) *httptransport.ErrorResponse[E] { + // Normalize empty body: convert nil to empty slice for consistent handling + body := err.Body + if body == nil { + body = []byte{} + } + + contentTypesToTry := []httptransport.ContentType{ + httptransport.ContentTypeJson, + httptransport.ContentTypeMultipartFormData, + httptransport.ContentTypeFormUrlEncoded, + httptransport.ContentTypeText, + httptransport.ContentTypeBinary, + } + + for _, contentType := range contentTypesToTry { + tempTarget := new(E) + unmarshalErr := unmarshalWithContentType(body, tempTarget, contentType) + if unmarshalErr == nil { + // Check if the unmarshaled value is a zero value (e.g., nil slice for []byte) + // For zero values, we want Data to be nil, not a pointer to zero value + if isEmptyValue(*tempTarget) { + // Return nil to indicate unmarshaling didn't produce meaningful data + // This allows callers to distinguish between "unmarshaled successfully" and "no data" + return nil + } + // Successfully unmarshaled, create a new error response with the unmarshaled data + unmarshaledError := err.Clone() + unmarshaledError.Data = tempTarget + // Ensure Body is also normalized (convert nil to empty slice) + if unmarshaledError.Body == nil { + unmarshaledError.Body = []byte{} + } + return &unmarshaledError } + } + + // If unmarshaling fails for all content types, Data remains nil (pointer to E) + return nil +} + +// isEmptyValue checks if a value is considered "empty" (zero value). +// For slices, this means nil or empty slice. For other types, it's the zero value. +func isEmptyValue[T any](v T) bool { + var zero T + if reflect.DeepEqual(v, zero) { + return true + } + // Also check if it's an empty slice (length 0) + vValue := reflect.ValueOf(v) + if vValue.Kind() == reflect.Slice { + return vValue.Len() == 0 + } + return false +} + +func unmarshalWithContentType[T any](body []byte, target *T, contentType httptransport.ContentType) error { + if contentType == httptransport.ContentTypeJson { + return contenttypes.FromJson(body, target) + } else if contentType == httptransport.ContentTypeFormUrlEncoded { + return contenttypes.FromFormUrlEncoded(body, target) + } else if contentType == httptransport.ContentTypeMultipartFormData { + return contenttypes.FromFormData(body, target) + } else if contentType == httptransport.ContentTypeText { + return contenttypes.FromText[T](body, target) + } else if contentType == httptransport.ContentTypeBinary { + return contenttypes.FromBinary(body, target) } else { - err := contenttypes.FromBinary(resp.Body, target) - if err != nil { - return nil, httptransport.NewErrorResponse[T](err, resp) - } + return contenttypes.FromBinary(body, target) } +} - resp.Data = *target +// HandleStream passes through streaming requests without unmarshaling. +// Streaming responses handle their own unmarshaling as chunks are consumed. +func (h *UnmarshalHandler[T, E]) HandleStream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + if h.nextHandler == nil { + err := errors.New("Handler chain terminated without terminating handler") + return nil, httptransport.NewErrorResponse[E](err, nil) + } - return resp, nil + return h.nextHandler.HandleStream(request) } -func (h *UnmarshalHandler[T]) SetNext(handler Handler[T]) { +// SetNext sets the next handler in the chain. +// This method is called during chain construction to link handlers together. +func (h *UnmarshalHandler[T, E]) SetNext(handler Handler[T, E]) { h.nextHandler = handler } diff --git a/pkg/project-client/internal/clients/rest/hooks/default_hook.go b/pkg/project-client/internal/clients/rest/hooks/default_hook.go index 8e1e0da..c0ad287 100644 --- a/pkg/project-client/internal/clients/rest/hooks/default_hook.go +++ b/pkg/project-client/internal/clients/rest/hooks/default_hook.go @@ -1,19 +1,26 @@ package hooks +// DefaultHook is a no-op hook implementation that passes through all requests and responses unchanged. +// Used as the default hook when no custom hook is provided. type DefaultHook struct{} +// NewDefaultHook creates a new default hook that performs no modifications. +// Returns a hook that passes through all requests, responses, and errors unchanged. func NewDefaultHook() Hook { return &DefaultHook{} } +// BeforeRequest passes the request through unchanged. func (h *DefaultHook) BeforeRequest(req Request, params map[string]string) Request { return req } +// AfterResponse passes the response through unchanged. func (h *DefaultHook) AfterResponse(req Request, resp Response, params map[string]string) Response { return resp } +// OnError passes the error response through unchanged. func (h *DefaultHook) OnError(req Request, resp ErrorResponse, params map[string]string) ErrorResponse { return resp } diff --git a/pkg/project-client/internal/clients/rest/hooks/hook.go b/pkg/project-client/internal/clients/rest/hooks/hook.go index bdbfacb..f8d4da4 100644 --- a/pkg/project-client/internal/clients/rest/hooks/hook.go +++ b/pkg/project-client/internal/clients/rest/hooks/hook.go @@ -1,11 +1,14 @@ package hooks +// Hook defines the interface for intercepting and modifying requests, responses, and errors. +// Implementations can inspect, modify, or log HTTP interactions at key points in the request lifecycle. type Hook interface { BeforeRequest(req Request, params map[string]string) Request AfterResponse(req Request, resp Response, params map[string]string) Response OnError(req Request, resp ErrorResponse, params map[string]string) ErrorResponse } +// Request defines the interface for accessing and modifying HTTP request properties within hooks. type Request interface { GetMethod() string SetMethod(method string) @@ -25,6 +28,7 @@ type Request interface { SetBody(body any) } +// Response defines the interface for accessing and modifying HTTP response properties within hooks. type Response interface { GetStatusCode() int SetStatusCode(statusCode int) @@ -34,6 +38,7 @@ type Response interface { SetBody(body []byte) } +// ErrorResponse defines the interface for accessing and modifying HTTP error responses within hooks. type ErrorResponse interface { Error() string GetError() error diff --git a/pkg/project-client/internal/clients/rest/httptransport/content-type.go b/pkg/project-client/internal/clients/rest/httptransport/content-type.go index 3b19200..63b87c9 100644 --- a/pkg/project-client/internal/clients/rest/httptransport/content-type.go +++ b/pkg/project-client/internal/clients/rest/httptransport/content-type.go @@ -1,5 +1,7 @@ package httptransport +// ContentType represents the serialization format for request and response bodies. +// Used to determine how to serialize request data and deserialize response data. type ContentType string const ( diff --git a/pkg/project-client/internal/clients/rest/httptransport/error_response.go b/pkg/project-client/internal/clients/rest/httptransport/error_response.go index 0da26fe..7aa67ab 100644 --- a/pkg/project-client/internal/clients/rest/httptransport/error_response.go +++ b/pkg/project-client/internal/clients/rest/httptransport/error_response.go @@ -1,16 +1,25 @@ package httptransport -import "fmt" +import ( + "fmt" + "net/http" +) +// ErrorResponse represents a failed HTTP request with error details and optional response data. +// It distinguishes between HTTP errors (with status codes) and other errors (network, serialization, etc.). +// Data is a pointer to allow nil when unmarshaling fails. type ErrorResponse[T any] struct { Err error IsHttpError bool StatusCode int Headers map[string]string Body []byte - Data T + Data *T + Raw *http.Response } +// NewErrorResponse creates an ErrorResponse from an error and an optional response. +// If response is provided, sets IsHttpError to true and includes response metadata. func NewErrorResponse[T any](err error, resp *Response[T]) *ErrorResponse[T] { if resp == nil { return &ErrorResponse[T]{ @@ -25,10 +34,12 @@ func NewErrorResponse[T any](err error, resp *Response[T]) *ErrorResponse[T] { StatusCode: resp.StatusCode, Headers: resp.Headers, Body: resp.Body, - Data: resp.Data, + Raw: resp.Raw, } } +// Clone creates a deep copy of the ErrorResponse including headers. +// Returns a new ErrorResponse with copied values. func (r *ErrorResponse[T]) Clone() ErrorResponse[T] { if r == nil { return ErrorResponse[T]{} @@ -42,10 +53,12 @@ func (r *ErrorResponse[T]) Clone() ErrorResponse[T] { return clone } +// Error implements the error interface, returning the error message string. func (r *ErrorResponse[T]) Error() string { return fmt.Sprintf("%s", r.Err) } +// GetError returns the underlying error. func (r *ErrorResponse[T]) GetError() error { return r.Err } diff --git a/pkg/project-client/internal/clients/rest/httptransport/request-builder.go b/pkg/project-client/internal/clients/rest/httptransport/request-builder.go index 9c60786..69b33b0 100644 --- a/pkg/project-client/internal/clients/rest/httptransport/request-builder.go +++ b/pkg/project-client/internal/clients/rest/httptransport/request-builder.go @@ -6,10 +6,14 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" ) +// RequestBuilder provides a fluent interface for constructing HTTP requests. +// Uses the builder pattern to incrementally configure request parameters, headers, body, and options. type RequestBuilder struct { request *Request } +// NewRequestBuilder creates a new request builder with default settings. +// Initializes empty maps for headers, query params, and path params. func NewRequestBuilder() *RequestBuilder { return &RequestBuilder{ request: &Request{ @@ -20,56 +24,78 @@ func NewRequestBuilder() *RequestBuilder { } } +// WithContext sets the request context for cancellation and timeout control. +// Returns the builder for method chaining. func (rb *RequestBuilder) WithContext(ctx context.Context) *RequestBuilder { rb.request.Context = ctx return rb } +// WithMethod sets the HTTP method (GET, POST, PUT, DELETE, etc.). +// Returns the builder for method chaining. func (rb *RequestBuilder) WithMethod(method string) *RequestBuilder { rb.request.Method = method return rb } +// WithPath sets the URL path for the request. +// Returns the builder for method chaining. func (rb *RequestBuilder) WithPath(path string) *RequestBuilder { rb.request.Path = path return rb } +// AddHeader adds a header key-value pair to the request. +// Returns the builder for method chaining. func (rb *RequestBuilder) AddHeader(key string, value string) *RequestBuilder { rb.request.SetHeader(key, value) return rb } +// AddPathParam adds a path parameter to be substituted into the URL path. +// Returns the builder for method chaining. func (rb *RequestBuilder) AddPathParam(key string, value any) *RequestBuilder { rb.request.SetPathParam(key, value) return rb } +// WithOptions sets the request options containing query/header parameters. +// Returns the builder for method chaining. func (rb *RequestBuilder) WithOptions(options any) *RequestBuilder { rb.request.Options = options return rb } +// WithBody sets the request body to be serialized. +// Returns the builder for method chaining. func (rb *RequestBuilder) WithBody(body any) *RequestBuilder { rb.request.Body = body return rb } +// WithConfig sets the SDK configuration including base URL, timeout, and auth credentials. +// Returns the builder for method chaining. func (rb *RequestBuilder) WithConfig(config clientconfig.Config) *RequestBuilder { rb.request.Config = config return rb } +// WithContentType sets the content type for serializing the request body. +// Returns the builder for method chaining. func (rb *RequestBuilder) WithContentType(contentType ContentType) *RequestBuilder { rb.request.ContentType = contentType return rb } +// WithResponseContentType sets the expected content type for deserializing the response. +// Returns the builder for method chaining. func (rb *RequestBuilder) WithResponseContentType(contentType ContentType) *RequestBuilder { rb.request.ResponseContentType = contentType return rb } +// Build returns the fully configured Request. +// Should be called after all configuration methods to obtain the final request. func (rb *RequestBuilder) Build() *Request { return rb.request } diff --git a/pkg/project-client/internal/clients/rest/httptransport/request.go b/pkg/project-client/internal/clients/rest/httptransport/request.go index 89f114b..61f9ae2 100644 --- a/pkg/project-client/internal/clients/rest/httptransport/request.go +++ b/pkg/project-client/internal/clients/rest/httptransport/request.go @@ -20,6 +20,8 @@ type paramMap struct { Value string } +// Request represents an HTTP request with all necessary configuration and parameters. +// Handles path/query/header serialization, content types, and authentication scopes. type Request struct { Context context.Context Method string @@ -34,6 +36,8 @@ type Request struct { ResponseContentType ContentType } +// NewRequest creates a new Request with default settings. +// Initializes maps for headers, query params, and path params, and sets default content types to JSON. func NewRequest(ctx context.Context, method string, path string, config clientconfig.Config) Request { return Request{ Context: ctx, @@ -48,6 +52,8 @@ func NewRequest(ctx context.Context, method string, path string, config clientco } } +// Clone creates a deep copy of the Request including all maps. +// Returns a new Request with copied values to prevent mutation of the original. func (r *Request) Clone() Request { if r == nil { return Request{ diff --git a/pkg/project-client/internal/clients/rest/httptransport/response.go b/pkg/project-client/internal/clients/rest/httptransport/response.go index 6cb54df..9145fdd 100644 --- a/pkg/project-client/internal/clients/rest/httptransport/response.go +++ b/pkg/project-client/internal/clients/rest/httptransport/response.go @@ -5,13 +5,18 @@ import ( "net/http" ) +// Response represents an HTTP response with deserialized data. +// Generic type T specifies the expected response data type. type Response[T any] struct { StatusCode int Headers map[string]string Body []byte Data T + Raw *http.Response } +// Clone creates a deep copy of the Response including headers. +// Returns a new Response with copied values. func (r *Response[T]) Clone() Response[T] { if r == nil { return Response[T]{ @@ -27,6 +32,8 @@ func (r *Response[T]) Clone() Response[T] { return clone } +// NewResponse creates a Response from an http.Response. +// Reads and stores the body, extracts headers, and initializes the response structure. func NewResponse[T any](resp *http.Response) (*Response[T], error) { defer resp.Body.Close() @@ -46,6 +53,7 @@ func NewResponse[T any](resp *http.Response) (*Response[T], error) { Headers: responseHeaders, Body: body, Data: *placeholderData, + Raw: resp, }, nil } diff --git a/pkg/project-client/internal/clients/rest/httptransport/stream.go b/pkg/project-client/internal/clients/rest/httptransport/stream.go new file mode 100644 index 0000000..1c53046 --- /dev/null +++ b/pkg/project-client/internal/clients/rest/httptransport/stream.go @@ -0,0 +1,193 @@ +package httptransport + +import ( + "bufio" + "context" + "encoding/json" + "errors" + "fmt" + "net/http" + "strings" + "sync" +) + +// ErrStreamClosed is returned when trying to read from a closed stream. +var ErrStreamClosed = errors.New("stream is closed") + +// StreamChunk represents a single chunk from a streaming response. +// Contains the deserialized data, raw bytes, and metadata about the response. +type StreamChunk[T any] struct { + Data T + Raw []byte + Metadata StreamChunkMetadata +} + +// StreamChunkMetadata contains metadata about a stream chunk. +// Includes HTTP headers and status code from the streaming response. +type StreamChunkMetadata struct { + Headers map[string]string + StatusCode int +} + +// Stream represents a streaming response from the API using Server-Sent Events (SSE) protocol. +// It handles chunk-by-chunk processing with context cancellation and thread-safe closure. +type Stream[T any] struct { + response *http.Response + scanner *bufio.Scanner + ctx context.Context + statusCode int + headers map[string]string + + mu sync.Mutex + closed bool +} + +// NewStream creates a new stream wrapper from an HTTP response with context for cancellation. +// Converts response headers to a map and initializes the stream scanner for reading chunks. +func NewStream[T any](resp *http.Response, ctx context.Context) *Stream[T] { + // Convert http.Header to map[string]string + headers := make(map[string]string) + for key, values := range resp.Header { + if len(values) > 0 { + headers[key] = values[0] + } + } + + return &Stream[T]{ + response: resp, + scanner: bufio.NewScanner(resp.Body), + ctx: ctx, + statusCode: resp.StatusCode, + headers: headers, + closed: false, + } +} + +// Next returns the next chunk from the stream by reading and parsing SSE data. +// Returns ErrStreamClosed when the stream has ended normally or receives [DONE] signal. +// Returns context errors if the context is cancelled or times out. Thread-safe for concurrent access. +func (s *Stream[T]) Next() (*StreamChunk[T], error) { + s.mu.Lock() + if s.closed { + s.mu.Unlock() + return nil, ErrStreamClosed + } + s.mu.Unlock() + + // Check if context is cancelled + select { + case <-s.ctx.Done(): + s.Close() + return nil, s.ctx.Err() + default: + } + + for s.scanner.Scan() { + line := s.scanner.Text() + data, ok := parseSSELine(line) + if !ok { + // Skip non-data lines or stream termination + if data == "" && line == "" { + continue + } + // [DONE] signal received + s.Close() + return nil, ErrStreamClosed + } + + var chunk T + if err := json.Unmarshal([]byte(data), &chunk); err != nil { + return nil, err + } + + return &StreamChunk[T]{ + Data: chunk, + Raw: []byte(data), + Metadata: StreamChunkMetadata{ + StatusCode: s.statusCode, + Headers: s.headers, + }, + }, nil + } + + if err := s.scanner.Err(); err != nil { + s.Close() + return nil, err + } + + s.Close() + return nil, ErrStreamClosed +} + +// Close closes the stream and releases resources including the response body. +// Idempotent - calling Close multiple times is safe. Thread-safe for concurrent access. +func (s *Stream[T]) Close() error { + s.mu.Lock() + defer s.mu.Unlock() + + if s.closed { + return nil + } + s.closed = true + return s.response.Body.Close() +} + +// IsClosed returns whether the stream has been closed. +// Thread-safe for concurrent access. +func (s *Stream[T]) IsClosed() bool { + s.mu.Lock() + defer s.mu.Unlock() + return s.closed +} + +// parseSSELine parses a Server-Sent Events line according to SSE protocol. +// SSE format: "data: {json content}\n\n". Returns the data content and true if valid, +// or empty string and false if the line should be skipped or signals stream termination ([DONE]). +func parseSSELine(line string) (string, bool) { + line = strings.TrimSpace(line) + if strings.HasPrefix(line, "data: ") { + data := strings.TrimPrefix(line, "data: ") + // Check for stream termination signal + if data == "[DONE]" { + return "", false + } + return data, true + } + return "", false +} + +// HandleStream creates a streaming HTTP request and returns a Stream for consuming chunks. +// Executes the HTTP request, validates the status code, and wraps the response in a Stream. +func HandleStream[T any](request Request) (*Stream[T], *ErrorResponse[T]) { + requestClone := request.Clone() + + client := http.Client{} + if requestClone.Config.Timeout != nil { + client.Timeout = *requestClone.Config.Timeout + } + + req, err := requestClone.CreateHttpRequest() + if err != nil { + return nil, NewErrorResponse[T](err, nil) + } + + resp, err := client.Do(req) + if err != nil { + return nil, NewErrorResponse[T](err, nil) + } + + if resp.StatusCode >= 400 { + resp.Body.Close() + err := fmt.Errorf("HTTP request failed with status code %d", resp.StatusCode) + return nil, NewErrorResponse[T](err, nil) + } + + // Get context from request, or use background if not available + ctx := request.Context + if ctx == nil { + ctx = context.Background() + } + + stream := NewStream[T](resp, ctx) + return stream, nil +} diff --git a/pkg/project-client/internal/configmanager/config_manager.go b/pkg/project-client/internal/configmanager/config_manager.go index 9ca7551..e8094df 100644 --- a/pkg/project-client/internal/configmanager/config_manager.go +++ b/pkg/project-client/internal/configmanager/config_manager.go @@ -5,14 +5,19 @@ import ( "time" ) +// ConfigManager manages configuration across all services with synchronized updates. +// Provides centralized configuration management and OAuth token handling for multiple services. type ConfigManager struct { Broadcasts clientconfig.Config Channels clientconfig.Config Events clientconfig.Config Integrations clientconfig.Config Users clientconfig.Config + Workflows clientconfig.Config } +// NewConfigManager creates a new configuration manager with the provided config and optional OAuth token service. +// Initializes service-specific configs and sets up OAuth token management if enabled. func NewConfigManager(config clientconfig.Config) *ConfigManager { return &ConfigManager{ Broadcasts: config, @@ -20,33 +25,45 @@ func NewConfigManager(config clientconfig.Config) *ConfigManager { Events: config, Integrations: config, Users: config, + Workflows: config, } } +// SetBaseUrl updates the BaseUrl configuration parameter across all services. +// Changes are applied synchronously to all registered service configurations. func (c *ConfigManager) SetBaseUrl(baseUrl string) { c.Broadcasts.SetBaseUrl(baseUrl) c.Channels.SetBaseUrl(baseUrl) c.Events.SetBaseUrl(baseUrl) c.Integrations.SetBaseUrl(baseUrl) c.Users.SetBaseUrl(baseUrl) + c.Workflows.SetBaseUrl(baseUrl) } +// SetTimeout updates the Timeout configuration parameter across all services. +// Changes are applied synchronously to all registered service configurations. func (c *ConfigManager) SetTimeout(timeout time.Duration) { c.Broadcasts.SetTimeout(timeout) c.Channels.SetTimeout(timeout) c.Events.SetTimeout(timeout) c.Integrations.SetTimeout(timeout) c.Users.SetTimeout(timeout) + c.Workflows.SetTimeout(timeout) } +// SetAccessToken updates the AccessToken configuration parameter across all services. +// Changes are applied synchronously to all registered service configurations. func (c *ConfigManager) SetAccessToken(accessToken string) { c.Broadcasts.SetAccessToken(accessToken) c.Channels.SetAccessToken(accessToken) c.Events.SetAccessToken(accessToken) c.Integrations.SetAccessToken(accessToken) c.Users.SetAccessToken(accessToken) + c.Workflows.SetAccessToken(accessToken) } +// UpdateAccessToken replaces an access token across all services that use the original value. +// Used for token refresh to update all service configurations simultaneously. func (c *ConfigManager) UpdateAccessToken(originalValue string, newValue string) { if c.Broadcasts.AccessToken != nil && *c.Broadcasts.AccessToken == originalValue { @@ -68,20 +85,44 @@ func (c *ConfigManager) UpdateAccessToken(originalValue string, newValue string) if c.Users.AccessToken != nil && *c.Users.AccessToken == originalValue { c.Users.SetAccessToken(newValue) } + + if c.Workflows.AccessToken != nil && *c.Workflows.AccessToken == originalValue { + c.Workflows.SetAccessToken(newValue) + } } +// GetBroadcasts returns the configuration for the Broadcasts service. +// Returns a pointer to the service-specific config for use in API calls. func (c *ConfigManager) GetBroadcasts() *clientconfig.Config { return &c.Broadcasts } + +// GetChannels returns the configuration for the Channels service. +// Returns a pointer to the service-specific config for use in API calls. func (c *ConfigManager) GetChannels() *clientconfig.Config { return &c.Channels } + +// GetEvents returns the configuration for the Events service. +// Returns a pointer to the service-specific config for use in API calls. func (c *ConfigManager) GetEvents() *clientconfig.Config { return &c.Events } + +// GetIntegrations returns the configuration for the Integrations service. +// Returns a pointer to the service-specific config for use in API calls. func (c *ConfigManager) GetIntegrations() *clientconfig.Config { return &c.Integrations } + +// GetUsers returns the configuration for the Users service. +// Returns a pointer to the service-specific config for use in API calls. func (c *ConfigManager) GetUsers() *clientconfig.Config { return &c.Users } + +// GetWorkflows returns the configuration for the Workflows service. +// Returns a pointer to the service-specific config for use in API calls. +func (c *ConfigManager) GetWorkflows() *clientconfig.Config { + return &c.Workflows +} diff --git a/pkg/project-client/internal/contenttypes/from_binary.go b/pkg/project-client/internal/contenttypes/from_binary.go index d1272fe..42e23d3 100644 --- a/pkg/project-client/internal/contenttypes/from_binary.go +++ b/pkg/project-client/internal/contenttypes/from_binary.go @@ -1,13 +1,34 @@ package contenttypes import ( + "encoding/base64" "fmt" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" + "reflect" ) +// FromBinary deserializes binary response data into a byte slice target. +// The target must be a non-nil pointer to []byte. Returns an error if conversion fails. func FromBinary(data any, target any) error { + targetValue := reflect.ValueOf(target) + + if targetValue.Kind() != reflect.Ptr || targetValue.IsNil() { + return fmt.Errorf("target must be a non-nil pointer") + } + + targetValue = targetValue.Elem() + if b, ok := data.([]byte); ok { - target = &b - return nil + if targetValue.Kind() == reflect.Slice && targetValue.Type().Elem().Kind() == reflect.Uint8 { + targetValue.Set(reflect.ValueOf(b)) + return nil + } + + if targetValue.Kind() == reflect.Struct { + base64Str := base64.StdEncoding.EncodeToString(b) + jsonBody := []byte(`"` + base64Str + `"`) + return unmarshal.Unmarshal(jsonBody, target) + } } return fmt.Errorf("Failed to convert response body to byte array") diff --git a/pkg/project-client/internal/contenttypes/from_form_data.go b/pkg/project-client/internal/contenttypes/from_form_data.go index 2ec55c4..0c7aef7 100644 --- a/pkg/project-client/internal/contenttypes/from_form_data.go +++ b/pkg/project-client/internal/contenttypes/from_form_data.go @@ -7,6 +7,8 @@ import ( "strconv" ) +// FromFormData deserializes multipart/form-data into a struct. +// Uses 'form' tags to map form fields to struct fields. Supports string, int, float, and bool types. func FromFormData(formData []byte, dest interface{}) error { // Parse the form data into url.Values data, err := url.ParseQuery(string(formData)) @@ -22,6 +24,7 @@ func FromFormData(formData []byte, dest interface{}) error { val = val.Elem() // Iterate over each field in the struct + fieldsSet := 0 for i := 0; i < val.NumField(); i++ { field := val.Type().Field(i) fieldValue := val.Field(i) @@ -36,32 +39,52 @@ func FromFormData(formData []byte, dest interface{}) error { if formValues, ok := data[formKey]; ok && len(formValues) > 0 { formValue := formValues[0] + // Handle pointer fields by dereferencing + actualValue := fieldValue + if fieldValue.Kind() == reflect.Ptr { + if fieldValue.IsNil() { + // Create a new value of the underlying type + actualValue = reflect.New(fieldValue.Type().Elem()) + fieldValue.Set(actualValue) + } + actualValue = actualValue.Elem() + } + // Set the value on the struct field based on its type - switch fieldValue.Kind() { + switch actualValue.Kind() { case reflect.String: - fieldValue.SetString(formValue) + actualValue.SetString(formValue) + fieldsSet++ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: intVal, err := strconv.ParseInt(formValue, 10, 64) if err != nil { return fmt.Errorf("failed to parse int for field %s: %v", field.Name, err) } - fieldValue.SetInt(intVal) + actualValue.SetInt(intVal) + fieldsSet++ case reflect.Float32, reflect.Float64: floatVal, err := strconv.ParseFloat(formValue, 64) if err != nil { return fmt.Errorf("failed to parse float for field %s: %v", field.Name, err) } - fieldValue.SetFloat(floatVal) + actualValue.SetFloat(floatVal) + fieldsSet++ case reflect.Bool: boolVal, err := strconv.ParseBool(formValue) if err != nil { return fmt.Errorf("failed to parse bool for field %s: %v", field.Name, err) } - fieldValue.SetBool(boolVal) + actualValue.SetBool(boolVal) + fieldsSet++ default: return fmt.Errorf("unsupported field type for field %s", field.Name) } } } + + if fieldsSet == 0 { + return fmt.Errorf("no form fields were set - form data may be invalid or empty") + } + return nil } diff --git a/pkg/project-client/internal/contenttypes/from_form_url_encoded.go b/pkg/project-client/internal/contenttypes/from_form_url_encoded.go index d1171cf..56cb791 100644 --- a/pkg/project-client/internal/contenttypes/from_form_url_encoded.go +++ b/pkg/project-client/internal/contenttypes/from_form_url_encoded.go @@ -1,20 +1,33 @@ package contenttypes import ( + "fmt" "net/url" "reflect" "strings" ) +// FromFormUrlEncoded deserializes URL-encoded form data into a struct. +// Uses struct field json tags to map form keys to struct fields. Only string fields are supported. func FromFormUrlEncoded(data []byte, target any) error { values, err := url.ParseQuery(string(data)) if err != nil { return err } - targetVal := reflect.ValueOf(target).Elem() + targetVal := reflect.ValueOf(target) + if targetVal.Kind() != reflect.Ptr || targetVal.IsNil() { + return fmt.Errorf("target must be a non-nil pointer") + } + targetVal = targetVal.Elem() + + if targetVal.Kind() != reflect.Struct { + return fmt.Errorf("destination must be a pointer to a struct") + } + targetType := targetVal.Type() + fieldsSet := 0 for i := 0; i < targetType.NumField(); i++ { field := targetType.Field(i) fieldValue := targetVal.Field(i) @@ -23,11 +36,19 @@ func FromFormUrlEncoded(data []byte, target any) error { if value, found := values[key]; found && len(value) > 0 { updateFieldWithValue(fieldValue, value) + fieldsSet++ } } + + if fieldsSet == 0 { + return fmt.Errorf("no form fields were set - form data may be invalid or empty") + } + return nil } +// updateFieldWithValue sets a struct field value from form data values. +// Handles both pointer and non-pointer string fields, using the first value if multiple are present. func updateFieldWithValue(fieldValue reflect.Value, value []string) { firstValue := value[0] if fieldValue.Kind() == reflect.Ptr { @@ -38,10 +59,12 @@ func updateFieldWithValue(fieldValue reflect.Value, value []string) { fieldValue.Elem().SetString(firstValue) } } else if fieldValue.CanSet() { - fieldValue.SetString(firstValue) // Set only the first value if multiple are present + fieldValue.SetString(firstValue) } } +// getFieldName extracts the field name from json tag or uses the struct field name as fallback. +// Returns the name to use as the form key for this field. func getFieldName(field reflect.StructField) string { key := field.Tag.Get("json") if key != "" { diff --git a/pkg/project-client/internal/contenttypes/from_json.go b/pkg/project-client/internal/contenttypes/from_json.go index 506984b..1838cf0 100644 --- a/pkg/project-client/internal/contenttypes/from_json.go +++ b/pkg/project-client/internal/contenttypes/from_json.go @@ -5,6 +5,8 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" ) +// FromJson deserializes JSON data from HTTP response bodies into the target struct. +// Uses the custom unmarshal package to handle complex types and validations. func FromJson(data []byte, target any) error { err := unmarshal.Unmarshal(data, target) if err != nil { diff --git a/pkg/project-client/internal/contenttypes/from_text.go b/pkg/project-client/internal/contenttypes/from_text.go index a24ec1d..c5c00d1 100644 --- a/pkg/project-client/internal/contenttypes/from_text.go +++ b/pkg/project-client/internal/contenttypes/from_text.go @@ -1,11 +1,20 @@ package contenttypes import ( + "encoding/json" "fmt" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" "reflect" + "unicode/utf8" ) +// FromText deserializes plain text response data into a string target. +// The target must be a non-nil pointer to a string. Returns an error for unsupported types. func FromText[T any](data []byte, target any) error { + if !utf8.Valid(data) { + return fmt.Errorf("data is not valid UTF-8 text") + } + targetValue := reflect.ValueOf(target) if targetValue.Kind() != reflect.Ptr || targetValue.IsNil() { @@ -17,9 +26,14 @@ func FromText[T any](data []byte, target any) error { switch targetValue.Kind() { case reflect.String: targetValue.SetString(string(data)) + return nil + case reflect.Struct: + jsonBody, err := json.Marshal(string(data)) + if err != nil { + return fmt.Errorf("failed to marshal text as JSON string: %v", err) + } + return unmarshal.Unmarshal(jsonBody, target) default: return fmt.Errorf("unsupported target type: %s", targetValue.Kind()) } - - return nil } diff --git a/pkg/project-client/internal/contenttypes/to_binary.go b/pkg/project-client/internal/contenttypes/to_binary.go index 871a356..b9cd2c6 100644 --- a/pkg/project-client/internal/contenttypes/to_binary.go +++ b/pkg/project-client/internal/contenttypes/to_binary.go @@ -5,6 +5,8 @@ import ( "fmt" ) +// ToBinary serializes byte slice data for binary request bodies. +// Returns an error if the data is not a []byte. func ToBinary(data any) (*bytes.Reader, error) { byteData, ok := data.([]byte) if !ok { diff --git a/pkg/project-client/internal/contenttypes/to_form_data.go b/pkg/project-client/internal/contenttypes/to_form_data.go index 98b9a30..58bdfc8 100644 --- a/pkg/project-client/internal/contenttypes/to_form_data.go +++ b/pkg/project-client/internal/contenttypes/to_form_data.go @@ -8,7 +8,8 @@ import ( "strconv" ) -// ToForm converts any value (struct, array, map, or primitive) to form data +// ToFormData converts structs and primitives to multipart/form-data format for request bodies. +// Returns the encoded data, Content-Type header with boundary, and any error. Supports nested structs and byte arrays. func ToFormData(data interface{}) (*bytes.Reader, string, error) { buffer := &bytes.Buffer{} writer := multipart.NewWriter(buffer) @@ -30,6 +31,8 @@ func ToFormData(data interface{}) (*bytes.Reader, string, error) { return bytes.NewReader(buffer.Bytes()), contentTypeHeader, nil } +// encode recursively encodes a value into multipart form fields. +// Handles pointers, arrays/slices (byte arrays only), structs, and primitives. func encode(key string, v reflect.Value, writer *multipart.Writer) error { if v.Kind() == reflect.Ptr { if v.IsNil() { @@ -59,6 +62,8 @@ func encode(key string, v reflect.Value, writer *multipart.Writer) error { } } +// encodeStruct encodes all exported fields of a struct into multipart form fields. +// Uses 'form' tags for field names, supports nested bracket notation for nested structs. func encodeStruct(prefix string, v reflect.Value, writer *multipart.Writer) error { t := v.Type() @@ -89,6 +94,8 @@ func encodeStruct(prefix string, v reflect.Value, writer *multipart.Writer) erro return nil } +// formatValue converts a primitive value to its string representation for form encoding. +// Supports bool, int, uint, float, and string types. func formatValue(v reflect.Value) string { switch v.Kind() { case reflect.Bool: diff --git a/pkg/project-client/internal/contenttypes/to_form_url_encoded.go b/pkg/project-client/internal/contenttypes/to_form_url_encoded.go index 8f0b976..fdef93e 100644 --- a/pkg/project-client/internal/contenttypes/to_form_url_encoded.go +++ b/pkg/project-client/internal/contenttypes/to_form_url_encoded.go @@ -8,6 +8,8 @@ import ( "reflect" ) +// ToFormUrlEncoded serializes a struct to URL-encoded form format for request bodies. +// Uses struct field json tags as form keys. Supports string, int, float, and bool types. func ToFormUrlEncoded(data any) (*bytes.Reader, error) { val := utils.GetReflectValueFromAny(data) diff --git a/pkg/project-client/internal/contenttypes/to_json.go b/pkg/project-client/internal/contenttypes/to_json.go index cef6b77..120c292 100644 --- a/pkg/project-client/internal/contenttypes/to_json.go +++ b/pkg/project-client/internal/contenttypes/to_json.go @@ -5,6 +5,8 @@ import ( "encoding/json" ) +// ToJson serializes data to JSON format for HTTP request bodies. +// Returns a bytes.Reader containing the JSON-encoded data, or nil if data is nil. func ToJson(data any) (*bytes.Reader, error) { if data == nil { return nil, nil diff --git a/pkg/project-client/internal/contenttypes/to_text.go b/pkg/project-client/internal/contenttypes/to_text.go index dfb17d3..95c9337 100644 --- a/pkg/project-client/internal/contenttypes/to_text.go +++ b/pkg/project-client/internal/contenttypes/to_text.go @@ -5,6 +5,8 @@ import ( "fmt" ) +// ToText serializes string data to bytes for text/plain request bodies. +// Returns an error if the data is not a string. func ToText(data any) (*bytes.Reader, error) { switch v := data.(type) { case string: diff --git a/pkg/project-client/internal/marshal/from_complex_object.go b/pkg/project-client/internal/marshal/from_complex_object.go index 589530d..3f90150 100644 --- a/pkg/project-client/internal/marshal/from_complex_object.go +++ b/pkg/project-client/internal/marshal/from_complex_object.go @@ -8,6 +8,9 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/utils" ) +// FromComplexObject marshals a discriminated union (oneOf) struct to JSON. +// Finds the first non-nil field (the active variant) and marshals only that field. +// Returns an error if all fields are nil. func FromComplexObject(obj any) ([]byte, error) { types := utils.GetReflectType(reflect.TypeOf(obj)) values := utils.GetReflectValue(reflect.ValueOf(obj)) diff --git a/pkg/project-client/internal/serialization/serialize_object.go b/pkg/project-client/internal/serialization/serialize_object.go index 5696eab..8bbb45d 100644 --- a/pkg/project-client/internal/serialization/serialize_object.go +++ b/pkg/project-client/internal/serialization/serialize_object.go @@ -6,11 +6,14 @@ import ( "strings" ) +// paramMap represents a key-value pair for query parameter serialization. type paramMap struct { Key string Value string } +// SerializeObject serializes a struct to query parameter format with nested bracket notation. +// Converts struct fields to key[fieldName]=value format for complex query parameters. func SerializeObject(key string, input any) []paramMap { val := reflect.ValueOf(input) typ := reflect.TypeOf(input) @@ -44,6 +47,8 @@ func SerializeObject(key string, input any) []paramMap { return params } +// SerializeValue serializes any value to a string representation for query parameters. +// Handles primitives, arrays/slices, and nested structs recursively. func SerializeValue(key string, input any) string { val := reflect.ValueOf(input) typ := reflect.TypeOf(input) @@ -71,10 +76,14 @@ func SerializeValue(key string, input any) string { } } +// SerializePrimitive converts primitive types to their string representation. +// Uses fmt.Sprintf for consistent formatting. func SerializePrimitive(input any) string { return fmt.Sprintf("%v", input) } +// getJsonName extracts the JSON field name from a struct field's json tag. +// Returns the first part of the json tag before any comma. func getJsonName(field reflect.StructField) string { jsonTag := field.Tag.Get("json") return strings.Split(jsonTag, ",")[0] diff --git a/pkg/project-client/internal/unmarshal/to_complex_object.go b/pkg/project-client/internal/unmarshal/to_complex_object.go index 7c6584e..cad14c2 100644 --- a/pkg/project-client/internal/unmarshal/to_complex_object.go +++ b/pkg/project-client/internal/unmarshal/to_complex_object.go @@ -11,6 +11,8 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/validation" ) +// candidate represents a potential type match when deserializing a oneOf discriminated union. +// Tracks validation status and field counts to determine the best match. type candidate struct { obj any valid bool @@ -19,6 +21,9 @@ type candidate struct { kind reflect.Kind } +// ToComplexObject unmarshals JSON data into a discriminated union (oneOf) struct. +// Attempts to unmarshal into all possible types, validates each, and selects the best match +// based on required/optional field counts. Removes non-matching candidates from the result. func ToComplexObject[T any](data []byte, result *T) error { err := unmarshalIntoProps(data, result) if err != nil { @@ -35,7 +40,8 @@ func ToComplexObject[T any](data []byte, result *T) error { return nil } -// Try to Unmarshal the input data into the properties of a given struct. +// unmarshalIntoProps attempts to unmarshal JSON data into all fields of a oneOf struct. +// Tries to parse the data as each possible type (struct, array, primitive) and sets matching fields. func unmarshalIntoProps(data []byte, obj any) error { types := reflect.TypeOf(obj).Elem() values := reflect.ValueOf(obj).Elem() @@ -80,6 +86,8 @@ func unmarshalIntoProps(data []byte, obj any) error { return nil } +// createCandidatesFromProps creates a candidate entry for each non-nil field in the oneOf struct. +// Validates each candidate and counts required/optional fields for ranking. func createCandidatesFromProps(obj any) []candidate { values := utils.GetReflectValue(reflect.ValueOf(obj)) types := utils.GetReflectType(reflect.TypeOf(obj)) @@ -133,6 +141,8 @@ func createCandidatesFromProps(obj any) []candidate { return candidates } +// countFields recursively counts fields matching the predicate (required or optional) in a struct. +// Used to rank candidates by how many required/optional fields were successfully unmarshaled. func countFields(c any, isFieldRequiredOrOptional func(reflect.StructField) bool) int { values := utils.GetReflectValue(reflect.ValueOf(c)) types := utils.GetReflectType(reflect.TypeOf(c)) @@ -163,6 +173,7 @@ func countFields(c any, isFieldRequiredOrOptional func(reflect.StructField) bool return count } +// countArrayFields counts matching fields across all elements in an array. func countArrayFields(candidates any, isFieldRequiredOrOptional func(reflect.StructField) bool) int { count := 0 values := utils.GetReflectValue(reflect.ValueOf(candidates)) @@ -174,11 +185,14 @@ func countArrayFields(candidates any, isFieldRequiredOrOptional func(reflect.Str return count } +// isValid checks if a candidate passes all validation constraints. func isValid(candidate any) bool { err := validation.ValidateData(candidate) return err == nil } +// chooseCandidateIndex selects the best matching candidate from the list. +// Prefers non-primitive types first, then falls back to primitives in order: bool, int, float, string. func chooseCandidateIndex(candidates []candidate) int { chosenCandidateIndex := chooseNonPrimitiveCandidate(candidates) @@ -189,6 +203,8 @@ func chooseCandidateIndex(candidates []candidate) int { return chosenCandidateIndex } +// chooseNonPrimitiveCandidate selects the best non-primitive (struct/array) candidate. +// Prioritizes candidates with more required fields, then more optional fields. func chooseNonPrimitiveCandidate(candidates []candidate) int { chosenCandidateIndex := -1 chosenCandidateRequiredCount := -1 @@ -205,6 +221,8 @@ func chooseNonPrimitiveCandidate(candidates []candidate) int { return chosenCandidateIndex } +// isBetterCandidate determines if a candidate is better than the currently chosen one. +// A candidate is better if it has more required fields, or equal required but more optional fields. func isBetterCandidate(c candidate, chosenCandidateRequiredCount int, chosenCandidateOptionalCount int) bool { if !c.valid || isPrimitive(c.kind) { return false @@ -221,6 +239,8 @@ func isBetterCandidate(c candidate, chosenCandidateRequiredCount int, chosenCand return false } +// choosePrimitiveCandidate selects the first non-nil primitive candidate in priority order. +// Priority: bool > int > float > string. func choosePrimitiveCandidate(candidates []candidate) int { predicates := []func(kind reflect.Kind) bool{isBool, isInteger, isFloat, isString} @@ -234,6 +254,8 @@ func choosePrimitiveCandidate(candidates []candidate) int { return -1 } +// removeOtherCandidates zeroes out all fields except the chosen candidate. +// Ensures only the matched oneOf variant remains in the result struct. func removeOtherCandidates(obj any, chosenCandidateIndex int) { values := utils.GetReflectValue(reflect.ValueOf(obj)) types := utils.GetReflectType(reflect.TypeOf(obj)) @@ -246,6 +268,7 @@ func removeOtherCandidates(obj any, chosenCandidateIndex int) { } } +// findFirstNonNil finds the first candidate matching the kind predicate. func findFirstNonNil(candidates []candidate, predicate func(kind reflect.Kind) bool) int { for i, c := range candidates { if c.obj != nil && predicate(c.kind) { diff --git a/pkg/project-client/internal/unmarshal/to_object.go b/pkg/project-client/internal/unmarshal/to_object.go index 040b0bc..829a198 100644 --- a/pkg/project-client/internal/unmarshal/to_object.go +++ b/pkg/project-client/internal/unmarshal/to_object.go @@ -4,6 +4,8 @@ import ( "encoding/json" ) +// ToObject unmarshals JSON bytes into a struct or array target using standard json.Unmarshal. +// Handles regular objects and arrays that don't require special unmarshaling logic. func ToObject(source []byte, target any) error { err := json.Unmarshal(source, target) if err != nil { diff --git a/pkg/project-client/internal/unmarshal/to_primitive.go b/pkg/project-client/internal/unmarshal/to_primitive.go index 42a74c2..5e67864 100644 --- a/pkg/project-client/internal/unmarshal/to_primitive.go +++ b/pkg/project-client/internal/unmarshal/to_primitive.go @@ -5,11 +5,15 @@ import ( "strconv" ) +// ToString unmarshals bytes into a string target. +// Sets the string value directly on the target pointer element. func ToString(source []byte, target reflect.Value) error { target.Elem().SetString(string(source)) return nil } +// ToInt unmarshals bytes into an int64 target by parsing the string representation. +// Returns an error if parsing fails. func ToInt(source []byte, target reflect.Value) error { intBody, err := strconv.ParseInt(string(source), 10, 64) if err != nil { @@ -21,6 +25,8 @@ func ToInt(source []byte, target reflect.Value) error { return nil } +// ToFloat unmarshals bytes into a float64 target by parsing the string representation. +// Returns an error if parsing fails. func ToFloat(source []byte, target reflect.Value) error { floatBody, err := strconv.ParseFloat(string(source), 64) if err != nil { @@ -32,6 +38,8 @@ func ToFloat(source []byte, target reflect.Value) error { return nil } +// ToBool unmarshals bytes into a bool target by parsing the string representation. +// Returns an error if parsing fails. func ToBool(source []byte, target reflect.Value) error { boolBody, err := strconv.ParseBool(string(source)) if err != nil { diff --git a/pkg/project-client/internal/unmarshal/unmarshal.go b/pkg/project-client/internal/unmarshal/unmarshal.go index 6ffebde..25aa212 100644 --- a/pkg/project-client/internal/unmarshal/unmarshal.go +++ b/pkg/project-client/internal/unmarshal/unmarshal.go @@ -7,8 +7,10 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/utils" ) +// Unmarshal deserializes JSON bytes into the target based on its type. +// Handles complex objects (oneOf), regular objects/arrays, and primitive types (string, int, float, bool). +// Target must be a non-nil pointer. func Unmarshal(source []byte, target any) error { - targetValue := reflect.ValueOf(target) if targetValue.Kind() != reflect.Ptr || targetValue.IsNil() { return fmt.Errorf("target must be a non-nil pointer") @@ -29,17 +31,21 @@ func Unmarshal(source []byte, target any) error { return nil } +// isArray checks if the target type is an array or slice. func isArray(target any) bool { targetType := reflect.TypeOf(target) kind := utils.GetReflectKind(targetType) return kind == reflect.Array || kind == reflect.Slice } +// isObject checks if the target type is a struct. func isObject(target any) bool { targetType := reflect.TypeOf(target) return utils.GetReflectKind(targetType) == reflect.Struct } +// isComplexObject checks if the target is a complex object (oneOf) where all fields have 'oneof' tags. +// Used to identify discriminated union types that require special unmarshaling logic. func isComplexObject(target any) bool { targetType := reflect.TypeOf(target) if utils.GetReflectKind(targetType) != reflect.Struct { @@ -57,6 +63,7 @@ func isComplexObject(target any) bool { return allFieldsAreOneOf } +// isOneOfField checks if a struct field has the 'oneof' tag, indicating it's part of a discriminated union. func isOneOfField(field reflect.StructField) bool { _, found := field.Tag.Lookup("oneof") return found diff --git a/pkg/project-client/internal/unmarshal/unmarshal_nullable.go b/pkg/project-client/internal/unmarshal/unmarshal_nullable.go index 21690ef..0f5939d 100644 --- a/pkg/project-client/internal/unmarshal/unmarshal_nullable.go +++ b/pkg/project-client/internal/unmarshal/unmarshal_nullable.go @@ -7,6 +7,8 @@ import ( "strings" ) +// UnmarshalNullable deserializes JSON into a struct with Nullable fields, correctly handling null values. +// Sets IsNull=true for fields that are explicitly null in the JSON, rather than unmarshaling them as zero values. func UnmarshalNullable(source []byte, target any) error { // Use a temporary map to decode the raw JSON var rawMap map[string]json.RawMessage @@ -60,6 +62,8 @@ func UnmarshalNullable(source []byte, target any) error { return nil } +// hasNullableFields checks if a struct contains any Nullable[T] pointer fields. +// Used to determine if special nullable unmarshaling logic should be applied. func hasNullableFields(obj any) bool { t := reflect.TypeOf(obj) diff --git a/pkg/project-client/internal/utils/utils.go b/pkg/project-client/internal/utils/utils.go index 13fe13d..2a43d20 100644 --- a/pkg/project-client/internal/utils/utils.go +++ b/pkg/project-client/internal/utils/utils.go @@ -2,6 +2,8 @@ package utils import "reflect" +// CloneMap creates a shallow copy of a map. +// Returns a new map with the same key-value pairs as the source. func CloneMap[T any](sourceMap map[string]T) map[string]T { newMap := make(map[string]T) for key, value := range sourceMap { @@ -11,11 +13,15 @@ func CloneMap[T any](sourceMap map[string]T) map[string]T { return newMap } +// GetReflectValueFromAny gets the reflect.Value from any type, dereferencing pointers. +// Wraps GetReflectValue for convenience when starting with an any type. func GetReflectValueFromAny(input any) reflect.Value { val := reflect.ValueOf(input) return GetReflectValue(val) } +// GetReflectValue dereferences pointer types to get the underlying value. +// Returns the element if the value is a pointer, otherwise returns the value unchanged. func GetReflectValue(fieldValue reflect.Value) reflect.Value { if fieldValue.Kind() == reflect.Pointer { return fieldValue.Elem() @@ -24,11 +30,15 @@ func GetReflectValue(fieldValue reflect.Value) reflect.Value { } } +// GetReflectTypeFromAny gets the reflect.Type from any type, dereferencing pointer types. +// Wraps GetReflectType for convenience when starting with an any type. func GetReflectTypeFromAny(input any) reflect.Type { dataType := reflect.TypeOf(input) return GetReflectType(dataType) } +// GetReflectType dereferences pointer types to get the underlying type. +// Returns the element type if the type is a pointer, otherwise returns the type unchanged. func GetReflectType(fieldType reflect.Type) reflect.Type { if fieldType.Kind() == reflect.Ptr { return fieldType.Elem() @@ -37,11 +47,15 @@ func GetReflectType(fieldType reflect.Type) reflect.Type { } } +// GetReflectKindFromAny gets the reflect.Kind from any type, dereferencing pointer types. +// Wraps GetReflectKind for convenience when starting with an any type. func GetReflectKindFromAny(input any) reflect.Kind { dataType := reflect.TypeOf(input) return GetReflectKind(dataType) } +// GetReflectKind dereferences pointer types to get the underlying kind. +// Returns the element kind if the type is a pointer, otherwise returns the kind unchanged. func GetReflectKind(fieldType reflect.Type) reflect.Kind { if fieldType.Kind() == reflect.Pointer { return fieldType.Elem().Kind() diff --git a/pkg/project-client/internal/validation/validate_array_length.go b/pkg/project-client/internal/validation/validate_array_length.go index 2f7bbd7..1b28357 100644 --- a/pkg/project-client/internal/validation/validate_array_length.go +++ b/pkg/project-client/internal/validation/validate_array_length.go @@ -8,6 +8,8 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/utils" ) +// validateArrayLength validates that an array or slice length is within 'minLength' and 'maxLength' tag constraints. +// Only validates array and slice types. Nil slices are skipped. func validateArrayLength(field reflect.StructField, value reflect.Value) error { kind := utils.GetReflectKind(value.Type()) if kind != reflect.Array && kind != reflect.Slice { @@ -31,6 +33,7 @@ func validateArrayLength(field reflect.StructField, value reflect.Value) error { return nil } +// validateMinLength validates that an array or slice meets the minimum length requirement from 'minLength' tag. func validateMinLength(field reflect.StructField, value reflect.Value) error { kind := utils.GetReflectKind(value.Type()) if kind == reflect.Slice && value.IsNil() { @@ -55,6 +58,7 @@ func validateMinLength(field reflect.StructField, value reflect.Value) error { return nil } +// validateMaxLength validates that an array or slice doesn't exceed the maximum length from 'maxLength' tag. func validateMaxLength(field reflect.StructField, value reflect.Value) error { kind := utils.GetReflectKind(value.Type()) if kind == reflect.Slice && value.IsNil() { diff --git a/pkg/project-client/internal/validation/validate_array_unique.go b/pkg/project-client/internal/validation/validate_array_unique.go index 45ef727..6777c25 100644 --- a/pkg/project-client/internal/validation/validate_array_unique.go +++ b/pkg/project-client/internal/validation/validate_array_unique.go @@ -5,6 +5,8 @@ import ( "reflect" ) +// validateArrayIsUnique validates that all elements in an array or slice are unique when 'uniqueItems:"true"' tag is present. +// Returns an error if duplicate elements are found. Nil values are skipped. func validateArrayIsUnique(field reflect.StructField, value reflect.Value) error { unique, found := field.Tag.Lookup("uniqueItems") if !found || unique != "true" || value.IsNil() { diff --git a/pkg/project-client/internal/validation/validate_max.go b/pkg/project-client/internal/validation/validate_max.go index e7f4c77..5acd817 100644 --- a/pkg/project-client/internal/validation/validate_max.go +++ b/pkg/project-client/internal/validation/validate_max.go @@ -8,6 +8,8 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/utils" ) +// validateMax validates that a numeric field value is less than or equal to the 'max' tag value. +// Supports int and float types. Nil values are skipped. func validateMax(field reflect.StructField, value reflect.Value) error { maxValue, found := field.Tag.Lookup("max") if !found || maxValue == "" || value.IsNil() { diff --git a/pkg/project-client/internal/validation/validate_min.go b/pkg/project-client/internal/validation/validate_min.go index e24c5c1..effc462 100644 --- a/pkg/project-client/internal/validation/validate_min.go +++ b/pkg/project-client/internal/validation/validate_min.go @@ -8,6 +8,8 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/utils" ) +// validateMin validates that a numeric field value is greater than or equal to the 'min' tag value. +// Supports int and float types. Nil values are skipped. func validateMin(field reflect.StructField, value reflect.Value) error { minValue, found := field.Tag.Lookup("min") if !found || minValue == "" || value.IsNil() { diff --git a/pkg/project-client/internal/validation/validate_multiple_of.go b/pkg/project-client/internal/validation/validate_multiple_of.go index 2368a23..2399632 100644 --- a/pkg/project-client/internal/validation/validate_multiple_of.go +++ b/pkg/project-client/internal/validation/validate_multiple_of.go @@ -9,6 +9,8 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/utils" ) +// validateMultipleOf validates that a numeric field value is a multiple of the 'multipleOf' tag value. +// Supports int and float types. Nil values are skipped. func validateMultipleOf(field reflect.StructField, value reflect.Value) error { multipleOfValue, found := field.Tag.Lookup("multipleOf") if !found || multipleOfValue == "" || value.IsNil() { diff --git a/pkg/project-client/internal/validation/validate_pattern.go b/pkg/project-client/internal/validation/validate_pattern.go index 70e8979..425d1cc 100644 --- a/pkg/project-client/internal/validation/validate_pattern.go +++ b/pkg/project-client/internal/validation/validate_pattern.go @@ -8,6 +8,8 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/utils" ) +// validatePattern validates that a string field matches the regex pattern specified in its 'pattern' tag. +// Returns an error if the field value doesn't match the pattern. Nil values are skipped. func validatePattern(field reflect.StructField, value reflect.Value) error { pattern, found := field.Tag.Lookup("pattern") if !found { diff --git a/pkg/project-client/internal/validation/validate_required.go b/pkg/project-client/internal/validation/validate_required.go index 6b1a638..9f0af0e 100644 --- a/pkg/project-client/internal/validation/validate_required.go +++ b/pkg/project-client/internal/validation/validate_required.go @@ -5,6 +5,8 @@ import ( "reflect" ) +// validateRequired checks if a required field has a non-nil value. +// Returns an error if the field has a 'required:"true"' tag and is nil. func validateRequired(fieldType reflect.StructField, fieldValue reflect.Value) error { if IsRequiredField(fieldType) && fieldValue.IsNil() { return fmt.Errorf("field %s is required", fieldType.Name) @@ -13,11 +15,13 @@ func validateRequired(fieldType reflect.StructField, fieldValue reflect.Value) e return nil } +// IsRequiredField checks if a struct field has the 'required:"true"' tag. func IsRequiredField(fieldType reflect.StructField) bool { required, found := fieldType.Tag.Lookup("required") return found && required == "true" } +// IsOptionalField checks if a struct field is optional (not required or no tag). func IsOptionalField(fieldType reflect.StructField) bool { required, found := fieldType.Tag.Lookup("required") return !found || required == "" || required == "false" diff --git a/pkg/project-client/internal/validation/validation.go b/pkg/project-client/internal/validation/validation.go index a1092bc..1e8ded4 100644 --- a/pkg/project-client/internal/validation/validation.go +++ b/pkg/project-client/internal/validation/validation.go @@ -6,8 +6,12 @@ import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/utils" ) +// validatorFunc defines the signature for field validation functions. type validatorFunc = func(fieldType reflect.StructField, fieldValue reflect.Value) error +// ValidateData validates data structures recursively according to struct field tags. +// Supports required, pattern, min, max, multipleOf, unique array, and array length validations. +// Handles Nullable wrappers and nested structs/arrays. func ValidateData(data any) error { if data == nil { return nil @@ -36,7 +40,7 @@ func ValidateData(data any) error { } if utils.GetReflectKind(dataType) == reflect.Struct { - return validateStruct(dataValue.Interface()) + return validateStructValue(dataValue) } else if dataType.Kind() == reflect.Array || dataType.Kind() == reflect.Slice { return validateArray(dataValue) } @@ -44,8 +48,15 @@ func ValidateData(data any) error { return nil } +// validateStruct validates a struct by interface value (for exported fields). +// Recursively validates nested structs and arrays according to their validation tags. func validateStruct(data any) error { value := reflect.ValueOf(data) + return validateStructValue(value) +} + +// validateStructValue validates a struct by reflect.Value (works with both exported and unexported fields) +func validateStructValue(value reflect.Value) error { // Recursively dereference pointers for value.Kind() == reflect.Ptr { @@ -60,18 +71,38 @@ func validateStruct(data any) error { if value.FieldByName("IsNull").Bool() { return nil } - // Get the actual value from the Nullable wrapper - value = value.FieldByName("Value") + // Get the actual value from the Nullable wrapper and restart validation from scratch + // This ensures the wrapped value is validated according to its actual type + wrappedValue := value.FieldByName("Value") + + if wrappedValue.CanInterface() { + return ValidateData(wrappedValue.Interface()) + } else { + // For unexported values, route to the appropriate validator based on type + innerKind := utils.GetReflectKind(wrappedValue.Type()) + if innerKind == reflect.Struct { + return validateStructValue(wrappedValue) + } else if innerKind == reflect.Array || innerKind == reflect.Slice { + return validateArray(wrappedValue) + } + return nil + } } structValue := utils.GetReflectValue(value) + for i := 0; i < structValue.NumField(); i++ { fieldValue := structValue.Field(i) fieldType := structValue.Type().Field(i) - err := validateField(fieldValue, fieldType) - if err != nil { - return err + // For unexported fields, skip field-level validation but still recurse into nested structs + isUnexported := fieldType.PkgPath != "" + + if !isUnexported { + err := validateField(fieldValue, fieldType) + if err != nil { + return err + } } // Only check IsNil for types that can be nil @@ -82,9 +113,25 @@ func validateStruct(data any) error { continue } + // Recurse into nested structs/arrays/slices, even if the field is unexported kind = utils.GetReflectKind(fieldType.Type) - if kind == reflect.Struct || kind == reflect.Array || kind == reflect.Slice { - err := ValidateData(fieldValue.Interface()) + if kind == reflect.Struct { + // For pointer fields, dereference first + valueToValidate := fieldValue + if fieldValue.Kind() == reflect.Ptr && !fieldValue.IsNil() { + valueToValidate = fieldValue.Elem() + } + + // Use validateStructValue to handle both exported and unexported fields + if valueToValidate.Kind() == reflect.Struct { + err := validateStructValue(valueToValidate) + if err != nil { + return err + } + } + } else if kind == reflect.Array || kind == reflect.Slice { + // For arrays/slices, validate using the existing validateArray function + err := validateArray(fieldValue) if err != nil { return err } @@ -94,6 +141,8 @@ func validateStruct(data any) error { return nil } +// validateArray validates each element in an array or slice recursively. +// Handles Nullable wrappers around arrays. func validateArray(value reflect.Value) error { // Check if this is a Nullable wrapper if isNullableType(value.Type()) { @@ -106,15 +155,31 @@ func validateArray(value reflect.Value) error { arrayValue := utils.GetReflectValue(value) for j := 0; j < arrayValue.Len(); j++ { - err := ValidateData(arrayValue.Index(j).Interface()) - if err != nil { - return err + elementValue := arrayValue.Index(j) + + // Try to validate the element - use Interface() if possible, otherwise use reflect.Value directly + if elementValue.CanInterface() { + err := ValidateData(elementValue.Interface()) + if err != nil { + return err + } + } else { + // For unexported elements, validate using reflect.Value directly + elementKind := utils.GetReflectKind(elementValue.Type()) + if elementKind == reflect.Struct { + err := validateStructValue(elementValue) + if err != nil { + return err + } + } } } return nil } +// isNullableType checks if a type is a Nullable wrapper struct. +// Returns true if the type has IsNull (bool) and Value fields. func isNullableType(t reflect.Type) bool { // Dereference pointer types until we hit the base type for t.Kind() == reflect.Ptr { @@ -142,6 +207,8 @@ func isNullableType(t reflect.Type) bool { return true } +// validateField runs all applicable validators on a struct field. +// Returns the first validation error encountered, or nil if all validations pass. func validateField(fieldValue reflect.Value, fieldType reflect.StructField) error { validators := getValidators(fieldType) for _, validator := range validators { @@ -154,6 +221,8 @@ func validateField(fieldValue reflect.Value, fieldType reflect.StructField) erro return nil } +// getValidators returns the list of all validator functions to apply to a field. +// Includes required, pattern, multipleOf, min, max, array unique, and array length validators. func getValidators(fieldType reflect.StructField) []validatorFunc { return []validatorFunc{ validateRequired, diff --git a/pkg/project-client/shared/client_error.go b/pkg/project-client/shared/client_error.go index e0607b7..b74abc9 100644 --- a/pkg/project-client/shared/client_error.go +++ b/pkg/project-client/shared/client_error.go @@ -2,23 +2,33 @@ package shared import ( "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/httptransport" + "net/http" ) -type ClientError struct { +// ClientError wraps API errors with detailed metadata including status code, headers, and raw response. +// It implements the error interface and provides structured access to error information. +type ClientError[T any] struct { Err error + Data *T Body []byte + Raw *http.Response Metadata ClientErrorMetadata } +// ClientErrorMetadata contains HTTP metadata associated with an error response. type ClientErrorMetadata struct { Headers map[string]string StatusCode int } -func NewClientError[T any](transportError *httptransport.ErrorResponse[T]) *ClientError { - return &ClientError{ +// NewClientError creates a new ClientError from an internal transport error. +// It extracts error details, body, status code, and headers into a user-facing error structure. +func NewClientError[T any](transportError *httptransport.ErrorResponse[T]) *ClientError[T] { + return &ClientError[T]{ Err: transportError.GetError(), + Data: transportError.Data, Body: transportError.GetBody(), + Raw: transportError.Raw, Metadata: ClientErrorMetadata{ StatusCode: transportError.GetStatusCode(), Headers: transportError.GetHeaders(), @@ -26,6 +36,13 @@ func NewClientError[T any](transportError *httptransport.ErrorResponse[T]) *Clie } } -func (e *ClientError) Error() string { +// Error implements the error interface, returning the error message string. +func (e *ClientError[T]) Error() string { return e.Err.Error() } + +// GetData returns the deserialized error response data. +// Returns nil if unmarshaling failed or the response body was empty. +func (e *ClientError[T]) GetData() *T { + return e.Data +} diff --git a/pkg/project-client/shared/client_response.go b/pkg/project-client/shared/client_response.go index 3019553..542538e 100644 --- a/pkg/project-client/shared/client_response.go +++ b/pkg/project-client/shared/client_response.go @@ -2,23 +2,31 @@ package shared import ( "encoding/json" - "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/httptransport" + "net/http" ) +// ClientResponse is the user-facing wrapper for API responses. +// It contains the deserialized data, raw HTTP response, and metadata like headers and status code. type ClientResponse[T any] struct { Data T + Raw *http.Response Metadata ClientResponseMetadata } +// ClientResponseMetadata contains HTTP metadata from the API response. +// Includes status code and headers for inspection and debugging. type ClientResponseMetadata struct { Headers map[string]string StatusCode int } +// NewClientResponse creates a new response wrapper from an internal transport response. +// Extracts data and metadata into a user-facing structure. func NewClientResponse[T any](resp *httptransport.Response[T]) *ClientResponse[T] { return &ClientResponse[T]{ Data: resp.Data, + Raw: resp.Raw, Metadata: ClientResponseMetadata{ StatusCode: resp.StatusCode, Headers: resp.Headers, @@ -26,10 +34,13 @@ func NewClientResponse[T any](resp *httptransport.Response[T]) *ClientResponse[T } } +// GetData returns the deserialized response data. func (r *ClientResponse[T]) GetData() T { return r.Data } +// String returns a JSON representation of the response for debugging. +// Returns an error message if JSON marshaling fails. func (r ClientResponse[T]) String() string { jsonData, err := json.MarshalIndent(r, "", " ") if err != nil { diff --git a/pkg/project-client/shared/user.go b/pkg/project-client/shared/user.go index ed8e6b8..b7c44e6 100644 --- a/pkg/project-client/shared/user.go +++ b/pkg/project-client/shared/user.go @@ -7,16 +7,26 @@ import ( ) type User struct { - CreatedAt *util.Nullable[string] `json:"created_at,omitempty"` - CustomAttributes *util.Nullable[any] `json:"custom_attributes,omitempty"` - Email *util.Nullable[string] `json:"email,omitempty"` - ExternalId *util.Nullable[string] `json:"external_id,omitempty"` - FirstName *util.Nullable[string] `json:"first_name,omitempty"` - Id *string `json:"id,omitempty"` - LastName *util.Nullable[string] `json:"last_name,omitempty"` - LastNotifiedAt *util.Nullable[string] `json:"last_notified_at,omitempty"` - LastSeenAt *util.Nullable[string] `json:"last_seen_at,omitempty"` - UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` + // The timestamp when the user was created. + CreatedAt *util.Nullable[string] `json:"created_at,omitempty"` + // Arbitrary custom values stored on the user. + CustomAttributes *util.Nullable[any] `json:"custom_attributes,omitempty"` + // The primary email address of the user. + Email *util.Nullable[string] `json:"email,omitempty"` + // The user identifier from an external system. + ExternalId *util.Nullable[string] `json:"external_id,omitempty"` + // The first name of the user. + FirstName *util.Nullable[string] `json:"first_name,omitempty"` + // The unique identifier for the user. + Id *string `json:"id,omitempty"` + // The last name of the user. + LastName *util.Nullable[string] `json:"last_name,omitempty"` + // The timestamp when the user last received a notification. + LastNotifiedAt *util.Nullable[string] `json:"last_notified_at,omitempty"` + // The timestamp when the user last opened the inbox. + LastSeenAt *util.Nullable[string] `json:"last_seen_at,omitempty"` + // The timestamp when the user was last updated. + UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` } func (u *User) GetCreatedAt() *util.Nullable[string] { diff --git a/pkg/project-client/users/request_params.go b/pkg/project-client/users/request_params.go index 3d9d96a..5861eff 100644 --- a/pkg/project-client/users/request_params.go +++ b/pkg/project-client/users/request_params.go @@ -1,5 +1,7 @@ package users +// ListUsersRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListUsersRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` @@ -7,15 +9,22 @@ type ListUsersRequestParams struct { Query *string `explode:"true" serializationStyle:"form" queryParam:"query"` } +// SetLimit sets the Limit parameter. func (params *ListUsersRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListUsersRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListUsersRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } + +// SetQuery sets the Query parameter. func (params *ListUsersRequestParams) SetQuery(query string) { params.Query = &query } diff --git a/pkg/project-client/users/users_service.go b/pkg/project-client/users/users_service.go index 5ba3c8b..54682d2 100644 --- a/pkg/project-client/users/users_service.go +++ b/pkg/project-client/users/users_service.go @@ -3,6 +3,7 @@ package users import ( "context" restClient "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/hooks" "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/httptransport" "github.com/magicbell/magicbell-go/pkg/project-client/internal/configmanager" "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" @@ -10,8 +11,11 @@ import ( "time" ) +// UsersService provides methods to interact with UsersService-related API endpoints. +// It uses a configuration manager for settings and supports custom hooks for request/response interception. type UsersService struct { manager *configmanager.ConfigManager + hook hooks.Hook } func NewUsersService() *UsersService { @@ -20,15 +24,28 @@ func NewUsersService() *UsersService { } } +// WithConfigManager sets the configuration manager for this service. +// Returns the service instance for method chaining. func (api *UsersService) WithConfigManager(manager *configmanager.ConfigManager) *UsersService { api.manager = manager return api } +// WithHook sets a custom hook for request/response interception. +// Returns the service instance for method chaining. +func (api *UsersService) WithHook(hook hooks.Hook) *UsersService { + api.hook = hook + return api +} + func (api *UsersService) getConfig() *clientconfig.Config { return api.manager.GetUsers() } +func (api *UsersService) getHook() hooks.Hook { + return api.hook +} + func (api *UsersService) SetBaseUrl(baseUrl string) { config := api.getConfig() config.SetBaseUrl(baseUrl) @@ -45,7 +62,7 @@ func (api *UsersService) SetAccessToken(accessToken string) { } // Lists all users in the project. -func (api *UsersService) ListUsers(ctx context.Context, params ListUsersRequestParams) (*shared.ClientResponse[UserCollection], *shared.ClientError) { +func (api *UsersService) ListUsers(ctx context.Context, params ListUsersRequestParams) (*shared.ClientResponse[UserCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -57,17 +74,17 @@ func (api *UsersService) ListUsers(ctx context.Context, params ListUsersRequestP WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[UserCollection](config) + client := restClient.NewRestClient[UserCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[UserCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[UserCollection](resp), nil } // Creates or updates a user with the provided details. The user will be associated with the project specified in the request context. -func (api *UsersService) SaveUser(ctx context.Context, user shared.User) (*shared.ClientResponse[shared.User], *shared.ClientError) { +func (api *UsersService) SaveUser(ctx context.Context, user shared.User) (*shared.ClientResponse[shared.User], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -80,17 +97,17 @@ func (api *UsersService) SaveUser(ctx context.Context, user shared.User) (*share WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[shared.User](config) + client := restClient.NewRestClient[shared.User, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[shared.User](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[shared.User](resp), nil } // Removes a user and all associated data from the project. -func (api *UsersService) DeleteUser(ctx context.Context, userId string) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *UsersService) DeleteUser(ctx context.Context, userId string) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -102,10 +119,10 @@ func (api *UsersService) DeleteUser(ctx context.Context, userId string) (*shared WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil diff --git a/pkg/project-client/util/nullable.go b/pkg/project-client/util/nullable.go index 43ae30b..055b3fa 100644 --- a/pkg/project-client/util/nullable.go +++ b/pkg/project-client/util/nullable.go @@ -2,11 +2,15 @@ package util import "encoding/json" +// Nullable represents an optional value that can be null in JSON. +// Used for API fields that distinguish between null, missing, and present values. type Nullable[T any] struct { Value T IsNull bool } +// MarshalJSON implements json.Marshaler to serialize null or the value. +// Returns "null" if IsNull is true, otherwise marshals the Value. func (n *Nullable[T]) MarshalJSON() ([]byte, error) { if n.IsNull { return []byte("null"), nil @@ -14,6 +18,8 @@ func (n *Nullable[T]) MarshalJSON() ([]byte, error) { return json.Marshal(n.Value) } +// UnmarshalJSON implements json.Unmarshaler to deserialize null or a value. +// Sets IsNull to true if the JSON is "null", otherwise unmarshals into Value. func (n *Nullable[T]) UnmarshalJSON(data []byte) error { if string(data) == "null" { n.IsNull = true diff --git a/pkg/project-client/util/to_pointer.go b/pkg/project-client/util/to_pointer.go index 3dceead..0906b11 100644 --- a/pkg/project-client/util/to_pointer.go +++ b/pkg/project-client/util/to_pointer.go @@ -1,5 +1,7 @@ package util +// ToPointer converts a value to a pointer to that value. +// Useful for creating pointers to literals or converting values to optional fields. func ToPointer[T any](v T) *T { return &v } diff --git a/pkg/project-client/workflows/create_run_response.go b/pkg/project-client/workflows/create_run_response.go new file mode 100644 index 0000000..0d6aa52 --- /dev/null +++ b/pkg/project-client/workflows/create_run_response.go @@ -0,0 +1,27 @@ +package workflows + +import "encoding/json" + +type CreateRunResponse struct { + // Identifier of the workflow run that was created. + Id *string `json:"id,omitempty" required:"true"` +} + +func (c *CreateRunResponse) GetId() *string { + if c == nil { + return nil + } + return c.Id +} + +func (c *CreateRunResponse) SetId(id string) { + c.Id = &id +} + +func (c CreateRunResponse) String() string { + jsonData, err := json.MarshalIndent(c, "", " ") + if err != nil { + return "error converting struct: CreateRunResponse to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/workflows/execute_workflow_request.go b/pkg/project-client/workflows/execute_workflow_request.go new file mode 100644 index 0000000..1f32e5c --- /dev/null +++ b/pkg/project-client/workflows/execute_workflow_request.go @@ -0,0 +1,52 @@ +package workflows + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" + "github.com/magicbell/magicbell-go/pkg/project-client/util" +) + +type ExecuteWorkflowRequest struct { + // Optional JSON payload that will be passed as the workflow input context. + Input *util.Nullable[any] `json:"input,omitempty"` + // The unique workflow key to execute (e.g. integration.stripe.charge.succeeded). + Key *string `json:"key,omitempty" required:"true" pattern:"^[A-Za-z0-9\_\.\-\:]+$"` +} + +func (e *ExecuteWorkflowRequest) GetInput() *util.Nullable[any] { + if e == nil { + return nil + } + return e.Input +} + +func (e *ExecuteWorkflowRequest) SetInput(input util.Nullable[any]) { + e.Input = &input +} + +func (e *ExecuteWorkflowRequest) SetInputNull() { + e.Input = &util.Nullable[any]{IsNull: true} +} + +func (e *ExecuteWorkflowRequest) GetKey() *string { + if e == nil { + return nil + } + return e.Key +} + +func (e *ExecuteWorkflowRequest) SetKey(key string) { + e.Key = &key +} + +func (e ExecuteWorkflowRequest) String() string { + jsonData, err := json.MarshalIndent(e, "", " ") + if err != nil { + return "error converting struct: ExecuteWorkflowRequest to string" + } + return string(jsonData) +} + +func (e *ExecuteWorkflowRequest) UnmarshalJSON(data []byte) error { + return unmarshal.UnmarshalNullable(data, e) +} diff --git a/pkg/project-client/workflows/get_run_response.go b/pkg/project-client/workflows/get_run_response.go new file mode 100644 index 0000000..f927e9b --- /dev/null +++ b/pkg/project-client/workflows/get_run_response.go @@ -0,0 +1,74 @@ +package workflows + +import "encoding/json" + +type GetRunResponse struct { + CreatedAt *string `json:"created_at,omitempty"` + Id *string `json:"id,omitempty"` + Input any `json:"input,omitempty"` + Status *GetRunResponseStatus `json:"status,omitempty"` + WorkflowKey *string `json:"workflow_key,omitempty"` +} + +func (g *GetRunResponse) GetCreatedAt() *string { + if g == nil { + return nil + } + return g.CreatedAt +} + +func (g *GetRunResponse) SetCreatedAt(createdAt string) { + g.CreatedAt = &createdAt +} + +func (g *GetRunResponse) GetId() *string { + if g == nil { + return nil + } + return g.Id +} + +func (g *GetRunResponse) SetId(id string) { + g.Id = &id +} + +func (g *GetRunResponse) GetInput() any { + if g == nil { + return nil + } + return g.Input +} + +func (g *GetRunResponse) SetInput(input any) { + g.Input = &input +} + +func (g *GetRunResponse) GetStatus() *GetRunResponseStatus { + if g == nil { + return nil + } + return g.Status +} + +func (g *GetRunResponse) SetStatus(status GetRunResponseStatus) { + g.Status = &status +} + +func (g *GetRunResponse) GetWorkflowKey() *string { + if g == nil { + return nil + } + return g.WorkflowKey +} + +func (g *GetRunResponse) SetWorkflowKey(workflowKey string) { + g.WorkflowKey = &workflowKey +} + +func (g GetRunResponse) String() string { + jsonData, err := json.MarshalIndent(g, "", " ") + if err != nil { + return "error converting struct: GetRunResponse to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/workflows/get_run_response_status.go b/pkg/project-client/workflows/get_run_response_status.go new file mode 100644 index 0000000..2b4d94e --- /dev/null +++ b/pkg/project-client/workflows/get_run_response_status.go @@ -0,0 +1,74 @@ +package workflows + +import "encoding/json" + +type GetRunResponseStatus struct { + CompletedAt *string `json:"completed_at,omitempty"` + Error *string `json:"error,omitempty"` + NextStep *int64 `json:"next_step,omitempty"` + StartedAt *string `json:"started_at,omitempty"` + State *int64 `json:"state,omitempty"` +} + +func (g *GetRunResponseStatus) GetCompletedAt() *string { + if g == nil { + return nil + } + return g.CompletedAt +} + +func (g *GetRunResponseStatus) SetCompletedAt(completedAt string) { + g.CompletedAt = &completedAt +} + +func (g *GetRunResponseStatus) GetError() *string { + if g == nil { + return nil + } + return g.Error +} + +func (g *GetRunResponseStatus) SetError(error string) { + g.Error = &error +} + +func (g *GetRunResponseStatus) GetNextStep() *int64 { + if g == nil { + return nil + } + return g.NextStep +} + +func (g *GetRunResponseStatus) SetNextStep(nextStep int64) { + g.NextStep = &nextStep +} + +func (g *GetRunResponseStatus) GetStartedAt() *string { + if g == nil { + return nil + } + return g.StartedAt +} + +func (g *GetRunResponseStatus) SetStartedAt(startedAt string) { + g.StartedAt = &startedAt +} + +func (g *GetRunResponseStatus) GetState() *int64 { + if g == nil { + return nil + } + return g.State +} + +func (g *GetRunResponseStatus) SetState(state int64) { + g.State = &state +} + +func (g GetRunResponseStatus) String() string { + jsonData, err := json.MarshalIndent(g, "", " ") + if err != nil { + return "error converting struct: GetRunResponseStatus to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/workflows/items.go b/pkg/project-client/workflows/items.go new file mode 100644 index 0000000..03034ac --- /dev/null +++ b/pkg/project-client/workflows/items.go @@ -0,0 +1,50 @@ +package workflows + +import "encoding/json" + +type Items struct { + Disabled *bool `json:"disabled,omitempty"` + Key *string `json:"key,omitempty" required:"true" minLength:"3" pattern:"^[A-Za-z0-9\_\.\-\:]+$"` + Steps []ItemsSteps `json:"steps,omitempty" required:"true"` +} + +func (i *Items) GetDisabled() *bool { + if i == nil { + return nil + } + return i.Disabled +} + +func (i *Items) SetDisabled(disabled bool) { + i.Disabled = &disabled +} + +func (i *Items) GetKey() *string { + if i == nil { + return nil + } + return i.Key +} + +func (i *Items) SetKey(key string) { + i.Key = &key +} + +func (i *Items) GetSteps() []ItemsSteps { + if i == nil { + return nil + } + return i.Steps +} + +func (i *Items) SetSteps(steps []ItemsSteps) { + i.Steps = steps +} + +func (i Items) String() string { + jsonData, err := json.MarshalIndent(i, "", " ") + if err != nil { + return "error converting struct: Items to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/workflows/items_steps.go b/pkg/project-client/workflows/items_steps.go new file mode 100644 index 0000000..c1135ae --- /dev/null +++ b/pkg/project-client/workflows/items_steps.go @@ -0,0 +1,67 @@ +package workflows + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" + "github.com/magicbell/magicbell-go/pkg/project-client/util" +) + +type ItemsSteps struct { + // Command to execute (e.g., broadcast, pause, wait, abort) + Command *string `json:"command,omitempty" required:"true" pattern:"^[a-z_]+$"` + If_ *util.Nullable[string] `json:"if,omitempty"` + Input *util.Nullable[any] `json:"input,omitempty"` +} + +func (i *ItemsSteps) GetCommand() *string { + if i == nil { + return nil + } + return i.Command +} + +func (i *ItemsSteps) SetCommand(command string) { + i.Command = &command +} + +func (i *ItemsSteps) GetIf_() *util.Nullable[string] { + if i == nil { + return nil + } + return i.If_ +} + +func (i *ItemsSteps) SetIf_(if_ util.Nullable[string]) { + i.If_ = &if_ +} + +func (i *ItemsSteps) SetIf_Null() { + i.If_ = &util.Nullable[string]{IsNull: true} +} + +func (i *ItemsSteps) GetInput() *util.Nullable[any] { + if i == nil { + return nil + } + return i.Input +} + +func (i *ItemsSteps) SetInput(input util.Nullable[any]) { + i.Input = &input +} + +func (i *ItemsSteps) SetInputNull() { + i.Input = &util.Nullable[any]{IsNull: true} +} + +func (i ItemsSteps) String() string { + jsonData, err := json.MarshalIndent(i, "", " ") + if err != nil { + return "error converting struct: ItemsSteps to string" + } + return string(jsonData) +} + +func (i *ItemsSteps) UnmarshalJSON(data []byte) error { + return unmarshal.UnmarshalNullable(data, i) +} diff --git a/pkg/project-client/workflows/workflow_definition.go b/pkg/project-client/workflows/workflow_definition.go new file mode 100644 index 0000000..e556876 --- /dev/null +++ b/pkg/project-client/workflows/workflow_definition.go @@ -0,0 +1,53 @@ +package workflows + +import "encoding/json" + +type WorkflowDefinition struct { + // When true, prevents the workflow from being triggered. + Disabled *bool `json:"disabled,omitempty"` + // Unique identifier for this workflow definition. + Key *string `json:"key,omitempty" required:"true" minLength:"3" pattern:"^[A-Za-z0-9\_\.\-\:]+$"` + // Ordered list describing each action that will run inside the workflow. + Steps []WorkflowDefinitionSteps `json:"steps,omitempty" required:"true"` +} + +func (w *WorkflowDefinition) GetDisabled() *bool { + if w == nil { + return nil + } + return w.Disabled +} + +func (w *WorkflowDefinition) SetDisabled(disabled bool) { + w.Disabled = &disabled +} + +func (w *WorkflowDefinition) GetKey() *string { + if w == nil { + return nil + } + return w.Key +} + +func (w *WorkflowDefinition) SetKey(key string) { + w.Key = &key +} + +func (w *WorkflowDefinition) GetSteps() []WorkflowDefinitionSteps { + if w == nil { + return nil + } + return w.Steps +} + +func (w *WorkflowDefinition) SetSteps(steps []WorkflowDefinitionSteps) { + w.Steps = steps +} + +func (w WorkflowDefinition) String() string { + jsonData, err := json.MarshalIndent(w, "", " ") + if err != nil { + return "error converting struct: WorkflowDefinition to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/workflows/workflow_definition_steps.go b/pkg/project-client/workflows/workflow_definition_steps.go new file mode 100644 index 0000000..9daed1a --- /dev/null +++ b/pkg/project-client/workflows/workflow_definition_steps.go @@ -0,0 +1,69 @@ +package workflows + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/unmarshal" + "github.com/magicbell/magicbell-go/pkg/project-client/util" +) + +type WorkflowDefinitionSteps struct { + // Command to execute (e.g., broadcast, pause, wait, abort) + Command *string `json:"command,omitempty" required:"true" pattern:"^[a-z_]+$"` + // JMESPath condition that must evaluate truthy for the step to run. + If_ *util.Nullable[string] `json:"if,omitempty"` + // Optional payload passed to the command when it executes. + Input *util.Nullable[any] `json:"input,omitempty"` +} + +func (w *WorkflowDefinitionSteps) GetCommand() *string { + if w == nil { + return nil + } + return w.Command +} + +func (w *WorkflowDefinitionSteps) SetCommand(command string) { + w.Command = &command +} + +func (w *WorkflowDefinitionSteps) GetIf_() *util.Nullable[string] { + if w == nil { + return nil + } + return w.If_ +} + +func (w *WorkflowDefinitionSteps) SetIf_(if_ util.Nullable[string]) { + w.If_ = &if_ +} + +func (w *WorkflowDefinitionSteps) SetIf_Null() { + w.If_ = &util.Nullable[string]{IsNull: true} +} + +func (w *WorkflowDefinitionSteps) GetInput() *util.Nullable[any] { + if w == nil { + return nil + } + return w.Input +} + +func (w *WorkflowDefinitionSteps) SetInput(input util.Nullable[any]) { + w.Input = &input +} + +func (w *WorkflowDefinitionSteps) SetInputNull() { + w.Input = &util.Nullable[any]{IsNull: true} +} + +func (w WorkflowDefinitionSteps) String() string { + jsonData, err := json.MarshalIndent(w, "", " ") + if err != nil { + return "error converting struct: WorkflowDefinitionSteps to string" + } + return string(jsonData) +} + +func (w *WorkflowDefinitionSteps) UnmarshalJSON(data []byte) error { + return unmarshal.UnmarshalNullable(data, w) +} diff --git a/pkg/project-client/workflows/workflow_list.go b/pkg/project-client/workflows/workflow_list.go new file mode 100644 index 0000000..4455000 --- /dev/null +++ b/pkg/project-client/workflows/workflow_list.go @@ -0,0 +1,26 @@ +package workflows + +import "encoding/json" + +type WorkflowList struct { + Items []Items `json:"items,omitempty"` +} + +func (w *WorkflowList) GetItems() []Items { + if w == nil { + return nil + } + return w.Items +} + +func (w *WorkflowList) SetItems(items []Items) { + w.Items = items +} + +func (w WorkflowList) String() string { + jsonData, err := json.MarshalIndent(w, "", " ") + if err != nil { + return "error converting struct: WorkflowList to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/workflows/workflow_run.go b/pkg/project-client/workflows/workflow_run.go new file mode 100644 index 0000000..399a899 --- /dev/null +++ b/pkg/project-client/workflows/workflow_run.go @@ -0,0 +1,62 @@ +package workflows + +import "encoding/json" + +type WorkflowRun struct { + CreatedAt *string `json:"created_at,omitempty"` + Id *string `json:"id,omitempty"` + Status *WorkflowRunStatus `json:"status,omitempty"` + WorkflowKey *string `json:"workflow_key,omitempty"` +} + +func (w *WorkflowRun) GetCreatedAt() *string { + if w == nil { + return nil + } + return w.CreatedAt +} + +func (w *WorkflowRun) SetCreatedAt(createdAt string) { + w.CreatedAt = &createdAt +} + +func (w *WorkflowRun) GetId() *string { + if w == nil { + return nil + } + return w.Id +} + +func (w *WorkflowRun) SetId(id string) { + w.Id = &id +} + +func (w *WorkflowRun) GetStatus() *WorkflowRunStatus { + if w == nil { + return nil + } + return w.Status +} + +func (w *WorkflowRun) SetStatus(status WorkflowRunStatus) { + w.Status = &status +} + +func (w *WorkflowRun) GetWorkflowKey() *string { + if w == nil { + return nil + } + return w.WorkflowKey +} + +func (w *WorkflowRun) SetWorkflowKey(workflowKey string) { + w.WorkflowKey = &workflowKey +} + +func (w WorkflowRun) String() string { + jsonData, err := json.MarshalIndent(w, "", " ") + if err != nil { + return "error converting struct: WorkflowRun to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/workflows/workflow_run_collection.go b/pkg/project-client/workflows/workflow_run_collection.go new file mode 100644 index 0000000..f6780de --- /dev/null +++ b/pkg/project-client/workflows/workflow_run_collection.go @@ -0,0 +1,41 @@ +package workflows + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/project-client/shared" +) + +type WorkflowRunCollection struct { + Data []WorkflowRun `json:"data,omitempty"` + Links *shared.Links `json:"links,omitempty"` +} + +func (w *WorkflowRunCollection) GetData() []WorkflowRun { + if w == nil { + return nil + } + return w.Data +} + +func (w *WorkflowRunCollection) SetData(data []WorkflowRun) { + w.Data = data +} + +func (w *WorkflowRunCollection) GetLinks() *shared.Links { + if w == nil { + return nil + } + return w.Links +} + +func (w *WorkflowRunCollection) SetLinks(links shared.Links) { + w.Links = &links +} + +func (w WorkflowRunCollection) String() string { + jsonData, err := json.MarshalIndent(w, "", " ") + if err != nil { + return "error converting struct: WorkflowRunCollection to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/workflows/workflow_run_status.go b/pkg/project-client/workflows/workflow_run_status.go new file mode 100644 index 0000000..9ade0ea --- /dev/null +++ b/pkg/project-client/workflows/workflow_run_status.go @@ -0,0 +1,74 @@ +package workflows + +import "encoding/json" + +type WorkflowRunStatus struct { + CompletedAt *string `json:"completed_at,omitempty"` + Error *string `json:"error,omitempty"` + NextStep *int64 `json:"next_step,omitempty"` + StartedAt *string `json:"started_at,omitempty"` + State *int64 `json:"state,omitempty"` +} + +func (w *WorkflowRunStatus) GetCompletedAt() *string { + if w == nil { + return nil + } + return w.CompletedAt +} + +func (w *WorkflowRunStatus) SetCompletedAt(completedAt string) { + w.CompletedAt = &completedAt +} + +func (w *WorkflowRunStatus) GetError() *string { + if w == nil { + return nil + } + return w.Error +} + +func (w *WorkflowRunStatus) SetError(error string) { + w.Error = &error +} + +func (w *WorkflowRunStatus) GetNextStep() *int64 { + if w == nil { + return nil + } + return w.NextStep +} + +func (w *WorkflowRunStatus) SetNextStep(nextStep int64) { + w.NextStep = &nextStep +} + +func (w *WorkflowRunStatus) GetStartedAt() *string { + if w == nil { + return nil + } + return w.StartedAt +} + +func (w *WorkflowRunStatus) SetStartedAt(startedAt string) { + w.StartedAt = &startedAt +} + +func (w *WorkflowRunStatus) GetState() *int64 { + if w == nil { + return nil + } + return w.State +} + +func (w *WorkflowRunStatus) SetState(state int64) { + w.State = &state +} + +func (w WorkflowRunStatus) String() string { + jsonData, err := json.MarshalIndent(w, "", " ") + if err != nil { + return "error converting struct: WorkflowRunStatus to string" + } + return string(jsonData) +} diff --git a/pkg/project-client/workflows/workflows_service.go b/pkg/project-client/workflows/workflows_service.go new file mode 100644 index 0000000..da8801d --- /dev/null +++ b/pkg/project-client/workflows/workflows_service.go @@ -0,0 +1,194 @@ +package workflows + +import ( + "context" + restClient "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/hooks" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/clients/rest/httptransport" + "github.com/magicbell/magicbell-go/pkg/project-client/internal/configmanager" + "github.com/magicbell/magicbell-go/pkg/project-client/clientconfig" + "github.com/magicbell/magicbell-go/pkg/project-client/shared" + "time" +) + +// WorkflowsService provides methods to interact with WorkflowsService-related API endpoints. +// It uses a configuration manager for settings and supports custom hooks for request/response interception. +type WorkflowsService struct { + manager *configmanager.ConfigManager + hook hooks.Hook +} + +func NewWorkflowsService() *WorkflowsService { + return &WorkflowsService{ + manager: configmanager.NewConfigManager(clientconfig.Config{}), + } +} + +// WithConfigManager sets the configuration manager for this service. +// Returns the service instance for method chaining. +func (api *WorkflowsService) WithConfigManager(manager *configmanager.ConfigManager) *WorkflowsService { + api.manager = manager + return api +} + +// WithHook sets a custom hook for request/response interception. +// Returns the service instance for method chaining. +func (api *WorkflowsService) WithHook(hook hooks.Hook) *WorkflowsService { + api.hook = hook + return api +} + +func (api *WorkflowsService) getConfig() *clientconfig.Config { + return api.manager.GetWorkflows() +} + +func (api *WorkflowsService) getHook() hooks.Hook { + return api.hook +} + +func (api *WorkflowsService) SetBaseUrl(baseUrl string) { + config := api.getConfig() + config.SetBaseUrl(baseUrl) +} + +func (api *WorkflowsService) SetTimeout(timeout time.Duration) { + config := api.getConfig() + config.SetTimeout(timeout) +} + +func (api *WorkflowsService) SetAccessToken(accessToken string) { + config := api.getConfig() + config.SetAccessToken(accessToken) +} + +// Retrieves all workflow definitions for the project +func (api *WorkflowsService) FetchWorkflows(ctx context.Context) (*shared.ClientResponse[WorkflowList], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("GET"). + WithPath("/workflows"). + WithConfig(config). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[WorkflowList, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[WorkflowList](resp), nil +} + +// Creates or updates a workflow definition for the project +func (api *WorkflowsService) SaveWorkflow(ctx context.Context, workflowDefinition WorkflowDefinition) (*shared.ClientResponse[WorkflowDefinition], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("PUT"). + WithPath("/workflows"). + WithConfig(config). + WithBody(workflowDefinition). + AddHeader("CONTENT-TYPE", "application/json"). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[WorkflowDefinition, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[WorkflowDefinition](resp), nil +} + +// Retrieves a workflow definition by key +func (api *WorkflowsService) FetchWorkflow(ctx context.Context) (*shared.ClientResponse[WorkflowDefinition], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("GET"). + WithPath("/workflows/*"). + WithConfig(config). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[WorkflowDefinition, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[WorkflowDefinition](resp), nil +} + +// Executes a workflow with the provided input parameters +func (api *WorkflowsService) CreateWorkflowRun(ctx context.Context, executeWorkflowRequest ExecuteWorkflowRequest) (*shared.ClientResponse[CreateRunResponse], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("POST"). + WithPath("/workflows/runs"). + WithConfig(config). + WithBody(executeWorkflowRequest). + AddHeader("CONTENT-TYPE", "application/json"). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[CreateRunResponse, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[CreateRunResponse](resp), nil +} + +// Retrieves the status and details of a workflow run +func (api *WorkflowsService) FetchWorkflowRun(ctx context.Context, runId string) (*shared.ClientResponse[GetRunResponse], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("GET"). + WithPath("/workflows/runs/{run_id}"). + WithConfig(config). + AddPathParam("run_id", runId). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[GetRunResponse, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[GetRunResponse](resp), nil +} + +// Retrieves all runs for a specific workflow +func (api *WorkflowsService) ListWorkflowRuns(ctx context.Context, workflowKey string) (*shared.ClientResponse[WorkflowRunCollection], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("GET"). + WithPath("/workflows/{workflow_key}/runs"). + WithConfig(config). + AddPathParam("workflow_key", workflowKey). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[WorkflowRunCollection, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[WorkflowRunCollection](resp), nil +} diff --git a/pkg/user-client/channels/apns_token.go b/pkg/user-client/channels/apns_token.go index a30aa6c..2461dc1 100644 --- a/pkg/user-client/channels/apns_token.go +++ b/pkg/user-client/channels/apns_token.go @@ -7,15 +7,20 @@ import ( ) type ApnsToken struct { - // (Optional) The bundle identifier of the application that is registering this token. Use this field to override the default identifier specified in the projects APNs integration. - AppId *string `json:"app_id,omitempty" pattern:"^[a-zA-Z0-9]+(.[a-zA-Z0-9]+)*$"` - CreatedAt *string `json:"created_at,omitempty" required:"true"` - DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"64"` + // The bundle identifier of the application registering this token. Use this to override the default identifier configured on the APNs integration. + AppId *string `json:"app_id,omitempty" pattern:"^[a-zA-Z0-9]+(.[a-zA-Z0-9]+)*$"` + // The timestamp when the token was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The APNs device token to register with MagicBell. + DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"64"` + // The timestamp when the token was discarded, if applicable. DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - // (Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in `production`. + // The unique identifier for the token. + Id *string `json:"id,omitempty" required:"true"` + // The APNs environment this token belongs to. If omitted we assume it targets `production`. InstallationId *ApnsTokenInstallationId `json:"installation_id,omitempty"` - UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` + // The timestamp when the token metadata last changed. + UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` } func (a *ApnsToken) GetAppId() *string { @@ -114,11 +119,3 @@ func (a ApnsToken) String() string { func (a *ApnsToken) UnmarshalJSON(data []byte) error { return unmarshal.UnmarshalNullable(data, a) } - -// (Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in `production`. -type ApnsTokenInstallationId string - -const ( - APNS_TOKEN_INSTALLATION_ID_DEVELOPMENT ApnsTokenInstallationId = "development" - APNS_TOKEN_INSTALLATION_ID_PRODUCTION ApnsTokenInstallationId = "production" -) diff --git a/pkg/user-client/channels/apns_token_installation_id.go b/pkg/user-client/channels/apns_token_installation_id.go new file mode 100644 index 0000000..dbdaa99 --- /dev/null +++ b/pkg/user-client/channels/apns_token_installation_id.go @@ -0,0 +1,9 @@ +package channels + +// The APNs environment this token belongs to. If omitted we assume it targets `production`. +type ApnsTokenInstallationId string + +const ( + APNS_TOKEN_INSTALLATION_ID_DEVELOPMENT ApnsTokenInstallationId = "development" + APNS_TOKEN_INSTALLATION_ID_PRODUCTION ApnsTokenInstallationId = "production" +) diff --git a/pkg/user-client/channels/apns_token_payload.go b/pkg/user-client/channels/apns_token_payload.go index a289c42..c2276e9 100644 --- a/pkg/user-client/channels/apns_token_payload.go +++ b/pkg/user-client/channels/apns_token_payload.go @@ -3,10 +3,11 @@ package channels import "encoding/json" type ApnsTokenPayload struct { - // (Optional) The bundle identifier of the application that is registering this token. Use this field to override the default identifier specified in the projects APNs integration. - AppId *string `json:"app_id,omitempty" pattern:"^[a-zA-Z0-9]+(.[a-zA-Z0-9]+)*$"` + // The bundle identifier of the application registering this token. Use this to override the default identifier configured on the APNs integration. + AppId *string `json:"app_id,omitempty" pattern:"^[a-zA-Z0-9]+(.[a-zA-Z0-9]+)*$"` + // The APNs device token to register with MagicBell. DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"64"` - // (Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in `production`. + // The APNs environment this token belongs to. If omitted we assume it targets `production`. InstallationId *ApnsTokenPayloadInstallationId `json:"installation_id,omitempty"` } @@ -50,11 +51,3 @@ func (a ApnsTokenPayload) String() string { } return string(jsonData) } - -// (Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in `production`. -type ApnsTokenPayloadInstallationId string - -const ( - APNS_TOKEN_PAYLOAD_INSTALLATION_ID_DEVELOPMENT ApnsTokenPayloadInstallationId = "development" - APNS_TOKEN_PAYLOAD_INSTALLATION_ID_PRODUCTION ApnsTokenPayloadInstallationId = "production" -) diff --git a/pkg/user-client/channels/apns_token_payload_installation_id.go b/pkg/user-client/channels/apns_token_payload_installation_id.go new file mode 100644 index 0000000..4bacccc --- /dev/null +++ b/pkg/user-client/channels/apns_token_payload_installation_id.go @@ -0,0 +1,9 @@ +package channels + +// The APNs environment this token belongs to. If omitted we assume it targets `production`. +type ApnsTokenPayloadInstallationId string + +const ( + APNS_TOKEN_PAYLOAD_INSTALLATION_ID_DEVELOPMENT ApnsTokenPayloadInstallationId = "development" + APNS_TOKEN_PAYLOAD_INSTALLATION_ID_PRODUCTION ApnsTokenPayloadInstallationId = "production" +) diff --git a/pkg/user-client/channels/categories.go b/pkg/user-client/channels/categories.go new file mode 100644 index 0000000..351dc5a --- /dev/null +++ b/pkg/user-client/channels/categories.go @@ -0,0 +1,62 @@ +package channels + +import ( + "encoding/json" + "github.com/magicbell/magicbell-go/pkg/user-client/internal/unmarshal" + "github.com/magicbell/magicbell-go/pkg/user-client/util" +) + +type Categories struct { + Channels []Channels `json:"channels,omitempty"` + Key *string `json:"key,omitempty" maxLength:"255" pattern:"^[A-Za-z0-9_\.\-/:]+$"` + Label *util.Nullable[string] `json:"label,omitempty" maxLength:"255"` +} + +func (c *Categories) GetChannels() []Channels { + if c == nil { + return nil + } + return c.Channels +} + +func (c *Categories) SetChannels(channels []Channels) { + c.Channels = channels +} + +func (c *Categories) GetKey() *string { + if c == nil { + return nil + } + return c.Key +} + +func (c *Categories) SetKey(key string) { + c.Key = &key +} + +func (c *Categories) GetLabel() *util.Nullable[string] { + if c == nil { + return nil + } + return c.Label +} + +func (c *Categories) SetLabel(label util.Nullable[string]) { + c.Label = &label +} + +func (c *Categories) SetLabelNull() { + c.Label = &util.Nullable[string]{IsNull: true} +} + +func (c Categories) String() string { + jsonData, err := json.MarshalIndent(c, "", " ") + if err != nil { + return "error converting struct: Categories to string" + } + return string(jsonData) +} + +func (c *Categories) UnmarshalJSON(data []byte) error { + return unmarshal.UnmarshalNullable(data, c) +} diff --git a/pkg/user-client/channels/channels.go b/pkg/user-client/channels/channels.go new file mode 100644 index 0000000..4b2f3f9 --- /dev/null +++ b/pkg/user-client/channels/channels.go @@ -0,0 +1,38 @@ +package channels + +import "encoding/json" + +type Channels struct { + Enabled *bool `json:"enabled,omitempty"` + Name *string `json:"name,omitempty"` +} + +func (c *Channels) GetEnabled() *bool { + if c == nil { + return nil + } + return c.Enabled +} + +func (c *Channels) SetEnabled(enabled bool) { + c.Enabled = &enabled +} + +func (c *Channels) GetName() *string { + if c == nil { + return nil + } + return c.Name +} + +func (c *Channels) SetName(name string) { + c.Name = &name +} + +func (c Channels) String() string { + jsonData, err := json.MarshalIndent(c, "", " ") + if err != nil { + return "error converting struct: Channels to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/channels/channels_service.go b/pkg/user-client/channels/channels_service.go index c0340a2..6f6004e 100644 --- a/pkg/user-client/channels/channels_service.go +++ b/pkg/user-client/channels/channels_service.go @@ -3,6 +3,7 @@ package channels import ( "context" restClient "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest" + "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/hooks" "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/httptransport" "github.com/magicbell/magicbell-go/pkg/user-client/internal/configmanager" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" @@ -10,8 +11,11 @@ import ( "time" ) +// ChannelsService provides methods to interact with ChannelsService-related API endpoints. +// It uses a configuration manager for settings and supports custom hooks for request/response interception. type ChannelsService struct { manager *configmanager.ConfigManager + hook hooks.Hook } func NewChannelsService() *ChannelsService { @@ -20,15 +24,28 @@ func NewChannelsService() *ChannelsService { } } +// WithConfigManager sets the configuration manager for this service. +// Returns the service instance for method chaining. func (api *ChannelsService) WithConfigManager(manager *configmanager.ConfigManager) *ChannelsService { api.manager = manager return api } +// WithHook sets a custom hook for request/response interception. +// Returns the service instance for method chaining. +func (api *ChannelsService) WithHook(hook hooks.Hook) *ChannelsService { + api.hook = hook + return api +} + func (api *ChannelsService) getConfig() *clientconfig.Config { return api.manager.GetChannels() } +func (api *ChannelsService) getHook() hooks.Hook { + return api.hook +} + func (api *ChannelsService) SetBaseUrl(baseUrl string) { config := api.getConfig() config.SetBaseUrl(baseUrl) @@ -45,7 +62,7 @@ func (api *ChannelsService) SetAccessToken(accessToken string) { } // Lists all Inbox tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. -func (api *ChannelsService) ListInboxTokens(ctx context.Context, params ListInboxTokensRequestParams) (*shared.ClientResponse[InboxTokenResponseCollection], *shared.ClientError) { +func (api *ChannelsService) ListInboxTokens(ctx context.Context, params ListInboxTokensRequestParams) (*shared.ClientResponse[InboxTokenResponseCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -57,17 +74,17 @@ func (api *ChannelsService) ListInboxTokens(ctx context.Context, params ListInbo WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[InboxTokenResponseCollection](config) + client := restClient.NewRestClient[InboxTokenResponseCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[InboxTokenResponseCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[InboxTokenResponseCollection](resp), nil } // Saves the Inbox token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. -func (api *ChannelsService) SaveInboxToken(ctx context.Context, inboxToken InboxToken) (*shared.ClientResponse[InboxToken], *shared.ClientError) { +func (api *ChannelsService) SaveInboxToken(ctx context.Context, inboxToken InboxToken) (*shared.ClientResponse[InboxToken], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -80,17 +97,17 @@ func (api *ChannelsService) SaveInboxToken(ctx context.Context, inboxToken Inbox WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[InboxToken](config) + client := restClient.NewRestClient[InboxToken, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[InboxToken](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[InboxToken](resp), nil } // Fetches details of a specific Inbox token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. -func (api *ChannelsService) FetchInboxToken(ctx context.Context, tokenId string) (*shared.ClientResponse[InboxTokenResponse], *shared.ClientError) { +func (api *ChannelsService) FetchInboxToken(ctx context.Context, tokenId string) (*shared.ClientResponse[InboxTokenResponse], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -102,17 +119,17 @@ func (api *ChannelsService) FetchInboxToken(ctx context.Context, tokenId string) WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[InboxTokenResponse](config) + client := restClient.NewRestClient[InboxTokenResponse, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[InboxTokenResponse](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[InboxTokenResponse](resp), nil } // Deletes one of the authenticated user's Inbox tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. -func (api *ChannelsService) DeleteInboxToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError) { +func (api *ChannelsService) DeleteInboxToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -124,17 +141,17 @@ func (api *ChannelsService) DeleteInboxToken(ctx context.Context, tokenId string WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[DiscardResult](config) + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[DiscardResult](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[DiscardResult](resp), nil } // Lists all APNs tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. -func (api *ChannelsService) ListApnsTokens(ctx context.Context, params ListApnsTokensRequestParams) (*shared.ClientResponse[ApnsTokenCollection], *shared.ClientError) { +func (api *ChannelsService) ListApnsTokens(ctx context.Context, params ListApnsTokensRequestParams) (*shared.ClientResponse[ApnsTokenCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -146,17 +163,17 @@ func (api *ChannelsService) ListApnsTokens(ctx context.Context, params ListApnsT WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[ApnsTokenCollection](config) + client := restClient.NewRestClient[ApnsTokenCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[ApnsTokenCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[ApnsTokenCollection](resp), nil } // Saves the APNs token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. -func (api *ChannelsService) SaveApnsToken(ctx context.Context, apnsTokenPayload ApnsTokenPayload) (*shared.ClientResponse[ApnsTokenPayload], *shared.ClientError) { +func (api *ChannelsService) SaveApnsToken(ctx context.Context, apnsTokenPayload ApnsTokenPayload) (*shared.ClientResponse[ApnsTokenPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -169,17 +186,17 @@ func (api *ChannelsService) SaveApnsToken(ctx context.Context, apnsTokenPayload WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[ApnsTokenPayload](config) + client := restClient.NewRestClient[ApnsTokenPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[ApnsTokenPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[ApnsTokenPayload](resp), nil } // Fetches details of a specific APNs token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. -func (api *ChannelsService) FetchApnsToken(ctx context.Context, tokenId string) (*shared.ClientResponse[ApnsToken], *shared.ClientError) { +func (api *ChannelsService) FetchApnsToken(ctx context.Context, tokenId string) (*shared.ClientResponse[ApnsToken], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -191,17 +208,17 @@ func (api *ChannelsService) FetchApnsToken(ctx context.Context, tokenId string) WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[ApnsToken](config) + client := restClient.NewRestClient[ApnsToken, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[ApnsToken](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[ApnsToken](resp), nil } // Deletes one of the authenticated user's APNs tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. -func (api *ChannelsService) DeleteApnsToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError) { +func (api *ChannelsService) DeleteApnsToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -213,17 +230,17 @@ func (api *ChannelsService) DeleteApnsToken(ctx context.Context, tokenId string) WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[DiscardResult](config) + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[DiscardResult](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[DiscardResult](resp), nil } // Lists all Expo tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. -func (api *ChannelsService) ListExpoTokens(ctx context.Context, params ListExpoTokensRequestParams) (*shared.ClientResponse[ExpoTokenCollection], *shared.ClientError) { +func (api *ChannelsService) ListExpoTokens(ctx context.Context, params ListExpoTokensRequestParams) (*shared.ClientResponse[ExpoTokenCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -235,17 +252,17 @@ func (api *ChannelsService) ListExpoTokens(ctx context.Context, params ListExpoT WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[ExpoTokenCollection](config) + client := restClient.NewRestClient[ExpoTokenCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[ExpoTokenCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[ExpoTokenCollection](resp), nil } // Saves the Expo token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. -func (api *ChannelsService) SaveExpoToken(ctx context.Context, expoTokenPayload ExpoTokenPayload) (*shared.ClientResponse[ExpoTokenPayload], *shared.ClientError) { +func (api *ChannelsService) SaveExpoToken(ctx context.Context, expoTokenPayload ExpoTokenPayload) (*shared.ClientResponse[ExpoTokenPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -258,17 +275,17 @@ func (api *ChannelsService) SaveExpoToken(ctx context.Context, expoTokenPayload WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[ExpoTokenPayload](config) + client := restClient.NewRestClient[ExpoTokenPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[ExpoTokenPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[ExpoTokenPayload](resp), nil } // Fetches details of a specific Expo token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. -func (api *ChannelsService) FetchExpoToken(ctx context.Context, tokenId string) (*shared.ClientResponse[ExpoToken], *shared.ClientError) { +func (api *ChannelsService) FetchExpoToken(ctx context.Context, tokenId string) (*shared.ClientResponse[ExpoToken], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -280,17 +297,17 @@ func (api *ChannelsService) FetchExpoToken(ctx context.Context, tokenId string) WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[ExpoToken](config) + client := restClient.NewRestClient[ExpoToken, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[ExpoToken](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[ExpoToken](resp), nil } // Deletes one of the authenticated user's Expo tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. -func (api *ChannelsService) DeleteExpoToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError) { +func (api *ChannelsService) DeleteExpoToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -302,17 +319,17 @@ func (api *ChannelsService) DeleteExpoToken(ctx context.Context, tokenId string) WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[DiscardResult](config) + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[DiscardResult](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[DiscardResult](resp), nil } // Lists all FCM tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. -func (api *ChannelsService) ListFcmTokens(ctx context.Context, params ListFcmTokensRequestParams) (*shared.ClientResponse[FcmTokenCollection], *shared.ClientError) { +func (api *ChannelsService) ListFcmTokens(ctx context.Context, params ListFcmTokensRequestParams) (*shared.ClientResponse[FcmTokenCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -324,17 +341,17 @@ func (api *ChannelsService) ListFcmTokens(ctx context.Context, params ListFcmTok WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[FcmTokenCollection](config) + client := restClient.NewRestClient[FcmTokenCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[FcmTokenCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[FcmTokenCollection](resp), nil } // Saves the FCM token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. -func (api *ChannelsService) SaveFcmToken(ctx context.Context, fcmTokenPayload FcmTokenPayload) (*shared.ClientResponse[FcmTokenPayload], *shared.ClientError) { +func (api *ChannelsService) SaveFcmToken(ctx context.Context, fcmTokenPayload FcmTokenPayload) (*shared.ClientResponse[FcmTokenPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -347,17 +364,17 @@ func (api *ChannelsService) SaveFcmToken(ctx context.Context, fcmTokenPayload Fc WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[FcmTokenPayload](config) + client := restClient.NewRestClient[FcmTokenPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[FcmTokenPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[FcmTokenPayload](resp), nil } // Fetches details of a specific FCM token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. -func (api *ChannelsService) FetchFcmToken(ctx context.Context, tokenId string) (*shared.ClientResponse[FcmToken], *shared.ClientError) { +func (api *ChannelsService) FetchFcmToken(ctx context.Context, tokenId string) (*shared.ClientResponse[FcmToken], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -369,17 +386,17 @@ func (api *ChannelsService) FetchFcmToken(ctx context.Context, tokenId string) ( WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[FcmToken](config) + client := restClient.NewRestClient[FcmToken, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[FcmToken](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[FcmToken](resp), nil } // Deletes one of the authenticated user's FCM tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. -func (api *ChannelsService) DeleteFcmToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError) { +func (api *ChannelsService) DeleteFcmToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -391,17 +408,106 @@ func (api *ChannelsService) DeleteFcmToken(ctx context.Context, tokenId string) WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[DiscardResult](config) + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[DiscardResult](err) + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[DiscardResult](resp), nil +} + +// Lists all MagicBell SlackBot tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. +func (api *ChannelsService) ListMagicbellSlackbotTokens(ctx context.Context, params ListMagicbellSlackbotTokensRequestParams) (*shared.ClientResponse[SlackTokenCollection], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("GET"). + WithPath("/channels/slack/magicbell_slackbot/tokens"). + WithConfig(config). + WithOptions(params). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[SlackTokenCollection, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[SlackTokenCollection](resp), nil +} + +// Saves the MagicBell SlackBot token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. +func (api *ChannelsService) SaveMagicbellSlackbotToken(ctx context.Context, slackTokenPayload SlackTokenPayload) (*shared.ClientResponse[SlackTokenPayload], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("PUT"). + WithPath("/channels/slack/magicbell_slackbot/tokens"). + WithConfig(config). + WithBody(slackTokenPayload). + AddHeader("CONTENT-TYPE", "application/json"). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[SlackTokenPayload, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[SlackTokenPayload](resp), nil +} + +// Fetches details of a specific MagicBell SlackBot token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. +func (api *ChannelsService) FetchMagicbellSlackbotToken(ctx context.Context, tokenId string) (*shared.ClientResponse[SlackToken], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("GET"). + WithPath("/channels/slack/magicbell_slackbot/tokens/{token_id}"). + WithConfig(config). + AddPathParam("token_id", tokenId). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[SlackToken, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[SlackToken](resp), nil +} + +// Deletes one of the authenticated user's MagicBell SlackBot tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. +func (api *ChannelsService) DeleteMagicbellSlackbotToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("DELETE"). + WithPath("/channels/slack/magicbell_slackbot/tokens/{token_id}"). + WithConfig(config). + AddPathParam("token_id", tokenId). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[DiscardResult](resp), nil } // Lists all Slack tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. -func (api *ChannelsService) ListSlackTokens(ctx context.Context, params ListSlackTokensRequestParams) (*shared.ClientResponse[SlackTokenCollection], *shared.ClientError) { +func (api *ChannelsService) ListSlackTokens(ctx context.Context, params ListSlackTokensRequestParams) (*shared.ClientResponse[SlackTokenCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -413,17 +519,17 @@ func (api *ChannelsService) ListSlackTokens(ctx context.Context, params ListSlac WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[SlackTokenCollection](config) + client := restClient.NewRestClient[SlackTokenCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[SlackTokenCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[SlackTokenCollection](resp), nil } // Saves the Slack token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. -func (api *ChannelsService) SaveSlackToken(ctx context.Context, slackTokenPayload SlackTokenPayload) (*shared.ClientResponse[SlackTokenPayload], *shared.ClientError) { +func (api *ChannelsService) SaveSlackToken(ctx context.Context, slackTokenPayload SlackTokenPayload) (*shared.ClientResponse[SlackTokenPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -436,17 +542,17 @@ func (api *ChannelsService) SaveSlackToken(ctx context.Context, slackTokenPayloa WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[SlackTokenPayload](config) + client := restClient.NewRestClient[SlackTokenPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[SlackTokenPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[SlackTokenPayload](resp), nil } // Fetches details of a specific Slack token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. -func (api *ChannelsService) FetchSlackToken(ctx context.Context, tokenId string) (*shared.ClientResponse[SlackToken], *shared.ClientError) { +func (api *ChannelsService) FetchSlackToken(ctx context.Context, tokenId string) (*shared.ClientResponse[SlackToken], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -458,17 +564,17 @@ func (api *ChannelsService) FetchSlackToken(ctx context.Context, tokenId string) WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[SlackToken](config) + client := restClient.NewRestClient[SlackToken, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[SlackToken](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[SlackToken](resp), nil } // Deletes one of the authenticated user's Slack tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. -func (api *ChannelsService) DeleteSlackToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError) { +func (api *ChannelsService) DeleteSlackToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -480,17 +586,17 @@ func (api *ChannelsService) DeleteSlackToken(ctx context.Context, tokenId string WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[DiscardResult](config) + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[DiscardResult](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[DiscardResult](resp), nil } // Lists all Teams tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. -func (api *ChannelsService) ListTeamsTokens(ctx context.Context, params ListTeamsTokensRequestParams) (*shared.ClientResponse[TeamsTokenCollection], *shared.ClientError) { +func (api *ChannelsService) ListTeamsTokens(ctx context.Context, params ListTeamsTokensRequestParams) (*shared.ClientResponse[TeamsTokenCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -502,17 +608,17 @@ func (api *ChannelsService) ListTeamsTokens(ctx context.Context, params ListTeam WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[TeamsTokenCollection](config) + client := restClient.NewRestClient[TeamsTokenCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[TeamsTokenCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[TeamsTokenCollection](resp), nil } // Saves the Teams token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. -func (api *ChannelsService) SaveTeamsToken(ctx context.Context, teamsTokenPayload TeamsTokenPayload) (*shared.ClientResponse[TeamsTokenPayload], *shared.ClientError) { +func (api *ChannelsService) SaveTeamsToken(ctx context.Context, teamsTokenPayload TeamsTokenPayload) (*shared.ClientResponse[TeamsTokenPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -525,17 +631,17 @@ func (api *ChannelsService) SaveTeamsToken(ctx context.Context, teamsTokenPayloa WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[TeamsTokenPayload](config) + client := restClient.NewRestClient[TeamsTokenPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[TeamsTokenPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[TeamsTokenPayload](resp), nil } // Fetches details of a specific Teams token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. -func (api *ChannelsService) FetchTeamsToken(ctx context.Context, tokenId string) (*shared.ClientResponse[TeamsToken], *shared.ClientError) { +func (api *ChannelsService) FetchTeamsToken(ctx context.Context, tokenId string) (*shared.ClientResponse[TeamsToken], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -547,17 +653,17 @@ func (api *ChannelsService) FetchTeamsToken(ctx context.Context, tokenId string) WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[TeamsToken](config) + client := restClient.NewRestClient[TeamsToken, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[TeamsToken](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[TeamsToken](resp), nil } // Deletes one of the authenticated user's Teams tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. -func (api *ChannelsService) DeleteTeamsToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError) { +func (api *ChannelsService) DeleteTeamsToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -569,17 +675,61 @@ func (api *ChannelsService) DeleteTeamsToken(ctx context.Context, tokenId string WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[DiscardResult](config) + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[DiscardResult](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[DiscardResult](resp), nil } +// Fetch a user's channel delivery preferences. +func (api *ChannelsService) FetchUserPreferences(ctx context.Context) (*shared.ClientResponse[UserPreferences], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("GET"). + WithPath("/channels/user_preferences"). + WithConfig(config). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[UserPreferences, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[UserPreferences](resp), nil +} + +// Save a user's channel preferences. +func (api *ChannelsService) SaveUserPreferences(ctx context.Context, userPreferences UserPreferences) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("PUT"). + WithPath("/channels/user_preferences"). + WithConfig(config). + WithBody(userPreferences). + AddHeader("CONTENT-TYPE", "application/json"). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[any, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[any](resp), nil +} + // Lists all Web Push tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. -func (api *ChannelsService) ListWebPushTokens(ctx context.Context, params ListWebPushTokensRequestParams) (*shared.ClientResponse[WebPushTokenCollection], *shared.ClientError) { +func (api *ChannelsService) ListWebPushTokens(ctx context.Context, params ListWebPushTokensRequestParams) (*shared.ClientResponse[WebPushTokenCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -591,17 +741,17 @@ func (api *ChannelsService) ListWebPushTokens(ctx context.Context, params ListWe WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[WebPushTokenCollection](config) + client := restClient.NewRestClient[WebPushTokenCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[WebPushTokenCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[WebPushTokenCollection](resp), nil } // Saves the Web Push token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. -func (api *ChannelsService) SaveWebPushToken(ctx context.Context, webPushTokenPayload shared.WebPushTokenPayload) (*shared.ClientResponse[shared.WebPushTokenPayload], *shared.ClientError) { +func (api *ChannelsService) SaveWebPushToken(ctx context.Context, webPushTokenPayload shared.WebPushTokenPayload) (*shared.ClientResponse[shared.WebPushTokenPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -614,17 +764,17 @@ func (api *ChannelsService) SaveWebPushToken(ctx context.Context, webPushTokenPa WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[shared.WebPushTokenPayload](config) + client := restClient.NewRestClient[shared.WebPushTokenPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[shared.WebPushTokenPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[shared.WebPushTokenPayload](resp), nil } // Fetches details of a specific Web Push token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. -func (api *ChannelsService) FetchWebPushToken(ctx context.Context, tokenId string) (*shared.ClientResponse[WebPushToken], *shared.ClientError) { +func (api *ChannelsService) FetchWebPushToken(ctx context.Context, tokenId string) (*shared.ClientResponse[WebPushToken], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -636,17 +786,17 @@ func (api *ChannelsService) FetchWebPushToken(ctx context.Context, tokenId strin WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[WebPushToken](config) + client := restClient.NewRestClient[WebPushToken, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[WebPushToken](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[WebPushToken](resp), nil } // Deletes one of the authenticated user's Web Push tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. -func (api *ChannelsService) DeleteWebPushToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError) { +func (api *ChannelsService) DeleteWebPushToken(ctx context.Context, tokenId string) (*shared.ClientResponse[DiscardResult], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -658,10 +808,10 @@ func (api *ChannelsService) DeleteWebPushToken(ctx context.Context, tokenId stri WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[DiscardResult](config) + client := restClient.NewRestClient[DiscardResult, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[DiscardResult](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[DiscardResult](resp), nil diff --git a/pkg/user-client/channels/discard_result.go b/pkg/user-client/channels/discard_result.go index 47c1493..fe18ee9 100644 --- a/pkg/user-client/channels/discard_result.go +++ b/pkg/user-client/channels/discard_result.go @@ -3,8 +3,10 @@ package channels import "encoding/json" type DiscardResult struct { + // The timestamp when the token was discarded. DiscardedAt *string `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty"` + // The unique identifier for the discarded token. + Id *string `json:"id,omitempty"` } func (d *DiscardResult) GetDiscardedAt() *string { diff --git a/pkg/user-client/channels/expo_token.go b/pkg/user-client/channels/expo_token.go index 0314611..bf28cc4 100644 --- a/pkg/user-client/channels/expo_token.go +++ b/pkg/user-client/channels/expo_token.go @@ -7,11 +7,16 @@ import ( ) type ExpoToken struct { - CreatedAt *string `json:"created_at,omitempty" required:"true"` - DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"1"` + // The timestamp when the token was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The Expo push token returned by the Expo client. + DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"1"` + // The timestamp when the token was discarded, if applicable. DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` + // The unique identifier for the token. + Id *string `json:"id,omitempty" required:"true"` + // The timestamp when the token metadata last changed. + UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` } func (e *ExpoToken) GetCreatedAt() *string { diff --git a/pkg/user-client/channels/expo_token_payload.go b/pkg/user-client/channels/expo_token_payload.go index 160727c..da8149c 100644 --- a/pkg/user-client/channels/expo_token_payload.go +++ b/pkg/user-client/channels/expo_token_payload.go @@ -3,6 +3,7 @@ package channels import "encoding/json" type ExpoTokenPayload struct { + // The Expo push token returned by the Expo client. DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"1"` } diff --git a/pkg/user-client/channels/fcm_token.go b/pkg/user-client/channels/fcm_token.go index 60afb5a..7544eb6 100644 --- a/pkg/user-client/channels/fcm_token.go +++ b/pkg/user-client/channels/fcm_token.go @@ -7,12 +7,16 @@ import ( ) type FcmToken struct { - CreatedAt *string `json:"created_at,omitempty" required:"true"` - DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"64"` - DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - InstallationId *FcmTokenInstallationId `json:"installation_id,omitempty"` - UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` + // The timestamp when the token was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The Firebase Cloud Messaging device registration token to associate with the user. + DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"64"` + // The timestamp when the token was discarded, if applicable. + DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` + // The unique identifier for the token. + Id *string `json:"id,omitempty" required:"true"` + // The timestamp when the token metadata last changed. + UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` } func (f *FcmToken) GetCreatedAt() *string { @@ -63,17 +67,6 @@ func (f *FcmToken) SetId(id string) { f.Id = &id } -func (f *FcmToken) GetInstallationId() *FcmTokenInstallationId { - if f == nil { - return nil - } - return f.InstallationId -} - -func (f *FcmToken) SetInstallationId(installationId FcmTokenInstallationId) { - f.InstallationId = &installationId -} - func (f *FcmToken) GetUpdatedAt() *util.Nullable[string] { if f == nil { return nil @@ -100,10 +93,3 @@ func (f FcmToken) String() string { func (f *FcmToken) UnmarshalJSON(data []byte) error { return unmarshal.UnmarshalNullable(data, f) } - -type FcmTokenInstallationId string - -const ( - FCM_TOKEN_INSTALLATION_ID_DEVELOPMENT FcmTokenInstallationId = "development" - FCM_TOKEN_INSTALLATION_ID_PRODUCTION FcmTokenInstallationId = "production" -) diff --git a/pkg/user-client/channels/fcm_token_payload.go b/pkg/user-client/channels/fcm_token_payload.go index b40286b..1b6c26b 100644 --- a/pkg/user-client/channels/fcm_token_payload.go +++ b/pkg/user-client/channels/fcm_token_payload.go @@ -3,8 +3,8 @@ package channels import "encoding/json" type FcmTokenPayload struct { - DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"64"` - InstallationId *FcmTokenPayloadInstallationId `json:"installation_id,omitempty"` + // The Firebase Cloud Messaging device registration token to associate with the user. + DeviceToken *string `json:"device_token,omitempty" required:"true" minLength:"64"` } func (f *FcmTokenPayload) GetDeviceToken() *string { @@ -18,17 +18,6 @@ func (f *FcmTokenPayload) SetDeviceToken(deviceToken string) { f.DeviceToken = &deviceToken } -func (f *FcmTokenPayload) GetInstallationId() *FcmTokenPayloadInstallationId { - if f == nil { - return nil - } - return f.InstallationId -} - -func (f *FcmTokenPayload) SetInstallationId(installationId FcmTokenPayloadInstallationId) { - f.InstallationId = &installationId -} - func (f FcmTokenPayload) String() string { jsonData, err := json.MarshalIndent(f, "", " ") if err != nil { @@ -36,10 +25,3 @@ func (f FcmTokenPayload) String() string { } return string(jsonData) } - -type FcmTokenPayloadInstallationId string - -const ( - FCM_TOKEN_PAYLOAD_INSTALLATION_ID_DEVELOPMENT FcmTokenPayloadInstallationId = "development" - FCM_TOKEN_PAYLOAD_INSTALLATION_ID_PRODUCTION FcmTokenPayloadInstallationId = "production" -) diff --git a/pkg/user-client/channels/inbox_token.go b/pkg/user-client/channels/inbox_token.go index b9e89f3..800c51c 100644 --- a/pkg/user-client/channels/inbox_token.go +++ b/pkg/user-client/channels/inbox_token.go @@ -7,8 +7,10 @@ import ( ) type InboxToken struct { + // Realtime connection ID to restrict delivery to a specific Ably connection. ConnectionId *util.Nullable[string] `json:"connection_id,omitempty"` - Token *string `json:"token,omitempty" required:"true" minLength:"64"` + // The in-app inbox token generated for this user. + Token *string `json:"token,omitempty" required:"true" minLength:"64"` } func (i *InboxToken) GetConnectionId() *util.Nullable[string] { diff --git a/pkg/user-client/channels/inbox_token_response.go b/pkg/user-client/channels/inbox_token_response.go index 8396169..7111315 100644 --- a/pkg/user-client/channels/inbox_token_response.go +++ b/pkg/user-client/channels/inbox_token_response.go @@ -7,12 +7,18 @@ import ( ) type InboxTokenResponse struct { + // Realtime connection ID to restrict delivery to a specific Ably connection. ConnectionId *util.Nullable[string] `json:"connection_id,omitempty"` - CreatedAt *string `json:"created_at,omitempty" required:"true"` - DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - Token *string `json:"token,omitempty" required:"true" minLength:"64"` - UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` + // The timestamp when the token was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The timestamp when the token was discarded, if applicable. + DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` + // The unique identifier for the token. + Id *string `json:"id,omitempty" required:"true"` + // The in-app inbox token generated for this user. + Token *string `json:"token,omitempty" required:"true" minLength:"64"` + // The timestamp when the token metadata last changed. + UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` } func (i *InboxTokenResponse) GetConnectionId() *util.Nullable[string] { diff --git a/pkg/user-client/channels/request_params.go b/pkg/user-client/channels/request_params.go index b5b5e86..e1398b4 100644 --- a/pkg/user-client/channels/request_params.go +++ b/pkg/user-client/channels/request_params.go @@ -1,113 +1,185 @@ package channels +// ListInboxTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListInboxTokensRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListInboxTokensRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListInboxTokensRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListInboxTokensRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } +// ListApnsTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListApnsTokensRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListApnsTokensRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListApnsTokensRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListApnsTokensRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } +// ListExpoTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListExpoTokensRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListExpoTokensRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListExpoTokensRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListExpoTokensRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } +// ListFcmTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListFcmTokensRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListFcmTokensRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListFcmTokensRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListFcmTokensRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } +// ListMagicbellSlackbotTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. +type ListMagicbellSlackbotTokensRequestParams struct { + Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` + StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` + EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` +} + +// SetLimit sets the Limit parameter. +func (params *ListMagicbellSlackbotTokensRequestParams) SetLimit(limit int64) { + params.Limit = &limit +} + +// SetStartingAfter sets the StartingAfter parameter. +func (params *ListMagicbellSlackbotTokensRequestParams) SetStartingAfter(startingAfter string) { + params.StartingAfter = &startingAfter +} + +// SetEndingBefore sets the EndingBefore parameter. +func (params *ListMagicbellSlackbotTokensRequestParams) SetEndingBefore(endingBefore string) { + params.EndingBefore = &endingBefore +} + +// ListSlackTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListSlackTokensRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListSlackTokensRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListSlackTokensRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListSlackTokensRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } +// ListTeamsTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListTeamsTokensRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListTeamsTokensRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListTeamsTokensRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListTeamsTokensRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } +// ListWebPushTokensRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListWebPushTokensRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` EndingBefore *string `explode:"true" serializationStyle:"form" queryParam:"ending_before"` } +// SetLimit sets the Limit parameter. func (params *ListWebPushTokensRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListWebPushTokensRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListWebPushTokensRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } diff --git a/pkg/user-client/channels/slack_token.go b/pkg/user-client/channels/slack_token.go index 7d661d8..64a54a3 100644 --- a/pkg/user-client/channels/slack_token.go +++ b/pkg/user-client/channels/slack_token.go @@ -7,11 +7,15 @@ import ( ) type SlackToken struct { - CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The timestamp when the token was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The timestamp when the token was discarded, if applicable. DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - Oauth *SlackTokenOauth `json:"oauth,omitempty"` - UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` + // The unique identifier for the token. + Id *string `json:"id,omitempty" required:"true"` + Oauth *SlackTokenOauth `json:"oauth,omitempty"` + // The timestamp when the token metadata last changed. + UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` // Obtained directly from the incoming_webhook object in the installation response from the Slack API. Webhook *SlackTokenWebhook `json:"webhook,omitempty"` } @@ -101,74 +105,3 @@ func (s SlackToken) String() string { func (s *SlackToken) UnmarshalJSON(data []byte) error { return unmarshal.UnmarshalNullable(data, s) } - -type SlackTokenOauth struct { - ChannelId *string `json:"channel_id,omitempty" required:"true"` - InstallationId *string `json:"installation_id,omitempty" required:"true"` - Scope *string `json:"scope,omitempty"` -} - -func (s *SlackTokenOauth) GetChannelId() *string { - if s == nil { - return nil - } - return s.ChannelId -} - -func (s *SlackTokenOauth) SetChannelId(channelId string) { - s.ChannelId = &channelId -} - -func (s *SlackTokenOauth) GetInstallationId() *string { - if s == nil { - return nil - } - return s.InstallationId -} - -func (s *SlackTokenOauth) SetInstallationId(installationId string) { - s.InstallationId = &installationId -} - -func (s *SlackTokenOauth) GetScope() *string { - if s == nil { - return nil - } - return s.Scope -} - -func (s *SlackTokenOauth) SetScope(scope string) { - s.Scope = &scope -} - -func (s SlackTokenOauth) String() string { - jsonData, err := json.MarshalIndent(s, "", " ") - if err != nil { - return "error converting struct: SlackTokenOauth to string" - } - return string(jsonData) -} - -// Obtained directly from the incoming_webhook object in the installation response from the Slack API. -type SlackTokenWebhook struct { - Url *string `json:"url,omitempty" required:"true" minLength:"1"` -} - -func (s *SlackTokenWebhook) GetUrl() *string { - if s == nil { - return nil - } - return s.Url -} - -func (s *SlackTokenWebhook) SetUrl(url string) { - s.Url = &url -} - -func (s SlackTokenWebhook) String() string { - jsonData, err := json.MarshalIndent(s, "", " ") - if err != nil { - return "error converting struct: SlackTokenWebhook to string" - } - return string(jsonData) -} diff --git a/pkg/user-client/channels/slack_token_oauth.go b/pkg/user-client/channels/slack_token_oauth.go new file mode 100644 index 0000000..f74b7a9 --- /dev/null +++ b/pkg/user-client/channels/slack_token_oauth.go @@ -0,0 +1,53 @@ +package channels + +import "encoding/json" + +type SlackTokenOauth struct { + // The ID of the Slack channel this installation is associated with + ChannelId *string `json:"channel_id,omitempty" required:"true"` + // A unique identifier for this Slack workspace installation + InstallationId *string `json:"installation_id,omitempty" required:"true"` + // The OAuth scope granted during installation + Scope *string `json:"scope,omitempty"` +} + +func (s *SlackTokenOauth) GetChannelId() *string { + if s == nil { + return nil + } + return s.ChannelId +} + +func (s *SlackTokenOauth) SetChannelId(channelId string) { + s.ChannelId = &channelId +} + +func (s *SlackTokenOauth) GetInstallationId() *string { + if s == nil { + return nil + } + return s.InstallationId +} + +func (s *SlackTokenOauth) SetInstallationId(installationId string) { + s.InstallationId = &installationId +} + +func (s *SlackTokenOauth) GetScope() *string { + if s == nil { + return nil + } + return s.Scope +} + +func (s *SlackTokenOauth) SetScope(scope string) { + s.Scope = &scope +} + +func (s SlackTokenOauth) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SlackTokenOauth to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/channels/slack_token_payload.go b/pkg/user-client/channels/slack_token_payload.go index 0ae0e75..2d1b68e 100644 --- a/pkg/user-client/channels/slack_token_payload.go +++ b/pkg/user-client/channels/slack_token_payload.go @@ -37,74 +37,3 @@ func (s SlackTokenPayload) String() string { } return string(jsonData) } - -type SlackTokenPayloadOauth struct { - ChannelId *string `json:"channel_id,omitempty" required:"true"` - InstallationId *string `json:"installation_id,omitempty" required:"true"` - Scope *string `json:"scope,omitempty"` -} - -func (s *SlackTokenPayloadOauth) GetChannelId() *string { - if s == nil { - return nil - } - return s.ChannelId -} - -func (s *SlackTokenPayloadOauth) SetChannelId(channelId string) { - s.ChannelId = &channelId -} - -func (s *SlackTokenPayloadOauth) GetInstallationId() *string { - if s == nil { - return nil - } - return s.InstallationId -} - -func (s *SlackTokenPayloadOauth) SetInstallationId(installationId string) { - s.InstallationId = &installationId -} - -func (s *SlackTokenPayloadOauth) GetScope() *string { - if s == nil { - return nil - } - return s.Scope -} - -func (s *SlackTokenPayloadOauth) SetScope(scope string) { - s.Scope = &scope -} - -func (s SlackTokenPayloadOauth) String() string { - jsonData, err := json.MarshalIndent(s, "", " ") - if err != nil { - return "error converting struct: SlackTokenPayloadOauth to string" - } - return string(jsonData) -} - -// Obtained directly from the incoming_webhook object in the installation response from the Slack API. -type SlackTokenPayloadWebhook struct { - Url *string `json:"url,omitempty" required:"true" minLength:"1"` -} - -func (s *SlackTokenPayloadWebhook) GetUrl() *string { - if s == nil { - return nil - } - return s.Url -} - -func (s *SlackTokenPayloadWebhook) SetUrl(url string) { - s.Url = &url -} - -func (s SlackTokenPayloadWebhook) String() string { - jsonData, err := json.MarshalIndent(s, "", " ") - if err != nil { - return "error converting struct: SlackTokenPayloadWebhook to string" - } - return string(jsonData) -} diff --git a/pkg/user-client/channels/slack_token_payload_oauth.go b/pkg/user-client/channels/slack_token_payload_oauth.go new file mode 100644 index 0000000..96873b3 --- /dev/null +++ b/pkg/user-client/channels/slack_token_payload_oauth.go @@ -0,0 +1,53 @@ +package channels + +import "encoding/json" + +type SlackTokenPayloadOauth struct { + // The ID of the Slack channel this installation is associated with + ChannelId *string `json:"channel_id,omitempty" required:"true"` + // A unique identifier for this Slack workspace installation + InstallationId *string `json:"installation_id,omitempty" required:"true"` + // The OAuth scope granted during installation + Scope *string `json:"scope,omitempty"` +} + +func (s *SlackTokenPayloadOauth) GetChannelId() *string { + if s == nil { + return nil + } + return s.ChannelId +} + +func (s *SlackTokenPayloadOauth) SetChannelId(channelId string) { + s.ChannelId = &channelId +} + +func (s *SlackTokenPayloadOauth) GetInstallationId() *string { + if s == nil { + return nil + } + return s.InstallationId +} + +func (s *SlackTokenPayloadOauth) SetInstallationId(installationId string) { + s.InstallationId = &installationId +} + +func (s *SlackTokenPayloadOauth) GetScope() *string { + if s == nil { + return nil + } + return s.Scope +} + +func (s *SlackTokenPayloadOauth) SetScope(scope string) { + s.Scope = &scope +} + +func (s SlackTokenPayloadOauth) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SlackTokenPayloadOauth to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/channels/slack_token_payload_webhook.go b/pkg/user-client/channels/slack_token_payload_webhook.go new file mode 100644 index 0000000..1d6ccb3 --- /dev/null +++ b/pkg/user-client/channels/slack_token_payload_webhook.go @@ -0,0 +1,28 @@ +package channels + +import "encoding/json" + +// Obtained directly from the incoming_webhook object in the installation response from the Slack API. +type SlackTokenPayloadWebhook struct { + // The URL for the incoming webhook from Slack + Url *string `json:"url,omitempty" required:"true" minLength:"1"` +} + +func (s *SlackTokenPayloadWebhook) GetUrl() *string { + if s == nil { + return nil + } + return s.Url +} + +func (s *SlackTokenPayloadWebhook) SetUrl(url string) { + s.Url = &url +} + +func (s SlackTokenPayloadWebhook) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SlackTokenPayloadWebhook to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/channels/slack_token_webhook.go b/pkg/user-client/channels/slack_token_webhook.go new file mode 100644 index 0000000..28b257a --- /dev/null +++ b/pkg/user-client/channels/slack_token_webhook.go @@ -0,0 +1,28 @@ +package channels + +import "encoding/json" + +// Obtained directly from the incoming_webhook object in the installation response from the Slack API. +type SlackTokenWebhook struct { + // The URL for the incoming webhook from Slack + Url *string `json:"url,omitempty" required:"true" minLength:"1"` +} + +func (s *SlackTokenWebhook) GetUrl() *string { + if s == nil { + return nil + } + return s.Url +} + +func (s *SlackTokenWebhook) SetUrl(url string) { + s.Url = &url +} + +func (s SlackTokenWebhook) String() string { + jsonData, err := json.MarshalIndent(s, "", " ") + if err != nil { + return "error converting struct: SlackTokenWebhook to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/channels/teams_token.go b/pkg/user-client/channels/teams_token.go index 5cdbe3e..94fc00b 100644 --- a/pkg/user-client/channels/teams_token.go +++ b/pkg/user-client/channels/teams_token.go @@ -7,11 +7,15 @@ import ( ) type TeamsToken struct { - CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The timestamp when the token was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The timestamp when the token was discarded, if applicable. DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` - Webhook *TeamsTokenWebhook `json:"webhook,omitempty"` + // The unique identifier for the token. + Id *string `json:"id,omitempty" required:"true"` + // The timestamp when the token metadata last changed. + UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` + Webhook *TeamsTokenWebhook `json:"webhook,omitempty"` } func (t *TeamsToken) GetCreatedAt() *string { @@ -88,26 +92,3 @@ func (t TeamsToken) String() string { func (t *TeamsToken) UnmarshalJSON(data []byte) error { return unmarshal.UnmarshalNullable(data, t) } - -type TeamsTokenWebhook struct { - Url *string `json:"url,omitempty"` -} - -func (t *TeamsTokenWebhook) GetUrl() *string { - if t == nil { - return nil - } - return t.Url -} - -func (t *TeamsTokenWebhook) SetUrl(url string) { - t.Url = &url -} - -func (t TeamsTokenWebhook) String() string { - jsonData, err := json.MarshalIndent(t, "", " ") - if err != nil { - return "error converting struct: TeamsTokenWebhook to string" - } - return string(jsonData) -} diff --git a/pkg/user-client/channels/teams_token_payload.go b/pkg/user-client/channels/teams_token_payload.go index 1f97fb4..96407ec 100644 --- a/pkg/user-client/channels/teams_token_payload.go +++ b/pkg/user-client/channels/teams_token_payload.go @@ -24,26 +24,3 @@ func (t TeamsTokenPayload) String() string { } return string(jsonData) } - -type TeamsTokenPayloadWebhook struct { - Url *string `json:"url,omitempty"` -} - -func (t *TeamsTokenPayloadWebhook) GetUrl() *string { - if t == nil { - return nil - } - return t.Url -} - -func (t *TeamsTokenPayloadWebhook) SetUrl(url string) { - t.Url = &url -} - -func (t TeamsTokenPayloadWebhook) String() string { - jsonData, err := json.MarshalIndent(t, "", " ") - if err != nil { - return "error converting struct: TeamsTokenPayloadWebhook to string" - } - return string(jsonData) -} diff --git a/pkg/user-client/channels/teams_token_payload_webhook.go b/pkg/user-client/channels/teams_token_payload_webhook.go new file mode 100644 index 0000000..27be5c8 --- /dev/null +++ b/pkg/user-client/channels/teams_token_payload_webhook.go @@ -0,0 +1,26 @@ +package channels + +import "encoding/json" + +type TeamsTokenPayloadWebhook struct { + Url *string `json:"url,omitempty"` +} + +func (t *TeamsTokenPayloadWebhook) GetUrl() *string { + if t == nil { + return nil + } + return t.Url +} + +func (t *TeamsTokenPayloadWebhook) SetUrl(url string) { + t.Url = &url +} + +func (t TeamsTokenPayloadWebhook) String() string { + jsonData, err := json.MarshalIndent(t, "", " ") + if err != nil { + return "error converting struct: TeamsTokenPayloadWebhook to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/channels/teams_token_webhook.go b/pkg/user-client/channels/teams_token_webhook.go new file mode 100644 index 0000000..ce2c616 --- /dev/null +++ b/pkg/user-client/channels/teams_token_webhook.go @@ -0,0 +1,26 @@ +package channels + +import "encoding/json" + +type TeamsTokenWebhook struct { + Url *string `json:"url,omitempty"` +} + +func (t *TeamsTokenWebhook) GetUrl() *string { + if t == nil { + return nil + } + return t.Url +} + +func (t *TeamsTokenWebhook) SetUrl(url string) { + t.Url = &url +} + +func (t TeamsTokenWebhook) String() string { + jsonData, err := json.MarshalIndent(t, "", " ") + if err != nil { + return "error converting struct: TeamsTokenWebhook to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/channels/user_preferences.go b/pkg/user-client/channels/user_preferences.go new file mode 100644 index 0000000..d82d279 --- /dev/null +++ b/pkg/user-client/channels/user_preferences.go @@ -0,0 +1,26 @@ +package channels + +import "encoding/json" + +type UserPreferences struct { + Categories []Categories `json:"categories,omitempty"` +} + +func (u *UserPreferences) GetCategories() []Categories { + if u == nil { + return nil + } + return u.Categories +} + +func (u *UserPreferences) SetCategories(categories []Categories) { + u.Categories = categories +} + +func (u UserPreferences) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: UserPreferences to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/channels/web_push_token.go b/pkg/user-client/channels/web_push_token.go index 9d58c56..efdab1c 100644 --- a/pkg/user-client/channels/web_push_token.go +++ b/pkg/user-client/channels/web_push_token.go @@ -7,13 +7,17 @@ import ( ) type WebPushToken struct { - CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The timestamp when the token was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The timestamp when the token was discarded, if applicable. DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` // The push subscription URL obtained from PushSubscription.endpoint after calling registration.pushManager.subscribe(). This is the unique URL for this device that push messages will be sent to. Endpoint *string `json:"endpoint,omitempty" required:"true"` - Id *string `json:"id,omitempty" required:"true"` + // The unique identifier for the token. + Id *string `json:"id,omitempty" required:"true"` // The encryption keys from the PushSubscription.getKey() method, needed to encrypt push messages for this subscription. - Keys *WebPushTokenKeys `json:"keys,omitempty" required:"true"` + Keys *WebPushTokenKeys `json:"keys,omitempty" required:"true"` + // The timestamp when the token metadata last changed. UpdatedAt *util.Nullable[string] `json:"updated_at,omitempty"` } @@ -102,41 +106,3 @@ func (w WebPushToken) String() string { func (w *WebPushToken) UnmarshalJSON(data []byte) error { return unmarshal.UnmarshalNullable(data, w) } - -// The encryption keys from the PushSubscription.getKey() method, needed to encrypt push messages for this subscription. -type WebPushTokenKeys struct { - // The authentication secret obtained from PushSubscription.getKey('auth'). Used to encrypt push messages for this subscription. - Auth *string `json:"auth,omitempty" required:"true"` - // The P-256 ECDH public key obtained from PushSubscription.getKey('p256dh'). Used to encrypt push messages for this subscription. - P256dh *string `json:"p256dh,omitempty" required:"true"` -} - -func (w *WebPushTokenKeys) GetAuth() *string { - if w == nil { - return nil - } - return w.Auth -} - -func (w *WebPushTokenKeys) SetAuth(auth string) { - w.Auth = &auth -} - -func (w *WebPushTokenKeys) GetP256dh() *string { - if w == nil { - return nil - } - return w.P256dh -} - -func (w *WebPushTokenKeys) SetP256dh(p256dh string) { - w.P256dh = &p256dh -} - -func (w WebPushTokenKeys) String() string { - jsonData, err := json.MarshalIndent(w, "", " ") - if err != nil { - return "error converting struct: WebPushTokenKeys to string" - } - return string(jsonData) -} diff --git a/pkg/user-client/channels/web_push_token_keys.go b/pkg/user-client/channels/web_push_token_keys.go new file mode 100644 index 0000000..77d977f --- /dev/null +++ b/pkg/user-client/channels/web_push_token_keys.go @@ -0,0 +1,41 @@ +package channels + +import "encoding/json" + +// The encryption keys from the PushSubscription.getKey() method, needed to encrypt push messages for this subscription. +type WebPushTokenKeys struct { + // The authentication secret obtained from PushSubscription.getKey('auth'). Used to encrypt push messages for this subscription. + Auth *string `json:"auth,omitempty" required:"true"` + // The P-256 ECDH public key obtained from PushSubscription.getKey('p256dh'). Used to encrypt push messages for this subscription. + P256dh *string `json:"p256dh,omitempty" required:"true"` +} + +func (w *WebPushTokenKeys) GetAuth() *string { + if w == nil { + return nil + } + return w.Auth +} + +func (w *WebPushTokenKeys) SetAuth(auth string) { + w.Auth = &auth +} + +func (w *WebPushTokenKeys) GetP256dh() *string { + if w == nil { + return nil + } + return w.P256dh +} + +func (w *WebPushTokenKeys) SetP256dh(p256dh string) { + w.P256dh = &p256dh +} + +func (w WebPushTokenKeys) String() string { + jsonData, err := json.MarshalIndent(w, "", " ") + if err != nil { + return "error converting struct: WebPushTokenKeys to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/client/client.go b/pkg/user-client/client/client.go index 9f4f24c..2768d97 100644 --- a/pkg/user-client/client/client.go +++ b/pkg/user-client/client/client.go @@ -1,6 +1,7 @@ package client import ( + "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/hooks" "github.com/magicbell/magicbell-go/pkg/user-client/internal/configmanager" "github.com/magicbell/magicbell-go/pkg/user-client/channels" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" @@ -9,6 +10,8 @@ import ( "time" ) +// Client is the main SDK client that provides access to all service endpoints. +// It manages configuration, authentication, and service instances with centralized settings. type Client struct { Channels *channels.ChannelsService Integrations *integrations.IntegrationsService @@ -22,9 +25,13 @@ func NewClient(config clientconfig.Config) *Client { notifications := notifications.NewNotificationsService() manager := configmanager.NewConfigManager(config) + hook := hooks.NewDefaultHook() channels.WithConfigManager(manager) integrations.WithConfigManager(manager) notifications.WithConfigManager(manager) + channels.WithHook(hook) + integrations.WithHook(hook) + notifications.WithHook(hook) return &Client{ Channels: channels, diff --git a/pkg/user-client/clientconfig/config.go b/pkg/user-client/clientconfig/config.go index c98e36e..bde446e 100644 --- a/pkg/user-client/clientconfig/config.go +++ b/pkg/user-client/clientconfig/config.go @@ -1,14 +1,23 @@ package clientconfig -import "time" +import ( + "time" + "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/hooks" +) + +// Config holds all configuration parameters for the SDK client. +// It manages base URL, timeout, authentication credentials, and custom hooks. type Config struct { BaseUrl *string Timeout *time.Duration AccessToken *string HookParams map[string]string + hook hooks.Hook } +// NewConfig creates a new Config instance with default values. +// Sets the base URL to the default environment and timeout to 10 seconds. func NewConfig() Config { baseUrl := DEFAULT_ENVIRONMENT timeout := time.Second * 10 diff --git a/pkg/user-client/clientconfig/environments.go b/pkg/user-client/clientconfig/environments.go index 9993362..10b97cd 100644 --- a/pkg/user-client/clientconfig/environments.go +++ b/pkg/user-client/clientconfig/environments.go @@ -1,5 +1,7 @@ package clientconfig +// Environment constants define the available base URLs for different deployment environments. +// Use these constants when configuring the SDK client. const ( DEFAULT_ENVIRONMENT = "https://api.magicbell.com/v2" ) diff --git a/pkg/user-client/integrations/authed_user.go b/pkg/user-client/integrations/authed_user.go new file mode 100644 index 0000000..9defce8 --- /dev/null +++ b/pkg/user-client/integrations/authed_user.go @@ -0,0 +1,92 @@ +package integrations + +import "encoding/json" + +type AuthedUser struct { + // User token returned from the OAuth exchange. + AccessToken *string `json:"access_token,omitempty"` + // Seconds until the user token expires. + ExpiresIn *int64 `json:"expires_in,omitempty"` + // Slack user ID for the installer. + Id *string `json:"id,omitempty" required:"true"` + // Refresh token for the authed user. + RefreshToken *string `json:"refresh_token,omitempty"` + // Space-delimited OAuth scopes granted to the user token. + Scope *string `json:"scope,omitempty"` + // Token type value provided by Slack. + TokenType *string `json:"token_type,omitempty"` +} + +func (a *AuthedUser) GetAccessToken() *string { + if a == nil { + return nil + } + return a.AccessToken +} + +func (a *AuthedUser) SetAccessToken(accessToken string) { + a.AccessToken = &accessToken +} + +func (a *AuthedUser) GetExpiresIn() *int64 { + if a == nil { + return nil + } + return a.ExpiresIn +} + +func (a *AuthedUser) SetExpiresIn(expiresIn int64) { + a.ExpiresIn = &expiresIn +} + +func (a *AuthedUser) GetId() *string { + if a == nil { + return nil + } + return a.Id +} + +func (a *AuthedUser) SetId(id string) { + a.Id = &id +} + +func (a *AuthedUser) GetRefreshToken() *string { + if a == nil { + return nil + } + return a.RefreshToken +} + +func (a *AuthedUser) SetRefreshToken(refreshToken string) { + a.RefreshToken = &refreshToken +} + +func (a *AuthedUser) GetScope() *string { + if a == nil { + return nil + } + return a.Scope +} + +func (a *AuthedUser) SetScope(scope string) { + a.Scope = &scope +} + +func (a *AuthedUser) GetTokenType() *string { + if a == nil { + return nil + } + return a.TokenType +} + +func (a *AuthedUser) SetTokenType(tokenType string) { + a.TokenType = &tokenType +} + +func (a AuthedUser) String() string { + jsonData, err := json.MarshalIndent(a, "", " ") + if err != nil { + return "error converting struct: AuthedUser to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/banner.go b/pkg/user-client/integrations/banner.go new file mode 100644 index 0000000..e8209df --- /dev/null +++ b/pkg/user-client/integrations/banner.go @@ -0,0 +1,67 @@ +package integrations + +import "encoding/json" + +// Top banner styling options. +type Banner struct { + // Banner background color. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` + // Opacity applied to the banner background. + BackgroundOpacity *float64 `json:"backgroundOpacity,omitempty"` + // Font size for banner text. + FontSize *string `json:"fontSize,omitempty" required:"true"` + // Banner text color. + TextColor *string `json:"textColor,omitempty" required:"true"` +} + +func (b *Banner) GetBackgroundColor() *string { + if b == nil { + return nil + } + return b.BackgroundColor +} + +func (b *Banner) SetBackgroundColor(backgroundColor string) { + b.BackgroundColor = &backgroundColor +} + +func (b *Banner) GetBackgroundOpacity() *float64 { + if b == nil { + return nil + } + return b.BackgroundOpacity +} + +func (b *Banner) SetBackgroundOpacity(backgroundOpacity float64) { + b.BackgroundOpacity = &backgroundOpacity +} + +func (b *Banner) GetFontSize() *string { + if b == nil { + return nil + } + return b.FontSize +} + +func (b *Banner) SetFontSize(fontSize string) { + b.FontSize = &fontSize +} + +func (b *Banner) GetTextColor() *string { + if b == nil { + return nil + } + return b.TextColor +} + +func (b *Banner) SetTextColor(textColor string) { + b.TextColor = &textColor +} + +func (b Banner) String() string { + jsonData, err := json.MarshalIndent(b, "", " ") + if err != nil { + return "error converting struct: Banner to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/default_.go b/pkg/user-client/integrations/default_.go new file mode 100644 index 0000000..f0a19b3 --- /dev/null +++ b/pkg/user-client/integrations/default_.go @@ -0,0 +1,119 @@ +package integrations + +import "encoding/json" + +// Base styles applied to every notification item. +type Default_ struct { + // Background color for notifications in their default state. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` + // Border radius applied to each notification card. + BorderRadius *string `json:"borderRadius,omitempty" required:"true"` + // Font family for notification text. + FontFamily *string `json:"fontFamily,omitempty" required:"true"` + // Font size for notification text. + FontSize *string `json:"fontSize,omitempty" required:"true"` + // Styles applied when a notification is hovered. + Hover *DefaultHover `json:"hover,omitempty"` + // CSS margin applied around each notification card. + Margin *string `json:"margin,omitempty" required:"true"` + // Accent colors for notification state indicators. + State *DefaultState `json:"state,omitempty"` + // Default text color for notifications. + TextColor *string `json:"textColor,omitempty" required:"true"` +} + +func (d *Default_) GetBackgroundColor() *string { + if d == nil { + return nil + } + return d.BackgroundColor +} + +func (d *Default_) SetBackgroundColor(backgroundColor string) { + d.BackgroundColor = &backgroundColor +} + +func (d *Default_) GetBorderRadius() *string { + if d == nil { + return nil + } + return d.BorderRadius +} + +func (d *Default_) SetBorderRadius(borderRadius string) { + d.BorderRadius = &borderRadius +} + +func (d *Default_) GetFontFamily() *string { + if d == nil { + return nil + } + return d.FontFamily +} + +func (d *Default_) SetFontFamily(fontFamily string) { + d.FontFamily = &fontFamily +} + +func (d *Default_) GetFontSize() *string { + if d == nil { + return nil + } + return d.FontSize +} + +func (d *Default_) SetFontSize(fontSize string) { + d.FontSize = &fontSize +} + +func (d *Default_) GetHover() *DefaultHover { + if d == nil { + return nil + } + return d.Hover +} + +func (d *Default_) SetHover(hover DefaultHover) { + d.Hover = &hover +} + +func (d *Default_) GetMargin() *string { + if d == nil { + return nil + } + return d.Margin +} + +func (d *Default_) SetMargin(margin string) { + d.Margin = &margin +} + +func (d *Default_) GetState() *DefaultState { + if d == nil { + return nil + } + return d.State +} + +func (d *Default_) SetState(state DefaultState) { + d.State = &state +} + +func (d *Default_) GetTextColor() *string { + if d == nil { + return nil + } + return d.TextColor +} + +func (d *Default_) SetTextColor(textColor string) { + d.TextColor = &textColor +} + +func (d Default_) String() string { + jsonData, err := json.MarshalIndent(d, "", " ") + if err != nil { + return "error converting struct: Default_ to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/default_hover.go b/pkg/user-client/integrations/default_hover.go new file mode 100644 index 0000000..ec5f5c4 --- /dev/null +++ b/pkg/user-client/integrations/default_hover.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// Styles applied when a notification is hovered. +type DefaultHover struct { + // Background color on hover. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` +} + +func (d *DefaultHover) GetBackgroundColor() *string { + if d == nil { + return nil + } + return d.BackgroundColor +} + +func (d *DefaultHover) SetBackgroundColor(backgroundColor string) { + d.BackgroundColor = &backgroundColor +} + +func (d DefaultHover) String() string { + jsonData, err := json.MarshalIndent(d, "", " ") + if err != nil { + return "error converting struct: DefaultHover to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/default_state.go b/pkg/user-client/integrations/default_state.go new file mode 100644 index 0000000..85a4ebd --- /dev/null +++ b/pkg/user-client/integrations/default_state.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// Accent colors for notification state indicators. +type DefaultState struct { + // Color used for the state indicator. + Color *string `json:"color,omitempty" required:"true"` +} + +func (d *DefaultState) GetColor() *string { + if d == nil { + return nil + } + return d.Color +} + +func (d *DefaultState) SetColor(color string) { + d.Color = &color +} + +func (d DefaultState) String() string { + jsonData, err := json.MarshalIndent(d, "", " ") + if err != nil { + return "error converting struct: DefaultState to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/dialog.go b/pkg/user-client/integrations/dialog.go new file mode 100644 index 0000000..d76c3f7 --- /dev/null +++ b/pkg/user-client/integrations/dialog.go @@ -0,0 +1,54 @@ +package integrations + +import "encoding/json" + +// Styling for confirmation and action dialogs. +type Dialog struct { + // Accent color for dialog buttons and highlights. + AccentColor *string `json:"accentColor,omitempty" required:"true"` + // Dialog background color. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` + // Dialog text color. + TextColor *string `json:"textColor,omitempty" required:"true"` +} + +func (d *Dialog) GetAccentColor() *string { + if d == nil { + return nil + } + return d.AccentColor +} + +func (d *Dialog) SetAccentColor(accentColor string) { + d.AccentColor = &accentColor +} + +func (d *Dialog) GetBackgroundColor() *string { + if d == nil { + return nil + } + return d.BackgroundColor +} + +func (d *Dialog) SetBackgroundColor(backgroundColor string) { + d.BackgroundColor = &backgroundColor +} + +func (d *Dialog) GetTextColor() *string { + if d == nil { + return nil + } + return d.TextColor +} + +func (d *Dialog) SetTextColor(textColor string) { + d.TextColor = &textColor +} + +func (d Dialog) String() string { + jsonData, err := json.MarshalIndent(d, "", " ") + if err != nil { + return "error converting struct: Dialog to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/enterprise.go b/pkg/user-client/integrations/enterprise.go new file mode 100644 index 0000000..16cb93b --- /dev/null +++ b/pkg/user-client/integrations/enterprise.go @@ -0,0 +1,40 @@ +package integrations + +import "encoding/json" + +type Enterprise struct { + // Enterprise grid identifier. + Id *string `json:"id,omitempty" required:"true"` + // Enterprise grid name. + Name *string `json:"name,omitempty" required:"true"` +} + +func (e *Enterprise) GetId() *string { + if e == nil { + return nil + } + return e.Id +} + +func (e *Enterprise) SetId(id string) { + e.Id = &id +} + +func (e *Enterprise) GetName() *string { + if e == nil { + return nil + } + return e.Name +} + +func (e *Enterprise) SetName(name string) { + e.Name = &name +} + +func (e Enterprise) String() string { + jsonData, err := json.MarshalIndent(e, "", " ") + if err != nil { + return "error converting struct: Enterprise to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/footer.go b/pkg/user-client/integrations/footer.go new file mode 100644 index 0000000..4cce7a5 --- /dev/null +++ b/pkg/user-client/integrations/footer.go @@ -0,0 +1,67 @@ +package integrations + +import "encoding/json" + +// Footer styling for the inbox modal. +type Footer struct { + // Footer background color. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` + // Border radius applied to the footer container. + BorderRadius *string `json:"borderRadius,omitempty" required:"true"` + // Font size used in the footer. + FontSize *string `json:"fontSize,omitempty" required:"true"` + // Footer text color. + TextColor *string `json:"textColor,omitempty" required:"true"` +} + +func (f *Footer) GetBackgroundColor() *string { + if f == nil { + return nil + } + return f.BackgroundColor +} + +func (f *Footer) SetBackgroundColor(backgroundColor string) { + f.BackgroundColor = &backgroundColor +} + +func (f *Footer) GetBorderRadius() *string { + if f == nil { + return nil + } + return f.BorderRadius +} + +func (f *Footer) SetBorderRadius(borderRadius string) { + f.BorderRadius = &borderRadius +} + +func (f *Footer) GetFontSize() *string { + if f == nil { + return nil + } + return f.FontSize +} + +func (f *Footer) SetFontSize(fontSize string) { + f.FontSize = &fontSize +} + +func (f *Footer) GetTextColor() *string { + if f == nil { + return nil + } + return f.TextColor +} + +func (f *Footer) SetTextColor(textColor string) { + f.TextColor = &textColor +} + +func (f Footer) String() string { + jsonData, err := json.MarshalIndent(f, "", " ") + if err != nil { + return "error converting struct: Footer to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/header.go b/pkg/user-client/integrations/header.go new file mode 100644 index 0000000..1105c44 --- /dev/null +++ b/pkg/user-client/integrations/header.go @@ -0,0 +1,80 @@ +package integrations + +import "encoding/json" + +// Header styling for the inbox modal. +type Header struct { + // Header background color. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` + // Border radius applied to the header container. + BorderRadius *string `json:"borderRadius,omitempty" required:"true"` + // CSS font family for the header title. + FontFamily *string `json:"fontFamily,omitempty" required:"true"` + // Font size used in the header. + FontSize *string `json:"fontSize,omitempty" required:"true"` + // Header text color. + TextColor *string `json:"textColor,omitempty" required:"true"` +} + +func (h *Header) GetBackgroundColor() *string { + if h == nil { + return nil + } + return h.BackgroundColor +} + +func (h *Header) SetBackgroundColor(backgroundColor string) { + h.BackgroundColor = &backgroundColor +} + +func (h *Header) GetBorderRadius() *string { + if h == nil { + return nil + } + return h.BorderRadius +} + +func (h *Header) SetBorderRadius(borderRadius string) { + h.BorderRadius = &borderRadius +} + +func (h *Header) GetFontFamily() *string { + if h == nil { + return nil + } + return h.FontFamily +} + +func (h *Header) SetFontFamily(fontFamily string) { + h.FontFamily = &fontFamily +} + +func (h *Header) GetFontSize() *string { + if h == nil { + return nil + } + return h.FontSize +} + +func (h *Header) SetFontSize(fontSize string) { + h.FontSize = &fontSize +} + +func (h *Header) GetTextColor() *string { + if h == nil { + return nil + } + return h.TextColor +} + +func (h *Header) SetTextColor(textColor string) { + h.TextColor = &textColor +} + +func (h Header) String() string { + jsonData, err := json.MarshalIndent(h, "", " ") + if err != nil { + return "error converting struct: Header to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/icon.go b/pkg/user-client/integrations/icon.go new file mode 100644 index 0000000..315ccdf --- /dev/null +++ b/pkg/user-client/integrations/icon.go @@ -0,0 +1,41 @@ +package integrations + +import "encoding/json" + +// Launcher icon styling overrides. +type Icon struct { + // CSS color used for the icon border. + BorderColor *string `json:"borderColor,omitempty" required:"true"` + // Width of the launcher icon (any CSS length). + Width *string `json:"width,omitempty" required:"true"` +} + +func (i *Icon) GetBorderColor() *string { + if i == nil { + return nil + } + return i.BorderColor +} + +func (i *Icon) SetBorderColor(borderColor string) { + i.BorderColor = &borderColor +} + +func (i *Icon) GetWidth() *string { + if i == nil { + return nil + } + return i.Width +} + +func (i *Icon) SetWidth(width string) { + i.Width = &width +} + +func (i Icon) String() string { + jsonData, err := json.MarshalIndent(i, "", " ") + if err != nil { + return "error converting struct: Icon to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/images.go b/pkg/user-client/integrations/images.go new file mode 100644 index 0000000..3b4b07a --- /dev/null +++ b/pkg/user-client/integrations/images.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// Image overrides for assets used in the inbox UI. +type Images struct { + // URL for the illustration shown when the inbox is empty. + EmptyInboxUrl *string `json:"emptyInboxUrl,omitempty" required:"true"` +} + +func (i *Images) GetEmptyInboxUrl() *string { + if i == nil { + return nil + } + return i.EmptyInboxUrl +} + +func (i *Images) SetEmptyInboxUrl(emptyInboxUrl string) { + i.EmptyInboxUrl = &emptyInboxUrl +} + +func (i Images) String() string { + jsonData, err := json.MarshalIndent(i, "", " ") + if err != nil { + return "error converting struct: Images to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/inbox_config_payload.go b/pkg/user-client/integrations/inbox_config_payload.go index 75c4060..19f53a4 100644 --- a/pkg/user-client/integrations/inbox_config_payload.go +++ b/pkg/user-client/integrations/inbox_config_payload.go @@ -7,9 +7,12 @@ import ( ) type InboxConfigPayload struct { + // Image overrides for assets used in the inbox UI. Images *util.Nullable[Images] `json:"images,omitempty" required:"true"` + // Locale code (ISO language tag) used to localize built-in strings. Locale *util.Nullable[string] `json:"locale,omitempty" required:"true" minLength:"2"` - Theme *util.Nullable[Theme] `json:"theme,omitempty" required:"true"` + // Visual customization options for the hosted inbox widget. + Theme *util.Nullable[Theme] `json:"theme,omitempty" required:"true"` } func (i *InboxConfigPayload) GetImages() *util.Nullable[Images] { @@ -68,825 +71,3 @@ func (i InboxConfigPayload) String() string { func (i *InboxConfigPayload) UnmarshalJSON(data []byte) error { return unmarshal.UnmarshalNullable(data, i) } - -type Images struct { - EmptyInboxUrl *string `json:"emptyInboxUrl,omitempty" required:"true"` -} - -func (i *Images) GetEmptyInboxUrl() *string { - if i == nil { - return nil - } - return i.EmptyInboxUrl -} - -func (i *Images) SetEmptyInboxUrl(emptyInboxUrl string) { - i.EmptyInboxUrl = &emptyInboxUrl -} - -func (i Images) String() string { - jsonData, err := json.MarshalIndent(i, "", " ") - if err != nil { - return "error converting struct: Images to string" - } - return string(jsonData) -} - -type Theme struct { - Banner *Banner `json:"banner,omitempty"` - Dialog *Dialog `json:"dialog,omitempty"` - Footer *Footer `json:"footer,omitempty"` - Header *Header `json:"header,omitempty"` - Icon *Icon `json:"icon,omitempty"` - Notification *ThemeNotification `json:"notification,omitempty"` - UnseenBadge *UnseenBadge `json:"unseenBadge,omitempty"` -} - -func (t *Theme) GetBanner() *Banner { - if t == nil { - return nil - } - return t.Banner -} - -func (t *Theme) SetBanner(banner Banner) { - t.Banner = &banner -} - -func (t *Theme) GetDialog() *Dialog { - if t == nil { - return nil - } - return t.Dialog -} - -func (t *Theme) SetDialog(dialog Dialog) { - t.Dialog = &dialog -} - -func (t *Theme) GetFooter() *Footer { - if t == nil { - return nil - } - return t.Footer -} - -func (t *Theme) SetFooter(footer Footer) { - t.Footer = &footer -} - -func (t *Theme) GetHeader() *Header { - if t == nil { - return nil - } - return t.Header -} - -func (t *Theme) SetHeader(header Header) { - t.Header = &header -} - -func (t *Theme) GetIcon() *Icon { - if t == nil { - return nil - } - return t.Icon -} - -func (t *Theme) SetIcon(icon Icon) { - t.Icon = &icon -} - -func (t *Theme) GetNotification() *ThemeNotification { - if t == nil { - return nil - } - return t.Notification -} - -func (t *Theme) SetNotification(notification ThemeNotification) { - t.Notification = ¬ification -} - -func (t *Theme) GetUnseenBadge() *UnseenBadge { - if t == nil { - return nil - } - return t.UnseenBadge -} - -func (t *Theme) SetUnseenBadge(unseenBadge UnseenBadge) { - t.UnseenBadge = &unseenBadge -} - -func (t Theme) String() string { - jsonData, err := json.MarshalIndent(t, "", " ") - if err != nil { - return "error converting struct: Theme to string" - } - return string(jsonData) -} - -type Banner struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` - BackgroundOpacity *float64 `json:"backgroundOpacity,omitempty"` - FontSize *string `json:"fontSize,omitempty" required:"true"` - TextColor *string `json:"textColor,omitempty" required:"true"` -} - -func (b *Banner) GetBackgroundColor() *string { - if b == nil { - return nil - } - return b.BackgroundColor -} - -func (b *Banner) SetBackgroundColor(backgroundColor string) { - b.BackgroundColor = &backgroundColor -} - -func (b *Banner) GetBackgroundOpacity() *float64 { - if b == nil { - return nil - } - return b.BackgroundOpacity -} - -func (b *Banner) SetBackgroundOpacity(backgroundOpacity float64) { - b.BackgroundOpacity = &backgroundOpacity -} - -func (b *Banner) GetFontSize() *string { - if b == nil { - return nil - } - return b.FontSize -} - -func (b *Banner) SetFontSize(fontSize string) { - b.FontSize = &fontSize -} - -func (b *Banner) GetTextColor() *string { - if b == nil { - return nil - } - return b.TextColor -} - -func (b *Banner) SetTextColor(textColor string) { - b.TextColor = &textColor -} - -func (b Banner) String() string { - jsonData, err := json.MarshalIndent(b, "", " ") - if err != nil { - return "error converting struct: Banner to string" - } - return string(jsonData) -} - -type Dialog struct { - AccentColor *string `json:"accentColor,omitempty" required:"true"` - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` - TextColor *string `json:"textColor,omitempty" required:"true"` -} - -func (d *Dialog) GetAccentColor() *string { - if d == nil { - return nil - } - return d.AccentColor -} - -func (d *Dialog) SetAccentColor(accentColor string) { - d.AccentColor = &accentColor -} - -func (d *Dialog) GetBackgroundColor() *string { - if d == nil { - return nil - } - return d.BackgroundColor -} - -func (d *Dialog) SetBackgroundColor(backgroundColor string) { - d.BackgroundColor = &backgroundColor -} - -func (d *Dialog) GetTextColor() *string { - if d == nil { - return nil - } - return d.TextColor -} - -func (d *Dialog) SetTextColor(textColor string) { - d.TextColor = &textColor -} - -func (d Dialog) String() string { - jsonData, err := json.MarshalIndent(d, "", " ") - if err != nil { - return "error converting struct: Dialog to string" - } - return string(jsonData) -} - -type Footer struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` - BorderRadius *string `json:"borderRadius,omitempty" required:"true"` - FontSize *string `json:"fontSize,omitempty" required:"true"` - TextColor *string `json:"textColor,omitempty" required:"true"` -} - -func (f *Footer) GetBackgroundColor() *string { - if f == nil { - return nil - } - return f.BackgroundColor -} - -func (f *Footer) SetBackgroundColor(backgroundColor string) { - f.BackgroundColor = &backgroundColor -} - -func (f *Footer) GetBorderRadius() *string { - if f == nil { - return nil - } - return f.BorderRadius -} - -func (f *Footer) SetBorderRadius(borderRadius string) { - f.BorderRadius = &borderRadius -} - -func (f *Footer) GetFontSize() *string { - if f == nil { - return nil - } - return f.FontSize -} - -func (f *Footer) SetFontSize(fontSize string) { - f.FontSize = &fontSize -} - -func (f *Footer) GetTextColor() *string { - if f == nil { - return nil - } - return f.TextColor -} - -func (f *Footer) SetTextColor(textColor string) { - f.TextColor = &textColor -} - -func (f Footer) String() string { - jsonData, err := json.MarshalIndent(f, "", " ") - if err != nil { - return "error converting struct: Footer to string" - } - return string(jsonData) -} - -type Header struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` - BorderRadius *string `json:"borderRadius,omitempty" required:"true"` - FontFamily *string `json:"fontFamily,omitempty" required:"true"` - FontSize *string `json:"fontSize,omitempty" required:"true"` - TextColor *string `json:"textColor,omitempty" required:"true"` -} - -func (h *Header) GetBackgroundColor() *string { - if h == nil { - return nil - } - return h.BackgroundColor -} - -func (h *Header) SetBackgroundColor(backgroundColor string) { - h.BackgroundColor = &backgroundColor -} - -func (h *Header) GetBorderRadius() *string { - if h == nil { - return nil - } - return h.BorderRadius -} - -func (h *Header) SetBorderRadius(borderRadius string) { - h.BorderRadius = &borderRadius -} - -func (h *Header) GetFontFamily() *string { - if h == nil { - return nil - } - return h.FontFamily -} - -func (h *Header) SetFontFamily(fontFamily string) { - h.FontFamily = &fontFamily -} - -func (h *Header) GetFontSize() *string { - if h == nil { - return nil - } - return h.FontSize -} - -func (h *Header) SetFontSize(fontSize string) { - h.FontSize = &fontSize -} - -func (h *Header) GetTextColor() *string { - if h == nil { - return nil - } - return h.TextColor -} - -func (h *Header) SetTextColor(textColor string) { - h.TextColor = &textColor -} - -func (h Header) String() string { - jsonData, err := json.MarshalIndent(h, "", " ") - if err != nil { - return "error converting struct: Header to string" - } - return string(jsonData) -} - -type Icon struct { - BorderColor *string `json:"borderColor,omitempty" required:"true"` - Width *string `json:"width,omitempty" required:"true"` -} - -func (i *Icon) GetBorderColor() *string { - if i == nil { - return nil - } - return i.BorderColor -} - -func (i *Icon) SetBorderColor(borderColor string) { - i.BorderColor = &borderColor -} - -func (i *Icon) GetWidth() *string { - if i == nil { - return nil - } - return i.Width -} - -func (i *Icon) SetWidth(width string) { - i.Width = &width -} - -func (i Icon) String() string { - jsonData, err := json.MarshalIndent(i, "", " ") - if err != nil { - return "error converting struct: Icon to string" - } - return string(jsonData) -} - -type ThemeNotification struct { - Default_ *Default_ `json:"default,omitempty" required:"true"` - Unread *Unread `json:"unread,omitempty" required:"true"` - Unseen *Unseen `json:"unseen,omitempty" required:"true"` -} - -func (t *ThemeNotification) GetDefault_() *Default_ { - if t == nil { - return nil - } - return t.Default_ -} - -func (t *ThemeNotification) SetDefault_(default_ Default_) { - t.Default_ = &default_ -} - -func (t *ThemeNotification) GetUnread() *Unread { - if t == nil { - return nil - } - return t.Unread -} - -func (t *ThemeNotification) SetUnread(unread Unread) { - t.Unread = &unread -} - -func (t *ThemeNotification) GetUnseen() *Unseen { - if t == nil { - return nil - } - return t.Unseen -} - -func (t *ThemeNotification) SetUnseen(unseen Unseen) { - t.Unseen = &unseen -} - -func (t ThemeNotification) String() string { - jsonData, err := json.MarshalIndent(t, "", " ") - if err != nil { - return "error converting struct: ThemeNotification to string" - } - return string(jsonData) -} - -type Default_ struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` - BorderRadius *string `json:"borderRadius,omitempty" required:"true"` - FontFamily *string `json:"fontFamily,omitempty" required:"true"` - FontSize *string `json:"fontSize,omitempty" required:"true"` - Hover *DefaultHover `json:"hover,omitempty"` - Margin *string `json:"margin,omitempty" required:"true"` - State *DefaultState `json:"state,omitempty"` - TextColor *string `json:"textColor,omitempty" required:"true"` -} - -func (d *Default_) GetBackgroundColor() *string { - if d == nil { - return nil - } - return d.BackgroundColor -} - -func (d *Default_) SetBackgroundColor(backgroundColor string) { - d.BackgroundColor = &backgroundColor -} - -func (d *Default_) GetBorderRadius() *string { - if d == nil { - return nil - } - return d.BorderRadius -} - -func (d *Default_) SetBorderRadius(borderRadius string) { - d.BorderRadius = &borderRadius -} - -func (d *Default_) GetFontFamily() *string { - if d == nil { - return nil - } - return d.FontFamily -} - -func (d *Default_) SetFontFamily(fontFamily string) { - d.FontFamily = &fontFamily -} - -func (d *Default_) GetFontSize() *string { - if d == nil { - return nil - } - return d.FontSize -} - -func (d *Default_) SetFontSize(fontSize string) { - d.FontSize = &fontSize -} - -func (d *Default_) GetHover() *DefaultHover { - if d == nil { - return nil - } - return d.Hover -} - -func (d *Default_) SetHover(hover DefaultHover) { - d.Hover = &hover -} - -func (d *Default_) GetMargin() *string { - if d == nil { - return nil - } - return d.Margin -} - -func (d *Default_) SetMargin(margin string) { - d.Margin = &margin -} - -func (d *Default_) GetState() *DefaultState { - if d == nil { - return nil - } - return d.State -} - -func (d *Default_) SetState(state DefaultState) { - d.State = &state -} - -func (d *Default_) GetTextColor() *string { - if d == nil { - return nil - } - return d.TextColor -} - -func (d *Default_) SetTextColor(textColor string) { - d.TextColor = &textColor -} - -func (d Default_) String() string { - jsonData, err := json.MarshalIndent(d, "", " ") - if err != nil { - return "error converting struct: Default_ to string" - } - return string(jsonData) -} - -type DefaultHover struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` -} - -func (d *DefaultHover) GetBackgroundColor() *string { - if d == nil { - return nil - } - return d.BackgroundColor -} - -func (d *DefaultHover) SetBackgroundColor(backgroundColor string) { - d.BackgroundColor = &backgroundColor -} - -func (d DefaultHover) String() string { - jsonData, err := json.MarshalIndent(d, "", " ") - if err != nil { - return "error converting struct: DefaultHover to string" - } - return string(jsonData) -} - -type DefaultState struct { - Color *string `json:"color,omitempty" required:"true"` -} - -func (d *DefaultState) GetColor() *string { - if d == nil { - return nil - } - return d.Color -} - -func (d *DefaultState) SetColor(color string) { - d.Color = &color -} - -func (d DefaultState) String() string { - jsonData, err := json.MarshalIndent(d, "", " ") - if err != nil { - return "error converting struct: DefaultState to string" - } - return string(jsonData) -} - -type Unread struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` - Hover *UnreadHover `json:"hover,omitempty"` - State *UnreadState `json:"state,omitempty"` - TextColor *string `json:"textColor,omitempty" required:"true"` -} - -func (u *Unread) GetBackgroundColor() *string { - if u == nil { - return nil - } - return u.BackgroundColor -} - -func (u *Unread) SetBackgroundColor(backgroundColor string) { - u.BackgroundColor = &backgroundColor -} - -func (u *Unread) GetHover() *UnreadHover { - if u == nil { - return nil - } - return u.Hover -} - -func (u *Unread) SetHover(hover UnreadHover) { - u.Hover = &hover -} - -func (u *Unread) GetState() *UnreadState { - if u == nil { - return nil - } - return u.State -} - -func (u *Unread) SetState(state UnreadState) { - u.State = &state -} - -func (u *Unread) GetTextColor() *string { - if u == nil { - return nil - } - return u.TextColor -} - -func (u *Unread) SetTextColor(textColor string) { - u.TextColor = &textColor -} - -func (u Unread) String() string { - jsonData, err := json.MarshalIndent(u, "", " ") - if err != nil { - return "error converting struct: Unread to string" - } - return string(jsonData) -} - -type UnreadHover struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` -} - -func (u *UnreadHover) GetBackgroundColor() *string { - if u == nil { - return nil - } - return u.BackgroundColor -} - -func (u *UnreadHover) SetBackgroundColor(backgroundColor string) { - u.BackgroundColor = &backgroundColor -} - -func (u UnreadHover) String() string { - jsonData, err := json.MarshalIndent(u, "", " ") - if err != nil { - return "error converting struct: UnreadHover to string" - } - return string(jsonData) -} - -type UnreadState struct { - Color *string `json:"color,omitempty" required:"true"` -} - -func (u *UnreadState) GetColor() *string { - if u == nil { - return nil - } - return u.Color -} - -func (u *UnreadState) SetColor(color string) { - u.Color = &color -} - -func (u UnreadState) String() string { - jsonData, err := json.MarshalIndent(u, "", " ") - if err != nil { - return "error converting struct: UnreadState to string" - } - return string(jsonData) -} - -type Unseen struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` - Hover *UnseenHover `json:"hover,omitempty"` - State *UnseenState `json:"state,omitempty"` - TextColor *string `json:"textColor,omitempty" required:"true"` -} - -func (u *Unseen) GetBackgroundColor() *string { - if u == nil { - return nil - } - return u.BackgroundColor -} - -func (u *Unseen) SetBackgroundColor(backgroundColor string) { - u.BackgroundColor = &backgroundColor -} - -func (u *Unseen) GetHover() *UnseenHover { - if u == nil { - return nil - } - return u.Hover -} - -func (u *Unseen) SetHover(hover UnseenHover) { - u.Hover = &hover -} - -func (u *Unseen) GetState() *UnseenState { - if u == nil { - return nil - } - return u.State -} - -func (u *Unseen) SetState(state UnseenState) { - u.State = &state -} - -func (u *Unseen) GetTextColor() *string { - if u == nil { - return nil - } - return u.TextColor -} - -func (u *Unseen) SetTextColor(textColor string) { - u.TextColor = &textColor -} - -func (u Unseen) String() string { - jsonData, err := json.MarshalIndent(u, "", " ") - if err != nil { - return "error converting struct: Unseen to string" - } - return string(jsonData) -} - -type UnseenHover struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` -} - -func (u *UnseenHover) GetBackgroundColor() *string { - if u == nil { - return nil - } - return u.BackgroundColor -} - -func (u *UnseenHover) SetBackgroundColor(backgroundColor string) { - u.BackgroundColor = &backgroundColor -} - -func (u UnseenHover) String() string { - jsonData, err := json.MarshalIndent(u, "", " ") - if err != nil { - return "error converting struct: UnseenHover to string" - } - return string(jsonData) -} - -type UnseenState struct { - Color *string `json:"color,omitempty" required:"true"` -} - -func (u *UnseenState) GetColor() *string { - if u == nil { - return nil - } - return u.Color -} - -func (u *UnseenState) SetColor(color string) { - u.Color = &color -} - -func (u UnseenState) String() string { - jsonData, err := json.MarshalIndent(u, "", " ") - if err != nil { - return "error converting struct: UnseenState to string" - } - return string(jsonData) -} - -type UnseenBadge struct { - BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` -} - -func (u *UnseenBadge) GetBackgroundColor() *string { - if u == nil { - return nil - } - return u.BackgroundColor -} - -func (u *UnseenBadge) SetBackgroundColor(backgroundColor string) { - u.BackgroundColor = &backgroundColor -} - -func (u UnseenBadge) String() string { - jsonData, err := json.MarshalIndent(u, "", " ") - if err != nil { - return "error converting struct: UnseenBadge to string" - } - return string(jsonData) -} diff --git a/pkg/user-client/integrations/incoming_webhook.go b/pkg/user-client/integrations/incoming_webhook.go new file mode 100644 index 0000000..c19aa30 --- /dev/null +++ b/pkg/user-client/integrations/incoming_webhook.go @@ -0,0 +1,53 @@ +package integrations + +import "encoding/json" + +type IncomingWebhook struct { + // Human readable name for the webhook channel. + Channel *string `json:"channel,omitempty" required:"true"` + // URL users can visit to manage the webhook. + ConfigurationUrl *string `json:"configuration_url,omitempty" required:"true"` + // Webhook URL that Slack posts events to. + Url *string `json:"url,omitempty" required:"true"` +} + +func (i *IncomingWebhook) GetChannel() *string { + if i == nil { + return nil + } + return i.Channel +} + +func (i *IncomingWebhook) SetChannel(channel string) { + i.Channel = &channel +} + +func (i *IncomingWebhook) GetConfigurationUrl() *string { + if i == nil { + return nil + } + return i.ConfigurationUrl +} + +func (i *IncomingWebhook) SetConfigurationUrl(configurationUrl string) { + i.ConfigurationUrl = &configurationUrl +} + +func (i *IncomingWebhook) GetUrl() *string { + if i == nil { + return nil + } + return i.Url +} + +func (i *IncomingWebhook) SetUrl(url string) { + i.Url = &url +} + +func (i IncomingWebhook) String() string { + jsonData, err := json.MarshalIndent(i, "", " ") + if err != nil { + return "error converting struct: IncomingWebhook to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/integrations_service.go b/pkg/user-client/integrations/integrations_service.go index af5dc58..e875500 100644 --- a/pkg/user-client/integrations/integrations_service.go +++ b/pkg/user-client/integrations/integrations_service.go @@ -3,6 +3,7 @@ package integrations import ( "context" restClient "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest" + "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/hooks" "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/httptransport" "github.com/magicbell/magicbell-go/pkg/user-client/internal/configmanager" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" @@ -10,8 +11,11 @@ import ( "time" ) +// IntegrationsService provides methods to interact with IntegrationsService-related API endpoints. +// It uses a configuration manager for settings and supports custom hooks for request/response interception. type IntegrationsService struct { manager *configmanager.ConfigManager + hook hooks.Hook } func NewIntegrationsService() *IntegrationsService { @@ -20,15 +24,28 @@ func NewIntegrationsService() *IntegrationsService { } } +// WithConfigManager sets the configuration manager for this service. +// Returns the service instance for method chaining. func (api *IntegrationsService) WithConfigManager(manager *configmanager.ConfigManager) *IntegrationsService { api.manager = manager return api } +// WithHook sets a custom hook for request/response interception. +// Returns the service instance for method chaining. +func (api *IntegrationsService) WithHook(hook hooks.Hook) *IntegrationsService { + api.hook = hook + return api +} + func (api *IntegrationsService) getConfig() *clientconfig.Config { return api.manager.GetIntegrations() } +func (api *IntegrationsService) getHook() hooks.Hook { + return api.hook +} + func (api *IntegrationsService) SetBaseUrl(baseUrl string) { config := api.getConfig() config.SetBaseUrl(baseUrl) @@ -45,7 +62,7 @@ func (api *IntegrationsService) SetAccessToken(accessToken string) { } // Creates a new installation of a Inbox integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration. -func (api *IntegrationsService) SaveInboxInstallation(ctx context.Context, inboxConfigPayload InboxConfigPayload) (*shared.ClientResponse[InboxConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) SaveInboxInstallation(ctx context.Context, inboxConfigPayload InboxConfigPayload) (*shared.ClientResponse[InboxConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -58,17 +75,17 @@ func (api *IntegrationsService) SaveInboxInstallation(ctx context.Context, inbox WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[InboxConfigPayload](config) + client := restClient.NewRestClient[InboxConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[InboxConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[InboxConfigPayload](resp), nil } // Initiates the installation flow for an Inbox integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required. -func (api *IntegrationsService) StartInboxInstallation(ctx context.Context) (*shared.ClientResponse[InboxConfigPayload], *shared.ClientError) { +func (api *IntegrationsService) StartInboxInstallation(ctx context.Context) (*shared.ClientResponse[InboxConfigPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -79,17 +96,86 @@ func (api *IntegrationsService) StartInboxInstallation(ctx context.Context) (*sh WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[InboxConfigPayload](config) + client := restClient.NewRestClient[InboxConfigPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[InboxConfigPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[InboxConfigPayload](resp), nil } +// Creates a new installation of a MagicBell SlackBot integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration. +func (api *IntegrationsService) SaveMagicbellSlackbotInstallation(ctx context.Context, slackInstallation SlackInstallation) (*shared.ClientResponse[SlackInstallation], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("PUT"). + WithPath("/integrations/magicbell_slackbot/installations"). + WithConfig(config). + WithBody(slackInstallation). + AddHeader("CONTENT-TYPE", "application/json"). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[SlackInstallation, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[SlackInstallation](resp), nil +} + +// Completes the installation flow for the MagicBell SlackBot integration. This endpoint is typically called after the user has completed any required authorization steps with MagicBell SlackBot. +func (api *IntegrationsService) FinishMagicbellSlackbotInstallation(ctx context.Context, slackFinishInstallResponse SlackFinishInstallResponse) (*shared.ClientResponse[SlackInstallation], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("POST"). + WithPath("/integrations/magicbell_slackbot/installations/finish"). + WithConfig(config). + WithBody(slackFinishInstallResponse). + AddHeader("CONTENT-TYPE", "application/json"). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[SlackInstallation, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[SlackInstallation](resp), nil +} + +// Initiates the installation flow for a MagicBell SlackBot integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required. +func (api *IntegrationsService) StartMagicbellSlackbotInstallation(ctx context.Context, slackStartInstall SlackStartInstall) (*shared.ClientResponse[SlackStartInstallResponseContent], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("POST"). + WithPath("/integrations/magicbell_slackbot/installations/start"). + WithConfig(config). + WithBody(slackStartInstall). + AddHeader("CONTENT-TYPE", "application/json"). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[SlackStartInstallResponseContent, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[SlackStartInstallResponseContent](resp), nil +} + // Creates a new installation of a Slack integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration. -func (api *IntegrationsService) SaveSlackInstallation(ctx context.Context, slackInstallation SlackInstallation) (*shared.ClientResponse[SlackInstallation], *shared.ClientError) { +func (api *IntegrationsService) SaveSlackInstallation(ctx context.Context, slackInstallation SlackInstallation) (*shared.ClientResponse[SlackInstallation], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -102,17 +188,17 @@ func (api *IntegrationsService) SaveSlackInstallation(ctx context.Context, slack WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[SlackInstallation](config) + client := restClient.NewRestClient[SlackInstallation, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[SlackInstallation](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[SlackInstallation](resp), nil } // Completes the installation flow for the Slack integration. This endpoint is typically called after the user has completed any required authorization steps with Slack. -func (api *IntegrationsService) FinishSlackInstallation(ctx context.Context, slackFinishInstallResponse SlackFinishInstallResponse) (*shared.ClientResponse[SlackInstallation], *shared.ClientError) { +func (api *IntegrationsService) FinishSlackInstallation(ctx context.Context, slackFinishInstallResponse SlackFinishInstallResponse) (*shared.ClientResponse[SlackInstallation], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -125,17 +211,17 @@ func (api *IntegrationsService) FinishSlackInstallation(ctx context.Context, sla WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[SlackInstallation](config) + client := restClient.NewRestClient[SlackInstallation, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[SlackInstallation](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[SlackInstallation](resp), nil } // Initiates the installation flow for a Slack integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required. -func (api *IntegrationsService) StartSlackInstallation(ctx context.Context, slackStartInstall SlackStartInstall) (*shared.ClientResponse[SlackStartInstallResponseContent], *shared.ClientError) { +func (api *IntegrationsService) StartSlackInstallation(ctx context.Context, slackStartInstall SlackStartInstall) (*shared.ClientResponse[SlackStartInstallResponseContent], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -148,17 +234,17 @@ func (api *IntegrationsService) StartSlackInstallation(ctx context.Context, slac WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[SlackStartInstallResponseContent](config) + client := restClient.NewRestClient[SlackStartInstallResponseContent, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[SlackStartInstallResponseContent](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[SlackStartInstallResponseContent](resp), nil } // Creates a new installation of a Web Push integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration. -func (api *IntegrationsService) SaveWebPushInstallation(ctx context.Context, webPushTokenPayload shared.WebPushTokenPayload) (*shared.ClientResponse[shared.WebPushTokenPayload], *shared.ClientError) { +func (api *IntegrationsService) SaveWebPushInstallation(ctx context.Context, webPushTokenPayload shared.WebPushTokenPayload) (*shared.ClientResponse[shared.WebPushTokenPayload], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -171,17 +257,17 @@ func (api *IntegrationsService) SaveWebPushInstallation(ctx context.Context, web WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[shared.WebPushTokenPayload](config) + client := restClient.NewRestClient[shared.WebPushTokenPayload, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[shared.WebPushTokenPayload](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[shared.WebPushTokenPayload](resp), nil } // Initiates the installation flow for a Web Push integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required. -func (api *IntegrationsService) StartWebPushInstallation(ctx context.Context) (*shared.ClientResponse[WebPushStartInstallationResponse], *shared.ClientError) { +func (api *IntegrationsService) StartWebPushInstallation(ctx context.Context) (*shared.ClientResponse[WebPushStartInstallationResponse], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -192,10 +278,10 @@ func (api *IntegrationsService) StartWebPushInstallation(ctx context.Context) (* WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[WebPushStartInstallationResponse](config) + client := restClient.NewRestClient[WebPushStartInstallationResponse, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[WebPushStartInstallationResponse](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[WebPushStartInstallationResponse](resp), nil diff --git a/pkg/user-client/integrations/slack_installation.go b/pkg/user-client/integrations/slack_installation.go index a36fa39..8f6b1f8 100644 --- a/pkg/user-client/integrations/slack_installation.go +++ b/pkg/user-client/integrations/slack_installation.go @@ -3,19 +3,28 @@ package integrations import "encoding/json" type SlackInstallation struct { - AccessToken *string `json:"access_token,omitempty" required:"true"` - AppId *string `json:"app_id,omitempty" required:"true"` - AuthedUser *AuthedUser `json:"authed_user,omitempty" required:"true"` - BotUserId *string `json:"bot_user_id,omitempty"` - Enterprise *Enterprise `json:"enterprise,omitempty"` - ExpiresIn *int64 `json:"expires_in,omitempty"` - Id *string `json:"id,omitempty" pattern:"^[A-Z0-9]+-.*$"` - IncomingWebhook *IncomingWebhook `json:"incoming_webhook,omitempty"` - IsEnterpriseInstall *bool `json:"is_enterprise_install,omitempty"` - RefreshToken *string `json:"refresh_token,omitempty"` - Scope *string `json:"scope,omitempty"` - Team *Team `json:"team,omitempty" required:"true"` - TokenType *string `json:"token_type,omitempty"` + // Bot token returned from the Slack OAuth exchange. + AccessToken *string `json:"access_token,omitempty" required:"true"` + // Slack app identifier for the installed app. + AppId *string `json:"app_id,omitempty" required:"true"` + AuthedUser *AuthedUser `json:"authed_user,omitempty" required:"true"` + // Slack user ID of the installed bot. + BotUserId *string `json:"bot_user_id,omitempty"` + Enterprise *Enterprise `json:"enterprise,omitempty"` + // Seconds until the bot access token expires. + ExpiresIn *int64 `json:"expires_in,omitempty"` + // Unique identifier MagicBell assigns to the Slack installation. + Id *string `json:"id,omitempty" pattern:"^[A-Z0-9]+-.*$"` + IncomingWebhook *IncomingWebhook `json:"incoming_webhook,omitempty"` + // Indicates whether the installation occurred on an enterprise grid. + IsEnterpriseInstall *bool `json:"is_enterprise_install,omitempty"` + // Refresh token for regenerating the bot access token. + RefreshToken *string `json:"refresh_token,omitempty"` + // Space-delimited OAuth scopes granted to the bot token. + Scope *string `json:"scope,omitempty"` + Team *Team `json:"team,omitempty" required:"true"` + // Type of bot token returned by Slack. + TokenType *string `json:"token_type,omitempty"` } func (s *SlackInstallation) GetAccessToken() *string { @@ -168,203 +177,3 @@ func (s SlackInstallation) String() string { } return string(jsonData) } - -type AuthedUser struct { - AccessToken *string `json:"access_token,omitempty"` - ExpiresIn *int64 `json:"expires_in,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - RefreshToken *string `json:"refresh_token,omitempty"` - Scope *string `json:"scope,omitempty"` - TokenType *string `json:"token_type,omitempty"` -} - -func (a *AuthedUser) GetAccessToken() *string { - if a == nil { - return nil - } - return a.AccessToken -} - -func (a *AuthedUser) SetAccessToken(accessToken string) { - a.AccessToken = &accessToken -} - -func (a *AuthedUser) GetExpiresIn() *int64 { - if a == nil { - return nil - } - return a.ExpiresIn -} - -func (a *AuthedUser) SetExpiresIn(expiresIn int64) { - a.ExpiresIn = &expiresIn -} - -func (a *AuthedUser) GetId() *string { - if a == nil { - return nil - } - return a.Id -} - -func (a *AuthedUser) SetId(id string) { - a.Id = &id -} - -func (a *AuthedUser) GetRefreshToken() *string { - if a == nil { - return nil - } - return a.RefreshToken -} - -func (a *AuthedUser) SetRefreshToken(refreshToken string) { - a.RefreshToken = &refreshToken -} - -func (a *AuthedUser) GetScope() *string { - if a == nil { - return nil - } - return a.Scope -} - -func (a *AuthedUser) SetScope(scope string) { - a.Scope = &scope -} - -func (a *AuthedUser) GetTokenType() *string { - if a == nil { - return nil - } - return a.TokenType -} - -func (a *AuthedUser) SetTokenType(tokenType string) { - a.TokenType = &tokenType -} - -func (a AuthedUser) String() string { - jsonData, err := json.MarshalIndent(a, "", " ") - if err != nil { - return "error converting struct: AuthedUser to string" - } - return string(jsonData) -} - -type Enterprise struct { - Id *string `json:"id,omitempty" required:"true"` - Name *string `json:"name,omitempty" required:"true"` -} - -func (e *Enterprise) GetId() *string { - if e == nil { - return nil - } - return e.Id -} - -func (e *Enterprise) SetId(id string) { - e.Id = &id -} - -func (e *Enterprise) GetName() *string { - if e == nil { - return nil - } - return e.Name -} - -func (e *Enterprise) SetName(name string) { - e.Name = &name -} - -func (e Enterprise) String() string { - jsonData, err := json.MarshalIndent(e, "", " ") - if err != nil { - return "error converting struct: Enterprise to string" - } - return string(jsonData) -} - -type IncomingWebhook struct { - Channel *string `json:"channel,omitempty" required:"true"` - ConfigurationUrl *string `json:"configuration_url,omitempty" required:"true"` - Url *string `json:"url,omitempty" required:"true"` -} - -func (i *IncomingWebhook) GetChannel() *string { - if i == nil { - return nil - } - return i.Channel -} - -func (i *IncomingWebhook) SetChannel(channel string) { - i.Channel = &channel -} - -func (i *IncomingWebhook) GetConfigurationUrl() *string { - if i == nil { - return nil - } - return i.ConfigurationUrl -} - -func (i *IncomingWebhook) SetConfigurationUrl(configurationUrl string) { - i.ConfigurationUrl = &configurationUrl -} - -func (i *IncomingWebhook) GetUrl() *string { - if i == nil { - return nil - } - return i.Url -} - -func (i *IncomingWebhook) SetUrl(url string) { - i.Url = &url -} - -func (i IncomingWebhook) String() string { - jsonData, err := json.MarshalIndent(i, "", " ") - if err != nil { - return "error converting struct: IncomingWebhook to string" - } - return string(jsonData) -} - -type Team struct { - Id *string `json:"id,omitempty" required:"true"` - Name *string `json:"name,omitempty"` -} - -func (t *Team) GetId() *string { - if t == nil { - return nil - } - return t.Id -} - -func (t *Team) SetId(id string) { - t.Id = &id -} - -func (t *Team) GetName() *string { - if t == nil { - return nil - } - return t.Name -} - -func (t *Team) SetName(name string) { - t.Name = &name -} - -func (t Team) String() string { - jsonData, err := json.MarshalIndent(t, "", " ") - if err != nil { - return "error converting struct: Team to string" - } - return string(jsonData) -} diff --git a/pkg/user-client/integrations/slack_start_install.go b/pkg/user-client/integrations/slack_start_install.go index 1937c0b..498e9c8 100644 --- a/pkg/user-client/integrations/slack_start_install.go +++ b/pkg/user-client/integrations/slack_start_install.go @@ -3,10 +3,14 @@ package integrations import "encoding/json" type SlackStartInstall struct { - AppId *string `json:"app_id,omitempty" required:"true"` - AuthUrl *string `json:"auth_url,omitempty"` + // Slack app ID that the installation flow should use. + AppId *string `json:"app_id,omitempty" required:"true"` + // Optional override for the authorization URL returned to the client. + AuthUrl *string `json:"auth_url,omitempty"` + // Additional OAuth scopes to request during installation. ExtraScopes []string `json:"extra_scopes,omitempty"` - RedirectUrl *string `json:"redirect_url,omitempty"` + // Custom redirect URL to use after OAuth completes. + RedirectUrl *string `json:"redirect_url,omitempty"` } func (s *SlackStartInstall) GetAppId() *string { diff --git a/pkg/user-client/integrations/team.go b/pkg/user-client/integrations/team.go new file mode 100644 index 0000000..d9b2eb2 --- /dev/null +++ b/pkg/user-client/integrations/team.go @@ -0,0 +1,40 @@ +package integrations + +import "encoding/json" + +type Team struct { + // Workspace ID where the app was installed. + Id *string `json:"id,omitempty" required:"true"` + // Workspace name where the app was installed. + Name *string `json:"name,omitempty"` +} + +func (t *Team) GetId() *string { + if t == nil { + return nil + } + return t.Id +} + +func (t *Team) SetId(id string) { + t.Id = &id +} + +func (t *Team) GetName() *string { + if t == nil { + return nil + } + return t.Name +} + +func (t *Team) SetName(name string) { + t.Name = &name +} + +func (t Team) String() string { + jsonData, err := json.MarshalIndent(t, "", " ") + if err != nil { + return "error converting struct: Team to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/theme.go b/pkg/user-client/integrations/theme.go new file mode 100644 index 0000000..317b1bd --- /dev/null +++ b/pkg/user-client/integrations/theme.go @@ -0,0 +1,106 @@ +package integrations + +import "encoding/json" + +// Visual customization options for the hosted inbox widget. +type Theme struct { + // Top banner styling options. + Banner *Banner `json:"banner,omitempty"` + // Styling for confirmation and action dialogs. + Dialog *Dialog `json:"dialog,omitempty"` + // Footer styling for the inbox modal. + Footer *Footer `json:"footer,omitempty"` + // Header styling for the inbox modal. + Header *Header `json:"header,omitempty"` + // Launcher icon styling overrides. + Icon *Icon `json:"icon,omitempty"` + // Styling overrides for notification list items. + Notification *ThemeNotification `json:"notification,omitempty"` + // Badge styling for unseen notification counts. + UnseenBadge *UnseenBadge `json:"unseenBadge,omitempty"` +} + +func (t *Theme) GetBanner() *Banner { + if t == nil { + return nil + } + return t.Banner +} + +func (t *Theme) SetBanner(banner Banner) { + t.Banner = &banner +} + +func (t *Theme) GetDialog() *Dialog { + if t == nil { + return nil + } + return t.Dialog +} + +func (t *Theme) SetDialog(dialog Dialog) { + t.Dialog = &dialog +} + +func (t *Theme) GetFooter() *Footer { + if t == nil { + return nil + } + return t.Footer +} + +func (t *Theme) SetFooter(footer Footer) { + t.Footer = &footer +} + +func (t *Theme) GetHeader() *Header { + if t == nil { + return nil + } + return t.Header +} + +func (t *Theme) SetHeader(header Header) { + t.Header = &header +} + +func (t *Theme) GetIcon() *Icon { + if t == nil { + return nil + } + return t.Icon +} + +func (t *Theme) SetIcon(icon Icon) { + t.Icon = &icon +} + +func (t *Theme) GetNotification() *ThemeNotification { + if t == nil { + return nil + } + return t.Notification +} + +func (t *Theme) SetNotification(notification ThemeNotification) { + t.Notification = ¬ification +} + +func (t *Theme) GetUnseenBadge() *UnseenBadge { + if t == nil { + return nil + } + return t.UnseenBadge +} + +func (t *Theme) SetUnseenBadge(unseenBadge UnseenBadge) { + t.UnseenBadge = &unseenBadge +} + +func (t Theme) String() string { + jsonData, err := json.MarshalIndent(t, "", " ") + if err != nil { + return "error converting struct: Theme to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/theme_notification.go b/pkg/user-client/integrations/theme_notification.go new file mode 100644 index 0000000..d025188 --- /dev/null +++ b/pkg/user-client/integrations/theme_notification.go @@ -0,0 +1,54 @@ +package integrations + +import "encoding/json" + +// Styling overrides for notification list items. +type ThemeNotification struct { + // Base styles applied to every notification item. + Default_ *Default_ `json:"default,omitempty" required:"true"` + // Overrides for unread notifications. + Unread *Unread `json:"unread,omitempty" required:"true"` + // Overrides for unseen notifications. + Unseen *Unseen `json:"unseen,omitempty" required:"true"` +} + +func (t *ThemeNotification) GetDefault_() *Default_ { + if t == nil { + return nil + } + return t.Default_ +} + +func (t *ThemeNotification) SetDefault_(default_ Default_) { + t.Default_ = &default_ +} + +func (t *ThemeNotification) GetUnread() *Unread { + if t == nil { + return nil + } + return t.Unread +} + +func (t *ThemeNotification) SetUnread(unread Unread) { + t.Unread = &unread +} + +func (t *ThemeNotification) GetUnseen() *Unseen { + if t == nil { + return nil + } + return t.Unseen +} + +func (t *ThemeNotification) SetUnseen(unseen Unseen) { + t.Unseen = &unseen +} + +func (t ThemeNotification) String() string { + jsonData, err := json.MarshalIndent(t, "", " ") + if err != nil { + return "error converting struct: ThemeNotification to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/unread.go b/pkg/user-client/integrations/unread.go new file mode 100644 index 0000000..2555479 --- /dev/null +++ b/pkg/user-client/integrations/unread.go @@ -0,0 +1,67 @@ +package integrations + +import "encoding/json" + +// Overrides for unread notifications. +type Unread struct { + // Background color applied to unread notifications. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` + // Hover styles for unread notifications. + Hover *UnreadHover `json:"hover,omitempty"` + // State indicator styling for unread notifications. + State *UnreadState `json:"state,omitempty"` + // Text color used when a notification is unread. + TextColor *string `json:"textColor,omitempty" required:"true"` +} + +func (u *Unread) GetBackgroundColor() *string { + if u == nil { + return nil + } + return u.BackgroundColor +} + +func (u *Unread) SetBackgroundColor(backgroundColor string) { + u.BackgroundColor = &backgroundColor +} + +func (u *Unread) GetHover() *UnreadHover { + if u == nil { + return nil + } + return u.Hover +} + +func (u *Unread) SetHover(hover UnreadHover) { + u.Hover = &hover +} + +func (u *Unread) GetState() *UnreadState { + if u == nil { + return nil + } + return u.State +} + +func (u *Unread) SetState(state UnreadState) { + u.State = &state +} + +func (u *Unread) GetTextColor() *string { + if u == nil { + return nil + } + return u.TextColor +} + +func (u *Unread) SetTextColor(textColor string) { + u.TextColor = &textColor +} + +func (u Unread) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: Unread to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/unread_hover.go b/pkg/user-client/integrations/unread_hover.go new file mode 100644 index 0000000..cbff9b3 --- /dev/null +++ b/pkg/user-client/integrations/unread_hover.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// Hover styles for unread notifications. +type UnreadHover struct { + // Background color on hover for unread notifications. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` +} + +func (u *UnreadHover) GetBackgroundColor() *string { + if u == nil { + return nil + } + return u.BackgroundColor +} + +func (u *UnreadHover) SetBackgroundColor(backgroundColor string) { + u.BackgroundColor = &backgroundColor +} + +func (u UnreadHover) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: UnreadHover to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/unread_state.go b/pkg/user-client/integrations/unread_state.go new file mode 100644 index 0000000..ce38d9f --- /dev/null +++ b/pkg/user-client/integrations/unread_state.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// State indicator styling for unread notifications. +type UnreadState struct { + // Color for the unread state indicator. + Color *string `json:"color,omitempty" required:"true"` +} + +func (u *UnreadState) GetColor() *string { + if u == nil { + return nil + } + return u.Color +} + +func (u *UnreadState) SetColor(color string) { + u.Color = &color +} + +func (u UnreadState) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: UnreadState to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/unseen.go b/pkg/user-client/integrations/unseen.go new file mode 100644 index 0000000..577d61b --- /dev/null +++ b/pkg/user-client/integrations/unseen.go @@ -0,0 +1,67 @@ +package integrations + +import "encoding/json" + +// Overrides for unseen notifications. +type Unseen struct { + // Background color applied to unseen notifications. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` + // Hover styles for unseen notifications. + Hover *UnseenHover `json:"hover,omitempty"` + // State indicator styling for unseen notifications. + State *UnseenState `json:"state,omitempty"` + // Text color used when a notification is unseen. + TextColor *string `json:"textColor,omitempty" required:"true"` +} + +func (u *Unseen) GetBackgroundColor() *string { + if u == nil { + return nil + } + return u.BackgroundColor +} + +func (u *Unseen) SetBackgroundColor(backgroundColor string) { + u.BackgroundColor = &backgroundColor +} + +func (u *Unseen) GetHover() *UnseenHover { + if u == nil { + return nil + } + return u.Hover +} + +func (u *Unseen) SetHover(hover UnseenHover) { + u.Hover = &hover +} + +func (u *Unseen) GetState() *UnseenState { + if u == nil { + return nil + } + return u.State +} + +func (u *Unseen) SetState(state UnseenState) { + u.State = &state +} + +func (u *Unseen) GetTextColor() *string { + if u == nil { + return nil + } + return u.TextColor +} + +func (u *Unseen) SetTextColor(textColor string) { + u.TextColor = &textColor +} + +func (u Unseen) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: Unseen to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/unseen_badge.go b/pkg/user-client/integrations/unseen_badge.go new file mode 100644 index 0000000..e08fc30 --- /dev/null +++ b/pkg/user-client/integrations/unseen_badge.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// Badge styling for unseen notification counts. +type UnseenBadge struct { + // Badge background color. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` +} + +func (u *UnseenBadge) GetBackgroundColor() *string { + if u == nil { + return nil + } + return u.BackgroundColor +} + +func (u *UnseenBadge) SetBackgroundColor(backgroundColor string) { + u.BackgroundColor = &backgroundColor +} + +func (u UnseenBadge) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: UnseenBadge to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/unseen_hover.go b/pkg/user-client/integrations/unseen_hover.go new file mode 100644 index 0000000..38f4351 --- /dev/null +++ b/pkg/user-client/integrations/unseen_hover.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// Hover styles for unseen notifications. +type UnseenHover struct { + // Background color on hover for unseen notifications. + BackgroundColor *string `json:"backgroundColor,omitempty" required:"true"` +} + +func (u *UnseenHover) GetBackgroundColor() *string { + if u == nil { + return nil + } + return u.BackgroundColor +} + +func (u *UnseenHover) SetBackgroundColor(backgroundColor string) { + u.BackgroundColor = &backgroundColor +} + +func (u UnseenHover) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: UnseenHover to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/unseen_state.go b/pkg/user-client/integrations/unseen_state.go new file mode 100644 index 0000000..3a4e258 --- /dev/null +++ b/pkg/user-client/integrations/unseen_state.go @@ -0,0 +1,28 @@ +package integrations + +import "encoding/json" + +// State indicator styling for unseen notifications. +type UnseenState struct { + // Color for the unseen state indicator. + Color *string `json:"color,omitempty" required:"true"` +} + +func (u *UnseenState) GetColor() *string { + if u == nil { + return nil + } + return u.Color +} + +func (u *UnseenState) SetColor(color string) { + u.Color = &color +} + +func (u UnseenState) String() string { + jsonData, err := json.MarshalIndent(u, "", " ") + if err != nil { + return "error converting struct: UnseenState to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/integrations/web_push_start_installation_response.go b/pkg/user-client/integrations/web_push_start_installation_response.go index 7c85037..16f84b5 100644 --- a/pkg/user-client/integrations/web_push_start_installation_response.go +++ b/pkg/user-client/integrations/web_push_start_installation_response.go @@ -3,7 +3,9 @@ package integrations import "encoding/json" type WebPushStartInstallationResponse struct { + // Auth secret returned from PushSubscription.getKey('auth'). AuthToken *string `json:"auth_token,omitempty" required:"true" minLength:"8"` + // VAPID public key generated for this web push installation. PublicKey *string `json:"public_key,omitempty" required:"true" maxLength:"128" minLength:"8"` } diff --git a/pkg/user-client/internal/clients/rest/client.go b/pkg/user-client/internal/clients/rest/client.go index 5a3b39b..31199de 100644 --- a/pkg/user-client/internal/clients/rest/client.go +++ b/pkg/user-client/internal/clients/rest/client.go @@ -7,20 +7,25 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" ) -type RestClient[T any] struct { - handlers *handlers.HandlerChain[T] +// RestClient is a generic HTTP client that handles API requests through a chain of handlers. +// It supports both regular and streaming requests with type-safe response handling. +// T is the response type, E is the error type. +type RestClient[T any, E any] struct { + handlers *handlers.HandlerChain[T, E] } -func NewRestClient[T any](config clientconfig.Config) *RestClient[T] { - retryHandler := handlers.NewRetryHandler[T]() - bearerTokenHandler := handlers.NewAccessTokenHandler[T]() - responseValidationHandler := handlers.NewResponseValidationHandler[T]() - unmarshalHandler := handlers.NewUnmarshalHandler[T]() - requestValidationHandler := handlers.NewRequestValidationHandler[T]() - hookHandler := handlers.NewHookHandler[T](hooks.NewDefaultHook()) - terminatingHandler := handlers.NewTerminatingHandler[T]() +// NewRestClient creates a new REST client with the configured handler chain. +// Initializes all handlers in the correct order for request processing. +func NewRestClient[T any, E any](config clientconfig.Config, hook hooks.Hook) *RestClient[T, E] { + retryHandler := handlers.NewRetryHandler[T, E]() + bearerTokenHandler := handlers.NewAccessTokenHandler[T, E]() + responseValidationHandler := handlers.NewResponseValidationHandler[T, E]() + unmarshalHandler := handlers.NewUnmarshalHandler[T, E]() + requestValidationHandler := handlers.NewRequestValidationHandler[T, E]() + hookHandler := handlers.NewHookHandler[T, E](hook) + terminatingHandler := handlers.NewTerminatingHandler[T, E]() - handlers := handlers.BuildHandlerChain[T](). + handlers := handlers.BuildHandlerChain[T, E](). AddHandler(retryHandler). AddHandler(bearerTokenHandler). AddHandler(responseValidationHandler). @@ -29,11 +34,19 @@ func NewRestClient[T any](config clientconfig.Config) *RestClient[T] { AddHandler(hookHandler). AddHandler(terminatingHandler) - return &RestClient[T]{ + return &RestClient[T, E]{ handlers: handlers, } } -func (client *RestClient[T]) Call(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// Call executes a regular HTTP request through the handler chain. +// Returns the response with deserialized data or an error response. +func (client *RestClient[T, E]) Call(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { return client.handlers.CallApi(request) } + +// Stream executes a streaming HTTP request through the handler chain. +// Returns a stream for consuming response chunks or an error response. +func (client *RestClient[T, E]) Stream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + return client.handlers.StreamApi(request) +} diff --git a/pkg/user-client/internal/clients/rest/handlers/bearer_token_handler.go b/pkg/user-client/internal/clients/rest/handlers/bearer_token_handler.go index 5a6dfff..890aff4 100644 --- a/pkg/user-client/internal/clients/rest/handlers/bearer_token_handler.go +++ b/pkg/user-client/internal/clients/rest/handlers/bearer_token_handler.go @@ -7,32 +7,59 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/httptransport" ) -type AccessTokenHandler[T any] struct { - nextHandler Handler[T] +// AccessTokenHandler adds a Bearer token to the Authorization header for authentication. +// It injects the configured access token into requests that require token-based auth. +// T is the response type, E is the error type. +type AccessTokenHandler[T any, E any] struct { + nextHandler Handler[T, E] } -func NewAccessTokenHandler[T any]() *AccessTokenHandler[T] { - return &AccessTokenHandler[T]{ +// NewAccessTokenHandler creates a new Bearer token authentication handler. +// Returns a handler that will inject the access token as a Bearer token in the Authorization header. +func NewAccessTokenHandler[T any, E any]() *AccessTokenHandler[T, E] { + return &AccessTokenHandler[T, E]{ nextHandler: nil, } } -func (h *AccessTokenHandler[T]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// prepareRequest clones the request and adds the Bearer token header if configured. +// Formats the token as "Bearer " and sets the Authorization header. +func (h *AccessTokenHandler[T, E]) prepareRequest(request httptransport.Request) (httptransport.Request, error) { if h.nextHandler == nil { - err := errors.New("Handler chain terminated without terminating handler") - return nil, httptransport.NewErrorResponse[T](err, nil) + return httptransport.Request{}, errors.New("Handler chain terminated without terminating handler") } nextRequest := request.Clone() - if request.Config.AccessToken == nil { - return h.nextHandler.Handle(nextRequest) + + if request.Config.AccessToken != nil { + nextRequest.SetHeader("Authorization", fmt.Sprintf("Bearer %s", *request.Config.AccessToken)) } - nextRequest.SetHeader("Authorization", fmt.Sprintf("Bearer %s", *request.Config.AccessToken)) + return nextRequest, nil +} +// Handle processes a regular request by adding the Bearer token if configured. +// Returns the response from the next handler after authentication is applied. +func (h *AccessTokenHandler[T, E]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { + nextRequest, err := h.prepareRequest(request) + if err != nil { + return nil, httptransport.NewErrorResponse[E](err, nil) + } return h.nextHandler.Handle(nextRequest) } -func (h *AccessTokenHandler[T]) SetNext(handler Handler[T]) { +// HandleStream processes a streaming request by adding the Bearer token if configured. +// Returns the stream from the next handler after authentication is applied. +func (h *AccessTokenHandler[T, E]) HandleStream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + nextRequest, err := h.prepareRequest(request) + if err != nil { + return nil, httptransport.NewErrorResponse[E](err, nil) + } + return h.nextHandler.HandleStream(nextRequest) +} + +// SetNext sets the next handler in the chain. +// This method is called during chain construction to link handlers together. +func (h *AccessTokenHandler[T, E]) SetNext(handler Handler[T, E]) { h.nextHandler = handler } diff --git a/pkg/user-client/internal/clients/rest/handlers/handler_chain.go b/pkg/user-client/internal/clients/rest/handlers/handler_chain.go index eec8a96..9a5590c 100644 --- a/pkg/user-client/internal/clients/rest/handlers/handler_chain.go +++ b/pkg/user-client/internal/clients/rest/handlers/handler_chain.go @@ -4,21 +4,31 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/httptransport" ) -type Handler[T any] interface { - Handle(req httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) - SetNext(handler Handler[T]) +// Handler defines the interface for request processing in the handler chain. +// Each handler can process both regular and streaming requests. +// T is the response type, E is the error type. +type Handler[T any, E any] interface { + Handle(req httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) + HandleStream(req httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) + SetNext(handler Handler[T, E]) } -type HandlerChain[T any] struct { - head Handler[T] - tail Handler[T] +// HandlerChain manages a chain of handlers for processing requests. +// Implements the chain of responsibility pattern for request/response processing. +type HandlerChain[T any, E any] struct { + head Handler[T, E] + tail Handler[T, E] } -func BuildHandlerChain[T any]() *HandlerChain[T] { - return &HandlerChain[T]{} +// BuildHandlerChain creates a new empty handler chain. +// Handlers can be added using AddHandler to build the processing pipeline. +func BuildHandlerChain[T any, E any]() *HandlerChain[T, E] { + return &HandlerChain[T, E]{} } -func (chain *HandlerChain[T]) AddHandler(handler Handler[T]) *HandlerChain[T] { +// AddHandler appends a handler to the end of the chain. +// Returns the chain for method chaining. Handlers execute in the order they are added. +func (chain *HandlerChain[T, E]) AddHandler(handler Handler[T, E]) *HandlerChain[T, E] { if chain.head == nil { chain.head = handler chain.tail = handler @@ -31,6 +41,14 @@ func (chain *HandlerChain[T]) AddHandler(handler Handler[T]) *HandlerChain[T] { return chain } -func (chain *HandlerChain[T]) CallApi(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// CallApi processes a regular HTTP request through the handler chain. +// Returns the processed response or an error response. +func (chain *HandlerChain[T, E]) CallApi(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { return chain.head.Handle(request) } + +// StreamApi processes a streaming HTTP request through the handler chain. +// Returns a stream for consuming response chunks or an error response. +func (chain *HandlerChain[T, E]) StreamApi(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + return chain.head.HandleStream(request) +} diff --git a/pkg/user-client/internal/clients/rest/handlers/hook_handler.go b/pkg/user-client/internal/clients/rest/handlers/hook_handler.go index b11a6d8..e53be69 100644 --- a/pkg/user-client/internal/clients/rest/handlers/hook_handler.go +++ b/pkg/user-client/internal/clients/rest/handlers/hook_handler.go @@ -7,22 +7,29 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/httptransport" ) -type HookHandler[T any] struct { - nextHandler Handler[T] +// HookHandler executes custom hook callbacks before and after request processing. +// It allows users to intercept and modify requests, responses, and errors through the hook interface. +// T is the response type, E is the error type. +type HookHandler[T any, E any] struct { + nextHandler Handler[T, E] hook hooks.Hook } -func NewHookHandler[T any](hook hooks.Hook) *HookHandler[T] { - return &HookHandler[T]{ +// NewHookHandler creates a new hook handler with the provided hook implementation. +// Returns a handler that will execute BeforeRequest, AfterResponse, and OnError callbacks. +func NewHookHandler[T any, E any](hook hooks.Hook) *HookHandler[T, E] { + return &HookHandler[T, E]{ hook: hook, nextHandler: nil, } } -func (h *HookHandler[T]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// Handle processes a regular request through the hook lifecycle. +// Executes BeforeRequest, passes the request through the chain, then executes AfterResponse or OnError. +func (h *HookHandler[T, E]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { if h.nextHandler == nil { err := errors.New("Handler chain terminated without terminating handler") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } clonedReq := request.Clone() @@ -31,17 +38,17 @@ func (h *HookHandler[T]) Handle(request httptransport.Request) (*httptransport.R nextRequest, ok := hookReq.(*httptransport.Request) if !ok { err := errors.New("hook returned invalid request") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } response, err := h.nextHandler.Handle(*nextRequest) if err != nil && err.IsHttpError { clonedError := err.Clone() hookError := h.hook.OnError(hookReq, &clonedError, clonedReq.Config.HookParams) - nextError, ok := hookError.(*httptransport.ErrorResponse[T]) + nextError, ok := hookError.(*httptransport.ErrorResponse[E]) if !ok { err := errors.New("hook returned invalid error") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } return nil, nextError @@ -54,12 +61,34 @@ func (h *HookHandler[T]) Handle(request httptransport.Request) (*httptransport.R nextResponse, ok := hookResp.(*httptransport.Response[T]) if !ok { err := errors.New("hook returned invalid response") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } return nextResponse, nil } -func (h *HookHandler[T]) SetNext(handler Handler[T]) { +// HandleStream processes a streaming request by executing the BeforeRequest hook. +// Returns the stream from the next handler after the request hook is applied. +func (h *HookHandler[T, E]) HandleStream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + if h.nextHandler == nil { + err := errors.New("Handler chain terminated without terminating handler") + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + clonedReq := request.Clone() + hookReq := h.hook.BeforeRequest(&clonedReq, clonedReq.Config.HookParams) + + nextRequest, ok := hookReq.(*httptransport.Request) + if !ok { + err := errors.New("hook returned invalid request") + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + return h.nextHandler.HandleStream(*nextRequest) +} + +// SetNext sets the next handler in the chain. +// This method is called during chain construction to link handlers together. +func (h *HookHandler[T, E]) SetNext(handler Handler[T, E]) { h.nextHandler = handler } diff --git a/pkg/user-client/internal/clients/rest/handlers/request_validation_handler.go b/pkg/user-client/internal/clients/rest/handlers/request_validation_handler.go index 0048f12..79f4e42 100644 --- a/pkg/user-client/internal/clients/rest/handlers/request_validation_handler.go +++ b/pkg/user-client/internal/clients/rest/handlers/request_validation_handler.go @@ -7,35 +7,65 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/validation" ) -type RequestValidationHandler[T any] struct { - nextHandler Handler[T] +// RequestValidationHandler validates request body and options before sending. +// It ensures that all required fields are present and values meet the specified constraints. +// T is the response type, E is the error type. +type RequestValidationHandler[T any, E any] struct { + nextHandler Handler[T, E] } -func NewRequestValidationHandler[T any]() *RequestValidationHandler[T] { - return &RequestValidationHandler[T]{ +// NewRequestValidationHandler creates a new request validation handler. +// Returns a handler that will validate request body and options against defined schemas. +func NewRequestValidationHandler[T any, E any]() *RequestValidationHandler[T, E] { + return &RequestValidationHandler[T, E]{ nextHandler: nil, } } -func (h *RequestValidationHandler[T]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// Handle validates the request body and options before passing to the next handler. +// Returns a validation error if any constraints are violated, otherwise continues the chain. +func (h *RequestValidationHandler[T, E]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { if h.nextHandler == nil { err := errors.New("Handler chain terminated without terminating handler") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } err := validation.ValidateData(request.Body) if err != nil { - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } err = validation.ValidateData(request.Options) if err != nil { - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } return h.nextHandler.Handle(request) } -func (h *RequestValidationHandler[T]) SetNext(handler Handler[T]) { +// HandleStream validates the request body and options before initiating a stream. +// Returns a validation error if any constraints are violated, otherwise continues the chain. +func (h *RequestValidationHandler[T, E]) HandleStream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + if h.nextHandler == nil { + err := errors.New("Handler chain terminated without terminating handler") + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + err := validation.ValidateData(request.Body) + if err != nil { + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + err = validation.ValidateData(request.Options) + if err != nil { + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + return h.nextHandler.HandleStream(request) +} + +// SetNext sets the next handler in the chain. +// This method is called during chain construction to link handlers together. +func (h *RequestValidationHandler[T, E]) SetNext(handler Handler[T, E]) { h.nextHandler = handler } diff --git a/pkg/user-client/internal/clients/rest/handlers/response_validation_handler.go b/pkg/user-client/internal/clients/rest/handlers/response_validation_handler.go index 08fefd5..6883e33 100644 --- a/pkg/user-client/internal/clients/rest/handlers/response_validation_handler.go +++ b/pkg/user-client/internal/clients/rest/handlers/response_validation_handler.go @@ -7,20 +7,27 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/validation" ) -type ResponseValidationHandler[T any] struct { - nextHandler Handler[T] +// ResponseValidationHandler validates response data after deserialization. +// It ensures that the response data meets the expected schema and constraints. +// T is the response type, E is the error type. +type ResponseValidationHandler[T any, E any] struct { + nextHandler Handler[T, E] } -func NewResponseValidationHandler[T any]() *ResponseValidationHandler[T] { - return &ResponseValidationHandler[T]{ +// NewResponseValidationHandler creates a new response validation handler. +// Returns a handler that will validate response data against defined schemas. +func NewResponseValidationHandler[T any, E any]() *ResponseValidationHandler[T, E] { + return &ResponseValidationHandler[T, E]{ nextHandler: nil, } } -func (h *ResponseValidationHandler[T]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// Handle validates the response data after it's been processed by the handler chain. +// Returns a validation error if the response data doesn't meet the schema, otherwise returns the response. +func (h *ResponseValidationHandler[T, E]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { if h.nextHandler == nil { err := errors.New("Handler chain terminated without terminating handler") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } resp, handlerError := h.nextHandler.Handle(request) @@ -30,12 +37,26 @@ func (h *ResponseValidationHandler[T]) Handle(request httptransport.Request) (*h err := validation.ValidateData(resp.Data) if err != nil { - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } return resp, nil } -func (h *ResponseValidationHandler[T]) SetNext(handler Handler[T]) { +// HandleStream passes through streaming requests without validation. +// Streaming responses are validated as they are consumed by the caller. +func (h *ResponseValidationHandler[T, E]) HandleStream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + if h.nextHandler == nil { + err := errors.New("Handler chain terminated without terminating handler") + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + // Streaming responses are validated as they are consumed, so just pass through + return h.nextHandler.HandleStream(request) +} + +// SetNext sets the next handler in the chain. +// This method is called during chain construction to link handlers together. +func (h *ResponseValidationHandler[T, E]) SetNext(handler Handler[T, E]) { h.nextHandler = handler } diff --git a/pkg/user-client/internal/clients/rest/handlers/retry_handler.go b/pkg/user-client/internal/clients/rest/handlers/retry_handler.go index 92c708a..4c91eab 100644 --- a/pkg/user-client/internal/clients/rest/handlers/retry_handler.go +++ b/pkg/user-client/internal/clients/rest/handlers/retry_handler.go @@ -12,23 +12,30 @@ const ( retryDelay = 150 * time.Millisecond ) -type RetryHandler[T any] struct { - nextHandler Handler[T] +// RetryHandler automatically retries failed requests with exponential backoff. +// It retries requests that fail or return 4xx/5xx status codes up to maxRetries times. +// T is the response type, E is the error type. +type RetryHandler[T any, E any] struct { + nextHandler Handler[T, E] } -func NewRetryHandler[T any]() *RetryHandler[T] { - return &RetryHandler[T]{ +// NewRetryHandler creates a new retry handler with configured max retries and delay. +// Returns a handler that will automatically retry failed requests with backoff. +func NewRetryHandler[T any, E any]() *RetryHandler[T, E] { + return &RetryHandler[T, E]{ nextHandler: nil, } } -func (h *RetryHandler[T]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// Handle processes a request with automatic retry logic on failures or error status codes. +// Implements exponential backoff between retry attempts. Returns the first successful response or the final error. +func (h *RetryHandler[T, E]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { if h.nextHandler == nil { err := errors.New("Handler chain terminated without terminating handler") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } - var err *httptransport.ErrorResponse[T] + var err *httptransport.ErrorResponse[E] for tryCount := 0; tryCount < maxRetries; tryCount++ { nextRequest := request.Clone() @@ -45,9 +52,39 @@ func (h *RetryHandler[T]) Handle(request httptransport.Request) (*httptransport. backoffDuration := time.Duration(tryCount) * retryDelay time.Sleep(backoffDuration) } - return nil, httptransport.NewErrorResponse[T](err, nil) + if err != nil { + return nil, err + } + return nil, httptransport.NewErrorResponse[E](errors.New("max retries exceeded"), nil) +} + +// HandleStream processes a streaming request with automatic retry logic on failures. +// Retries failed stream connections with exponential backoff. Returns the first successful stream or the final error. +func (h *RetryHandler[T, E]) HandleStream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + if h.nextHandler == nil { + err := errors.New("Handler chain terminated without terminating handler") + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + var errResp *httptransport.ErrorResponse[E] + for tryCount := 0; tryCount < maxRetries; tryCount++ { + nextRequest := request.Clone() + + stream, err := h.nextHandler.HandleStream(nextRequest) + if err == nil { + return stream, nil + } + + errResp = err + + backoffDuration := time.Duration(tryCount) * retryDelay + time.Sleep(backoffDuration) + } + return nil, errResp } -func (h *RetryHandler[T]) SetNext(handler Handler[T]) { +// SetNext sets the next handler in the chain. +// This method is called during chain construction to link handlers together. +func (h *RetryHandler[T, E]) SetNext(handler Handler[T, E]) { h.nextHandler = handler } diff --git a/pkg/user-client/internal/clients/rest/handlers/terminating_handler.go b/pkg/user-client/internal/clients/rest/handlers/terminating_handler.go index d7ad55a..568536a 100644 --- a/pkg/user-client/internal/clients/rest/handlers/terminating_handler.go +++ b/pkg/user-client/internal/clients/rest/handlers/terminating_handler.go @@ -1,19 +1,27 @@ package handlers import ( + "context" "fmt" "net/http" "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/httptransport" ) -type TerminatingHandler[T any] struct{} +// TerminatingHandler is the final handler in the chain that executes the actual HTTP request. +// It creates an HTTP client, sends the request, and converts the http.Response to a transport response. +// T is the response type, E is the error type. +type TerminatingHandler[T any, E any] struct{} -func NewTerminatingHandler[T any]() *TerminatingHandler[T] { - return &TerminatingHandler[T]{} +// NewTerminatingHandler creates a new terminating handler. +// Returns the handler that will execute HTTP requests and should be the last in the chain. +func NewTerminatingHandler[T any, E any]() *TerminatingHandler[T, E] { + return &TerminatingHandler[T, E]{} } -func (h *TerminatingHandler[T]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// Handle executes the HTTP request using the standard http.Client and returns the response. +// This is the final handler in the chain that performs the actual network call. +func (h *TerminatingHandler[T, E]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { requestClone := request.Clone() client := http.Client{} @@ -23,27 +31,71 @@ func (h *TerminatingHandler[T]) Handle(request httptransport.Request) (*httptran req, err := requestClone.CreateHttpRequest() if err != nil { - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } resp, err := client.Do(req) if err != nil { - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } transportResponse, responseErr := httptransport.NewResponse[T](resp) if responseErr != nil { - return nil, httptransport.NewErrorResponse[T](responseErr, transportResponse) + return nil, httptransport.NewErrorResponse[E](responseErr, nil) } if transportResponse.StatusCode >= 400 { err := fmt.Errorf("HTTP request failed with status code %d", transportResponse.StatusCode) - return nil, httptransport.NewErrorResponse[T](err, transportResponse) + errorResponse := &httptransport.Response[E]{ + StatusCode: transportResponse.StatusCode, + Headers: transportResponse.Headers, + Body: transportResponse.Body, + Raw: transportResponse.Raw, + } + return nil, httptransport.NewErrorResponse[E](err, errorResponse) } return transportResponse, nil } -func (h *TerminatingHandler[T]) SetNext(handler Handler[T]) { +// HandleStream executes a streaming HTTP request and returns a stream for consuming the response. +// Creates an HTTP client, sends the request, and wraps the response body in a stream for chunk-by-chunk processing. +func (h *TerminatingHandler[T, E]) HandleStream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + requestClone := request.Clone() + + client := http.Client{} + if requestClone.Config.Timeout != nil { + client.Timeout = *requestClone.Config.Timeout + } + + req, err := requestClone.CreateHttpRequest() + if err != nil { + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + resp, err := client.Do(req) + if err != nil { + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + if resp.StatusCode >= 400 { + resp.Body.Close() + err := fmt.Errorf("HTTP request failed with status code %d", resp.StatusCode) + return nil, httptransport.NewErrorResponse[E](err, nil) + } + + // Get context from request, or use background if not available + ctx := request.Context + if ctx == nil { + ctx = context.Background() + } + + stream := httptransport.NewStream[T](resp, ctx) + return stream, nil +} + +// SetNext logs a warning as the terminating handler should always be the last in the chain. +// Calling this method indicates a misconfiguration in the handler chain setup. +func (h *TerminatingHandler[T, E]) SetNext(handler Handler[T, E]) { fmt.Println("WARNING: SetNext should not be called on the terminating handler.") } diff --git a/pkg/user-client/internal/clients/rest/handlers/unmarshal_handler.go b/pkg/user-client/internal/clients/rest/handlers/unmarshal_handler.go index e8179e8..c4758c3 100644 --- a/pkg/user-client/internal/clients/rest/handlers/unmarshal_handler.go +++ b/pkg/user-client/internal/clients/rest/handlers/unmarshal_handler.go @@ -2,70 +2,168 @@ package handlers import ( "errors" + "fmt" + "reflect" "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/httptransport" "github.com/magicbell/magicbell-go/pkg/user-client/internal/contenttypes" ) -type UnmarshalHandler[T any] struct { - nextHandler Handler[T] +// UnmarshalHandler deserializes response bodies based on content type. +// It supports JSON, form data, text, and binary content types, converting raw bytes to typed data. +// T is the response type, E is the error type. +type UnmarshalHandler[T any, E any] struct { + nextHandler Handler[T, E] } -func NewUnmarshalHandler[T any]() *UnmarshalHandler[T] { - return &UnmarshalHandler[T]{ +// NewUnmarshalHandler creates a new unmarshaling handler. +// Returns a handler that will deserialize response bodies according to the requested content type. +func NewUnmarshalHandler[T any, E any]() *UnmarshalHandler[T, E] { + return &UnmarshalHandler[T, E]{ nextHandler: nil, } } -func (h *UnmarshalHandler[T]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[T]) { +// Handle deserializes the response body from the next handler based on the response content type. +// Supports JSON, form-urlencoded, multipart form data, text, and binary formats. +func (h *UnmarshalHandler[T, E]) Handle(request httptransport.Request) (*httptransport.Response[T], *httptransport.ErrorResponse[E]) { if h.nextHandler == nil { err := errors.New("Handler chain terminated without terminating handler") - return nil, httptransport.NewErrorResponse[T](err, nil) + return nil, httptransport.NewErrorResponse[E](err, nil) } resp, handlerError := h.nextHandler.Handle(request) if handlerError != nil { + // Try to unmarshal error response body into the error type E + if handlerError.IsHttpError && len(handlerError.Body) > 0 { + unmarshaledError := h.tryUnmarshalErrorBody(handlerError) + if unmarshaledError != nil { + return nil, unmarshaledError + } + } return nil, handlerError } - target := new(T) - if request.ResponseContentType == httptransport.ContentTypeJson { - err := contenttypes.FromJson(resp.Body, target) - if err != nil { - return nil, httptransport.NewErrorResponse[T](err, resp) - } - } else if request.ResponseContentType == httptransport.ContentTypeFormUrlEncoded { - err := contenttypes.FromFormUrlEncoded(resp.Body, target) - if err != nil { - return nil, httptransport.NewErrorResponse[T](err, resp) - } - } else if request.ResponseContentType == httptransport.ContentTypeMultipartFormData { - err := contenttypes.FromFormData(resp.Body, target) - if err != nil { - return nil, httptransport.NewErrorResponse[T](err, resp) - } - } else if request.ResponseContentType == httptransport.ContentTypeText { - err := contenttypes.FromText[T](resp.Body, target) - if err != nil { - return nil, httptransport.NewErrorResponse[T](err, resp) + if len(resp.Body) == 0 { + var zeroValue T + resp.Data = zeroValue + return resp, nil + } + + contentTypesToTry := []httptransport.ContentType{ + httptransport.ContentTypeJson, + httptransport.ContentTypeMultipartFormData, + httptransport.ContentTypeFormUrlEncoded, + httptransport.ContentTypeText, + httptransport.ContentTypeBinary, + } + + var lastErr error + for _, contentType := range contentTypesToTry { + tempTarget := new(T) + err := unmarshalWithContentType(resp.Body, tempTarget, contentType) + if err == nil { + resp.Data = *tempTarget + return resp, nil } - } else if request.ResponseContentType == httptransport.ContentTypeBinary { - err := contenttypes.FromBinary(resp.Body, target) - if err != nil { - return nil, httptransport.NewErrorResponse[T](err, resp) + lastErr = err + } + + if lastErr == nil { + lastErr = fmt.Errorf("failed to unmarshal response with any content type") + } + + return nil, httptransport.NewErrorResponse[E](lastErr, nil) +} + +// tryUnmarshalErrorBody attempts to unmarshal the error response body into the error type E. +// Returns a new ErrorResponse with unmarshaled data if successful, or nil if unmarshaling fails. +// For []byte error types, FromBinary will handle copying the body directly. +func (h *UnmarshalHandler[T, E]) tryUnmarshalErrorBody(err *httptransport.ErrorResponse[E]) *httptransport.ErrorResponse[E] { + // Normalize empty body: convert nil to empty slice for consistent handling + body := err.Body + if body == nil { + body = []byte{} + } + + contentTypesToTry := []httptransport.ContentType{ + httptransport.ContentTypeJson, + httptransport.ContentTypeMultipartFormData, + httptransport.ContentTypeFormUrlEncoded, + httptransport.ContentTypeText, + httptransport.ContentTypeBinary, + } + + for _, contentType := range contentTypesToTry { + tempTarget := new(E) + unmarshalErr := unmarshalWithContentType(body, tempTarget, contentType) + if unmarshalErr == nil { + // Check if the unmarshaled value is a zero value (e.g., nil slice for []byte) + // For zero values, we want Data to be nil, not a pointer to zero value + if isEmptyValue(*tempTarget) { + // Return nil to indicate unmarshaling didn't produce meaningful data + // This allows callers to distinguish between "unmarshaled successfully" and "no data" + return nil + } + // Successfully unmarshaled, create a new error response with the unmarshaled data + unmarshaledError := err.Clone() + unmarshaledError.Data = tempTarget + // Ensure Body is also normalized (convert nil to empty slice) + if unmarshaledError.Body == nil { + unmarshaledError.Body = []byte{} + } + return &unmarshaledError } + } + + // If unmarshaling fails for all content types, Data remains nil (pointer to E) + return nil +} + +// isEmptyValue checks if a value is considered "empty" (zero value). +// For slices, this means nil or empty slice. For other types, it's the zero value. +func isEmptyValue[T any](v T) bool { + var zero T + if reflect.DeepEqual(v, zero) { + return true + } + // Also check if it's an empty slice (length 0) + vValue := reflect.ValueOf(v) + if vValue.Kind() == reflect.Slice { + return vValue.Len() == 0 + } + return false +} + +func unmarshalWithContentType[T any](body []byte, target *T, contentType httptransport.ContentType) error { + if contentType == httptransport.ContentTypeJson { + return contenttypes.FromJson(body, target) + } else if contentType == httptransport.ContentTypeFormUrlEncoded { + return contenttypes.FromFormUrlEncoded(body, target) + } else if contentType == httptransport.ContentTypeMultipartFormData { + return contenttypes.FromFormData(body, target) + } else if contentType == httptransport.ContentTypeText { + return contenttypes.FromText[T](body, target) + } else if contentType == httptransport.ContentTypeBinary { + return contenttypes.FromBinary(body, target) } else { - err := contenttypes.FromBinary(resp.Body, target) - if err != nil { - return nil, httptransport.NewErrorResponse[T](err, resp) - } + return contenttypes.FromBinary(body, target) } +} - resp.Data = *target +// HandleStream passes through streaming requests without unmarshaling. +// Streaming responses handle their own unmarshaling as chunks are consumed. +func (h *UnmarshalHandler[T, E]) HandleStream(request httptransport.Request) (*httptransport.Stream[T], *httptransport.ErrorResponse[E]) { + if h.nextHandler == nil { + err := errors.New("Handler chain terminated without terminating handler") + return nil, httptransport.NewErrorResponse[E](err, nil) + } - return resp, nil + return h.nextHandler.HandleStream(request) } -func (h *UnmarshalHandler[T]) SetNext(handler Handler[T]) { +// SetNext sets the next handler in the chain. +// This method is called during chain construction to link handlers together. +func (h *UnmarshalHandler[T, E]) SetNext(handler Handler[T, E]) { h.nextHandler = handler } diff --git a/pkg/user-client/internal/clients/rest/hooks/default_hook.go b/pkg/user-client/internal/clients/rest/hooks/default_hook.go index 8e1e0da..c0ad287 100644 --- a/pkg/user-client/internal/clients/rest/hooks/default_hook.go +++ b/pkg/user-client/internal/clients/rest/hooks/default_hook.go @@ -1,19 +1,26 @@ package hooks +// DefaultHook is a no-op hook implementation that passes through all requests and responses unchanged. +// Used as the default hook when no custom hook is provided. type DefaultHook struct{} +// NewDefaultHook creates a new default hook that performs no modifications. +// Returns a hook that passes through all requests, responses, and errors unchanged. func NewDefaultHook() Hook { return &DefaultHook{} } +// BeforeRequest passes the request through unchanged. func (h *DefaultHook) BeforeRequest(req Request, params map[string]string) Request { return req } +// AfterResponse passes the response through unchanged. func (h *DefaultHook) AfterResponse(req Request, resp Response, params map[string]string) Response { return resp } +// OnError passes the error response through unchanged. func (h *DefaultHook) OnError(req Request, resp ErrorResponse, params map[string]string) ErrorResponse { return resp } diff --git a/pkg/user-client/internal/clients/rest/hooks/hook.go b/pkg/user-client/internal/clients/rest/hooks/hook.go index bdbfacb..f8d4da4 100644 --- a/pkg/user-client/internal/clients/rest/hooks/hook.go +++ b/pkg/user-client/internal/clients/rest/hooks/hook.go @@ -1,11 +1,14 @@ package hooks +// Hook defines the interface for intercepting and modifying requests, responses, and errors. +// Implementations can inspect, modify, or log HTTP interactions at key points in the request lifecycle. type Hook interface { BeforeRequest(req Request, params map[string]string) Request AfterResponse(req Request, resp Response, params map[string]string) Response OnError(req Request, resp ErrorResponse, params map[string]string) ErrorResponse } +// Request defines the interface for accessing and modifying HTTP request properties within hooks. type Request interface { GetMethod() string SetMethod(method string) @@ -25,6 +28,7 @@ type Request interface { SetBody(body any) } +// Response defines the interface for accessing and modifying HTTP response properties within hooks. type Response interface { GetStatusCode() int SetStatusCode(statusCode int) @@ -34,6 +38,7 @@ type Response interface { SetBody(body []byte) } +// ErrorResponse defines the interface for accessing and modifying HTTP error responses within hooks. type ErrorResponse interface { Error() string GetError() error diff --git a/pkg/user-client/internal/clients/rest/httptransport/content-type.go b/pkg/user-client/internal/clients/rest/httptransport/content-type.go index 3b19200..63b87c9 100644 --- a/pkg/user-client/internal/clients/rest/httptransport/content-type.go +++ b/pkg/user-client/internal/clients/rest/httptransport/content-type.go @@ -1,5 +1,7 @@ package httptransport +// ContentType represents the serialization format for request and response bodies. +// Used to determine how to serialize request data and deserialize response data. type ContentType string const ( diff --git a/pkg/user-client/internal/clients/rest/httptransport/error_response.go b/pkg/user-client/internal/clients/rest/httptransport/error_response.go index 0da26fe..7aa67ab 100644 --- a/pkg/user-client/internal/clients/rest/httptransport/error_response.go +++ b/pkg/user-client/internal/clients/rest/httptransport/error_response.go @@ -1,16 +1,25 @@ package httptransport -import "fmt" +import ( + "fmt" + "net/http" +) +// ErrorResponse represents a failed HTTP request with error details and optional response data. +// It distinguishes between HTTP errors (with status codes) and other errors (network, serialization, etc.). +// Data is a pointer to allow nil when unmarshaling fails. type ErrorResponse[T any] struct { Err error IsHttpError bool StatusCode int Headers map[string]string Body []byte - Data T + Data *T + Raw *http.Response } +// NewErrorResponse creates an ErrorResponse from an error and an optional response. +// If response is provided, sets IsHttpError to true and includes response metadata. func NewErrorResponse[T any](err error, resp *Response[T]) *ErrorResponse[T] { if resp == nil { return &ErrorResponse[T]{ @@ -25,10 +34,12 @@ func NewErrorResponse[T any](err error, resp *Response[T]) *ErrorResponse[T] { StatusCode: resp.StatusCode, Headers: resp.Headers, Body: resp.Body, - Data: resp.Data, + Raw: resp.Raw, } } +// Clone creates a deep copy of the ErrorResponse including headers. +// Returns a new ErrorResponse with copied values. func (r *ErrorResponse[T]) Clone() ErrorResponse[T] { if r == nil { return ErrorResponse[T]{} @@ -42,10 +53,12 @@ func (r *ErrorResponse[T]) Clone() ErrorResponse[T] { return clone } +// Error implements the error interface, returning the error message string. func (r *ErrorResponse[T]) Error() string { return fmt.Sprintf("%s", r.Err) } +// GetError returns the underlying error. func (r *ErrorResponse[T]) GetError() error { return r.Err } diff --git a/pkg/user-client/internal/clients/rest/httptransport/request-builder.go b/pkg/user-client/internal/clients/rest/httptransport/request-builder.go index 0de38ed..2e21148 100644 --- a/pkg/user-client/internal/clients/rest/httptransport/request-builder.go +++ b/pkg/user-client/internal/clients/rest/httptransport/request-builder.go @@ -6,10 +6,14 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" ) +// RequestBuilder provides a fluent interface for constructing HTTP requests. +// Uses the builder pattern to incrementally configure request parameters, headers, body, and options. type RequestBuilder struct { request *Request } +// NewRequestBuilder creates a new request builder with default settings. +// Initializes empty maps for headers, query params, and path params. func NewRequestBuilder() *RequestBuilder { return &RequestBuilder{ request: &Request{ @@ -20,56 +24,78 @@ func NewRequestBuilder() *RequestBuilder { } } +// WithContext sets the request context for cancellation and timeout control. +// Returns the builder for method chaining. func (rb *RequestBuilder) WithContext(ctx context.Context) *RequestBuilder { rb.request.Context = ctx return rb } +// WithMethod sets the HTTP method (GET, POST, PUT, DELETE, etc.). +// Returns the builder for method chaining. func (rb *RequestBuilder) WithMethod(method string) *RequestBuilder { rb.request.Method = method return rb } +// WithPath sets the URL path for the request. +// Returns the builder for method chaining. func (rb *RequestBuilder) WithPath(path string) *RequestBuilder { rb.request.Path = path return rb } +// AddHeader adds a header key-value pair to the request. +// Returns the builder for method chaining. func (rb *RequestBuilder) AddHeader(key string, value string) *RequestBuilder { rb.request.SetHeader(key, value) return rb } +// AddPathParam adds a path parameter to be substituted into the URL path. +// Returns the builder for method chaining. func (rb *RequestBuilder) AddPathParam(key string, value any) *RequestBuilder { rb.request.SetPathParam(key, value) return rb } +// WithOptions sets the request options containing query/header parameters. +// Returns the builder for method chaining. func (rb *RequestBuilder) WithOptions(options any) *RequestBuilder { rb.request.Options = options return rb } +// WithBody sets the request body to be serialized. +// Returns the builder for method chaining. func (rb *RequestBuilder) WithBody(body any) *RequestBuilder { rb.request.Body = body return rb } +// WithConfig sets the SDK configuration including base URL, timeout, and auth credentials. +// Returns the builder for method chaining. func (rb *RequestBuilder) WithConfig(config clientconfig.Config) *RequestBuilder { rb.request.Config = config return rb } +// WithContentType sets the content type for serializing the request body. +// Returns the builder for method chaining. func (rb *RequestBuilder) WithContentType(contentType ContentType) *RequestBuilder { rb.request.ContentType = contentType return rb } +// WithResponseContentType sets the expected content type for deserializing the response. +// Returns the builder for method chaining. func (rb *RequestBuilder) WithResponseContentType(contentType ContentType) *RequestBuilder { rb.request.ResponseContentType = contentType return rb } +// Build returns the fully configured Request. +// Should be called after all configuration methods to obtain the final request. func (rb *RequestBuilder) Build() *Request { return rb.request } diff --git a/pkg/user-client/internal/clients/rest/httptransport/request.go b/pkg/user-client/internal/clients/rest/httptransport/request.go index f0e15bf..13410ea 100644 --- a/pkg/user-client/internal/clients/rest/httptransport/request.go +++ b/pkg/user-client/internal/clients/rest/httptransport/request.go @@ -20,6 +20,8 @@ type paramMap struct { Value string } +// Request represents an HTTP request with all necessary configuration and parameters. +// Handles path/query/header serialization, content types, and authentication scopes. type Request struct { Context context.Context Method string @@ -34,6 +36,8 @@ type Request struct { ResponseContentType ContentType } +// NewRequest creates a new Request with default settings. +// Initializes maps for headers, query params, and path params, and sets default content types to JSON. func NewRequest(ctx context.Context, method string, path string, config clientconfig.Config) Request { return Request{ Context: ctx, @@ -48,6 +52,8 @@ func NewRequest(ctx context.Context, method string, path string, config clientco } } +// Clone creates a deep copy of the Request including all maps. +// Returns a new Request with copied values to prevent mutation of the original. func (r *Request) Clone() Request { if r == nil { return Request{ diff --git a/pkg/user-client/internal/clients/rest/httptransport/response.go b/pkg/user-client/internal/clients/rest/httptransport/response.go index 6cb54df..9145fdd 100644 --- a/pkg/user-client/internal/clients/rest/httptransport/response.go +++ b/pkg/user-client/internal/clients/rest/httptransport/response.go @@ -5,13 +5,18 @@ import ( "net/http" ) +// Response represents an HTTP response with deserialized data. +// Generic type T specifies the expected response data type. type Response[T any] struct { StatusCode int Headers map[string]string Body []byte Data T + Raw *http.Response } +// Clone creates a deep copy of the Response including headers. +// Returns a new Response with copied values. func (r *Response[T]) Clone() Response[T] { if r == nil { return Response[T]{ @@ -27,6 +32,8 @@ func (r *Response[T]) Clone() Response[T] { return clone } +// NewResponse creates a Response from an http.Response. +// Reads and stores the body, extracts headers, and initializes the response structure. func NewResponse[T any](resp *http.Response) (*Response[T], error) { defer resp.Body.Close() @@ -46,6 +53,7 @@ func NewResponse[T any](resp *http.Response) (*Response[T], error) { Headers: responseHeaders, Body: body, Data: *placeholderData, + Raw: resp, }, nil } diff --git a/pkg/user-client/internal/clients/rest/httptransport/stream.go b/pkg/user-client/internal/clients/rest/httptransport/stream.go new file mode 100644 index 0000000..1c53046 --- /dev/null +++ b/pkg/user-client/internal/clients/rest/httptransport/stream.go @@ -0,0 +1,193 @@ +package httptransport + +import ( + "bufio" + "context" + "encoding/json" + "errors" + "fmt" + "net/http" + "strings" + "sync" +) + +// ErrStreamClosed is returned when trying to read from a closed stream. +var ErrStreamClosed = errors.New("stream is closed") + +// StreamChunk represents a single chunk from a streaming response. +// Contains the deserialized data, raw bytes, and metadata about the response. +type StreamChunk[T any] struct { + Data T + Raw []byte + Metadata StreamChunkMetadata +} + +// StreamChunkMetadata contains metadata about a stream chunk. +// Includes HTTP headers and status code from the streaming response. +type StreamChunkMetadata struct { + Headers map[string]string + StatusCode int +} + +// Stream represents a streaming response from the API using Server-Sent Events (SSE) protocol. +// It handles chunk-by-chunk processing with context cancellation and thread-safe closure. +type Stream[T any] struct { + response *http.Response + scanner *bufio.Scanner + ctx context.Context + statusCode int + headers map[string]string + + mu sync.Mutex + closed bool +} + +// NewStream creates a new stream wrapper from an HTTP response with context for cancellation. +// Converts response headers to a map and initializes the stream scanner for reading chunks. +func NewStream[T any](resp *http.Response, ctx context.Context) *Stream[T] { + // Convert http.Header to map[string]string + headers := make(map[string]string) + for key, values := range resp.Header { + if len(values) > 0 { + headers[key] = values[0] + } + } + + return &Stream[T]{ + response: resp, + scanner: bufio.NewScanner(resp.Body), + ctx: ctx, + statusCode: resp.StatusCode, + headers: headers, + closed: false, + } +} + +// Next returns the next chunk from the stream by reading and parsing SSE data. +// Returns ErrStreamClosed when the stream has ended normally or receives [DONE] signal. +// Returns context errors if the context is cancelled or times out. Thread-safe for concurrent access. +func (s *Stream[T]) Next() (*StreamChunk[T], error) { + s.mu.Lock() + if s.closed { + s.mu.Unlock() + return nil, ErrStreamClosed + } + s.mu.Unlock() + + // Check if context is cancelled + select { + case <-s.ctx.Done(): + s.Close() + return nil, s.ctx.Err() + default: + } + + for s.scanner.Scan() { + line := s.scanner.Text() + data, ok := parseSSELine(line) + if !ok { + // Skip non-data lines or stream termination + if data == "" && line == "" { + continue + } + // [DONE] signal received + s.Close() + return nil, ErrStreamClosed + } + + var chunk T + if err := json.Unmarshal([]byte(data), &chunk); err != nil { + return nil, err + } + + return &StreamChunk[T]{ + Data: chunk, + Raw: []byte(data), + Metadata: StreamChunkMetadata{ + StatusCode: s.statusCode, + Headers: s.headers, + }, + }, nil + } + + if err := s.scanner.Err(); err != nil { + s.Close() + return nil, err + } + + s.Close() + return nil, ErrStreamClosed +} + +// Close closes the stream and releases resources including the response body. +// Idempotent - calling Close multiple times is safe. Thread-safe for concurrent access. +func (s *Stream[T]) Close() error { + s.mu.Lock() + defer s.mu.Unlock() + + if s.closed { + return nil + } + s.closed = true + return s.response.Body.Close() +} + +// IsClosed returns whether the stream has been closed. +// Thread-safe for concurrent access. +func (s *Stream[T]) IsClosed() bool { + s.mu.Lock() + defer s.mu.Unlock() + return s.closed +} + +// parseSSELine parses a Server-Sent Events line according to SSE protocol. +// SSE format: "data: {json content}\n\n". Returns the data content and true if valid, +// or empty string and false if the line should be skipped or signals stream termination ([DONE]). +func parseSSELine(line string) (string, bool) { + line = strings.TrimSpace(line) + if strings.HasPrefix(line, "data: ") { + data := strings.TrimPrefix(line, "data: ") + // Check for stream termination signal + if data == "[DONE]" { + return "", false + } + return data, true + } + return "", false +} + +// HandleStream creates a streaming HTTP request and returns a Stream for consuming chunks. +// Executes the HTTP request, validates the status code, and wraps the response in a Stream. +func HandleStream[T any](request Request) (*Stream[T], *ErrorResponse[T]) { + requestClone := request.Clone() + + client := http.Client{} + if requestClone.Config.Timeout != nil { + client.Timeout = *requestClone.Config.Timeout + } + + req, err := requestClone.CreateHttpRequest() + if err != nil { + return nil, NewErrorResponse[T](err, nil) + } + + resp, err := client.Do(req) + if err != nil { + return nil, NewErrorResponse[T](err, nil) + } + + if resp.StatusCode >= 400 { + resp.Body.Close() + err := fmt.Errorf("HTTP request failed with status code %d", resp.StatusCode) + return nil, NewErrorResponse[T](err, nil) + } + + // Get context from request, or use background if not available + ctx := request.Context + if ctx == nil { + ctx = context.Background() + } + + stream := NewStream[T](resp, ctx) + return stream, nil +} diff --git a/pkg/user-client/internal/configmanager/config_manager.go b/pkg/user-client/internal/configmanager/config_manager.go index 491d72d..98cedcf 100644 --- a/pkg/user-client/internal/configmanager/config_manager.go +++ b/pkg/user-client/internal/configmanager/config_manager.go @@ -5,12 +5,16 @@ import ( "time" ) +// ConfigManager manages configuration across all services with synchronized updates. +// Provides centralized configuration management and OAuth token handling for multiple services. type ConfigManager struct { Channels clientconfig.Config Integrations clientconfig.Config Notifications clientconfig.Config } +// NewConfigManager creates a new configuration manager with the provided config and optional OAuth token service. +// Initializes service-specific configs and sets up OAuth token management if enabled. func NewConfigManager(config clientconfig.Config) *ConfigManager { return &ConfigManager{ Channels: config, @@ -19,24 +23,32 @@ func NewConfigManager(config clientconfig.Config) *ConfigManager { } } +// SetBaseUrl updates the BaseUrl configuration parameter across all services. +// Changes are applied synchronously to all registered service configurations. func (c *ConfigManager) SetBaseUrl(baseUrl string) { c.Channels.SetBaseUrl(baseUrl) c.Integrations.SetBaseUrl(baseUrl) c.Notifications.SetBaseUrl(baseUrl) } +// SetTimeout updates the Timeout configuration parameter across all services. +// Changes are applied synchronously to all registered service configurations. func (c *ConfigManager) SetTimeout(timeout time.Duration) { c.Channels.SetTimeout(timeout) c.Integrations.SetTimeout(timeout) c.Notifications.SetTimeout(timeout) } +// SetAccessToken updates the AccessToken configuration parameter across all services. +// Changes are applied synchronously to all registered service configurations. func (c *ConfigManager) SetAccessToken(accessToken string) { c.Channels.SetAccessToken(accessToken) c.Integrations.SetAccessToken(accessToken) c.Notifications.SetAccessToken(accessToken) } +// UpdateAccessToken replaces an access token across all services that use the original value. +// Used for token refresh to update all service configurations simultaneously. func (c *ConfigManager) UpdateAccessToken(originalValue string, newValue string) { if c.Channels.AccessToken != nil && *c.Channels.AccessToken == originalValue { @@ -52,12 +64,20 @@ func (c *ConfigManager) UpdateAccessToken(originalValue string, newValue string) } } +// GetChannels returns the configuration for the Channels service. +// Returns a pointer to the service-specific config for use in API calls. func (c *ConfigManager) GetChannels() *clientconfig.Config { return &c.Channels } + +// GetIntegrations returns the configuration for the Integrations service. +// Returns a pointer to the service-specific config for use in API calls. func (c *ConfigManager) GetIntegrations() *clientconfig.Config { return &c.Integrations } + +// GetNotifications returns the configuration for the Notifications service. +// Returns a pointer to the service-specific config for use in API calls. func (c *ConfigManager) GetNotifications() *clientconfig.Config { return &c.Notifications } diff --git a/pkg/user-client/internal/contenttypes/from_binary.go b/pkg/user-client/internal/contenttypes/from_binary.go index d1272fe..9946c7a 100644 --- a/pkg/user-client/internal/contenttypes/from_binary.go +++ b/pkg/user-client/internal/contenttypes/from_binary.go @@ -1,13 +1,34 @@ package contenttypes import ( + "encoding/base64" "fmt" + "github.com/magicbell/magicbell-go/pkg/user-client/internal/unmarshal" + "reflect" ) +// FromBinary deserializes binary response data into a byte slice target. +// The target must be a non-nil pointer to []byte. Returns an error if conversion fails. func FromBinary(data any, target any) error { + targetValue := reflect.ValueOf(target) + + if targetValue.Kind() != reflect.Ptr || targetValue.IsNil() { + return fmt.Errorf("target must be a non-nil pointer") + } + + targetValue = targetValue.Elem() + if b, ok := data.([]byte); ok { - target = &b - return nil + if targetValue.Kind() == reflect.Slice && targetValue.Type().Elem().Kind() == reflect.Uint8 { + targetValue.Set(reflect.ValueOf(b)) + return nil + } + + if targetValue.Kind() == reflect.Struct { + base64Str := base64.StdEncoding.EncodeToString(b) + jsonBody := []byte(`"` + base64Str + `"`) + return unmarshal.Unmarshal(jsonBody, target) + } } return fmt.Errorf("Failed to convert response body to byte array") diff --git a/pkg/user-client/internal/contenttypes/from_form_data.go b/pkg/user-client/internal/contenttypes/from_form_data.go index 2ec55c4..0c7aef7 100644 --- a/pkg/user-client/internal/contenttypes/from_form_data.go +++ b/pkg/user-client/internal/contenttypes/from_form_data.go @@ -7,6 +7,8 @@ import ( "strconv" ) +// FromFormData deserializes multipart/form-data into a struct. +// Uses 'form' tags to map form fields to struct fields. Supports string, int, float, and bool types. func FromFormData(formData []byte, dest interface{}) error { // Parse the form data into url.Values data, err := url.ParseQuery(string(formData)) @@ -22,6 +24,7 @@ func FromFormData(formData []byte, dest interface{}) error { val = val.Elem() // Iterate over each field in the struct + fieldsSet := 0 for i := 0; i < val.NumField(); i++ { field := val.Type().Field(i) fieldValue := val.Field(i) @@ -36,32 +39,52 @@ func FromFormData(formData []byte, dest interface{}) error { if formValues, ok := data[formKey]; ok && len(formValues) > 0 { formValue := formValues[0] + // Handle pointer fields by dereferencing + actualValue := fieldValue + if fieldValue.Kind() == reflect.Ptr { + if fieldValue.IsNil() { + // Create a new value of the underlying type + actualValue = reflect.New(fieldValue.Type().Elem()) + fieldValue.Set(actualValue) + } + actualValue = actualValue.Elem() + } + // Set the value on the struct field based on its type - switch fieldValue.Kind() { + switch actualValue.Kind() { case reflect.String: - fieldValue.SetString(formValue) + actualValue.SetString(formValue) + fieldsSet++ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: intVal, err := strconv.ParseInt(formValue, 10, 64) if err != nil { return fmt.Errorf("failed to parse int for field %s: %v", field.Name, err) } - fieldValue.SetInt(intVal) + actualValue.SetInt(intVal) + fieldsSet++ case reflect.Float32, reflect.Float64: floatVal, err := strconv.ParseFloat(formValue, 64) if err != nil { return fmt.Errorf("failed to parse float for field %s: %v", field.Name, err) } - fieldValue.SetFloat(floatVal) + actualValue.SetFloat(floatVal) + fieldsSet++ case reflect.Bool: boolVal, err := strconv.ParseBool(formValue) if err != nil { return fmt.Errorf("failed to parse bool for field %s: %v", field.Name, err) } - fieldValue.SetBool(boolVal) + actualValue.SetBool(boolVal) + fieldsSet++ default: return fmt.Errorf("unsupported field type for field %s", field.Name) } } } + + if fieldsSet == 0 { + return fmt.Errorf("no form fields were set - form data may be invalid or empty") + } + return nil } diff --git a/pkg/user-client/internal/contenttypes/from_form_url_encoded.go b/pkg/user-client/internal/contenttypes/from_form_url_encoded.go index d1171cf..56cb791 100644 --- a/pkg/user-client/internal/contenttypes/from_form_url_encoded.go +++ b/pkg/user-client/internal/contenttypes/from_form_url_encoded.go @@ -1,20 +1,33 @@ package contenttypes import ( + "fmt" "net/url" "reflect" "strings" ) +// FromFormUrlEncoded deserializes URL-encoded form data into a struct. +// Uses struct field json tags to map form keys to struct fields. Only string fields are supported. func FromFormUrlEncoded(data []byte, target any) error { values, err := url.ParseQuery(string(data)) if err != nil { return err } - targetVal := reflect.ValueOf(target).Elem() + targetVal := reflect.ValueOf(target) + if targetVal.Kind() != reflect.Ptr || targetVal.IsNil() { + return fmt.Errorf("target must be a non-nil pointer") + } + targetVal = targetVal.Elem() + + if targetVal.Kind() != reflect.Struct { + return fmt.Errorf("destination must be a pointer to a struct") + } + targetType := targetVal.Type() + fieldsSet := 0 for i := 0; i < targetType.NumField(); i++ { field := targetType.Field(i) fieldValue := targetVal.Field(i) @@ -23,11 +36,19 @@ func FromFormUrlEncoded(data []byte, target any) error { if value, found := values[key]; found && len(value) > 0 { updateFieldWithValue(fieldValue, value) + fieldsSet++ } } + + if fieldsSet == 0 { + return fmt.Errorf("no form fields were set - form data may be invalid or empty") + } + return nil } +// updateFieldWithValue sets a struct field value from form data values. +// Handles both pointer and non-pointer string fields, using the first value if multiple are present. func updateFieldWithValue(fieldValue reflect.Value, value []string) { firstValue := value[0] if fieldValue.Kind() == reflect.Ptr { @@ -38,10 +59,12 @@ func updateFieldWithValue(fieldValue reflect.Value, value []string) { fieldValue.Elem().SetString(firstValue) } } else if fieldValue.CanSet() { - fieldValue.SetString(firstValue) // Set only the first value if multiple are present + fieldValue.SetString(firstValue) } } +// getFieldName extracts the field name from json tag or uses the struct field name as fallback. +// Returns the name to use as the form key for this field. func getFieldName(field reflect.StructField) string { key := field.Tag.Get("json") if key != "" { diff --git a/pkg/user-client/internal/contenttypes/from_json.go b/pkg/user-client/internal/contenttypes/from_json.go index f9a056a..e69828c 100644 --- a/pkg/user-client/internal/contenttypes/from_json.go +++ b/pkg/user-client/internal/contenttypes/from_json.go @@ -5,6 +5,8 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/unmarshal" ) +// FromJson deserializes JSON data from HTTP response bodies into the target struct. +// Uses the custom unmarshal package to handle complex types and validations. func FromJson(data []byte, target any) error { err := unmarshal.Unmarshal(data, target) if err != nil { diff --git a/pkg/user-client/internal/contenttypes/from_text.go b/pkg/user-client/internal/contenttypes/from_text.go index a24ec1d..2d2ed02 100644 --- a/pkg/user-client/internal/contenttypes/from_text.go +++ b/pkg/user-client/internal/contenttypes/from_text.go @@ -1,11 +1,20 @@ package contenttypes import ( + "encoding/json" "fmt" + "github.com/magicbell/magicbell-go/pkg/user-client/internal/unmarshal" "reflect" + "unicode/utf8" ) +// FromText deserializes plain text response data into a string target. +// The target must be a non-nil pointer to a string. Returns an error for unsupported types. func FromText[T any](data []byte, target any) error { + if !utf8.Valid(data) { + return fmt.Errorf("data is not valid UTF-8 text") + } + targetValue := reflect.ValueOf(target) if targetValue.Kind() != reflect.Ptr || targetValue.IsNil() { @@ -17,9 +26,14 @@ func FromText[T any](data []byte, target any) error { switch targetValue.Kind() { case reflect.String: targetValue.SetString(string(data)) + return nil + case reflect.Struct: + jsonBody, err := json.Marshal(string(data)) + if err != nil { + return fmt.Errorf("failed to marshal text as JSON string: %v", err) + } + return unmarshal.Unmarshal(jsonBody, target) default: return fmt.Errorf("unsupported target type: %s", targetValue.Kind()) } - - return nil } diff --git a/pkg/user-client/internal/contenttypes/to_binary.go b/pkg/user-client/internal/contenttypes/to_binary.go index 871a356..b9cd2c6 100644 --- a/pkg/user-client/internal/contenttypes/to_binary.go +++ b/pkg/user-client/internal/contenttypes/to_binary.go @@ -5,6 +5,8 @@ import ( "fmt" ) +// ToBinary serializes byte slice data for binary request bodies. +// Returns an error if the data is not a []byte. func ToBinary(data any) (*bytes.Reader, error) { byteData, ok := data.([]byte) if !ok { diff --git a/pkg/user-client/internal/contenttypes/to_form_data.go b/pkg/user-client/internal/contenttypes/to_form_data.go index 98b9a30..58bdfc8 100644 --- a/pkg/user-client/internal/contenttypes/to_form_data.go +++ b/pkg/user-client/internal/contenttypes/to_form_data.go @@ -8,7 +8,8 @@ import ( "strconv" ) -// ToForm converts any value (struct, array, map, or primitive) to form data +// ToFormData converts structs and primitives to multipart/form-data format for request bodies. +// Returns the encoded data, Content-Type header with boundary, and any error. Supports nested structs and byte arrays. func ToFormData(data interface{}) (*bytes.Reader, string, error) { buffer := &bytes.Buffer{} writer := multipart.NewWriter(buffer) @@ -30,6 +31,8 @@ func ToFormData(data interface{}) (*bytes.Reader, string, error) { return bytes.NewReader(buffer.Bytes()), contentTypeHeader, nil } +// encode recursively encodes a value into multipart form fields. +// Handles pointers, arrays/slices (byte arrays only), structs, and primitives. func encode(key string, v reflect.Value, writer *multipart.Writer) error { if v.Kind() == reflect.Ptr { if v.IsNil() { @@ -59,6 +62,8 @@ func encode(key string, v reflect.Value, writer *multipart.Writer) error { } } +// encodeStruct encodes all exported fields of a struct into multipart form fields. +// Uses 'form' tags for field names, supports nested bracket notation for nested structs. func encodeStruct(prefix string, v reflect.Value, writer *multipart.Writer) error { t := v.Type() @@ -89,6 +94,8 @@ func encodeStruct(prefix string, v reflect.Value, writer *multipart.Writer) erro return nil } +// formatValue converts a primitive value to its string representation for form encoding. +// Supports bool, int, uint, float, and string types. func formatValue(v reflect.Value) string { switch v.Kind() { case reflect.Bool: diff --git a/pkg/user-client/internal/contenttypes/to_form_url_encoded.go b/pkg/user-client/internal/contenttypes/to_form_url_encoded.go index 670e6f1..6745c64 100644 --- a/pkg/user-client/internal/contenttypes/to_form_url_encoded.go +++ b/pkg/user-client/internal/contenttypes/to_form_url_encoded.go @@ -8,6 +8,8 @@ import ( "reflect" ) +// ToFormUrlEncoded serializes a struct to URL-encoded form format for request bodies. +// Uses struct field json tags as form keys. Supports string, int, float, and bool types. func ToFormUrlEncoded(data any) (*bytes.Reader, error) { val := utils.GetReflectValueFromAny(data) diff --git a/pkg/user-client/internal/contenttypes/to_json.go b/pkg/user-client/internal/contenttypes/to_json.go index cef6b77..120c292 100644 --- a/pkg/user-client/internal/contenttypes/to_json.go +++ b/pkg/user-client/internal/contenttypes/to_json.go @@ -5,6 +5,8 @@ import ( "encoding/json" ) +// ToJson serializes data to JSON format for HTTP request bodies. +// Returns a bytes.Reader containing the JSON-encoded data, or nil if data is nil. func ToJson(data any) (*bytes.Reader, error) { if data == nil { return nil, nil diff --git a/pkg/user-client/internal/contenttypes/to_text.go b/pkg/user-client/internal/contenttypes/to_text.go index dfb17d3..95c9337 100644 --- a/pkg/user-client/internal/contenttypes/to_text.go +++ b/pkg/user-client/internal/contenttypes/to_text.go @@ -5,6 +5,8 @@ import ( "fmt" ) +// ToText serializes string data to bytes for text/plain request bodies. +// Returns an error if the data is not a string. func ToText(data any) (*bytes.Reader, error) { switch v := data.(type) { case string: diff --git a/pkg/user-client/internal/marshal/from_complex_object.go b/pkg/user-client/internal/marshal/from_complex_object.go index 30e670f..e2b2a56 100644 --- a/pkg/user-client/internal/marshal/from_complex_object.go +++ b/pkg/user-client/internal/marshal/from_complex_object.go @@ -8,6 +8,9 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/utils" ) +// FromComplexObject marshals a discriminated union (oneOf) struct to JSON. +// Finds the first non-nil field (the active variant) and marshals only that field. +// Returns an error if all fields are nil. func FromComplexObject(obj any) ([]byte, error) { types := utils.GetReflectType(reflect.TypeOf(obj)) values := utils.GetReflectValue(reflect.ValueOf(obj)) diff --git a/pkg/user-client/internal/serialization/serialize_object.go b/pkg/user-client/internal/serialization/serialize_object.go index 5696eab..8bbb45d 100644 --- a/pkg/user-client/internal/serialization/serialize_object.go +++ b/pkg/user-client/internal/serialization/serialize_object.go @@ -6,11 +6,14 @@ import ( "strings" ) +// paramMap represents a key-value pair for query parameter serialization. type paramMap struct { Key string Value string } +// SerializeObject serializes a struct to query parameter format with nested bracket notation. +// Converts struct fields to key[fieldName]=value format for complex query parameters. func SerializeObject(key string, input any) []paramMap { val := reflect.ValueOf(input) typ := reflect.TypeOf(input) @@ -44,6 +47,8 @@ func SerializeObject(key string, input any) []paramMap { return params } +// SerializeValue serializes any value to a string representation for query parameters. +// Handles primitives, arrays/slices, and nested structs recursively. func SerializeValue(key string, input any) string { val := reflect.ValueOf(input) typ := reflect.TypeOf(input) @@ -71,10 +76,14 @@ func SerializeValue(key string, input any) string { } } +// SerializePrimitive converts primitive types to their string representation. +// Uses fmt.Sprintf for consistent formatting. func SerializePrimitive(input any) string { return fmt.Sprintf("%v", input) } +// getJsonName extracts the JSON field name from a struct field's json tag. +// Returns the first part of the json tag before any comma. func getJsonName(field reflect.StructField) string { jsonTag := field.Tag.Get("json") return strings.Split(jsonTag, ",")[0] diff --git a/pkg/user-client/internal/unmarshal/to_complex_object.go b/pkg/user-client/internal/unmarshal/to_complex_object.go index 8014792..6a28600 100644 --- a/pkg/user-client/internal/unmarshal/to_complex_object.go +++ b/pkg/user-client/internal/unmarshal/to_complex_object.go @@ -11,6 +11,8 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/validation" ) +// candidate represents a potential type match when deserializing a oneOf discriminated union. +// Tracks validation status and field counts to determine the best match. type candidate struct { obj any valid bool @@ -19,6 +21,9 @@ type candidate struct { kind reflect.Kind } +// ToComplexObject unmarshals JSON data into a discriminated union (oneOf) struct. +// Attempts to unmarshal into all possible types, validates each, and selects the best match +// based on required/optional field counts. Removes non-matching candidates from the result. func ToComplexObject[T any](data []byte, result *T) error { err := unmarshalIntoProps(data, result) if err != nil { @@ -35,7 +40,8 @@ func ToComplexObject[T any](data []byte, result *T) error { return nil } -// Try to Unmarshal the input data into the properties of a given struct. +// unmarshalIntoProps attempts to unmarshal JSON data into all fields of a oneOf struct. +// Tries to parse the data as each possible type (struct, array, primitive) and sets matching fields. func unmarshalIntoProps(data []byte, obj any) error { types := reflect.TypeOf(obj).Elem() values := reflect.ValueOf(obj).Elem() @@ -80,6 +86,8 @@ func unmarshalIntoProps(data []byte, obj any) error { return nil } +// createCandidatesFromProps creates a candidate entry for each non-nil field in the oneOf struct. +// Validates each candidate and counts required/optional fields for ranking. func createCandidatesFromProps(obj any) []candidate { values := utils.GetReflectValue(reflect.ValueOf(obj)) types := utils.GetReflectType(reflect.TypeOf(obj)) @@ -133,6 +141,8 @@ func createCandidatesFromProps(obj any) []candidate { return candidates } +// countFields recursively counts fields matching the predicate (required or optional) in a struct. +// Used to rank candidates by how many required/optional fields were successfully unmarshaled. func countFields(c any, isFieldRequiredOrOptional func(reflect.StructField) bool) int { values := utils.GetReflectValue(reflect.ValueOf(c)) types := utils.GetReflectType(reflect.TypeOf(c)) @@ -163,6 +173,7 @@ func countFields(c any, isFieldRequiredOrOptional func(reflect.StructField) bool return count } +// countArrayFields counts matching fields across all elements in an array. func countArrayFields(candidates any, isFieldRequiredOrOptional func(reflect.StructField) bool) int { count := 0 values := utils.GetReflectValue(reflect.ValueOf(candidates)) @@ -174,11 +185,14 @@ func countArrayFields(candidates any, isFieldRequiredOrOptional func(reflect.Str return count } +// isValid checks if a candidate passes all validation constraints. func isValid(candidate any) bool { err := validation.ValidateData(candidate) return err == nil } +// chooseCandidateIndex selects the best matching candidate from the list. +// Prefers non-primitive types first, then falls back to primitives in order: bool, int, float, string. func chooseCandidateIndex(candidates []candidate) int { chosenCandidateIndex := chooseNonPrimitiveCandidate(candidates) @@ -189,6 +203,8 @@ func chooseCandidateIndex(candidates []candidate) int { return chosenCandidateIndex } +// chooseNonPrimitiveCandidate selects the best non-primitive (struct/array) candidate. +// Prioritizes candidates with more required fields, then more optional fields. func chooseNonPrimitiveCandidate(candidates []candidate) int { chosenCandidateIndex := -1 chosenCandidateRequiredCount := -1 @@ -205,6 +221,8 @@ func chooseNonPrimitiveCandidate(candidates []candidate) int { return chosenCandidateIndex } +// isBetterCandidate determines if a candidate is better than the currently chosen one. +// A candidate is better if it has more required fields, or equal required but more optional fields. func isBetterCandidate(c candidate, chosenCandidateRequiredCount int, chosenCandidateOptionalCount int) bool { if !c.valid || isPrimitive(c.kind) { return false @@ -221,6 +239,8 @@ func isBetterCandidate(c candidate, chosenCandidateRequiredCount int, chosenCand return false } +// choosePrimitiveCandidate selects the first non-nil primitive candidate in priority order. +// Priority: bool > int > float > string. func choosePrimitiveCandidate(candidates []candidate) int { predicates := []func(kind reflect.Kind) bool{isBool, isInteger, isFloat, isString} @@ -234,6 +254,8 @@ func choosePrimitiveCandidate(candidates []candidate) int { return -1 } +// removeOtherCandidates zeroes out all fields except the chosen candidate. +// Ensures only the matched oneOf variant remains in the result struct. func removeOtherCandidates(obj any, chosenCandidateIndex int) { values := utils.GetReflectValue(reflect.ValueOf(obj)) types := utils.GetReflectType(reflect.TypeOf(obj)) @@ -246,6 +268,7 @@ func removeOtherCandidates(obj any, chosenCandidateIndex int) { } } +// findFirstNonNil finds the first candidate matching the kind predicate. func findFirstNonNil(candidates []candidate, predicate func(kind reflect.Kind) bool) int { for i, c := range candidates { if c.obj != nil && predicate(c.kind) { diff --git a/pkg/user-client/internal/unmarshal/to_object.go b/pkg/user-client/internal/unmarshal/to_object.go index 040b0bc..829a198 100644 --- a/pkg/user-client/internal/unmarshal/to_object.go +++ b/pkg/user-client/internal/unmarshal/to_object.go @@ -4,6 +4,8 @@ import ( "encoding/json" ) +// ToObject unmarshals JSON bytes into a struct or array target using standard json.Unmarshal. +// Handles regular objects and arrays that don't require special unmarshaling logic. func ToObject(source []byte, target any) error { err := json.Unmarshal(source, target) if err != nil { diff --git a/pkg/user-client/internal/unmarshal/to_primitive.go b/pkg/user-client/internal/unmarshal/to_primitive.go index 42a74c2..5e67864 100644 --- a/pkg/user-client/internal/unmarshal/to_primitive.go +++ b/pkg/user-client/internal/unmarshal/to_primitive.go @@ -5,11 +5,15 @@ import ( "strconv" ) +// ToString unmarshals bytes into a string target. +// Sets the string value directly on the target pointer element. func ToString(source []byte, target reflect.Value) error { target.Elem().SetString(string(source)) return nil } +// ToInt unmarshals bytes into an int64 target by parsing the string representation. +// Returns an error if parsing fails. func ToInt(source []byte, target reflect.Value) error { intBody, err := strconv.ParseInt(string(source), 10, 64) if err != nil { @@ -21,6 +25,8 @@ func ToInt(source []byte, target reflect.Value) error { return nil } +// ToFloat unmarshals bytes into a float64 target by parsing the string representation. +// Returns an error if parsing fails. func ToFloat(source []byte, target reflect.Value) error { floatBody, err := strconv.ParseFloat(string(source), 64) if err != nil { @@ -32,6 +38,8 @@ func ToFloat(source []byte, target reflect.Value) error { return nil } +// ToBool unmarshals bytes into a bool target by parsing the string representation. +// Returns an error if parsing fails. func ToBool(source []byte, target reflect.Value) error { boolBody, err := strconv.ParseBool(string(source)) if err != nil { diff --git a/pkg/user-client/internal/unmarshal/unmarshal.go b/pkg/user-client/internal/unmarshal/unmarshal.go index 84253f1..f567b16 100644 --- a/pkg/user-client/internal/unmarshal/unmarshal.go +++ b/pkg/user-client/internal/unmarshal/unmarshal.go @@ -7,8 +7,10 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/utils" ) +// Unmarshal deserializes JSON bytes into the target based on its type. +// Handles complex objects (oneOf), regular objects/arrays, and primitive types (string, int, float, bool). +// Target must be a non-nil pointer. func Unmarshal(source []byte, target any) error { - targetValue := reflect.ValueOf(target) if targetValue.Kind() != reflect.Ptr || targetValue.IsNil() { return fmt.Errorf("target must be a non-nil pointer") @@ -29,17 +31,21 @@ func Unmarshal(source []byte, target any) error { return nil } +// isArray checks if the target type is an array or slice. func isArray(target any) bool { targetType := reflect.TypeOf(target) kind := utils.GetReflectKind(targetType) return kind == reflect.Array || kind == reflect.Slice } +// isObject checks if the target type is a struct. func isObject(target any) bool { targetType := reflect.TypeOf(target) return utils.GetReflectKind(targetType) == reflect.Struct } +// isComplexObject checks if the target is a complex object (oneOf) where all fields have 'oneof' tags. +// Used to identify discriminated union types that require special unmarshaling logic. func isComplexObject(target any) bool { targetType := reflect.TypeOf(target) if utils.GetReflectKind(targetType) != reflect.Struct { @@ -57,6 +63,7 @@ func isComplexObject(target any) bool { return allFieldsAreOneOf } +// isOneOfField checks if a struct field has the 'oneof' tag, indicating it's part of a discriminated union. func isOneOfField(field reflect.StructField) bool { _, found := field.Tag.Lookup("oneof") return found diff --git a/pkg/user-client/internal/unmarshal/unmarshal_nullable.go b/pkg/user-client/internal/unmarshal/unmarshal_nullable.go index 21690ef..0f5939d 100644 --- a/pkg/user-client/internal/unmarshal/unmarshal_nullable.go +++ b/pkg/user-client/internal/unmarshal/unmarshal_nullable.go @@ -7,6 +7,8 @@ import ( "strings" ) +// UnmarshalNullable deserializes JSON into a struct with Nullable fields, correctly handling null values. +// Sets IsNull=true for fields that are explicitly null in the JSON, rather than unmarshaling them as zero values. func UnmarshalNullable(source []byte, target any) error { // Use a temporary map to decode the raw JSON var rawMap map[string]json.RawMessage @@ -60,6 +62,8 @@ func UnmarshalNullable(source []byte, target any) error { return nil } +// hasNullableFields checks if a struct contains any Nullable[T] pointer fields. +// Used to determine if special nullable unmarshaling logic should be applied. func hasNullableFields(obj any) bool { t := reflect.TypeOf(obj) diff --git a/pkg/user-client/internal/utils/utils.go b/pkg/user-client/internal/utils/utils.go index 13fe13d..2a43d20 100644 --- a/pkg/user-client/internal/utils/utils.go +++ b/pkg/user-client/internal/utils/utils.go @@ -2,6 +2,8 @@ package utils import "reflect" +// CloneMap creates a shallow copy of a map. +// Returns a new map with the same key-value pairs as the source. func CloneMap[T any](sourceMap map[string]T) map[string]T { newMap := make(map[string]T) for key, value := range sourceMap { @@ -11,11 +13,15 @@ func CloneMap[T any](sourceMap map[string]T) map[string]T { return newMap } +// GetReflectValueFromAny gets the reflect.Value from any type, dereferencing pointers. +// Wraps GetReflectValue for convenience when starting with an any type. func GetReflectValueFromAny(input any) reflect.Value { val := reflect.ValueOf(input) return GetReflectValue(val) } +// GetReflectValue dereferences pointer types to get the underlying value. +// Returns the element if the value is a pointer, otherwise returns the value unchanged. func GetReflectValue(fieldValue reflect.Value) reflect.Value { if fieldValue.Kind() == reflect.Pointer { return fieldValue.Elem() @@ -24,11 +30,15 @@ func GetReflectValue(fieldValue reflect.Value) reflect.Value { } } +// GetReflectTypeFromAny gets the reflect.Type from any type, dereferencing pointer types. +// Wraps GetReflectType for convenience when starting with an any type. func GetReflectTypeFromAny(input any) reflect.Type { dataType := reflect.TypeOf(input) return GetReflectType(dataType) } +// GetReflectType dereferences pointer types to get the underlying type. +// Returns the element type if the type is a pointer, otherwise returns the type unchanged. func GetReflectType(fieldType reflect.Type) reflect.Type { if fieldType.Kind() == reflect.Ptr { return fieldType.Elem() @@ -37,11 +47,15 @@ func GetReflectType(fieldType reflect.Type) reflect.Type { } } +// GetReflectKindFromAny gets the reflect.Kind from any type, dereferencing pointer types. +// Wraps GetReflectKind for convenience when starting with an any type. func GetReflectKindFromAny(input any) reflect.Kind { dataType := reflect.TypeOf(input) return GetReflectKind(dataType) } +// GetReflectKind dereferences pointer types to get the underlying kind. +// Returns the element kind if the type is a pointer, otherwise returns the kind unchanged. func GetReflectKind(fieldType reflect.Type) reflect.Kind { if fieldType.Kind() == reflect.Pointer { return fieldType.Elem().Kind() diff --git a/pkg/user-client/internal/validation/validate_array_length.go b/pkg/user-client/internal/validation/validate_array_length.go index 2d260ce..4b65574 100644 --- a/pkg/user-client/internal/validation/validate_array_length.go +++ b/pkg/user-client/internal/validation/validate_array_length.go @@ -8,6 +8,8 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/utils" ) +// validateArrayLength validates that an array or slice length is within 'minLength' and 'maxLength' tag constraints. +// Only validates array and slice types. Nil slices are skipped. func validateArrayLength(field reflect.StructField, value reflect.Value) error { kind := utils.GetReflectKind(value.Type()) if kind != reflect.Array && kind != reflect.Slice { @@ -31,6 +33,7 @@ func validateArrayLength(field reflect.StructField, value reflect.Value) error { return nil } +// validateMinLength validates that an array or slice meets the minimum length requirement from 'minLength' tag. func validateMinLength(field reflect.StructField, value reflect.Value) error { kind := utils.GetReflectKind(value.Type()) if kind == reflect.Slice && value.IsNil() { @@ -55,6 +58,7 @@ func validateMinLength(field reflect.StructField, value reflect.Value) error { return nil } +// validateMaxLength validates that an array or slice doesn't exceed the maximum length from 'maxLength' tag. func validateMaxLength(field reflect.StructField, value reflect.Value) error { kind := utils.GetReflectKind(value.Type()) if kind == reflect.Slice && value.IsNil() { diff --git a/pkg/user-client/internal/validation/validate_array_unique.go b/pkg/user-client/internal/validation/validate_array_unique.go index 45ef727..6777c25 100644 --- a/pkg/user-client/internal/validation/validate_array_unique.go +++ b/pkg/user-client/internal/validation/validate_array_unique.go @@ -5,6 +5,8 @@ import ( "reflect" ) +// validateArrayIsUnique validates that all elements in an array or slice are unique when 'uniqueItems:"true"' tag is present. +// Returns an error if duplicate elements are found. Nil values are skipped. func validateArrayIsUnique(field reflect.StructField, value reflect.Value) error { unique, found := field.Tag.Lookup("uniqueItems") if !found || unique != "true" || value.IsNil() { diff --git a/pkg/user-client/internal/validation/validate_max.go b/pkg/user-client/internal/validation/validate_max.go index 307eff0..4c0d1e7 100644 --- a/pkg/user-client/internal/validation/validate_max.go +++ b/pkg/user-client/internal/validation/validate_max.go @@ -8,6 +8,8 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/utils" ) +// validateMax validates that a numeric field value is less than or equal to the 'max' tag value. +// Supports int and float types. Nil values are skipped. func validateMax(field reflect.StructField, value reflect.Value) error { maxValue, found := field.Tag.Lookup("max") if !found || maxValue == "" || value.IsNil() { diff --git a/pkg/user-client/internal/validation/validate_min.go b/pkg/user-client/internal/validation/validate_min.go index b65b10f..8e18ab1 100644 --- a/pkg/user-client/internal/validation/validate_min.go +++ b/pkg/user-client/internal/validation/validate_min.go @@ -8,6 +8,8 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/utils" ) +// validateMin validates that a numeric field value is greater than or equal to the 'min' tag value. +// Supports int and float types. Nil values are skipped. func validateMin(field reflect.StructField, value reflect.Value) error { minValue, found := field.Tag.Lookup("min") if !found || minValue == "" || value.IsNil() { diff --git a/pkg/user-client/internal/validation/validate_multiple_of.go b/pkg/user-client/internal/validation/validate_multiple_of.go index d701584..44e3d29 100644 --- a/pkg/user-client/internal/validation/validate_multiple_of.go +++ b/pkg/user-client/internal/validation/validate_multiple_of.go @@ -9,6 +9,8 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/utils" ) +// validateMultipleOf validates that a numeric field value is a multiple of the 'multipleOf' tag value. +// Supports int and float types. Nil values are skipped. func validateMultipleOf(field reflect.StructField, value reflect.Value) error { multipleOfValue, found := field.Tag.Lookup("multipleOf") if !found || multipleOfValue == "" || value.IsNil() { diff --git a/pkg/user-client/internal/validation/validate_pattern.go b/pkg/user-client/internal/validation/validate_pattern.go index 776d7c4..43422ed 100644 --- a/pkg/user-client/internal/validation/validate_pattern.go +++ b/pkg/user-client/internal/validation/validate_pattern.go @@ -8,6 +8,8 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/utils" ) +// validatePattern validates that a string field matches the regex pattern specified in its 'pattern' tag. +// Returns an error if the field value doesn't match the pattern. Nil values are skipped. func validatePattern(field reflect.StructField, value reflect.Value) error { pattern, found := field.Tag.Lookup("pattern") if !found { diff --git a/pkg/user-client/internal/validation/validate_required.go b/pkg/user-client/internal/validation/validate_required.go index 6b1a638..9f0af0e 100644 --- a/pkg/user-client/internal/validation/validate_required.go +++ b/pkg/user-client/internal/validation/validate_required.go @@ -5,6 +5,8 @@ import ( "reflect" ) +// validateRequired checks if a required field has a non-nil value. +// Returns an error if the field has a 'required:"true"' tag and is nil. func validateRequired(fieldType reflect.StructField, fieldValue reflect.Value) error { if IsRequiredField(fieldType) && fieldValue.IsNil() { return fmt.Errorf("field %s is required", fieldType.Name) @@ -13,11 +15,13 @@ func validateRequired(fieldType reflect.StructField, fieldValue reflect.Value) e return nil } +// IsRequiredField checks if a struct field has the 'required:"true"' tag. func IsRequiredField(fieldType reflect.StructField) bool { required, found := fieldType.Tag.Lookup("required") return found && required == "true" } +// IsOptionalField checks if a struct field is optional (not required or no tag). func IsOptionalField(fieldType reflect.StructField) bool { required, found := fieldType.Tag.Lookup("required") return !found || required == "" || required == "false" diff --git a/pkg/user-client/internal/validation/validation.go b/pkg/user-client/internal/validation/validation.go index e0fb1bb..2ff961b 100644 --- a/pkg/user-client/internal/validation/validation.go +++ b/pkg/user-client/internal/validation/validation.go @@ -6,8 +6,12 @@ import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/utils" ) +// validatorFunc defines the signature for field validation functions. type validatorFunc = func(fieldType reflect.StructField, fieldValue reflect.Value) error +// ValidateData validates data structures recursively according to struct field tags. +// Supports required, pattern, min, max, multipleOf, unique array, and array length validations. +// Handles Nullable wrappers and nested structs/arrays. func ValidateData(data any) error { if data == nil { return nil @@ -36,7 +40,7 @@ func ValidateData(data any) error { } if utils.GetReflectKind(dataType) == reflect.Struct { - return validateStruct(dataValue.Interface()) + return validateStructValue(dataValue) } else if dataType.Kind() == reflect.Array || dataType.Kind() == reflect.Slice { return validateArray(dataValue) } @@ -44,8 +48,15 @@ func ValidateData(data any) error { return nil } +// validateStruct validates a struct by interface value (for exported fields). +// Recursively validates nested structs and arrays according to their validation tags. func validateStruct(data any) error { value := reflect.ValueOf(data) + return validateStructValue(value) +} + +// validateStructValue validates a struct by reflect.Value (works with both exported and unexported fields) +func validateStructValue(value reflect.Value) error { // Recursively dereference pointers for value.Kind() == reflect.Ptr { @@ -60,18 +71,38 @@ func validateStruct(data any) error { if value.FieldByName("IsNull").Bool() { return nil } - // Get the actual value from the Nullable wrapper - value = value.FieldByName("Value") + // Get the actual value from the Nullable wrapper and restart validation from scratch + // This ensures the wrapped value is validated according to its actual type + wrappedValue := value.FieldByName("Value") + + if wrappedValue.CanInterface() { + return ValidateData(wrappedValue.Interface()) + } else { + // For unexported values, route to the appropriate validator based on type + innerKind := utils.GetReflectKind(wrappedValue.Type()) + if innerKind == reflect.Struct { + return validateStructValue(wrappedValue) + } else if innerKind == reflect.Array || innerKind == reflect.Slice { + return validateArray(wrappedValue) + } + return nil + } } structValue := utils.GetReflectValue(value) + for i := 0; i < structValue.NumField(); i++ { fieldValue := structValue.Field(i) fieldType := structValue.Type().Field(i) - err := validateField(fieldValue, fieldType) - if err != nil { - return err + // For unexported fields, skip field-level validation but still recurse into nested structs + isUnexported := fieldType.PkgPath != "" + + if !isUnexported { + err := validateField(fieldValue, fieldType) + if err != nil { + return err + } } // Only check IsNil for types that can be nil @@ -82,9 +113,25 @@ func validateStruct(data any) error { continue } + // Recurse into nested structs/arrays/slices, even if the field is unexported kind = utils.GetReflectKind(fieldType.Type) - if kind == reflect.Struct || kind == reflect.Array || kind == reflect.Slice { - err := ValidateData(fieldValue.Interface()) + if kind == reflect.Struct { + // For pointer fields, dereference first + valueToValidate := fieldValue + if fieldValue.Kind() == reflect.Ptr && !fieldValue.IsNil() { + valueToValidate = fieldValue.Elem() + } + + // Use validateStructValue to handle both exported and unexported fields + if valueToValidate.Kind() == reflect.Struct { + err := validateStructValue(valueToValidate) + if err != nil { + return err + } + } + } else if kind == reflect.Array || kind == reflect.Slice { + // For arrays/slices, validate using the existing validateArray function + err := validateArray(fieldValue) if err != nil { return err } @@ -94,6 +141,8 @@ func validateStruct(data any) error { return nil } +// validateArray validates each element in an array or slice recursively. +// Handles Nullable wrappers around arrays. func validateArray(value reflect.Value) error { // Check if this is a Nullable wrapper if isNullableType(value.Type()) { @@ -106,15 +155,31 @@ func validateArray(value reflect.Value) error { arrayValue := utils.GetReflectValue(value) for j := 0; j < arrayValue.Len(); j++ { - err := ValidateData(arrayValue.Index(j).Interface()) - if err != nil { - return err + elementValue := arrayValue.Index(j) + + // Try to validate the element - use Interface() if possible, otherwise use reflect.Value directly + if elementValue.CanInterface() { + err := ValidateData(elementValue.Interface()) + if err != nil { + return err + } + } else { + // For unexported elements, validate using reflect.Value directly + elementKind := utils.GetReflectKind(elementValue.Type()) + if elementKind == reflect.Struct { + err := validateStructValue(elementValue) + if err != nil { + return err + } + } } } return nil } +// isNullableType checks if a type is a Nullable wrapper struct. +// Returns true if the type has IsNull (bool) and Value fields. func isNullableType(t reflect.Type) bool { // Dereference pointer types until we hit the base type for t.Kind() == reflect.Ptr { @@ -142,6 +207,8 @@ func isNullableType(t reflect.Type) bool { return true } +// validateField runs all applicable validators on a struct field. +// Returns the first validation error encountered, or nil if all validations pass. func validateField(fieldValue reflect.Value, fieldType reflect.StructField) error { validators := getValidators(fieldType) for _, validator := range validators { @@ -154,6 +221,8 @@ func validateField(fieldValue reflect.Value, fieldType reflect.StructField) erro return nil } +// getValidators returns the list of all validator functions to apply to a field. +// Includes required, pattern, multipleOf, min, max, array unique, and array length validators. func getValidators(fieldType reflect.StructField) []validatorFunc { return []validatorFunc{ validateRequired, diff --git a/pkg/user-client/notifications/count_response.go b/pkg/user-client/notifications/count_response.go new file mode 100644 index 0000000..231f296 --- /dev/null +++ b/pkg/user-client/notifications/count_response.go @@ -0,0 +1,27 @@ +package notifications + +import "encoding/json" + +type CountResponse struct { + // The count of notifications matching the query. + Count *int64 `json:"count,omitempty" required:"true"` +} + +func (c *CountResponse) GetCount() *int64 { + if c == nil { + return nil + } + return c.Count +} + +func (c *CountResponse) SetCount(count int64) { + c.Count = &count +} + +func (c CountResponse) String() string { + jsonData, err := json.MarshalIndent(c, "", " ") + if err != nil { + return "error converting struct: CountResponse to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/notifications/notification.go b/pkg/user-client/notifications/notification.go index 029a0d8..a055f2f 100644 --- a/pkg/user-client/notifications/notification.go +++ b/pkg/user-client/notifications/notification.go @@ -7,21 +7,36 @@ import ( ) type Notification struct { - ActionUrl *util.Nullable[string] `json:"action_url,omitempty" maxLength:"2048"` - ArchivedAt *util.Nullable[string] `json:"archived_at,omitempty"` - Category *util.Nullable[string] `json:"category,omitempty" maxLength:"100"` - Content *util.Nullable[string] `json:"content,omitempty" maxLength:"10485760"` - CreatedAt *string `json:"created_at,omitempty" required:"true"` - CustomAttributes *util.Nullable[any] `json:"custom_attributes,omitempty"` - DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` - Id *string `json:"id,omitempty" required:"true"` - ReadAt *util.Nullable[string] `json:"read_at,omitempty"` - SeenAt *util.Nullable[string] `json:"seen_at,omitempty"` - SentAt *util.Nullable[string] `json:"sent_at,omitempty"` - Title *string `json:"title,omitempty" required:"true" maxLength:"255" minLength:"1"` - Topic *util.Nullable[string] `json:"topic,omitempty" maxLength:"100"` - UpdatedAt *string `json:"updated_at,omitempty" required:"true"` - UserId *string `json:"user_id,omitempty" required:"true"` + // The link associated with the notification. + ActionUrl *util.Nullable[string] `json:"action_url,omitempty" maxLength:"2048"` + // The timestamp when the notification was archived. + ArchivedAt *util.Nullable[string] `json:"archived_at,omitempty"` + // The category grouping for the notification. + Category *util.Nullable[string] `json:"category,omitempty" maxLength:"100"` + // The body content of the notification. + Content *util.Nullable[string] `json:"content,omitempty" maxLength:"10485760"` + // The timestamp when the notification was created. + CreatedAt *string `json:"created_at,omitempty" required:"true"` + // The custom data stored with the notification. + CustomAttributes *util.Nullable[any] `json:"custom_attributes,omitempty"` + // The timestamp when the notification was discarded. + DiscardedAt *util.Nullable[string] `json:"discarded_at,omitempty"` + // The unique identifier for the notification. + Id *string `json:"id,omitempty" required:"true"` + // The timestamp when the notification was marked as read. + ReadAt *util.Nullable[string] `json:"read_at,omitempty"` + // The timestamp when the notification was seen. + SeenAt *util.Nullable[string] `json:"seen_at,omitempty"` + // The timestamp when the notification was sent. + SentAt *util.Nullable[string] `json:"sent_at,omitempty"` + // The title that is displayed to recipients. + Title *string `json:"title,omitempty" required:"true" maxLength:"255" minLength:"1"` + // The topic for additional classification. + Topic *util.Nullable[string] `json:"topic,omitempty" maxLength:"100"` + // The timestamp when the notification was last updated. + UpdatedAt *string `json:"updated_at,omitempty" required:"true"` + // The user that should receive the notification. + UserId *string `json:"user_id,omitempty" required:"true"` } func (n *Notification) GetActionUrl() *util.Nullable[string] { diff --git a/pkg/user-client/notifications/notifications_service.go b/pkg/user-client/notifications/notifications_service.go index e3bc3ae..919c2b3 100644 --- a/pkg/user-client/notifications/notifications_service.go +++ b/pkg/user-client/notifications/notifications_service.go @@ -3,6 +3,7 @@ package notifications import ( "context" restClient "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest" + "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/hooks" "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/httptransport" "github.com/magicbell/magicbell-go/pkg/user-client/internal/configmanager" "github.com/magicbell/magicbell-go/pkg/user-client/clientconfig" @@ -10,8 +11,11 @@ import ( "time" ) +// NotificationsService provides methods to interact with NotificationsService-related API endpoints. +// It uses a configuration manager for settings and supports custom hooks for request/response interception. type NotificationsService struct { manager *configmanager.ConfigManager + hook hooks.Hook } func NewNotificationsService() *NotificationsService { @@ -20,15 +24,28 @@ func NewNotificationsService() *NotificationsService { } } +// WithConfigManager sets the configuration manager for this service. +// Returns the service instance for method chaining. func (api *NotificationsService) WithConfigManager(manager *configmanager.ConfigManager) *NotificationsService { api.manager = manager return api } +// WithHook sets a custom hook for request/response interception. +// Returns the service instance for method chaining. +func (api *NotificationsService) WithHook(hook hooks.Hook) *NotificationsService { + api.hook = hook + return api +} + func (api *NotificationsService) getConfig() *clientconfig.Config { return api.manager.GetNotifications() } +func (api *NotificationsService) getHook() hooks.Hook { + return api.hook +} + func (api *NotificationsService) SetBaseUrl(baseUrl string) { config := api.getConfig() config.SetBaseUrl(baseUrl) @@ -45,7 +62,7 @@ func (api *NotificationsService) SetAccessToken(accessToken string) { } // Lists all notifications for a user. -func (api *NotificationsService) ListNotifications(ctx context.Context, params ListNotificationsRequestParams) (*shared.ClientResponse[NotificationCollection], *shared.ClientError) { +func (api *NotificationsService) ListNotifications(ctx context.Context, params ListNotificationsRequestParams) (*shared.ClientResponse[NotificationCollection], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -57,17 +74,17 @@ func (api *NotificationsService) ListNotifications(ctx context.Context, params L WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[NotificationCollection](config) + client := restClient.NewRestClient[NotificationCollection, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[NotificationCollection](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[NotificationCollection](resp), nil } // Archive all notifications. -func (api *NotificationsService) ArchiveAllNotifications(ctx context.Context, params ArchiveAllNotificationsRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *NotificationsService) ArchiveAllNotifications(ctx context.Context, params ArchiveAllNotificationsRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -79,17 +96,17 @@ func (api *NotificationsService) ArchiveAllNotifications(ctx context.Context, pa WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Marks all notifications as read. -func (api *NotificationsService) MarkAllNotificationsRead(ctx context.Context, params MarkAllNotificationsReadRequestParams) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *NotificationsService) MarkAllNotificationsRead(ctx context.Context, params MarkAllNotificationsReadRequestParams) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -101,17 +118,39 @@ func (api *NotificationsService) MarkAllNotificationsRead(ctx context.Context, p WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } +// Returns the count of unread notifications for a user. Supports filtering by category and topic. +func (api *NotificationsService) FetchUnreadNotificationsCount(ctx context.Context, params FetchUnreadNotificationsCountRequestParams) (*shared.ClientResponse[CountResponse], *shared.ClientError[[]byte]) { + config := *api.getConfig() + + request := httptransport.NewRequestBuilder().WithContext(ctx). + WithMethod("GET"). + WithPath("/notifications/unread/count"). + WithConfig(config). + WithOptions(params). + WithContentType(httptransport.ContentTypeJson). + WithResponseContentType(httptransport.ContentTypeJson). + Build() + + client := restClient.NewRestClient[CountResponse, []byte](config, api.getHook()) + resp, err := client.Call(*request) + if err != nil { + return nil, shared.NewClientError[[]byte](err) + } + + return shared.NewClientResponse[CountResponse](resp), nil +} + // Gets a notification by ID. -func (api *NotificationsService) FetchNotification(ctx context.Context, notificationId string) (*shared.ClientResponse[Notification], *shared.ClientError) { +func (api *NotificationsService) FetchNotification(ctx context.Context, notificationId string) (*shared.ClientResponse[Notification], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -123,17 +162,17 @@ func (api *NotificationsService) FetchNotification(ctx context.Context, notifica WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[Notification](config) + client := restClient.NewRestClient[Notification, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[Notification](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[Notification](resp), nil } // Archive a notification. -func (api *NotificationsService) ArchiveNotification(ctx context.Context, notificationId string) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *NotificationsService) ArchiveNotification(ctx context.Context, notificationId string) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -145,17 +184,17 @@ func (api *NotificationsService) ArchiveNotification(ctx context.Context, notifi WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Marks a notification as read. -func (api *NotificationsService) MarkNotificationRead(ctx context.Context, notificationId string) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *NotificationsService) MarkNotificationRead(ctx context.Context, notificationId string) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -167,17 +206,17 @@ func (api *NotificationsService) MarkNotificationRead(ctx context.Context, notif WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Unarchives a notification. -func (api *NotificationsService) UnarchiveNotification(ctx context.Context, notificationId string) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *NotificationsService) UnarchiveNotification(ctx context.Context, notificationId string) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -189,17 +228,17 @@ func (api *NotificationsService) UnarchiveNotification(ctx context.Context, noti WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil } // Marks a notification as unread. -func (api *NotificationsService) MarkNotificationUnread(ctx context.Context, notificationId string) (*shared.ClientResponse[any], *shared.ClientError) { +func (api *NotificationsService) MarkNotificationUnread(ctx context.Context, notificationId string) (*shared.ClientResponse[any], *shared.ClientError[[]byte]) { config := *api.getConfig() request := httptransport.NewRequestBuilder().WithContext(ctx). @@ -211,10 +250,10 @@ func (api *NotificationsService) MarkNotificationUnread(ctx context.Context, not WithResponseContentType(httptransport.ContentTypeJson). Build() - client := restClient.NewRestClient[any](config) + client := restClient.NewRestClient[any, []byte](config, api.getHook()) resp, err := client.Call(*request) if err != nil { - return nil, shared.NewClientError[any](err) + return nil, shared.NewClientError[[]byte](err) } return shared.NewClientResponse[any](resp), nil diff --git a/pkg/user-client/notifications/request_params.go b/pkg/user-client/notifications/request_params.go index d72ed9f..642b10b 100644 --- a/pkg/user-client/notifications/request_params.go +++ b/pkg/user-client/notifications/request_params.go @@ -1,5 +1,7 @@ package notifications +// ListNotificationsRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ListNotificationsRequestParams struct { Limit *int64 `explode:"true" serializationStyle:"form" queryParam:"limit"` StartingAfter *string `explode:"true" serializationStyle:"form" queryParam:"starting_after"` @@ -9,45 +11,83 @@ type ListNotificationsRequestParams struct { Topic *string `explode:"true" serializationStyle:"form" queryParam:"topic"` } +// SetLimit sets the Limit parameter. func (params *ListNotificationsRequestParams) SetLimit(limit int64) { params.Limit = &limit } + +// SetStartingAfter sets the StartingAfter parameter. func (params *ListNotificationsRequestParams) SetStartingAfter(startingAfter string) { params.StartingAfter = &startingAfter } + +// SetEndingBefore sets the EndingBefore parameter. func (params *ListNotificationsRequestParams) SetEndingBefore(endingBefore string) { params.EndingBefore = &endingBefore } + +// SetStatus sets the Status parameter. func (params *ListNotificationsRequestParams) SetStatus(status string) { params.Status = &status } + +// SetCategory sets the Category parameter. func (params *ListNotificationsRequestParams) SetCategory(category string) { params.Category = &category } + +// SetTopic sets the Topic parameter. func (params *ListNotificationsRequestParams) SetTopic(topic string) { params.Topic = &topic } +// ArchiveAllNotificationsRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type ArchiveAllNotificationsRequestParams struct { Category *string `explode:"true" serializationStyle:"form" queryParam:"category"` Topic *string `explode:"true" serializationStyle:"form" queryParam:"topic"` } +// SetCategory sets the Category parameter. func (params *ArchiveAllNotificationsRequestParams) SetCategory(category string) { params.Category = &category } + +// SetTopic sets the Topic parameter. func (params *ArchiveAllNotificationsRequestParams) SetTopic(topic string) { params.Topic = &topic } +// MarkAllNotificationsReadRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. type MarkAllNotificationsReadRequestParams struct { Category *string `explode:"true" serializationStyle:"form" queryParam:"category"` Topic *string `explode:"true" serializationStyle:"form" queryParam:"topic"` } +// SetCategory sets the Category parameter. func (params *MarkAllNotificationsReadRequestParams) SetCategory(category string) { params.Category = &category } + +// SetTopic sets the Topic parameter. func (params *MarkAllNotificationsReadRequestParams) SetTopic(topic string) { params.Topic = &topic } + +// FetchUnreadNotificationsCountRequestParams holds the optional parameters for the API request. +// Use the Set methods to configure query parameters, headers, and path parameters. +type FetchUnreadNotificationsCountRequestParams struct { + Category *string `explode:"true" serializationStyle:"form" queryParam:"category"` + Topic *string `explode:"true" serializationStyle:"form" queryParam:"topic"` +} + +// SetCategory sets the Category parameter. +func (params *FetchUnreadNotificationsCountRequestParams) SetCategory(category string) { + params.Category = &category +} + +// SetTopic sets the Topic parameter. +func (params *FetchUnreadNotificationsCountRequestParams) SetTopic(topic string) { + params.Topic = &topic +} diff --git a/pkg/user-client/shared/client_error.go b/pkg/user-client/shared/client_error.go index 115c7c4..60f8522 100644 --- a/pkg/user-client/shared/client_error.go +++ b/pkg/user-client/shared/client_error.go @@ -2,23 +2,33 @@ package shared import ( "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/httptransport" + "net/http" ) -type ClientError struct { +// ClientError wraps API errors with detailed metadata including status code, headers, and raw response. +// It implements the error interface and provides structured access to error information. +type ClientError[T any] struct { Err error + Data *T Body []byte + Raw *http.Response Metadata ClientErrorMetadata } +// ClientErrorMetadata contains HTTP metadata associated with an error response. type ClientErrorMetadata struct { Headers map[string]string StatusCode int } -func NewClientError[T any](transportError *httptransport.ErrorResponse[T]) *ClientError { - return &ClientError{ +// NewClientError creates a new ClientError from an internal transport error. +// It extracts error details, body, status code, and headers into a user-facing error structure. +func NewClientError[T any](transportError *httptransport.ErrorResponse[T]) *ClientError[T] { + return &ClientError[T]{ Err: transportError.GetError(), + Data: transportError.Data, Body: transportError.GetBody(), + Raw: transportError.Raw, Metadata: ClientErrorMetadata{ StatusCode: transportError.GetStatusCode(), Headers: transportError.GetHeaders(), @@ -26,6 +36,13 @@ func NewClientError[T any](transportError *httptransport.ErrorResponse[T]) *Clie } } -func (e *ClientError) Error() string { +// Error implements the error interface, returning the error message string. +func (e *ClientError[T]) Error() string { return e.Err.Error() } + +// GetData returns the deserialized error response data. +// Returns nil if unmarshaling failed or the response body was empty. +func (e *ClientError[T]) GetData() *T { + return e.Data +} diff --git a/pkg/user-client/shared/client_response.go b/pkg/user-client/shared/client_response.go index 244f389..c774e00 100644 --- a/pkg/user-client/shared/client_response.go +++ b/pkg/user-client/shared/client_response.go @@ -2,23 +2,31 @@ package shared import ( "encoding/json" - "github.com/magicbell/magicbell-go/pkg/user-client/internal/clients/rest/httptransport" + "net/http" ) +// ClientResponse is the user-facing wrapper for API responses. +// It contains the deserialized data, raw HTTP response, and metadata like headers and status code. type ClientResponse[T any] struct { Data T + Raw *http.Response Metadata ClientResponseMetadata } +// ClientResponseMetadata contains HTTP metadata from the API response. +// Includes status code and headers for inspection and debugging. type ClientResponseMetadata struct { Headers map[string]string StatusCode int } +// NewClientResponse creates a new response wrapper from an internal transport response. +// Extracts data and metadata into a user-facing structure. func NewClientResponse[T any](resp *httptransport.Response[T]) *ClientResponse[T] { return &ClientResponse[T]{ Data: resp.Data, + Raw: resp.Raw, Metadata: ClientResponseMetadata{ StatusCode: resp.StatusCode, Headers: resp.Headers, @@ -26,10 +34,13 @@ func NewClientResponse[T any](resp *httptransport.Response[T]) *ClientResponse[T } } +// GetData returns the deserialized response data. func (r *ClientResponse[T]) GetData() T { return r.Data } +// String returns a JSON representation of the response for debugging. +// Returns an error message if JSON marshaling fails. func (r ClientResponse[T]) String() string { jsonData, err := json.MarshalIndent(r, "", " ") if err != nil { diff --git a/pkg/user-client/shared/web_push_token_payload.go b/pkg/user-client/shared/web_push_token_payload.go index 0b241fe..f9e78a9 100644 --- a/pkg/user-client/shared/web_push_token_payload.go +++ b/pkg/user-client/shared/web_push_token_payload.go @@ -38,41 +38,3 @@ func (w WebPushTokenPayload) String() string { } return string(jsonData) } - -// The encryption keys from the PushSubscription.getKey() method, needed to encrypt push messages for this subscription. -type WebPushTokenPayloadKeys struct { - // The authentication secret obtained from PushSubscription.getKey('auth'). Used to encrypt push messages for this subscription. - Auth *string `json:"auth,omitempty" required:"true"` - // The P-256 ECDH public key obtained from PushSubscription.getKey('p256dh'). Used to encrypt push messages for this subscription. - P256dh *string `json:"p256dh,omitempty" required:"true"` -} - -func (w *WebPushTokenPayloadKeys) GetAuth() *string { - if w == nil { - return nil - } - return w.Auth -} - -func (w *WebPushTokenPayloadKeys) SetAuth(auth string) { - w.Auth = &auth -} - -func (w *WebPushTokenPayloadKeys) GetP256dh() *string { - if w == nil { - return nil - } - return w.P256dh -} - -func (w *WebPushTokenPayloadKeys) SetP256dh(p256dh string) { - w.P256dh = &p256dh -} - -func (w WebPushTokenPayloadKeys) String() string { - jsonData, err := json.MarshalIndent(w, "", " ") - if err != nil { - return "error converting struct: WebPushTokenPayloadKeys to string" - } - return string(jsonData) -} diff --git a/pkg/user-client/shared/web_push_token_payload_keys.go b/pkg/user-client/shared/web_push_token_payload_keys.go new file mode 100644 index 0000000..66955f8 --- /dev/null +++ b/pkg/user-client/shared/web_push_token_payload_keys.go @@ -0,0 +1,41 @@ +package shared + +import "encoding/json" + +// The encryption keys from the PushSubscription.getKey() method, needed to encrypt push messages for this subscription. +type WebPushTokenPayloadKeys struct { + // The authentication secret obtained from PushSubscription.getKey('auth'). Used to encrypt push messages for this subscription. + Auth *string `json:"auth,omitempty" required:"true"` + // The P-256 ECDH public key obtained from PushSubscription.getKey('p256dh'). Used to encrypt push messages for this subscription. + P256dh *string `json:"p256dh,omitempty" required:"true"` +} + +func (w *WebPushTokenPayloadKeys) GetAuth() *string { + if w == nil { + return nil + } + return w.Auth +} + +func (w *WebPushTokenPayloadKeys) SetAuth(auth string) { + w.Auth = &auth +} + +func (w *WebPushTokenPayloadKeys) GetP256dh() *string { + if w == nil { + return nil + } + return w.P256dh +} + +func (w *WebPushTokenPayloadKeys) SetP256dh(p256dh string) { + w.P256dh = &p256dh +} + +func (w WebPushTokenPayloadKeys) String() string { + jsonData, err := json.MarshalIndent(w, "", " ") + if err != nil { + return "error converting struct: WebPushTokenPayloadKeys to string" + } + return string(jsonData) +} diff --git a/pkg/user-client/util/nullable.go b/pkg/user-client/util/nullable.go index 43ae30b..055b3fa 100644 --- a/pkg/user-client/util/nullable.go +++ b/pkg/user-client/util/nullable.go @@ -2,11 +2,15 @@ package util import "encoding/json" +// Nullable represents an optional value that can be null in JSON. +// Used for API fields that distinguish between null, missing, and present values. type Nullable[T any] struct { Value T IsNull bool } +// MarshalJSON implements json.Marshaler to serialize null or the value. +// Returns "null" if IsNull is true, otherwise marshals the Value. func (n *Nullable[T]) MarshalJSON() ([]byte, error) { if n.IsNull { return []byte("null"), nil @@ -14,6 +18,8 @@ func (n *Nullable[T]) MarshalJSON() ([]byte, error) { return json.Marshal(n.Value) } +// UnmarshalJSON implements json.Unmarshaler to deserialize null or a value. +// Sets IsNull to true if the JSON is "null", otherwise unmarshals into Value. func (n *Nullable[T]) UnmarshalJSON(data []byte) error { if string(data) == "null" { n.IsNull = true diff --git a/pkg/user-client/util/to_pointer.go b/pkg/user-client/util/to_pointer.go index 3dceead..0906b11 100644 --- a/pkg/user-client/util/to_pointer.go +++ b/pkg/user-client/util/to_pointer.go @@ -1,5 +1,7 @@ package util +// ToPointer converts a value to a pointer to that value. +// Useful for creating pointers to literals or converting values to optional fields. func ToPointer[T any](v T) *T { return &v }