From cb71048e9c4d49479b344ec427b80be25feb46b3 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 27 Dec 2024 02:55:46 +0000 Subject: [PATCH] SDK regeneration --- .github/workflows/publish.yml | 26 - trycourier.gemspec => courier.gemspec | 4 +- lib/{trycourier.rb => courier.rb} | 39 +- .../audiences/client.rb | 0 .../audiences/types/audience.rb | 0 .../audiences/types/audience_list_response.rb | 0 .../audiences/types/audience_member.rb | 0 .../types/audience_member_get_response.rb | 0 .../types/audience_member_list_response.rb | 0 .../types/audience_update_response.rb | 0 .../audiences/types/base_filter_config.rb | 0 .../audiences/types/comparison_operator.rb | 0 .../audiences/types/filter.rb | 0 .../audiences/types/filter_config.rb | 0 .../audiences/types/logical_operator.rb | 0 .../audiences/types/nested_filter_config.rb | 0 .../audiences/types/operator.rb | 0 .../audiences/types/single_filter_config.rb | 0 .../audit_events/client.rb | 0 .../audit_events/types/actor.rb | 0 .../audit_events/types/audit_event.rb | 0 .../types/get_audit_event_params.rb | 0 .../types/list_audit_events_params.rb | 0 .../types/list_audit_events_response.rb | 0 .../audit_events/types/target.rb | 0 .../auth_tokens/client.rb | 0 .../auth_tokens/types/issue_token_response.rb | 0 .../automations/client.rb | 0 .../automations/types/accessor_type.rb | 42 ++ .../automations/types/automation.rb | 0 .../types/automation_ad_hoc_invoke_params.rb | 0 .../automation_add_to_batch_max_items_type.rb | 48 ++ .../types/automation_add_to_batch_retain.rb | 63 ++ .../automation_add_to_batch_retain_type.rb | 12 + .../types/automation_add_to_batch_scope.rb | 11 + .../types/automation_add_to_batch_step.rb | 127 ++++ .../types/automation_add_to_digest_step.rb | 63 ++ .../types/automation_cancel_step.rb | 0 .../types/automation_delay_step.rb | 17 +- .../types/automation_fetch_data_step.rb | 95 +++ .../types/automation_fetch_data_webhook.rb | 68 +++ .../automation_fetch_data_webhook_method.rb | 10 + .../types/automation_invoke_params.rb | 0 .../types/automation_invoke_response.rb | 0 .../types/automation_invoke_step.rb | 0 .../automation_invoke_template_params.rb | 0 .../types/automation_run_context.rb | 0 .../types/automation_send_list_step.rb | 0 .../automations/types/automation_send_step.rb | 0 .../automations/types/automation_step.rb | 0 .../types/automation_step_option.rb | 48 ++ .../types/automation_throttle_on_throttle.rb | 42 ++ .../types/automation_throttle_scope.rb | 11 + .../types/automation_throttle_step.rb | 107 ++++ .../types/automation_update_profile_step.rb | 0 .../types/automation_v_2_send_step.rb | 0 .../automations/types/merge_algorithm.rb | 0 .../automations/types/profile.rb | 0 lib/{trycourier => courier}/brands/client.rb | 0 .../brands/types/brand.rb | 0 .../brands/types/brand_colors.rb | 0 .../brands/types/brand_get_all_response.rb | 0 .../brands/types/brand_parameters.rb | 0 .../brands/types/brand_settings.rb | 0 .../brands/types/brand_snippet.rb | 0 .../brands/types/brand_snippets.rb | 0 .../brands/types/brands_response.rb | 0 lib/{trycourier => courier}/bulk/client.rb | 8 +- .../bulk/types/bulk_create_job_response.rb | 0 .../bulk/types/bulk_get_job_params.rb | 0 .../bulk/types/bulk_get_job_response.rb | 0 .../bulk/types/bulk_get_job_users_params.rb | 0 .../bulk/types/bulk_get_job_users_response.rb | 0 .../bulk/types/bulk_ingest_error.rb | 0 .../bulk/types/bulk_ingest_users_params.rb | 0 .../bulk/types/bulk_ingest_users_response.rb | 0 .../bulk/types/bulk_job_status.rb | 0 .../bulk/types/bulk_job_user_status.rb | 0 .../bulk/types/bulk_message_user_response.rb | 0 .../types/inbound_bulk_content_message.rb | 26 +- .../bulk/types/inbound_bulk_message.rb | 0 .../bulk/types/inbound_bulk_message_user.rb | 0 .../bulk/types/inbound_bulk_message_v_1.rb | 0 .../bulk/types/inbound_bulk_message_v_2.rb | 0 .../types/inbound_bulk_template_message.rb | 26 +- .../bulk/types/job_details.rb | 0 .../commons/types/already_exists.rb | 0 .../commons/types/bad_request.rb | 0 .../commons/types/base_error.rb | 0 .../commons/types/channel_classification.rb | 0 .../commons/types/channel_preference.rb | 0 .../commons/types/conflict.rb | 0 .../commons/types/email.rb | 0 .../commons/types/message_not_found.rb | 0 .../commons/types/not_found.rb | 0 .../types/notification_preference_details.rb | 0 .../commons/types/notification_preferences.rb | 0 .../commons/types/paging.rb | 0 .../commons/types/payment_required.rb | 0 .../commons/types/preference_status.rb | 0 .../commons/types/recipient_preferences.rb | 0 .../commons/types/rule.rb | 0 .../commons/types/user_tenant_association.rb | 12 +- lib/courier/inbound/client.rb | 74 +++ .../inbound/types/inbound_track_event.rb | 74 +++ .../inbound/types/track_accepted_response.rb | 47 ++ lib/{trycourier => courier}/lists/client.rb | 24 +- .../lists/types/list.rb | 0 .../lists/types/list_get_all_response.rb | 0 .../types/list_get_subscriptions_response.rb | 0 .../lists/types/list_put_params.rb | 0 .../types/list_subscription_recipient.rb | 0 .../types/put_subscriptions_recipient.rb | 0 .../messages/client.rb | 28 +- .../messages/types/list_messages_response.rb | 0 .../messages/types/message_details.rb | 30 +- .../types/message_history_response.rb | 12 +- .../messages/types/message_status.rb | 1 + .../messages/types/reason.rb | 0 .../messages/types/render_output.rb | 0 .../messages/types/render_output_response.rb | 0 .../messages/types/rendered_message_block.rb | 0 .../types/rendered_message_content.rb | 0 .../notifications/client.rb | 156 +---- .../notifications/types/base_check.rb | 0 .../notifications/types/block_type.rb | 0 .../notifications/types/check.rb | 0 .../notifications/types/check_status.rb | 0 .../notifications/types/message_routing.rb | 0 .../types/message_routing_channel.rb | 0 .../types/message_routing_method.rb | 0 .../notifications/types/notification.rb | 105 ++++ .../notifications/types/notification_block.rb | 0 .../types/notification_channel.rb | 0 .../types/notification_channel_content.rb | 0 .../types/notification_content.rb | 0 .../types/notification_content_hierarchy.rb | 0 .../notification_get_content_response.rb | 0 .../types/notification_list_response.rb | 0 .../notifications/types/notification_tag.rb | 51 ++ .../types/notification_tag_data.rb} | 35 +- .../types/submission_checks_get_response.rb | 0 .../submission_checks_replace_response.rb | 0 .../profiles/client.rb | 41 ++ .../profiles/types/address.rb | 0 .../profiles/types/airship_profile.rb | 0 .../types/airship_profile_audience.rb | 0 .../delete_list_subscription_response.rb | 0 .../profiles/types/device_type.rb | 0 .../profiles/types/discord.rb | 0 .../profiles/types/expo.rb | 0 .../types/get_list_subscriptions_list.rb | 0 .../types/get_list_subscriptions_response.rb | 0 .../profiles/types/intercom.rb | 0 .../profiles/types/intercom_recipient.rb | 0 .../profiles/types/merge_profile_response.rb | 0 .../profiles/types/ms_teams.rb | 0 .../types/ms_teams_base_properties.rb | 0 .../profiles/types/multiple_tokens.rb | 0 lib/courier/profiles/types/pagerduty.rb | 63 ++ .../profiles/types/profile_get_parameters.rb | 0 .../profiles/types/profile_get_response.rb | 0 .../types/replace_profile_response.rb | 0 .../profiles/types/send_direct_message.rb | 0 .../profiles/types/send_to_channel.rb | 0 .../types/send_to_ms_teams_channel_id.rb | 0 .../types/send_to_ms_teams_channel_name.rb | 0 .../types/send_to_ms_teams_conversation_id.rb | 0 .../profiles/types/send_to_ms_teams_email.rb | 0 .../types/send_to_ms_teams_user_id.rb | 0 .../profiles/types/send_to_slack_channel.rb | 0 .../profiles/types/send_to_slack_email.rb | 0 .../profiles/types/send_to_slack_user_id.rb | 0 .../profiles/types/slack.rb | 0 .../profiles/types/slack_base_properties.rb | 0 .../profiles/types/snooze_rule.rb | 0 .../profiles/types/snooze_rule_type.rb | 0 .../types/subscribe_to_lists_request.rb | 0 .../subscribe_to_lists_request_list_object.rb | 0 .../types/subscribe_to_lists_response.rb | 0 .../profiles/types/token.rb | 0 .../profiles/types/user_profile.rb | 14 +- .../types/user_profile_firebase_token.rb | 48 ++ .../profiles/types/user_profile_patch.rb | 57 ++ .../profiles/types/webhook_auth_mode.rb | 11 + .../profiles/types/webhook_authentication.rb | 63 ++ lib/courier/profiles/types/webhook_method.rb | 10 + lib/courier/profiles/types/webhook_profile.rb | 82 +++ .../profiles/types/webhook_profile_type.rb | 10 + .../send/types/attachment.rb | 0 .../send/types/audience_filter.rb | 0 .../send/types/audience_recipient.rb | 0 .../send/types/base_message.rb | 26 +- .../send/types/base_message_send_to.rb | 53 ++ .../send/types/base_social_presence.rb | 0 .../send/types/brand_settings_email.rb | 0 .../send/types/brand_settings_in_app.rb | 0 .../types/brand_settings_social_presence.rb | 0 .../send/types/brand_template.rb | 0 .../send/types/brand_template_override.rb | 0 .../send/types/channel.rb | 7 +- .../send/types/channel_metadata.rb | 0 .../send/types/channel_source.rb | 0 .../send/types/content.rb | 0 .../send/types/content_message.rb | 54 +- .../send/types/criteria.rb | 0 .../send/types/delay.rb | 15 +- .../send/types/elemental_action_node.rb | 0 .../send/types/elemental_base_node.rb | 0 .../send/types/elemental_channel_node.rb | 0 .../send/types/elemental_content.rb | 0 .../send/types/elemental_content_sugar.rb | 0 .../send/types/elemental_divider_node.rb | 0 .../send/types/elemental_group_node.rb | 0 .../send/types/elemental_image_node.rb | 0 .../send/types/elemental_meta_node.rb | 0 .../send/types/elemental_node.rb | 0 .../send/types/elemental_quote_node.rb | 0 .../send/types/elemental_text_node.rb | 0 .../send/types/email_footer.rb | 0 .../send/types/email_head.rb | 0 .../send/types/email_header.rb | 0 .../send/types/expires_in_type.rb | 0 .../send/types/expiry.rb | 0 .../send/types/i_action_button_style.rb | 0 .../send/types/i_alignment.rb | 0 .../send/types/i_preferences.rb | 0 .../send/types/i_profile_preferences.rb | 0 .../send/types/icons.rb | 0 .../send/types/in_app_placement.rb | 0 .../types/invalid_list_pattern_recipient.rb | 0 .../send/types/invalid_list_recipient.rb | 0 .../send/types/invalid_user_recipient.rb | 0 .../send/types/list_filter.rb | 0 .../send/types/list_pattern_recipient.rb | 0 .../send/types/list_pattern_recipient_type.rb | 0 .../send/types/list_recipient.rb | 0 .../send/types/list_recipient_type.rb | 0 .../send/types/locale.rb | 0 .../send/types/locales.rb | 0 .../send/types/logo.rb | 0 .../send/types/message.rb | 0 .../send/types/message_channels.rb | 0 .../send/types/message_context.rb | 0 .../send/types/message_data.rb | 0 .../send/types/message_metadata.rb | 0 lib/courier/send/types/message_preferences.rb | 47 ++ .../send/types/message_providers.rb | 0 .../send/types/message_providers_type.rb | 0 .../send/types/message_recipient.rb | 0 .../send/types/metadata.rb | 0 .../send/types/ms_teams_recipient.rb | 0 lib/courier/send/types/pagerduty_recipient.rb | 53 ++ .../send/types/preference.rb | 0 .../send/types/preferences.rb | 0 .../send/types/recipient.rb | 35 ++ lib/courier/send/types/recipient_data.rb | 7 + .../send/types/routing.rb | 0 .../send/types/routing_channel.rb | 0 .../send/types/routing_method.rb | 0 .../send/types/routing_strategy_channel.rb | 0 .../send/types/routing_strategy_provider.rb | 0 .../send/types/rule_type.rb | 0 .../send/types/slack_recipient.rb | 0 .../send/types/template_message.rb | 54 +- .../send/types/text_align.rb | 0 .../send/types/text_style.rb | 0 .../send/types/timeout.rb | 0 .../send/types/timeouts.rb | 0 .../send/types/tracking_override.rb | 0 .../send/types/user_recipient.rb | 0 .../send/types/user_recipient_type.rb | 0 lib/{trycourier => courier}/send/types/utm.rb | 0 lib/courier/send/types/webhook_recipient.rb | 53 ++ .../send/types/widget_background.rb | 0 .../templates/client.rb | 0 .../templates/types/channel_identifier.rb | 0 .../types/list_templates_response.rb | 0 .../templates/types/notification_templates.rb | 12 +- .../templates/types/routing_strategy.rb | 0 .../types/routing_strategy_method.rb | 0 .../templates/types/tag.rb | 0 .../templates/types/tag_data.rb | 0 lib/{trycourier => courier}/tenants/client.rb | 92 ++- .../tenants/types/default_preferences.rb | 4 +- .../types/list_users_for_tenant_response.rb | 0 .../tenants/types/subscription_topic.rb | 70 +++ .../tenants/types/subscription_topic_new.rb | 60 ++ .../types/subscription_topic_status.rb | 0 .../tenants/types/template_property.rb | 0 .../tenants/types/tenant.rb | 7 +- .../tenants/types/tenant_list_response.rb | 0 .../translations/client.rb | 0 .../types/send_message_response.rb | 0 lib/{trycourier => courier}/users/client.rb | 0 .../users/preferences/client.rb | 61 +- .../preferences/types/topic_preference.rb | 0 .../types/topic_preference_update.rb | 62 ++ .../types/user_preferences_get_response.rb | 0 .../types/user_preferences_list_response.rb | 4 +- .../types/user_preferences_update_response.rb | 0 .../users/tenants/client.rb | 19 +- ...d_user_to_single_tenants_params_profile.rb | 1 + .../types/list_tenants_for_user_response.rb | 0 .../users/tokens/client.rb | 32 + .../tokens/types/delete_user_token_opts.rb | 0 .../users/tokens/types/device.rb | 0 .../users/tokens/types/expiry_date.rb | 0 .../tokens/types/get_all_tokens_response.rb | 0 .../users/tokens/types/get_user_token_opts.rb | 0 .../tokens/types/get_user_token_response.rb | 0 .../tokens/types/get_user_tokens_opts.rb | 0 .../users/tokens/types/patch_op.rb | 0 .../users/tokens/types/patch_operation.rb | 0 .../tokens/types/patch_user_token_opts.rb | 0 .../users/tokens/types/provider_key.rb | 0 .../users/tokens/types/put_user_token_opts.rb | 0 .../tokens/types/put_user_tokens_opts.rb | 0 .../users/tokens/types/token_status.rb | 0 .../users/tokens/types/tracking.rb | 0 .../users/tokens/types/user_token.rb | 0 lib/requests.rb | 8 +- .../types/automation_step_action.rb | 14 - .../notifications/types/notification.rb | 63 -- .../types/message_channel_email_override.rb | 119 ---- lib/trycourier/send/types/override.rb | 10 - lib/types_export.rb | 571 +++++++++--------- 327 files changed, 2666 insertions(+), 888 deletions(-) delete mode 100644 .github/workflows/publish.yml rename trycourier.gemspec => courier.gemspec (94%) rename lib/{trycourier.rb => courier.rb} (86%) rename lib/{trycourier => courier}/audiences/client.rb (100%) rename lib/{trycourier => courier}/audiences/types/audience.rb (100%) rename lib/{trycourier => courier}/audiences/types/audience_list_response.rb (100%) rename lib/{trycourier => courier}/audiences/types/audience_member.rb (100%) rename lib/{trycourier => courier}/audiences/types/audience_member_get_response.rb (100%) rename lib/{trycourier => courier}/audiences/types/audience_member_list_response.rb (100%) rename lib/{trycourier => courier}/audiences/types/audience_update_response.rb (100%) rename lib/{trycourier => courier}/audiences/types/base_filter_config.rb (100%) rename lib/{trycourier => courier}/audiences/types/comparison_operator.rb (100%) rename lib/{trycourier => courier}/audiences/types/filter.rb (100%) rename lib/{trycourier => courier}/audiences/types/filter_config.rb (100%) rename lib/{trycourier => courier}/audiences/types/logical_operator.rb (100%) rename lib/{trycourier => courier}/audiences/types/nested_filter_config.rb (100%) rename lib/{trycourier => courier}/audiences/types/operator.rb (100%) rename lib/{trycourier => courier}/audiences/types/single_filter_config.rb (100%) rename lib/{trycourier => courier}/audit_events/client.rb (100%) rename lib/{trycourier => courier}/audit_events/types/actor.rb (100%) rename lib/{trycourier => courier}/audit_events/types/audit_event.rb (100%) rename lib/{trycourier => courier}/audit_events/types/get_audit_event_params.rb (100%) rename lib/{trycourier => courier}/audit_events/types/list_audit_events_params.rb (100%) rename lib/{trycourier => courier}/audit_events/types/list_audit_events_response.rb (100%) rename lib/{trycourier => courier}/audit_events/types/target.rb (100%) rename lib/{trycourier => courier}/auth_tokens/client.rb (100%) rename lib/{trycourier => courier}/auth_tokens/types/issue_token_response.rb (100%) rename lib/{trycourier => courier}/automations/client.rb (100%) create mode 100644 lib/courier/automations/types/accessor_type.rb rename lib/{trycourier => courier}/automations/types/automation.rb (100%) rename lib/{trycourier => courier}/automations/types/automation_ad_hoc_invoke_params.rb (100%) create mode 100644 lib/courier/automations/types/automation_add_to_batch_max_items_type.rb create mode 100644 lib/courier/automations/types/automation_add_to_batch_retain.rb create mode 100644 lib/courier/automations/types/automation_add_to_batch_retain_type.rb create mode 100644 lib/courier/automations/types/automation_add_to_batch_scope.rb create mode 100644 lib/courier/automations/types/automation_add_to_batch_step.rb create mode 100644 lib/courier/automations/types/automation_add_to_digest_step.rb rename lib/{trycourier => courier}/automations/types/automation_cancel_step.rb (100%) rename lib/{trycourier => courier}/automations/types/automation_delay_step.rb (66%) create mode 100644 lib/courier/automations/types/automation_fetch_data_step.rb create mode 100644 lib/courier/automations/types/automation_fetch_data_webhook.rb create mode 100644 lib/courier/automations/types/automation_fetch_data_webhook_method.rb rename lib/{trycourier => courier}/automations/types/automation_invoke_params.rb (100%) rename lib/{trycourier => courier}/automations/types/automation_invoke_response.rb (100%) rename lib/{trycourier => courier}/automations/types/automation_invoke_step.rb (100%) rename lib/{trycourier => courier}/automations/types/automation_invoke_template_params.rb (100%) rename lib/{trycourier => courier}/automations/types/automation_run_context.rb (100%) rename lib/{trycourier => courier}/automations/types/automation_send_list_step.rb (100%) rename lib/{trycourier => courier}/automations/types/automation_send_step.rb (100%) rename lib/{trycourier => courier}/automations/types/automation_step.rb (100%) rename lib/{trycourier => courier}/automations/types/automation_step_option.rb (68%) create mode 100644 lib/courier/automations/types/automation_throttle_on_throttle.rb create mode 100644 lib/courier/automations/types/automation_throttle_scope.rb create mode 100644 lib/courier/automations/types/automation_throttle_step.rb rename lib/{trycourier => courier}/automations/types/automation_update_profile_step.rb (100%) rename lib/{trycourier => courier}/automations/types/automation_v_2_send_step.rb (100%) rename lib/{trycourier => courier}/automations/types/merge_algorithm.rb (100%) rename lib/{trycourier => courier}/automations/types/profile.rb (100%) rename lib/{trycourier => courier}/brands/client.rb (100%) rename lib/{trycourier => courier}/brands/types/brand.rb (100%) rename lib/{trycourier => courier}/brands/types/brand_colors.rb (100%) rename lib/{trycourier => courier}/brands/types/brand_get_all_response.rb (100%) rename lib/{trycourier => courier}/brands/types/brand_parameters.rb (100%) rename lib/{trycourier => courier}/brands/types/brand_settings.rb (100%) rename lib/{trycourier => courier}/brands/types/brand_snippet.rb (100%) rename lib/{trycourier => courier}/brands/types/brand_snippets.rb (100%) rename lib/{trycourier => courier}/brands/types/brands_response.rb (100%) rename lib/{trycourier => courier}/bulk/client.rb (95%) rename lib/{trycourier => courier}/bulk/types/bulk_create_job_response.rb (100%) rename lib/{trycourier => courier}/bulk/types/bulk_get_job_params.rb (100%) rename lib/{trycourier => courier}/bulk/types/bulk_get_job_response.rb (100%) rename lib/{trycourier => courier}/bulk/types/bulk_get_job_users_params.rb (100%) rename lib/{trycourier => courier}/bulk/types/bulk_get_job_users_response.rb (100%) rename lib/{trycourier => courier}/bulk/types/bulk_ingest_error.rb (100%) rename lib/{trycourier => courier}/bulk/types/bulk_ingest_users_params.rb (100%) rename lib/{trycourier => courier}/bulk/types/bulk_ingest_users_response.rb (100%) rename lib/{trycourier => courier}/bulk/types/bulk_job_status.rb (100%) rename lib/{trycourier => courier}/bulk/types/bulk_job_user_status.rb (100%) rename lib/{trycourier => courier}/bulk/types/bulk_message_user_response.rb (100%) rename lib/{trycourier => courier}/bulk/types/inbound_bulk_content_message.rb (82%) rename lib/{trycourier => courier}/bulk/types/inbound_bulk_message.rb (100%) rename lib/{trycourier => courier}/bulk/types/inbound_bulk_message_user.rb (100%) rename lib/{trycourier => courier}/bulk/types/inbound_bulk_message_v_1.rb (100%) rename lib/{trycourier => courier}/bulk/types/inbound_bulk_message_v_2.rb (100%) rename lib/{trycourier => courier}/bulk/types/inbound_bulk_template_message.rb (81%) rename lib/{trycourier => courier}/bulk/types/job_details.rb (100%) rename lib/{trycourier => courier}/commons/types/already_exists.rb (100%) rename lib/{trycourier => courier}/commons/types/bad_request.rb (100%) rename lib/{trycourier => courier}/commons/types/base_error.rb (100%) rename lib/{trycourier => courier}/commons/types/channel_classification.rb (100%) rename lib/{trycourier => courier}/commons/types/channel_preference.rb (100%) rename lib/{trycourier => courier}/commons/types/conflict.rb (100%) rename lib/{trycourier => courier}/commons/types/email.rb (100%) rename lib/{trycourier => courier}/commons/types/message_not_found.rb (100%) rename lib/{trycourier => courier}/commons/types/not_found.rb (100%) rename lib/{trycourier => courier}/commons/types/notification_preference_details.rb (100%) rename lib/{trycourier => courier}/commons/types/notification_preferences.rb (100%) rename lib/{trycourier => courier}/commons/types/paging.rb (100%) rename lib/{trycourier => courier}/commons/types/payment_required.rb (100%) rename lib/{trycourier => courier}/commons/types/preference_status.rb (100%) rename lib/{trycourier => courier}/commons/types/recipient_preferences.rb (100%) rename lib/{trycourier => courier}/commons/types/rule.rb (100%) rename lib/{trycourier => courier}/commons/types/user_tenant_association.rb (74%) create mode 100644 lib/courier/inbound/client.rb create mode 100644 lib/courier/inbound/types/inbound_track_event.rb create mode 100644 lib/courier/inbound/types/track_accepted_response.rb rename lib/{trycourier => courier}/lists/client.rb (94%) rename lib/{trycourier => courier}/lists/types/list.rb (100%) rename lib/{trycourier => courier}/lists/types/list_get_all_response.rb (100%) rename lib/{trycourier => courier}/lists/types/list_get_subscriptions_response.rb (100%) rename lib/{trycourier => courier}/lists/types/list_put_params.rb (100%) rename lib/{trycourier => courier}/lists/types/list_subscription_recipient.rb (100%) rename lib/{trycourier => courier}/lists/types/put_subscriptions_recipient.rb (100%) rename lib/{trycourier => courier}/messages/client.rb (90%) rename lib/{trycourier => courier}/messages/types/list_messages_response.rb (100%) rename lib/{trycourier => courier}/messages/types/message_details.rb (70%) rename lib/{trycourier => courier}/messages/types/message_history_response.rb (81%) rename lib/{trycourier => courier}/messages/types/message_status.rb (92%) rename lib/{trycourier => courier}/messages/types/reason.rb (100%) rename lib/{trycourier => courier}/messages/types/render_output.rb (100%) rename lib/{trycourier => courier}/messages/types/render_output_response.rb (100%) rename lib/{trycourier => courier}/messages/types/rendered_message_block.rb (100%) rename lib/{trycourier => courier}/messages/types/rendered_message_content.rb (100%) rename lib/{trycourier => courier}/notifications/client.rb (63%) rename lib/{trycourier => courier}/notifications/types/base_check.rb (100%) rename lib/{trycourier => courier}/notifications/types/block_type.rb (100%) rename lib/{trycourier => courier}/notifications/types/check.rb (100%) rename lib/{trycourier => courier}/notifications/types/check_status.rb (100%) rename lib/{trycourier => courier}/notifications/types/message_routing.rb (100%) rename lib/{trycourier => courier}/notifications/types/message_routing_channel.rb (100%) rename lib/{trycourier => courier}/notifications/types/message_routing_method.rb (100%) create mode 100644 lib/courier/notifications/types/notification.rb rename lib/{trycourier => courier}/notifications/types/notification_block.rb (100%) rename lib/{trycourier => courier}/notifications/types/notification_channel.rb (100%) rename lib/{trycourier => courier}/notifications/types/notification_channel_content.rb (100%) rename lib/{trycourier => courier}/notifications/types/notification_content.rb (100%) rename lib/{trycourier => courier}/notifications/types/notification_content_hierarchy.rb (100%) rename lib/{trycourier => courier}/notifications/types/notification_get_content_response.rb (100%) rename lib/{trycourier => courier}/notifications/types/notification_list_response.rb (100%) create mode 100644 lib/courier/notifications/types/notification_tag.rb rename lib/{trycourier/tenants/types/subscription_topic.rb => courier/notifications/types/notification_tag_data.rb} (52%) rename lib/{trycourier => courier}/notifications/types/submission_checks_get_response.rb (100%) rename lib/{trycourier => courier}/notifications/types/submission_checks_replace_response.rb (100%) rename lib/{trycourier => courier}/profiles/client.rb (89%) rename lib/{trycourier => courier}/profiles/types/address.rb (100%) rename lib/{trycourier => courier}/profiles/types/airship_profile.rb (100%) rename lib/{trycourier => courier}/profiles/types/airship_profile_audience.rb (100%) rename lib/{trycourier => courier}/profiles/types/delete_list_subscription_response.rb (100%) rename lib/{trycourier => courier}/profiles/types/device_type.rb (100%) rename lib/{trycourier => courier}/profiles/types/discord.rb (100%) rename lib/{trycourier => courier}/profiles/types/expo.rb (100%) rename lib/{trycourier => courier}/profiles/types/get_list_subscriptions_list.rb (100%) rename lib/{trycourier => courier}/profiles/types/get_list_subscriptions_response.rb (100%) rename lib/{trycourier => courier}/profiles/types/intercom.rb (100%) rename lib/{trycourier => courier}/profiles/types/intercom_recipient.rb (100%) rename lib/{trycourier => courier}/profiles/types/merge_profile_response.rb (100%) rename lib/{trycourier => courier}/profiles/types/ms_teams.rb (100%) rename lib/{trycourier => courier}/profiles/types/ms_teams_base_properties.rb (100%) rename lib/{trycourier => courier}/profiles/types/multiple_tokens.rb (100%) create mode 100644 lib/courier/profiles/types/pagerduty.rb rename lib/{trycourier => courier}/profiles/types/profile_get_parameters.rb (100%) rename lib/{trycourier => courier}/profiles/types/profile_get_response.rb (100%) rename lib/{trycourier => courier}/profiles/types/replace_profile_response.rb (100%) rename lib/{trycourier => courier}/profiles/types/send_direct_message.rb (100%) rename lib/{trycourier => courier}/profiles/types/send_to_channel.rb (100%) rename lib/{trycourier => courier}/profiles/types/send_to_ms_teams_channel_id.rb (100%) rename lib/{trycourier => courier}/profiles/types/send_to_ms_teams_channel_name.rb (100%) rename lib/{trycourier => courier}/profiles/types/send_to_ms_teams_conversation_id.rb (100%) rename lib/{trycourier => courier}/profiles/types/send_to_ms_teams_email.rb (100%) rename lib/{trycourier => courier}/profiles/types/send_to_ms_teams_user_id.rb (100%) rename lib/{trycourier => courier}/profiles/types/send_to_slack_channel.rb (100%) rename lib/{trycourier => courier}/profiles/types/send_to_slack_email.rb (100%) rename lib/{trycourier => courier}/profiles/types/send_to_slack_user_id.rb (100%) rename lib/{trycourier => courier}/profiles/types/slack.rb (100%) rename lib/{trycourier => courier}/profiles/types/slack_base_properties.rb (100%) rename lib/{trycourier => courier}/profiles/types/snooze_rule.rb (100%) rename lib/{trycourier => courier}/profiles/types/snooze_rule_type.rb (100%) rename lib/{trycourier => courier}/profiles/types/subscribe_to_lists_request.rb (100%) rename lib/{trycourier => courier}/profiles/types/subscribe_to_lists_request_list_object.rb (100%) rename lib/{trycourier => courier}/profiles/types/subscribe_to_lists_response.rb (100%) rename lib/{trycourier => courier}/profiles/types/token.rb (100%) rename lib/{trycourier => courier}/profiles/types/user_profile.rb (96%) create mode 100644 lib/courier/profiles/types/user_profile_firebase_token.rb create mode 100644 lib/courier/profiles/types/user_profile_patch.rb create mode 100644 lib/courier/profiles/types/webhook_auth_mode.rb create mode 100644 lib/courier/profiles/types/webhook_authentication.rb create mode 100644 lib/courier/profiles/types/webhook_method.rb create mode 100644 lib/courier/profiles/types/webhook_profile.rb create mode 100644 lib/courier/profiles/types/webhook_profile_type.rb rename lib/{trycourier => courier}/send/types/attachment.rb (100%) rename lib/{trycourier => courier}/send/types/audience_filter.rb (100%) rename lib/{trycourier => courier}/send/types/audience_recipient.rb (100%) rename lib/{trycourier => courier}/send/types/base_message.rb (80%) create mode 100644 lib/courier/send/types/base_message_send_to.rb rename lib/{trycourier => courier}/send/types/base_social_presence.rb (100%) rename lib/{trycourier => courier}/send/types/brand_settings_email.rb (100%) rename lib/{trycourier => courier}/send/types/brand_settings_in_app.rb (100%) rename lib/{trycourier => courier}/send/types/brand_settings_social_presence.rb (100%) rename lib/{trycourier => courier}/send/types/brand_template.rb (100%) rename lib/{trycourier => courier}/send/types/brand_template_override.rb (100%) rename lib/{trycourier => courier}/send/types/channel.rb (94%) rename lib/{trycourier => courier}/send/types/channel_metadata.rb (100%) rename lib/{trycourier => courier}/send/types/channel_source.rb (100%) rename lib/{trycourier => courier}/send/types/content.rb (100%) rename lib/{trycourier => courier}/send/types/content_message.rb (80%) rename lib/{trycourier => courier}/send/types/criteria.rb (100%) rename lib/{trycourier => courier}/send/types/delay.rb (52%) rename lib/{trycourier => courier}/send/types/elemental_action_node.rb (100%) rename lib/{trycourier => courier}/send/types/elemental_base_node.rb (100%) rename lib/{trycourier => courier}/send/types/elemental_channel_node.rb (100%) rename lib/{trycourier => courier}/send/types/elemental_content.rb (100%) rename lib/{trycourier => courier}/send/types/elemental_content_sugar.rb (100%) rename lib/{trycourier => courier}/send/types/elemental_divider_node.rb (100%) rename lib/{trycourier => courier}/send/types/elemental_group_node.rb (100%) rename lib/{trycourier => courier}/send/types/elemental_image_node.rb (100%) rename lib/{trycourier => courier}/send/types/elemental_meta_node.rb (100%) rename lib/{trycourier => courier}/send/types/elemental_node.rb (100%) rename lib/{trycourier => courier}/send/types/elemental_quote_node.rb (100%) rename lib/{trycourier => courier}/send/types/elemental_text_node.rb (100%) rename lib/{trycourier => courier}/send/types/email_footer.rb (100%) rename lib/{trycourier => courier}/send/types/email_head.rb (100%) rename lib/{trycourier => courier}/send/types/email_header.rb (100%) rename lib/{trycourier => courier}/send/types/expires_in_type.rb (100%) rename lib/{trycourier => courier}/send/types/expiry.rb (100%) rename lib/{trycourier => courier}/send/types/i_action_button_style.rb (100%) rename lib/{trycourier => courier}/send/types/i_alignment.rb (100%) rename lib/{trycourier => courier}/send/types/i_preferences.rb (100%) rename lib/{trycourier => courier}/send/types/i_profile_preferences.rb (100%) rename lib/{trycourier => courier}/send/types/icons.rb (100%) rename lib/{trycourier => courier}/send/types/in_app_placement.rb (100%) rename lib/{trycourier => courier}/send/types/invalid_list_pattern_recipient.rb (100%) rename lib/{trycourier => courier}/send/types/invalid_list_recipient.rb (100%) rename lib/{trycourier => courier}/send/types/invalid_user_recipient.rb (100%) rename lib/{trycourier => courier}/send/types/list_filter.rb (100%) rename lib/{trycourier => courier}/send/types/list_pattern_recipient.rb (100%) rename lib/{trycourier => courier}/send/types/list_pattern_recipient_type.rb (100%) rename lib/{trycourier => courier}/send/types/list_recipient.rb (100%) rename lib/{trycourier => courier}/send/types/list_recipient_type.rb (100%) rename lib/{trycourier => courier}/send/types/locale.rb (100%) rename lib/{trycourier => courier}/send/types/locales.rb (100%) rename lib/{trycourier => courier}/send/types/logo.rb (100%) rename lib/{trycourier => courier}/send/types/message.rb (100%) rename lib/{trycourier => courier}/send/types/message_channels.rb (100%) rename lib/{trycourier => courier}/send/types/message_context.rb (100%) rename lib/{trycourier => courier}/send/types/message_data.rb (100%) rename lib/{trycourier => courier}/send/types/message_metadata.rb (100%) create mode 100644 lib/courier/send/types/message_preferences.rb rename lib/{trycourier => courier}/send/types/message_providers.rb (100%) rename lib/{trycourier => courier}/send/types/message_providers_type.rb (100%) rename lib/{trycourier => courier}/send/types/message_recipient.rb (100%) rename lib/{trycourier => courier}/send/types/metadata.rb (100%) rename lib/{trycourier => courier}/send/types/ms_teams_recipient.rb (100%) create mode 100644 lib/courier/send/types/pagerduty_recipient.rb rename lib/{trycourier => courier}/send/types/preference.rb (100%) rename lib/{trycourier => courier}/send/types/preferences.rb (100%) rename lib/{trycourier => courier}/send/types/recipient.rb (71%) create mode 100644 lib/courier/send/types/recipient_data.rb rename lib/{trycourier => courier}/send/types/routing.rb (100%) rename lib/{trycourier => courier}/send/types/routing_channel.rb (100%) rename lib/{trycourier => courier}/send/types/routing_method.rb (100%) rename lib/{trycourier => courier}/send/types/routing_strategy_channel.rb (100%) rename lib/{trycourier => courier}/send/types/routing_strategy_provider.rb (100%) rename lib/{trycourier => courier}/send/types/rule_type.rb (100%) rename lib/{trycourier => courier}/send/types/slack_recipient.rb (100%) rename lib/{trycourier => courier}/send/types/template_message.rb (79%) rename lib/{trycourier => courier}/send/types/text_align.rb (100%) rename lib/{trycourier => courier}/send/types/text_style.rb (100%) rename lib/{trycourier => courier}/send/types/timeout.rb (100%) rename lib/{trycourier => courier}/send/types/timeouts.rb (100%) rename lib/{trycourier => courier}/send/types/tracking_override.rb (100%) rename lib/{trycourier => courier}/send/types/user_recipient.rb (100%) rename lib/{trycourier => courier}/send/types/user_recipient_type.rb (100%) rename lib/{trycourier => courier}/send/types/utm.rb (100%) create mode 100644 lib/courier/send/types/webhook_recipient.rb rename lib/{trycourier => courier}/send/types/widget_background.rb (100%) rename lib/{trycourier => courier}/templates/client.rb (100%) rename lib/{trycourier => courier}/templates/types/channel_identifier.rb (100%) rename lib/{trycourier => courier}/templates/types/list_templates_response.rb (100%) rename lib/{trycourier => courier}/templates/types/notification_templates.rb (77%) rename lib/{trycourier => courier}/templates/types/routing_strategy.rb (100%) rename lib/{trycourier => courier}/templates/types/routing_strategy_method.rb (100%) rename lib/{trycourier => courier}/templates/types/tag.rb (100%) rename lib/{trycourier => courier}/templates/types/tag_data.rb (100%) rename lib/{trycourier => courier}/tenants/client.rb (69%) rename lib/{trycourier => courier}/tenants/types/default_preferences.rb (89%) rename lib/{trycourier => courier}/tenants/types/list_users_for_tenant_response.rb (100%) create mode 100644 lib/courier/tenants/types/subscription_topic.rb create mode 100644 lib/courier/tenants/types/subscription_topic_new.rb rename lib/{trycourier => courier}/tenants/types/subscription_topic_status.rb (100%) rename lib/{trycourier => courier}/tenants/types/template_property.rb (100%) rename lib/{trycourier => courier}/tenants/types/tenant.rb (92%) rename lib/{trycourier => courier}/tenants/types/tenant_list_response.rb (100%) rename lib/{trycourier => courier}/translations/client.rb (100%) rename lib/{trycourier => courier}/types/send_message_response.rb (100%) rename lib/{trycourier => courier}/users/client.rb (100%) rename lib/{trycourier => courier}/users/preferences/client.rb (72%) rename lib/{trycourier => courier}/users/preferences/types/topic_preference.rb (100%) create mode 100644 lib/courier/users/preferences/types/topic_preference_update.rb rename lib/{trycourier => courier}/users/preferences/types/user_preferences_get_response.rb (100%) rename lib/{trycourier => courier}/users/preferences/types/user_preferences_list_response.rb (93%) rename lib/{trycourier => courier}/users/preferences/types/user_preferences_update_response.rb (100%) rename lib/{trycourier => courier}/users/tenants/client.rb (93%) rename lib/{trycourier => courier}/users/tenants/types/add_user_to_single_tenants_params_profile.rb (97%) rename lib/{trycourier => courier}/users/tenants/types/list_tenants_for_user_response.rb (100%) rename lib/{trycourier => courier}/users/tokens/client.rb (88%) rename lib/{trycourier => courier}/users/tokens/types/delete_user_token_opts.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/device.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/expiry_date.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/get_all_tokens_response.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/get_user_token_opts.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/get_user_token_response.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/get_user_tokens_opts.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/patch_op.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/patch_operation.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/patch_user_token_opts.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/provider_key.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/put_user_token_opts.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/put_user_tokens_opts.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/token_status.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/tracking.rb (100%) rename lib/{trycourier => courier}/users/tokens/types/user_token.rb (100%) delete mode 100644 lib/trycourier/automations/types/automation_step_action.rb delete mode 100644 lib/trycourier/notifications/types/notification.rb delete mode 100644 lib/trycourier/send/types/message_channel_email_override.rb delete mode 100644 lib/trycourier/send/types/override.rb diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index aa67735..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Publish Gem - -on: - push: - workflow_dispatch: - -jobs: - publish: - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v3 - - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.7 - bundler-cache: true - - - name: Build and Push Gem - env: - GEM_HOST_API_KEY: ${{ secrets.RUBY_GEMS_API_KEY }} - run: | - gem build trycourier.gemspec - - gem push trycourier-*.gem --host https://rubygems.org/ diff --git a/trycourier.gemspec b/courier.gemspec similarity index 94% rename from trycourier.gemspec rename to courier.gemspec index 3751223..b5bf8e2 100644 --- a/trycourier.gemspec +++ b/courier.gemspec @@ -3,8 +3,8 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| - spec.name = "trycourier" - spec.version = "3.1.2" + spec.name = "courier" + spec.version = "3.1.3" spec.authors = Courier::Gemconfig::AUTHORS spec.email = Courier::Gemconfig::EMAIL spec.summary = Courier::Gemconfig::SUMMARY diff --git a/lib/trycourier.rb b/lib/courier.rb similarity index 86% rename from lib/trycourier.rb rename to lib/courier.rb index 4cc28f8..36c8bf4 100644 --- a/lib/trycourier.rb +++ b/lib/courier.rb @@ -3,26 +3,27 @@ require_relative "environment" require_relative "types_export" require_relative "requests" -require_relative "trycourier/audiences/client" -require_relative "trycourier/audit_events/client" -require_relative "trycourier/auth_tokens/client" -require_relative "trycourier/automations/client" -require_relative "trycourier/brands/client" -require_relative "trycourier/bulk/client" -require_relative "trycourier/lists/client" -require_relative "trycourier/messages/client" -require_relative "trycourier/notifications/client" -require_relative "trycourier/profiles/client" -require_relative "trycourier/templates/client" -require_relative "trycourier/tenants/client" -require_relative "trycourier/translations/client" -require_relative "trycourier/users/client" -require_relative "trycourier/send/types/message" -require_relative "trycourier/types/send_message_response" +require_relative "courier/audiences/client" +require_relative "courier/audit_events/client" +require_relative "courier/auth_tokens/client" +require_relative "courier/automations/client" +require_relative "courier/brands/client" +require_relative "courier/bulk/client" +require_relative "courier/inbound/client" +require_relative "courier/lists/client" +require_relative "courier/messages/client" +require_relative "courier/notifications/client" +require_relative "courier/profiles/client" +require_relative "courier/templates/client" +require_relative "courier/tenants/client" +require_relative "courier/translations/client" +require_relative "courier/users/client" +require_relative "courier/send/types/message" +require_relative "courier/types/send_message_response" module Courier class Client - attr_reader :audiences, :audit_events, :auth_tokens, :automations, :brands, :bulk, :lists, :messages, + attr_reader :audiences, :audit_events, :auth_tokens, :automations, :brands, :bulk, :inbound, :lists, :messages, :notifications, :profiles, :templates, :tenants, :translations, :users # @param environment [Environment] @@ -40,6 +41,7 @@ def initialize(authorization_token:, environment: Environment::PRODUCTION, max_r @automations = AutomationsClient.new(request_client: @request_client) @brands = BrandsClient.new(request_client: @request_client) @bulk = BulkClient.new(request_client: @request_client) + @inbound = InboundClient.new(request_client: @request_client) @lists = ListsClient.new(request_client: @request_client) @messages = MessagesClient.new(request_client: @request_client) @notifications = NotificationsClient.new(request_client: @request_client) @@ -74,7 +76,7 @@ def send(message:, request_options: nil) end class AsyncClient - attr_reader :audiences, :audit_events, :auth_tokens, :automations, :brands, :bulk, :lists, :messages, + attr_reader :audiences, :audit_events, :auth_tokens, :automations, :brands, :bulk, :inbound, :lists, :messages, :notifications, :profiles, :templates, :tenants, :translations, :users # @param environment [Environment] @@ -92,6 +94,7 @@ def initialize(authorization_token:, environment: Environment::PRODUCTION, max_r @automations = AsyncAutomationsClient.new(request_client: @async_request_client) @brands = AsyncBrandsClient.new(request_client: @async_request_client) @bulk = AsyncBulkClient.new(request_client: @async_request_client) + @inbound = AsyncInboundClient.new(request_client: @async_request_client) @lists = AsyncListsClient.new(request_client: @async_request_client) @messages = AsyncMessagesClient.new(request_client: @async_request_client) @notifications = AsyncNotificationsClient.new(request_client: @async_request_client) diff --git a/lib/trycourier/audiences/client.rb b/lib/courier/audiences/client.rb similarity index 100% rename from lib/trycourier/audiences/client.rb rename to lib/courier/audiences/client.rb diff --git a/lib/trycourier/audiences/types/audience.rb b/lib/courier/audiences/types/audience.rb similarity index 100% rename from lib/trycourier/audiences/types/audience.rb rename to lib/courier/audiences/types/audience.rb diff --git a/lib/trycourier/audiences/types/audience_list_response.rb b/lib/courier/audiences/types/audience_list_response.rb similarity index 100% rename from lib/trycourier/audiences/types/audience_list_response.rb rename to lib/courier/audiences/types/audience_list_response.rb diff --git a/lib/trycourier/audiences/types/audience_member.rb b/lib/courier/audiences/types/audience_member.rb similarity index 100% rename from lib/trycourier/audiences/types/audience_member.rb rename to lib/courier/audiences/types/audience_member.rb diff --git a/lib/trycourier/audiences/types/audience_member_get_response.rb b/lib/courier/audiences/types/audience_member_get_response.rb similarity index 100% rename from lib/trycourier/audiences/types/audience_member_get_response.rb rename to lib/courier/audiences/types/audience_member_get_response.rb diff --git a/lib/trycourier/audiences/types/audience_member_list_response.rb b/lib/courier/audiences/types/audience_member_list_response.rb similarity index 100% rename from lib/trycourier/audiences/types/audience_member_list_response.rb rename to lib/courier/audiences/types/audience_member_list_response.rb diff --git a/lib/trycourier/audiences/types/audience_update_response.rb b/lib/courier/audiences/types/audience_update_response.rb similarity index 100% rename from lib/trycourier/audiences/types/audience_update_response.rb rename to lib/courier/audiences/types/audience_update_response.rb diff --git a/lib/trycourier/audiences/types/base_filter_config.rb b/lib/courier/audiences/types/base_filter_config.rb similarity index 100% rename from lib/trycourier/audiences/types/base_filter_config.rb rename to lib/courier/audiences/types/base_filter_config.rb diff --git a/lib/trycourier/audiences/types/comparison_operator.rb b/lib/courier/audiences/types/comparison_operator.rb similarity index 100% rename from lib/trycourier/audiences/types/comparison_operator.rb rename to lib/courier/audiences/types/comparison_operator.rb diff --git a/lib/trycourier/audiences/types/filter.rb b/lib/courier/audiences/types/filter.rb similarity index 100% rename from lib/trycourier/audiences/types/filter.rb rename to lib/courier/audiences/types/filter.rb diff --git a/lib/trycourier/audiences/types/filter_config.rb b/lib/courier/audiences/types/filter_config.rb similarity index 100% rename from lib/trycourier/audiences/types/filter_config.rb rename to lib/courier/audiences/types/filter_config.rb diff --git a/lib/trycourier/audiences/types/logical_operator.rb b/lib/courier/audiences/types/logical_operator.rb similarity index 100% rename from lib/trycourier/audiences/types/logical_operator.rb rename to lib/courier/audiences/types/logical_operator.rb diff --git a/lib/trycourier/audiences/types/nested_filter_config.rb b/lib/courier/audiences/types/nested_filter_config.rb similarity index 100% rename from lib/trycourier/audiences/types/nested_filter_config.rb rename to lib/courier/audiences/types/nested_filter_config.rb diff --git a/lib/trycourier/audiences/types/operator.rb b/lib/courier/audiences/types/operator.rb similarity index 100% rename from lib/trycourier/audiences/types/operator.rb rename to lib/courier/audiences/types/operator.rb diff --git a/lib/trycourier/audiences/types/single_filter_config.rb b/lib/courier/audiences/types/single_filter_config.rb similarity index 100% rename from lib/trycourier/audiences/types/single_filter_config.rb rename to lib/courier/audiences/types/single_filter_config.rb diff --git a/lib/trycourier/audit_events/client.rb b/lib/courier/audit_events/client.rb similarity index 100% rename from lib/trycourier/audit_events/client.rb rename to lib/courier/audit_events/client.rb diff --git a/lib/trycourier/audit_events/types/actor.rb b/lib/courier/audit_events/types/actor.rb similarity index 100% rename from lib/trycourier/audit_events/types/actor.rb rename to lib/courier/audit_events/types/actor.rb diff --git a/lib/trycourier/audit_events/types/audit_event.rb b/lib/courier/audit_events/types/audit_event.rb similarity index 100% rename from lib/trycourier/audit_events/types/audit_event.rb rename to lib/courier/audit_events/types/audit_event.rb diff --git a/lib/trycourier/audit_events/types/get_audit_event_params.rb b/lib/courier/audit_events/types/get_audit_event_params.rb similarity index 100% rename from lib/trycourier/audit_events/types/get_audit_event_params.rb rename to lib/courier/audit_events/types/get_audit_event_params.rb diff --git a/lib/trycourier/audit_events/types/list_audit_events_params.rb b/lib/courier/audit_events/types/list_audit_events_params.rb similarity index 100% rename from lib/trycourier/audit_events/types/list_audit_events_params.rb rename to lib/courier/audit_events/types/list_audit_events_params.rb diff --git a/lib/trycourier/audit_events/types/list_audit_events_response.rb b/lib/courier/audit_events/types/list_audit_events_response.rb similarity index 100% rename from lib/trycourier/audit_events/types/list_audit_events_response.rb rename to lib/courier/audit_events/types/list_audit_events_response.rb diff --git a/lib/trycourier/audit_events/types/target.rb b/lib/courier/audit_events/types/target.rb similarity index 100% rename from lib/trycourier/audit_events/types/target.rb rename to lib/courier/audit_events/types/target.rb diff --git a/lib/trycourier/auth_tokens/client.rb b/lib/courier/auth_tokens/client.rb similarity index 100% rename from lib/trycourier/auth_tokens/client.rb rename to lib/courier/auth_tokens/client.rb diff --git a/lib/trycourier/auth_tokens/types/issue_token_response.rb b/lib/courier/auth_tokens/types/issue_token_response.rb similarity index 100% rename from lib/trycourier/auth_tokens/types/issue_token_response.rb rename to lib/courier/auth_tokens/types/issue_token_response.rb diff --git a/lib/trycourier/automations/client.rb b/lib/courier/automations/client.rb similarity index 100% rename from lib/trycourier/automations/client.rb rename to lib/courier/automations/client.rb diff --git a/lib/courier/automations/types/accessor_type.rb b/lib/courier/automations/types/accessor_type.rb new file mode 100644 index 0000000..c2f9a04 --- /dev/null +++ b/lib/courier/automations/types/accessor_type.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true +require "json" + +module Courier + class Automations + class AccessorType + attr_reader :ref, :additional_properties + # @param ref [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Automations::AccessorType] + def initialize(ref:, additional_properties: nil) + # @type [String] + @ref = ref + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + # Deserialize a JSON object to an instance of AccessorType + # + # @param json_object [JSON] + # @return [Automations::AccessorType] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + ref = struct.$ref + new(ref: ref, additional_properties: struct) + end + # Serialize an instance of AccessorType to a JSON object + # + # @return [JSON] + def to_json + { "$ref": @ref }.to_json + end + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.ref.is_a?(String) != false || raise("Passed value for field obj.ref is not the expected type, validation failed.") + end + end + end +end \ No newline at end of file diff --git a/lib/trycourier/automations/types/automation.rb b/lib/courier/automations/types/automation.rb similarity index 100% rename from lib/trycourier/automations/types/automation.rb rename to lib/courier/automations/types/automation.rb diff --git a/lib/trycourier/automations/types/automation_ad_hoc_invoke_params.rb b/lib/courier/automations/types/automation_ad_hoc_invoke_params.rb similarity index 100% rename from lib/trycourier/automations/types/automation_ad_hoc_invoke_params.rb rename to lib/courier/automations/types/automation_ad_hoc_invoke_params.rb diff --git a/lib/courier/automations/types/automation_add_to_batch_max_items_type.rb b/lib/courier/automations/types/automation_add_to_batch_max_items_type.rb new file mode 100644 index 0000000..b0b3308 --- /dev/null +++ b/lib/courier/automations/types/automation_add_to_batch_max_items_type.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require "json" + +module Courier + class Automations + class AutomationAddToBatchMaxItemsType + # Deserialize a JSON object to an instance of AutomationAddToBatchMaxItemsType + # + # @param json_object [JSON] + # @return [Automations::AutomationAddToBatchMaxItemsType] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") + return json_object + rescue StandardError + # noop + end + begin + struct.is_a?(Integer) != false || raise("Passed value for field struct is not the expected type, validation failed.") + return json_object + rescue StandardError + # noop + end + struct + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Integer) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end + end +end diff --git a/lib/courier/automations/types/automation_add_to_batch_retain.rb b/lib/courier/automations/types/automation_add_to_batch_retain.rb new file mode 100644 index 0000000..62bf621 --- /dev/null +++ b/lib/courier/automations/types/automation_add_to_batch_retain.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require_relative "automation_add_to_batch_retain_type" +require "json" + +module Courier + class Automations + # Defines what items should be retained and passed along to the next steps when the batch is released + class AutomationAddToBatchRetain + attr_reader :type, :count, :sort_key, :additional_properties + + # @param type [Automations::AutomationAddToBatchRetainType] Keep N number of notifications based on the type. First/Last N based on notification received. + # highest/lowest based on a scoring key providing in the data accessed by sort_key + # @param count [Integer] The number of records to keep in batch. Default is 10 and only configurable by requesting from support. + # When configurable minimum is 2 and maximum is 100. + # @param sort_key [String] Defines the data value data[sort_key] that is used to sort the stored items. Required when type is set to highest or lowest. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Automations::AutomationAddToBatchRetain] + def initialize(type:, count:, sort_key: nil, additional_properties: nil) + # @type [Automations::AutomationAddToBatchRetainType] Keep N number of notifications based on the type. First/Last N based on notification received. + # highest/lowest based on a scoring key providing in the data accessed by sort_key + @type = type + # @type [Integer] The number of records to keep in batch. Default is 10 and only configurable by requesting from support. + # When configurable minimum is 2 and maximum is 100. + @count = count + # @type [String] Defines the data value data[sort_key] that is used to sort the stored items. Required when type is set to highest or lowest. + @sort_key = sort_key + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of AutomationAddToBatchRetain + # + # @param json_object [JSON] + # @return [Automations::AutomationAddToBatchRetain] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + JSON.parse(json_object) + type = struct.type + count = struct.count + sort_key = struct.sort_key + new(type: type, count: count, sort_key: sort_key, additional_properties: struct) + end + + # Serialize an instance of AutomationAddToBatchRetain to a JSON object + # + # @return [JSON] + def to_json(*_args) + { "type": @type, "count": @count, "sort_key": @sort_key }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.type.is_a?(Automations::AutomationAddToBatchRetainType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.count.is_a?(Integer) != false || raise("Passed value for field obj.count is not the expected type, validation failed.") + obj.sort_key&.is_a?(String) != false || raise("Passed value for field obj.sort_key is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/courier/automations/types/automation_add_to_batch_retain_type.rb b/lib/courier/automations/types/automation_add_to_batch_retain_type.rb new file mode 100644 index 0000000..2d1fd51 --- /dev/null +++ b/lib/courier/automations/types/automation_add_to_batch_retain_type.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Courier + class Automations + class AutomationAddToBatchRetainType + FIRST = "first" + LAST = "last" + HIGHEST = "highest" + LOWEST = "lowest" + end + end +end diff --git a/lib/courier/automations/types/automation_add_to_batch_scope.rb b/lib/courier/automations/types/automation_add_to_batch_scope.rb new file mode 100644 index 0000000..8163ec0 --- /dev/null +++ b/lib/courier/automations/types/automation_add_to_batch_scope.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Courier + class Automations + class AutomationAddToBatchScope + USER = "user" + GLOBAL = "global" + DYNAMIC = "dynamic" + end + end +end diff --git a/lib/courier/automations/types/automation_add_to_batch_step.rb b/lib/courier/automations/types/automation_add_to_batch_step.rb new file mode 100644 index 0000000..aed2d89 --- /dev/null +++ b/lib/courier/automations/types/automation_add_to_batch_step.rb @@ -0,0 +1,127 @@ +# frozen_string_literal: true + +require_relative "automation_add_to_batch_max_items_type" +require_relative "automation_add_to_batch_retain" +require_relative "automation_add_to_batch_scope" +require "json" + +module Courier + class Automations + class AutomationAddToBatchStep + attr_reader :action, :wait_period, :max_wait_period, :max_items, :retain, :scope, :batch_key, :batch_id, + :category_key, :if_, :ref, :additional_properties + + # @param action [String] + # @param wait_period [String] Defines the period of inactivity before the batch is released. Specified as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) + # @param max_wait_period [String] Defines the maximum wait time before the batch should be released. Must be less than wait period. Maximum of 60 days. Specified as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) + # @param max_items [Automations::AutomationAddToBatchMaxItemsType] If specified, the batch will release as soon as this number is reached + # @param retain [Automations::AutomationAddToBatchRetain] + # @param scope [Automations::AutomationAddToBatchScope] Determine the scope of the batching. If user, chosen in this order: recipient, profile.user_id, data.user_id, data.userId. + # If dynamic, then specify where the batch_key or a reference to the batch_key + # @param batch_key [String] If using scope=dynamic, provide the key or a reference (e.g., refs.data.batch_key) + # @param batch_id [String] + # @param category_key [String] Defines the field of the data object the batch is set to when complete. Defaults to `batch` + # @param if_ [String] + # @param ref [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Automations::AutomationAddToBatchStep] + def initialize(action:, wait_period:, max_wait_period:, retain:, max_items: nil, scope: nil, batch_key: nil, + batch_id: nil, category_key: nil, if_: nil, ref: nil, additional_properties: nil) + # @type [String] + @action = action + # @type [String] Defines the period of inactivity before the batch is released. Specified as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) + @wait_period = wait_period + # @type [String] Defines the maximum wait time before the batch should be released. Must be less than wait period. Maximum of 60 days. Specified as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) + @max_wait_period = max_wait_period + # @type [Automations::AutomationAddToBatchMaxItemsType] If specified, the batch will release as soon as this number is reached + @max_items = max_items + # @type [Automations::AutomationAddToBatchRetain] + @retain = retain + # @type [Automations::AutomationAddToBatchScope] Determine the scope of the batching. If user, chosen in this order: recipient, profile.user_id, data.user_id, data.userId. + # If dynamic, then specify where the batch_key or a reference to the batch_key + @scope = scope + # @type [String] If using scope=dynamic, provide the key or a reference (e.g., refs.data.batch_key) + @batch_key = batch_key + # @type [String] + @batch_id = batch_id + # @type [String] Defines the field of the data object the batch is set to when complete. Defaults to `batch` + @category_key = category_key + # @type [String] + @if_ = if_ + # @type [String] + @ref = ref + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of AutomationAddToBatchStep + # + # @param json_object [JSON] + # @return [Automations::AutomationAddToBatchStep] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + action = struct.action + wait_period = struct.wait_period + max_wait_period = struct.max_wait_period + if parsed_json["max_items"].nil? + max_items = nil + else + max_items = parsed_json["max_items"].to_json + max_items = Automations::AutomationAddToBatchMaxItemsType.from_json(json_object: max_items) + end + if parsed_json["retain"].nil? + retain = nil + else + retain = parsed_json["retain"].to_json + retain = Automations::AutomationAddToBatchRetain.from_json(json_object: retain) + end + scope = struct.scope + batch_key = struct.batch_key + batch_id = struct.batch_id + category_key = struct.category_key + if_ = struct.if + ref = struct.ref + new(action: action, wait_period: wait_period, max_wait_period: max_wait_period, max_items: max_items, + retain: retain, scope: scope, batch_key: batch_key, batch_id: batch_id, category_key: category_key, if_: if_, ref: ref, additional_properties: struct) + end + + # Serialize an instance of AutomationAddToBatchStep to a JSON object + # + # @return [JSON] + def to_json(*_args) + { + "action": @action, + "wait_period": @wait_period, + "max_wait_period": @max_wait_period, + "max_items": @max_items, + "retain": @retain, + "scope": @scope, + "batch_key": @batch_key, + "batch_id": @batch_id, + "category_key": @category_key, + "if": @if_, + "ref": @ref + }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.action.is_a?(String) != false || raise("Passed value for field obj.action is not the expected type, validation failed.") + obj.wait_period.is_a?(String) != false || raise("Passed value for field obj.wait_period is not the expected type, validation failed.") + obj.max_wait_period.is_a?(String) != false || raise("Passed value for field obj.max_wait_period is not the expected type, validation failed.") + obj.max_items.nil? || Automations::AutomationAddToBatchMaxItemsType.validate_raw(obj: obj.max_items) + Automations::AutomationAddToBatchRetain.validate_raw(obj: obj.retain) + obj.scope&.is_a?(Automations::AutomationAddToBatchScope) != false || raise("Passed value for field obj.scope is not the expected type, validation failed.") + obj.batch_key&.is_a?(String) != false || raise("Passed value for field obj.batch_key is not the expected type, validation failed.") + obj.batch_id&.is_a?(String) != false || raise("Passed value for field obj.batch_id is not the expected type, validation failed.") + obj.category_key&.is_a?(String) != false || raise("Passed value for field obj.category_key is not the expected type, validation failed.") + obj.if_&.is_a?(String) != false || raise("Passed value for field obj.if_ is not the expected type, validation failed.") + obj.ref&.is_a?(String) != false || raise("Passed value for field obj.ref is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/courier/automations/types/automation_add_to_digest_step.rb b/lib/courier/automations/types/automation_add_to_digest_step.rb new file mode 100644 index 0000000..551b7d0 --- /dev/null +++ b/lib/courier/automations/types/automation_add_to_digest_step.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require "json" + +module Courier + class Automations + class AutomationAddToDigestStep + attr_reader :action, :subscription_topic_id, :if_, :ref, :additional_properties + + # @param action [String] + # @param subscription_topic_id [String] The subscription topic that has digests enabled + # @param if_ [String] + # @param ref [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Automations::AutomationAddToDigestStep] + def initialize(action:, subscription_topic_id:, if_: nil, ref: nil, additional_properties: nil) + # @type [String] + @action = action + # @type [String] The subscription topic that has digests enabled + @subscription_topic_id = subscription_topic_id + # @type [String] + @if_ = if_ + # @type [String] + @ref = ref + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of AutomationAddToDigestStep + # + # @param json_object [JSON] + # @return [Automations::AutomationAddToDigestStep] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + JSON.parse(json_object) + action = struct.action + subscription_topic_id = struct.subscription_topic_id + if_ = struct.if + ref = struct.ref + new(action: action, subscription_topic_id: subscription_topic_id, if_: if_, ref: ref, + additional_properties: struct) + end + + # Serialize an instance of AutomationAddToDigestStep to a JSON object + # + # @return [JSON] + def to_json(*_args) + { "action": @action, "subscription_topic_id": @subscription_topic_id, "if": @if_, "ref": @ref }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.action.is_a?(String) != false || raise("Passed value for field obj.action is not the expected type, validation failed.") + obj.subscription_topic_id.is_a?(String) != false || raise("Passed value for field obj.subscription_topic_id is not the expected type, validation failed.") + obj.if_&.is_a?(String) != false || raise("Passed value for field obj.if_ is not the expected type, validation failed.") + obj.ref&.is_a?(String) != false || raise("Passed value for field obj.ref is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/trycourier/automations/types/automation_cancel_step.rb b/lib/courier/automations/types/automation_cancel_step.rb similarity index 100% rename from lib/trycourier/automations/types/automation_cancel_step.rb rename to lib/courier/automations/types/automation_cancel_step.rb diff --git a/lib/trycourier/automations/types/automation_delay_step.rb b/lib/courier/automations/types/automation_delay_step.rb similarity index 66% rename from lib/trycourier/automations/types/automation_delay_step.rb rename to lib/courier/automations/types/automation_delay_step.rb index 7679378..d83ceb2 100644 --- a/lib/trycourier/automations/types/automation_delay_step.rb +++ b/lib/courier/automations/types/automation_delay_step.rb @@ -5,18 +5,21 @@ module Courier class Automations class AutomationDelayStep - attr_reader :action, :until_, :if_, :ref, :additional_properties + attr_reader :action, :duration, :until_, :if_, :ref, :additional_properties # @param action [String] - # @param until_ [String] + # @param duration [String] The [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) string for how long to delay for + # @param until_ [String] The ISO 8601 timestamp for when the delay should end # @param if_ [String] # @param ref [String] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Automations::AutomationDelayStep] - def initialize(action:, until_: nil, if_: nil, ref: nil, additional_properties: nil) + def initialize(action:, duration: nil, until_: nil, if_: nil, ref: nil, additional_properties: nil) # @type [String] @action = action - # @type [String] + # @type [String] The [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) string for how long to delay for + @duration = duration + # @type [String] The ISO 8601 timestamp for when the delay should end @until_ = until_ # @type [String] @if_ = if_ @@ -34,17 +37,18 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) JSON.parse(json_object) action = struct.action + duration = struct.duration until_ = struct.until if_ = struct.if ref = struct.ref - new(action: action, until_: until_, if_: if_, ref: ref, additional_properties: struct) + new(action: action, duration: duration, until_: until_, if_: if_, ref: ref, additional_properties: struct) end # Serialize an instance of AutomationDelayStep to a JSON object # # @return [JSON] def to_json(*_args) - { "action": @action, "until": @until_, "if": @if_, "ref": @ref }.to_json + { "action": @action, "duration": @duration, "until": @until_, "if": @if_, "ref": @ref }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -53,6 +57,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.action.is_a?(String) != false || raise("Passed value for field obj.action is not the expected type, validation failed.") + obj.duration&.is_a?(String) != false || raise("Passed value for field obj.duration is not the expected type, validation failed.") obj.until_&.is_a?(String) != false || raise("Passed value for field obj.until_ is not the expected type, validation failed.") obj.if_&.is_a?(String) != false || raise("Passed value for field obj.if_ is not the expected type, validation failed.") obj.ref&.is_a?(String) != false || raise("Passed value for field obj.ref is not the expected type, validation failed.") diff --git a/lib/courier/automations/types/automation_fetch_data_step.rb b/lib/courier/automations/types/automation_fetch_data_step.rb new file mode 100644 index 0000000..4a40680 --- /dev/null +++ b/lib/courier/automations/types/automation_fetch_data_step.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: true + +require_relative "automation_fetch_data_webhook" +require_relative "merge_algorithm" +require "json" + +module Courier + class Automations + class AutomationFetchDataStep + attr_reader :action, :webhook, :merge_strategy, :idempotency_expiry, :idempotency_key, :if_, :ref, + :additional_properties + + # @param action [String] + # @param webhook [Automations::AutomationFetchDataWebhook] + # @param merge_strategy [Automations::MergeAlgorithm] + # @param idempotency_expiry [String] + # @param idempotency_key [String] + # @param if_ [String] + # @param ref [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Automations::AutomationFetchDataStep] + def initialize(action:, webhook:, merge_strategy:, idempotency_expiry: nil, idempotency_key: nil, if_: nil, + ref: nil, additional_properties: nil) + # @type [String] + @action = action + # @type [Automations::AutomationFetchDataWebhook] + @webhook = webhook + # @type [Automations::MergeAlgorithm] + @merge_strategy = merge_strategy + # @type [String] + @idempotency_expiry = idempotency_expiry + # @type [String] + @idempotency_key = idempotency_key + # @type [String] + @if_ = if_ + # @type [String] + @ref = ref + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of AutomationFetchDataStep + # + # @param json_object [JSON] + # @return [Automations::AutomationFetchDataStep] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + action = struct.action + if parsed_json["webhook"].nil? + webhook = nil + else + webhook = parsed_json["webhook"].to_json + webhook = Automations::AutomationFetchDataWebhook.from_json(json_object: webhook) + end + merge_strategy = struct.merge_strategy + idempotency_expiry = struct.idempotency_expiry + idempotency_key = struct.idempotency_key + if_ = struct.if + ref = struct.ref + new(action: action, webhook: webhook, merge_strategy: merge_strategy, idempotency_expiry: idempotency_expiry, + idempotency_key: idempotency_key, if_: if_, ref: ref, additional_properties: struct) + end + + # Serialize an instance of AutomationFetchDataStep to a JSON object + # + # @return [JSON] + def to_json(*_args) + { + "action": @action, + "webhook": @webhook, + "merge_strategy": @merge_strategy, + "idempotency_expiry": @idempotency_expiry, + "idempotency_key": @idempotency_key, + "if": @if_, + "ref": @ref + }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.action.is_a?(String) != false || raise("Passed value for field obj.action is not the expected type, validation failed.") + Automations::AutomationFetchDataWebhook.validate_raw(obj: obj.webhook) + obj.merge_strategy.is_a?(Automations::MergeAlgorithm) != false || raise("Passed value for field obj.merge_strategy is not the expected type, validation failed.") + obj.idempotency_expiry&.is_a?(String) != false || raise("Passed value for field obj.idempotency_expiry is not the expected type, validation failed.") + obj.idempotency_key&.is_a?(String) != false || raise("Passed value for field obj.idempotency_key is not the expected type, validation failed.") + obj.if_&.is_a?(String) != false || raise("Passed value for field obj.if_ is not the expected type, validation failed.") + obj.ref&.is_a?(String) != false || raise("Passed value for field obj.ref is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/courier/automations/types/automation_fetch_data_webhook.rb b/lib/courier/automations/types/automation_fetch_data_webhook.rb new file mode 100644 index 0000000..111dba7 --- /dev/null +++ b/lib/courier/automations/types/automation_fetch_data_webhook.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true + +require_relative "automation_fetch_data_webhook_method" +require "json" + +module Courier + class Automations + class AutomationFetchDataWebhook + attr_reader :body, :headers, :params, :method, :url, :additional_properties + + # @param body [Hash{String => String}] + # @param headers [Hash{String => String}] + # @param params [Hash{String => String}] + # @param method [Automations::AutomationFetchDataWebhookMethod] + # @param url [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Automations::AutomationFetchDataWebhook] + def initialize(method:, url:, body: nil, headers: nil, params: nil, additional_properties: nil) + # @type [Hash{String => String}] + @body = body + # @type [Hash{String => String}] + @headers = headers + # @type [Hash{String => String}] + @params = params + # @type [Automations::AutomationFetchDataWebhookMethod] + @method = method + # @type [String] + @url = url + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of AutomationFetchDataWebhook + # + # @param json_object [JSON] + # @return [Automations::AutomationFetchDataWebhook] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + JSON.parse(json_object) + body = struct.body + headers = struct.headers + params = struct.params + method = struct.method + url = struct.url + new(body: body, headers: headers, params: params, method: method, url: url, additional_properties: struct) + end + + # Serialize an instance of AutomationFetchDataWebhook to a JSON object + # + # @return [JSON] + def to_json(*_args) + { "body": @body, "headers": @headers, "params": @params, "method": @method, "url": @url }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.body&.is_a?(Hash) != false || raise("Passed value for field obj.body is not the expected type, validation failed.") + obj.headers&.is_a?(Hash) != false || raise("Passed value for field obj.headers is not the expected type, validation failed.") + obj.params&.is_a?(Hash) != false || raise("Passed value for field obj.params is not the expected type, validation failed.") + obj.method.is_a?(Automations::AutomationFetchDataWebhookMethod) != false || raise("Passed value for field obj.method is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/courier/automations/types/automation_fetch_data_webhook_method.rb b/lib/courier/automations/types/automation_fetch_data_webhook_method.rb new file mode 100644 index 0000000..30808c2 --- /dev/null +++ b/lib/courier/automations/types/automation_fetch_data_webhook_method.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Courier + class Automations + class AutomationFetchDataWebhookMethod + GET = "GET" + POST = "POST" + end + end +end diff --git a/lib/trycourier/automations/types/automation_invoke_params.rb b/lib/courier/automations/types/automation_invoke_params.rb similarity index 100% rename from lib/trycourier/automations/types/automation_invoke_params.rb rename to lib/courier/automations/types/automation_invoke_params.rb diff --git a/lib/trycourier/automations/types/automation_invoke_response.rb b/lib/courier/automations/types/automation_invoke_response.rb similarity index 100% rename from lib/trycourier/automations/types/automation_invoke_response.rb rename to lib/courier/automations/types/automation_invoke_response.rb diff --git a/lib/trycourier/automations/types/automation_invoke_step.rb b/lib/courier/automations/types/automation_invoke_step.rb similarity index 100% rename from lib/trycourier/automations/types/automation_invoke_step.rb rename to lib/courier/automations/types/automation_invoke_step.rb diff --git a/lib/trycourier/automations/types/automation_invoke_template_params.rb b/lib/courier/automations/types/automation_invoke_template_params.rb similarity index 100% rename from lib/trycourier/automations/types/automation_invoke_template_params.rb rename to lib/courier/automations/types/automation_invoke_template_params.rb diff --git a/lib/trycourier/automations/types/automation_run_context.rb b/lib/courier/automations/types/automation_run_context.rb similarity index 100% rename from lib/trycourier/automations/types/automation_run_context.rb rename to lib/courier/automations/types/automation_run_context.rb diff --git a/lib/trycourier/automations/types/automation_send_list_step.rb b/lib/courier/automations/types/automation_send_list_step.rb similarity index 100% rename from lib/trycourier/automations/types/automation_send_list_step.rb rename to lib/courier/automations/types/automation_send_list_step.rb diff --git a/lib/trycourier/automations/types/automation_send_step.rb b/lib/courier/automations/types/automation_send_step.rb similarity index 100% rename from lib/trycourier/automations/types/automation_send_step.rb rename to lib/courier/automations/types/automation_send_step.rb diff --git a/lib/trycourier/automations/types/automation_step.rb b/lib/courier/automations/types/automation_step.rb similarity index 100% rename from lib/trycourier/automations/types/automation_step.rb rename to lib/courier/automations/types/automation_step.rb diff --git a/lib/trycourier/automations/types/automation_step_option.rb b/lib/courier/automations/types/automation_step_option.rb similarity index 68% rename from lib/trycourier/automations/types/automation_step_option.rb rename to lib/courier/automations/types/automation_step_option.rb index 6651bbe..e01fd01 100644 --- a/lib/trycourier/automations/types/automation_step_option.rb +++ b/lib/courier/automations/types/automation_step_option.rb @@ -1,8 +1,12 @@ # frozen_string_literal: true require "json" +require_relative "automation_add_to_digest_step" +require_relative "automation_add_to_batch_step" +require_relative "automation_throttle_step" require_relative "automation_cancel_step" require_relative "automation_delay_step" +require_relative "automation_fetch_data_step" require_relative "automation_invoke_step" require_relative "automation_send_step" require_relative "automation_v_2_send_step" @@ -18,6 +22,24 @@ class AutomationStepOption # @return [Automations::AutomationStepOption] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) + begin + Automations::AutomationAddToDigestStep.validate_raw(obj: struct) + return Automations::AutomationAddToDigestStep.from_json(json_object: json_object) + rescue StandardError + # noop + end + begin + Automations::AutomationAddToBatchStep.validate_raw(obj: struct) + return Automations::AutomationAddToBatchStep.from_json(json_object: json_object) + rescue StandardError + # noop + end + begin + Automations::AutomationThrottleStep.validate_raw(obj: struct) + return Automations::AutomationThrottleStep.from_json(json_object: json_object) + rescue StandardError + # noop + end begin Automations::AutomationCancelStep.validate_raw(obj: struct) return Automations::AutomationCancelStep.from_json(json_object: json_object) @@ -30,6 +52,12 @@ def self.from_json(json_object:) rescue StandardError # noop end + begin + Automations::AutomationFetchDataStep.validate_raw(obj: struct) + return Automations::AutomationFetchDataStep.from_json(json_object: json_object) + rescue StandardError + # noop + end begin Automations::AutomationInvokeStep.validate_raw(obj: struct) return Automations::AutomationInvokeStep.from_json(json_object: json_object) @@ -68,6 +96,21 @@ def self.from_json(json_object:) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + begin + return Automations::AutomationAddToDigestStep.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Automations::AutomationAddToBatchStep.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Automations::AutomationThrottleStep.validate_raw(obj: obj) + rescue StandardError + # noop + end begin return Automations::AutomationCancelStep.validate_raw(obj: obj) rescue StandardError @@ -78,6 +121,11 @@ def self.validate_raw(obj:) rescue StandardError # noop end + begin + return Automations::AutomationFetchDataStep.validate_raw(obj: obj) + rescue StandardError + # noop + end begin return Automations::AutomationInvokeStep.validate_raw(obj: obj) rescue StandardError diff --git a/lib/courier/automations/types/automation_throttle_on_throttle.rb b/lib/courier/automations/types/automation_throttle_on_throttle.rb new file mode 100644 index 0000000..903e572 --- /dev/null +++ b/lib/courier/automations/types/automation_throttle_on_throttle.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true +require "json" + +module Courier + class Automations + class AutomationThrottleOnThrottle + attr_reader :node_id, :additional_properties + # @param node_id [String] The node to go to if the request is throttled + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Automations::AutomationThrottleOnThrottle] + def initialize(node_id:, additional_properties: nil) + # @type [String] The node to go to if the request is throttled + @node_id = node_id + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + # Deserialize a JSON object to an instance of AutomationThrottleOnThrottle + # + # @param json_object [JSON] + # @return [Automations::AutomationThrottleOnThrottle] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + node_id = struct.$node_id + new(node_id: node_id, additional_properties: struct) + end + # Serialize an instance of AutomationThrottleOnThrottle to a JSON object + # + # @return [JSON] + def to_json + { "$node_id": @node_id }.to_json + end + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.node_id.is_a?(String) != false || raise("Passed value for field obj.node_id is not the expected type, validation failed.") + end + end + end +end \ No newline at end of file diff --git a/lib/courier/automations/types/automation_throttle_scope.rb b/lib/courier/automations/types/automation_throttle_scope.rb new file mode 100644 index 0000000..4ce7b15 --- /dev/null +++ b/lib/courier/automations/types/automation_throttle_scope.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Courier + class Automations + class AutomationThrottleScope + USER = "user" + GLOBAL = "global" + DYNAMIC = "dynamic" + end + end +end diff --git a/lib/courier/automations/types/automation_throttle_step.rb b/lib/courier/automations/types/automation_throttle_step.rb new file mode 100644 index 0000000..8ef68e0 --- /dev/null +++ b/lib/courier/automations/types/automation_throttle_step.rb @@ -0,0 +1,107 @@ +# frozen_string_literal: true + +require_relative "automation_throttle_scope" +require_relative "automation_throttle_on_throttle" +require "json" + +module Courier + class Automations + class AutomationThrottleStep + attr_reader :action, :max_allowed, :period, :scope, :throttle_key, :should_alert, :on_throttle, :if_, :ref, + :additional_properties + + # @param action [String] + # @param max_allowed [Integer] Maximum number of allowed notifications in that timeframe + # @param period [String] Defines the throttle period which corresponds to the max_allowed. Specified as an ISO 8601 duration, https://en.wikipedia.org/wiki/ISO_8601#Durations + # @param scope [Automations::AutomationThrottleScope] + # @param throttle_key [String] If using scope=dynamic, provide the reference (e.g., refs.data.throttle_key) to the how the throttle should be identified + # @param should_alert [Boolean] Value must be true + # @param on_throttle [Automations::AutomationThrottleOnThrottle] + # @param if_ [String] + # @param ref [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Automations::AutomationThrottleStep] + def initialize(action:, max_allowed:, period:, scope:, should_alert:, on_throttle:, throttle_key: nil, if_: nil, + ref: nil, additional_properties: nil) + # @type [String] + @action = action + # @type [Integer] Maximum number of allowed notifications in that timeframe + @max_allowed = max_allowed + # @type [String] Defines the throttle period which corresponds to the max_allowed. Specified as an ISO 8601 duration, https://en.wikipedia.org/wiki/ISO_8601#Durations + @period = period + # @type [Automations::AutomationThrottleScope] + @scope = scope + # @type [String] If using scope=dynamic, provide the reference (e.g., refs.data.throttle_key) to the how the throttle should be identified + @throttle_key = throttle_key + # @type [Boolean] Value must be true + @should_alert = should_alert + # @type [Automations::AutomationThrottleOnThrottle] + @on_throttle = on_throttle + # @type [String] + @if_ = if_ + # @type [String] + @ref = ref + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of AutomationThrottleStep + # + # @param json_object [JSON] + # @return [Automations::AutomationThrottleStep] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + action = struct.action + max_allowed = struct.max_allowed + period = struct.period + scope = struct.scope + throttle_key = struct.throttle_key + should_alert = struct.should_alert + if parsed_json["on_throttle"].nil? + on_throttle = nil + else + on_throttle = parsed_json["on_throttle"].to_json + on_throttle = Automations::AutomationThrottleOnThrottle.from_json(json_object: on_throttle) + end + if_ = struct.if + ref = struct.ref + new(action: action, max_allowed: max_allowed, period: period, scope: scope, throttle_key: throttle_key, + should_alert: should_alert, on_throttle: on_throttle, if_: if_, ref: ref, additional_properties: struct) + end + + # Serialize an instance of AutomationThrottleStep to a JSON object + # + # @return [JSON] + def to_json(*_args) + { + "action": @action, + "max_allowed": @max_allowed, + "period": @period, + "scope": @scope, + "throttle_key": @throttle_key, + "should_alert": @should_alert, + "on_throttle": @on_throttle, + "if": @if_, + "ref": @ref + }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.action.is_a?(String) != false || raise("Passed value for field obj.action is not the expected type, validation failed.") + obj.max_allowed.is_a?(Integer) != false || raise("Passed value for field obj.max_allowed is not the expected type, validation failed.") + obj.period.is_a?(String) != false || raise("Passed value for field obj.period is not the expected type, validation failed.") + obj.scope.is_a?(Automations::AutomationThrottleScope) != false || raise("Passed value for field obj.scope is not the expected type, validation failed.") + obj.throttle_key&.is_a?(String) != false || raise("Passed value for field obj.throttle_key is not the expected type, validation failed.") + obj.should_alert.is_a?(Boolean) != false || raise("Passed value for field obj.should_alert is not the expected type, validation failed.") + Automations::AutomationThrottleOnThrottle.validate_raw(obj: obj.on_throttle) + obj.if_&.is_a?(String) != false || raise("Passed value for field obj.if_ is not the expected type, validation failed.") + obj.ref&.is_a?(String) != false || raise("Passed value for field obj.ref is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/trycourier/automations/types/automation_update_profile_step.rb b/lib/courier/automations/types/automation_update_profile_step.rb similarity index 100% rename from lib/trycourier/automations/types/automation_update_profile_step.rb rename to lib/courier/automations/types/automation_update_profile_step.rb diff --git a/lib/trycourier/automations/types/automation_v_2_send_step.rb b/lib/courier/automations/types/automation_v_2_send_step.rb similarity index 100% rename from lib/trycourier/automations/types/automation_v_2_send_step.rb rename to lib/courier/automations/types/automation_v_2_send_step.rb diff --git a/lib/trycourier/automations/types/merge_algorithm.rb b/lib/courier/automations/types/merge_algorithm.rb similarity index 100% rename from lib/trycourier/automations/types/merge_algorithm.rb rename to lib/courier/automations/types/merge_algorithm.rb diff --git a/lib/trycourier/automations/types/profile.rb b/lib/courier/automations/types/profile.rb similarity index 100% rename from lib/trycourier/automations/types/profile.rb rename to lib/courier/automations/types/profile.rb diff --git a/lib/trycourier/brands/client.rb b/lib/courier/brands/client.rb similarity index 100% rename from lib/trycourier/brands/client.rb rename to lib/courier/brands/client.rb diff --git a/lib/trycourier/brands/types/brand.rb b/lib/courier/brands/types/brand.rb similarity index 100% rename from lib/trycourier/brands/types/brand.rb rename to lib/courier/brands/types/brand.rb diff --git a/lib/trycourier/brands/types/brand_colors.rb b/lib/courier/brands/types/brand_colors.rb similarity index 100% rename from lib/trycourier/brands/types/brand_colors.rb rename to lib/courier/brands/types/brand_colors.rb diff --git a/lib/trycourier/brands/types/brand_get_all_response.rb b/lib/courier/brands/types/brand_get_all_response.rb similarity index 100% rename from lib/trycourier/brands/types/brand_get_all_response.rb rename to lib/courier/brands/types/brand_get_all_response.rb diff --git a/lib/trycourier/brands/types/brand_parameters.rb b/lib/courier/brands/types/brand_parameters.rb similarity index 100% rename from lib/trycourier/brands/types/brand_parameters.rb rename to lib/courier/brands/types/brand_parameters.rb diff --git a/lib/trycourier/brands/types/brand_settings.rb b/lib/courier/brands/types/brand_settings.rb similarity index 100% rename from lib/trycourier/brands/types/brand_settings.rb rename to lib/courier/brands/types/brand_settings.rb diff --git a/lib/trycourier/brands/types/brand_snippet.rb b/lib/courier/brands/types/brand_snippet.rb similarity index 100% rename from lib/trycourier/brands/types/brand_snippet.rb rename to lib/courier/brands/types/brand_snippet.rb diff --git a/lib/trycourier/brands/types/brand_snippets.rb b/lib/courier/brands/types/brand_snippets.rb similarity index 100% rename from lib/trycourier/brands/types/brand_snippets.rb rename to lib/courier/brands/types/brand_snippets.rb diff --git a/lib/trycourier/brands/types/brands_response.rb b/lib/courier/brands/types/brands_response.rb similarity index 100% rename from lib/trycourier/brands/types/brands_response.rb rename to lib/courier/brands/types/brands_response.rb diff --git a/lib/trycourier/bulk/client.rb b/lib/courier/bulk/client.rb similarity index 95% rename from lib/trycourier/bulk/client.rb rename to lib/courier/bulk/client.rb index d1b2a00..c854749 100644 --- a/lib/trycourier/bulk/client.rb +++ b/lib/courier/bulk/client.rb @@ -108,9 +108,10 @@ def get_job(job_id:, request_options: nil) # Get Bulk Job Users # # @param job_id [String] A unique identifier representing the bulk job + # @param cursor [String] A unique identifier that allows for fetching the next set of users added to the bulk job # @param request_options [RequestOptions] # @return [Bulk::BulkGetJobUsersResponse] - def get_users(job_id:, request_options: nil) + def get_users(job_id:, cursor: nil, request_options: nil) response = @request_client.conn.get("/bulk/#{job_id}/users") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? unless request_options&.authorization_token.nil? @@ -118,6 +119,7 @@ def get_users(job_id:, request_options: nil) request_options.authorization_token end req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "cursor": cursor }.compact end Bulk::BulkGetJobUsersResponse.from_json(json_object: response.body) end @@ -230,9 +232,10 @@ def get_job(job_id:, request_options: nil) # Get Bulk Job Users # # @param job_id [String] A unique identifier representing the bulk job + # @param cursor [String] A unique identifier that allows for fetching the next set of users added to the bulk job # @param request_options [RequestOptions] # @return [Bulk::BulkGetJobUsersResponse] - def get_users(job_id:, request_options: nil) + def get_users(job_id:, cursor: nil, request_options: nil) Async do response = @request_client.conn.get("/bulk/#{job_id}/users") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? @@ -241,6 +244,7 @@ def get_users(job_id:, request_options: nil) request_options.authorization_token end req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "cursor": cursor }.compact end Bulk::BulkGetJobUsersResponse.from_json(json_object: response.body) end diff --git a/lib/trycourier/bulk/types/bulk_create_job_response.rb b/lib/courier/bulk/types/bulk_create_job_response.rb similarity index 100% rename from lib/trycourier/bulk/types/bulk_create_job_response.rb rename to lib/courier/bulk/types/bulk_create_job_response.rb diff --git a/lib/trycourier/bulk/types/bulk_get_job_params.rb b/lib/courier/bulk/types/bulk_get_job_params.rb similarity index 100% rename from lib/trycourier/bulk/types/bulk_get_job_params.rb rename to lib/courier/bulk/types/bulk_get_job_params.rb diff --git a/lib/trycourier/bulk/types/bulk_get_job_response.rb b/lib/courier/bulk/types/bulk_get_job_response.rb similarity index 100% rename from lib/trycourier/bulk/types/bulk_get_job_response.rb rename to lib/courier/bulk/types/bulk_get_job_response.rb diff --git a/lib/trycourier/bulk/types/bulk_get_job_users_params.rb b/lib/courier/bulk/types/bulk_get_job_users_params.rb similarity index 100% rename from lib/trycourier/bulk/types/bulk_get_job_users_params.rb rename to lib/courier/bulk/types/bulk_get_job_users_params.rb diff --git a/lib/trycourier/bulk/types/bulk_get_job_users_response.rb b/lib/courier/bulk/types/bulk_get_job_users_response.rb similarity index 100% rename from lib/trycourier/bulk/types/bulk_get_job_users_response.rb rename to lib/courier/bulk/types/bulk_get_job_users_response.rb diff --git a/lib/trycourier/bulk/types/bulk_ingest_error.rb b/lib/courier/bulk/types/bulk_ingest_error.rb similarity index 100% rename from lib/trycourier/bulk/types/bulk_ingest_error.rb rename to lib/courier/bulk/types/bulk_ingest_error.rb diff --git a/lib/trycourier/bulk/types/bulk_ingest_users_params.rb b/lib/courier/bulk/types/bulk_ingest_users_params.rb similarity index 100% rename from lib/trycourier/bulk/types/bulk_ingest_users_params.rb rename to lib/courier/bulk/types/bulk_ingest_users_params.rb diff --git a/lib/trycourier/bulk/types/bulk_ingest_users_response.rb b/lib/courier/bulk/types/bulk_ingest_users_response.rb similarity index 100% rename from lib/trycourier/bulk/types/bulk_ingest_users_response.rb rename to lib/courier/bulk/types/bulk_ingest_users_response.rb diff --git a/lib/trycourier/bulk/types/bulk_job_status.rb b/lib/courier/bulk/types/bulk_job_status.rb similarity index 100% rename from lib/trycourier/bulk/types/bulk_job_status.rb rename to lib/courier/bulk/types/bulk_job_status.rb diff --git a/lib/trycourier/bulk/types/bulk_job_user_status.rb b/lib/courier/bulk/types/bulk_job_user_status.rb similarity index 100% rename from lib/trycourier/bulk/types/bulk_job_user_status.rb rename to lib/courier/bulk/types/bulk_job_user_status.rb diff --git a/lib/trycourier/bulk/types/bulk_message_user_response.rb b/lib/courier/bulk/types/bulk_message_user_response.rb similarity index 100% rename from lib/trycourier/bulk/types/bulk_message_user_response.rb rename to lib/courier/bulk/types/bulk_message_user_response.rb diff --git a/lib/trycourier/bulk/types/inbound_bulk_content_message.rb b/lib/courier/bulk/types/inbound_bulk_content_message.rb similarity index 82% rename from lib/trycourier/bulk/types/inbound_bulk_content_message.rb rename to lib/courier/bulk/types/inbound_bulk_content_message.rb index 7a07bd9..5c84a3e 100644 --- a/lib/trycourier/bulk/types/inbound_bulk_content_message.rb +++ b/lib/courier/bulk/types/inbound_bulk_content_message.rb @@ -5,6 +5,7 @@ require_relative "../../send/types/message_channels" require_relative "../../send/types/message_context" require_relative "../../send/types/message_metadata" +require_relative "../../send/types/message_preferences" require_relative "../../send/types/message_providers" require_relative "../../send/types/routing" require_relative "../../send/types/timeout" @@ -17,8 +18,8 @@ class Bulk # The message property has the following primary top-level properties. They define the destination and content of the message. # Additional advanced configuration fields [are defined below](https://www.courier.com/docs/reference/send/message/#other-message-properties). class InboundBulkContentMessage - attr_reader :content, :data, :brand_id, :channels, :context, :metadata, :providers, :routing, :timeout, :delay, - :expiry, :additional_properties + attr_reader :content, :data, :brand_id, :channels, :context, :metadata, :preferences, :providers, :routing, + :timeout, :delay, :expiry, :additional_properties # @param content [Send::Content] Describes the content of the message in a way that will work for email, push, # chat, or any channel. Either this or template must be specified. @@ -28,16 +29,17 @@ class InboundBulkContentMessage # @param channels [Send::MESSAGE_CHANNELS] "Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." # @param context [Send::MessageContext] Context to load with this recipient. Will override any context set on message.context. # @param metadata [Send::MessageMetadata] Metadata such as utm tracking attached with the notification through this channel. + # @param preferences [Send::MessagePreferences] # @param providers [Send::MESSAGE_PROVIDERS] An object whose keys are valid provider identifiers which map to an object. # @param routing [Send::Routing] # @param timeout [Send::Timeout] Time in ms to attempt the channel before failing over to the next available channel. - # @param delay [Send::Delay] Defines the time to wait before delivering the message. + # @param delay [Send::Delay] Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) (e.g., 'Mo-Fr 08:00-18:00pm') # @param expiry [Send::Expiry] "Expiry allows you to set an absolute or relative time in which a message expires. # Note: This is only valid for the Courier Inbox channel as of 12-08-2022." # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Bulk::InboundBulkContentMessage] - def initialize(content:, data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, providers: nil, - routing: nil, timeout: nil, delay: nil, expiry: nil, additional_properties: nil) + def initialize(content:, data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, preferences: nil, + providers: nil, routing: nil, timeout: nil, delay: nil, expiry: nil, additional_properties: nil) # @type [Send::Content] Describes the content of the message in a way that will work for email, push, # chat, or any channel. Either this or template must be specified. @content = content @@ -52,13 +54,15 @@ def initialize(content:, data: nil, brand_id: nil, channels: nil, context: nil, @context = context # @type [Send::MessageMetadata] Metadata such as utm tracking attached with the notification through this channel. @metadata = metadata + # @type [Send::MessagePreferences] + @preferences = preferences # @type [Send::MESSAGE_PROVIDERS] An object whose keys are valid provider identifiers which map to an object. @providers = providers # @type [Send::Routing] @routing = routing # @type [Send::Timeout] Time in ms to attempt the channel before failing over to the next available channel. @timeout = timeout - # @type [Send::Delay] Defines the time to wait before delivering the message. + # @type [Send::Delay] Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) (e.g., 'Mo-Fr 08:00-18:00pm') @delay = delay # @type [Send::Expiry] "Expiry allows you to set an absolute or relative time in which a message expires. # Note: This is only valid for the Courier Inbox channel as of 12-08-2022." @@ -95,6 +99,12 @@ def self.from_json(json_object:) metadata = parsed_json["metadata"].to_json metadata = Send::MessageMetadata.from_json(json_object: metadata) end + if parsed_json["preferences"].nil? + preferences = nil + else + preferences = parsed_json["preferences"].to_json + preferences = Send::MessagePreferences.from_json(json_object: preferences) + end providers = struct.providers if parsed_json["routing"].nil? routing = nil @@ -121,7 +131,7 @@ def self.from_json(json_object:) expiry = Send::Expiry.from_json(json_object: expiry) end new(content: content, data: data, brand_id: brand_id, channels: channels, context: context, metadata: metadata, - providers: providers, routing: routing, timeout: timeout, delay: delay, expiry: expiry, additional_properties: struct) + preferences: preferences, providers: providers, routing: routing, timeout: timeout, delay: delay, expiry: expiry, additional_properties: struct) end # Serialize an instance of InboundBulkContentMessage to a JSON object @@ -135,6 +145,7 @@ def to_json(*_args) "channels": @channels, "context": @context, "metadata": @metadata, + "preferences": @preferences, "providers": @providers, "routing": @routing, "timeout": @timeout, @@ -154,6 +165,7 @@ def self.validate_raw(obj:) obj.channels&.is_a?(Hash) != false || raise("Passed value for field obj.channels is not the expected type, validation failed.") obj.context.nil? || Send::MessageContext.validate_raw(obj: obj.context) obj.metadata.nil? || Send::MessageMetadata.validate_raw(obj: obj.metadata) + obj.preferences.nil? || Send::MessagePreferences.validate_raw(obj: obj.preferences) obj.providers&.is_a?(Hash) != false || raise("Passed value for field obj.providers is not the expected type, validation failed.") obj.routing.nil? || Send::Routing.validate_raw(obj: obj.routing) obj.timeout.nil? || Send::Timeout.validate_raw(obj: obj.timeout) diff --git a/lib/trycourier/bulk/types/inbound_bulk_message.rb b/lib/courier/bulk/types/inbound_bulk_message.rb similarity index 100% rename from lib/trycourier/bulk/types/inbound_bulk_message.rb rename to lib/courier/bulk/types/inbound_bulk_message.rb diff --git a/lib/trycourier/bulk/types/inbound_bulk_message_user.rb b/lib/courier/bulk/types/inbound_bulk_message_user.rb similarity index 100% rename from lib/trycourier/bulk/types/inbound_bulk_message_user.rb rename to lib/courier/bulk/types/inbound_bulk_message_user.rb diff --git a/lib/trycourier/bulk/types/inbound_bulk_message_v_1.rb b/lib/courier/bulk/types/inbound_bulk_message_v_1.rb similarity index 100% rename from lib/trycourier/bulk/types/inbound_bulk_message_v_1.rb rename to lib/courier/bulk/types/inbound_bulk_message_v_1.rb diff --git a/lib/trycourier/bulk/types/inbound_bulk_message_v_2.rb b/lib/courier/bulk/types/inbound_bulk_message_v_2.rb similarity index 100% rename from lib/trycourier/bulk/types/inbound_bulk_message_v_2.rb rename to lib/courier/bulk/types/inbound_bulk_message_v_2.rb diff --git a/lib/trycourier/bulk/types/inbound_bulk_template_message.rb b/lib/courier/bulk/types/inbound_bulk_template_message.rb similarity index 81% rename from lib/trycourier/bulk/types/inbound_bulk_template_message.rb rename to lib/courier/bulk/types/inbound_bulk_template_message.rb index 734470e..911cb57 100644 --- a/lib/trycourier/bulk/types/inbound_bulk_template_message.rb +++ b/lib/courier/bulk/types/inbound_bulk_template_message.rb @@ -4,6 +4,7 @@ require_relative "../../send/types/message_channels" require_relative "../../send/types/message_context" require_relative "../../send/types/message_metadata" +require_relative "../../send/types/message_preferences" require_relative "../../send/types/message_providers" require_relative "../../send/types/routing" require_relative "../../send/types/timeout" @@ -14,8 +15,8 @@ module Courier class Bulk class InboundBulkTemplateMessage - attr_reader :template, :data, :brand_id, :channels, :context, :metadata, :providers, :routing, :timeout, :delay, - :expiry, :additional_properties + attr_reader :template, :data, :brand_id, :channels, :context, :metadata, :preferences, :providers, :routing, + :timeout, :delay, :expiry, :additional_properties # @param template [String] The id of the notification template to be rendered and sent to the recipient(s). # This field or the content field must be supplied. @@ -25,16 +26,17 @@ class InboundBulkTemplateMessage # @param channels [Send::MESSAGE_CHANNELS] "Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." # @param context [Send::MessageContext] Context to load with this recipient. Will override any context set on message.context. # @param metadata [Send::MessageMetadata] Metadata such as utm tracking attached with the notification through this channel. + # @param preferences [Send::MessagePreferences] # @param providers [Send::MESSAGE_PROVIDERS] An object whose keys are valid provider identifiers which map to an object. # @param routing [Send::Routing] # @param timeout [Send::Timeout] Time in ms to attempt the channel before failing over to the next available channel. - # @param delay [Send::Delay] Defines the time to wait before delivering the message. + # @param delay [Send::Delay] Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) (e.g., 'Mo-Fr 08:00-18:00pm') # @param expiry [Send::Expiry] "Expiry allows you to set an absolute or relative time in which a message expires. # Note: This is only valid for the Courier Inbox channel as of 12-08-2022." # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Bulk::InboundBulkTemplateMessage] - def initialize(template:, data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, providers: nil, - routing: nil, timeout: nil, delay: nil, expiry: nil, additional_properties: nil) + def initialize(template:, data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, preferences: nil, + providers: nil, routing: nil, timeout: nil, delay: nil, expiry: nil, additional_properties: nil) # @type [String] The id of the notification template to be rendered and sent to the recipient(s). # This field or the content field must be supplied. @template = template @@ -49,13 +51,15 @@ def initialize(template:, data: nil, brand_id: nil, channels: nil, context: nil, @context = context # @type [Send::MessageMetadata] Metadata such as utm tracking attached with the notification through this channel. @metadata = metadata + # @type [Send::MessagePreferences] + @preferences = preferences # @type [Send::MESSAGE_PROVIDERS] An object whose keys are valid provider identifiers which map to an object. @providers = providers # @type [Send::Routing] @routing = routing # @type [Send::Timeout] Time in ms to attempt the channel before failing over to the next available channel. @timeout = timeout - # @type [Send::Delay] Defines the time to wait before delivering the message. + # @type [Send::Delay] Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) (e.g., 'Mo-Fr 08:00-18:00pm') @delay = delay # @type [Send::Expiry] "Expiry allows you to set an absolute or relative time in which a message expires. # Note: This is only valid for the Courier Inbox channel as of 12-08-2022." @@ -87,6 +91,12 @@ def self.from_json(json_object:) metadata = parsed_json["metadata"].to_json metadata = Send::MessageMetadata.from_json(json_object: metadata) end + if parsed_json["preferences"].nil? + preferences = nil + else + preferences = parsed_json["preferences"].to_json + preferences = Send::MessagePreferences.from_json(json_object: preferences) + end providers = struct.providers if parsed_json["routing"].nil? routing = nil @@ -113,7 +123,7 @@ def self.from_json(json_object:) expiry = Send::Expiry.from_json(json_object: expiry) end new(template: template, data: data, brand_id: brand_id, channels: channels, context: context, - metadata: metadata, providers: providers, routing: routing, timeout: timeout, delay: delay, expiry: expiry, additional_properties: struct) + metadata: metadata, preferences: preferences, providers: providers, routing: routing, timeout: timeout, delay: delay, expiry: expiry, additional_properties: struct) end # Serialize an instance of InboundBulkTemplateMessage to a JSON object @@ -127,6 +137,7 @@ def to_json(*_args) "channels": @channels, "context": @context, "metadata": @metadata, + "preferences": @preferences, "providers": @providers, "routing": @routing, "timeout": @timeout, @@ -146,6 +157,7 @@ def self.validate_raw(obj:) obj.channels&.is_a?(Hash) != false || raise("Passed value for field obj.channels is not the expected type, validation failed.") obj.context.nil? || Send::MessageContext.validate_raw(obj: obj.context) obj.metadata.nil? || Send::MessageMetadata.validate_raw(obj: obj.metadata) + obj.preferences.nil? || Send::MessagePreferences.validate_raw(obj: obj.preferences) obj.providers&.is_a?(Hash) != false || raise("Passed value for field obj.providers is not the expected type, validation failed.") obj.routing.nil? || Send::Routing.validate_raw(obj: obj.routing) obj.timeout.nil? || Send::Timeout.validate_raw(obj: obj.timeout) diff --git a/lib/trycourier/bulk/types/job_details.rb b/lib/courier/bulk/types/job_details.rb similarity index 100% rename from lib/trycourier/bulk/types/job_details.rb rename to lib/courier/bulk/types/job_details.rb diff --git a/lib/trycourier/commons/types/already_exists.rb b/lib/courier/commons/types/already_exists.rb similarity index 100% rename from lib/trycourier/commons/types/already_exists.rb rename to lib/courier/commons/types/already_exists.rb diff --git a/lib/trycourier/commons/types/bad_request.rb b/lib/courier/commons/types/bad_request.rb similarity index 100% rename from lib/trycourier/commons/types/bad_request.rb rename to lib/courier/commons/types/bad_request.rb diff --git a/lib/trycourier/commons/types/base_error.rb b/lib/courier/commons/types/base_error.rb similarity index 100% rename from lib/trycourier/commons/types/base_error.rb rename to lib/courier/commons/types/base_error.rb diff --git a/lib/trycourier/commons/types/channel_classification.rb b/lib/courier/commons/types/channel_classification.rb similarity index 100% rename from lib/trycourier/commons/types/channel_classification.rb rename to lib/courier/commons/types/channel_classification.rb diff --git a/lib/trycourier/commons/types/channel_preference.rb b/lib/courier/commons/types/channel_preference.rb similarity index 100% rename from lib/trycourier/commons/types/channel_preference.rb rename to lib/courier/commons/types/channel_preference.rb diff --git a/lib/trycourier/commons/types/conflict.rb b/lib/courier/commons/types/conflict.rb similarity index 100% rename from lib/trycourier/commons/types/conflict.rb rename to lib/courier/commons/types/conflict.rb diff --git a/lib/trycourier/commons/types/email.rb b/lib/courier/commons/types/email.rb similarity index 100% rename from lib/trycourier/commons/types/email.rb rename to lib/courier/commons/types/email.rb diff --git a/lib/trycourier/commons/types/message_not_found.rb b/lib/courier/commons/types/message_not_found.rb similarity index 100% rename from lib/trycourier/commons/types/message_not_found.rb rename to lib/courier/commons/types/message_not_found.rb diff --git a/lib/trycourier/commons/types/not_found.rb b/lib/courier/commons/types/not_found.rb similarity index 100% rename from lib/trycourier/commons/types/not_found.rb rename to lib/courier/commons/types/not_found.rb diff --git a/lib/trycourier/commons/types/notification_preference_details.rb b/lib/courier/commons/types/notification_preference_details.rb similarity index 100% rename from lib/trycourier/commons/types/notification_preference_details.rb rename to lib/courier/commons/types/notification_preference_details.rb diff --git a/lib/trycourier/commons/types/notification_preferences.rb b/lib/courier/commons/types/notification_preferences.rb similarity index 100% rename from lib/trycourier/commons/types/notification_preferences.rb rename to lib/courier/commons/types/notification_preferences.rb diff --git a/lib/trycourier/commons/types/paging.rb b/lib/courier/commons/types/paging.rb similarity index 100% rename from lib/trycourier/commons/types/paging.rb rename to lib/courier/commons/types/paging.rb diff --git a/lib/trycourier/commons/types/payment_required.rb b/lib/courier/commons/types/payment_required.rb similarity index 100% rename from lib/trycourier/commons/types/payment_required.rb rename to lib/courier/commons/types/payment_required.rb diff --git a/lib/trycourier/commons/types/preference_status.rb b/lib/courier/commons/types/preference_status.rb similarity index 100% rename from lib/trycourier/commons/types/preference_status.rb rename to lib/courier/commons/types/preference_status.rb diff --git a/lib/trycourier/commons/types/recipient_preferences.rb b/lib/courier/commons/types/recipient_preferences.rb similarity index 100% rename from lib/trycourier/commons/types/recipient_preferences.rb rename to lib/courier/commons/types/recipient_preferences.rb diff --git a/lib/trycourier/commons/types/rule.rb b/lib/courier/commons/types/rule.rb similarity index 100% rename from lib/trycourier/commons/types/rule.rb rename to lib/courier/commons/types/rule.rb diff --git a/lib/trycourier/commons/types/user_tenant_association.rb b/lib/courier/commons/types/user_tenant_association.rb similarity index 74% rename from lib/trycourier/commons/types/user_tenant_association.rb rename to lib/courier/commons/types/user_tenant_association.rb index a7d564c..ae22041 100644 --- a/lib/trycourier/commons/types/user_tenant_association.rb +++ b/lib/courier/commons/types/user_tenant_association.rb @@ -10,17 +10,17 @@ class UserTenantAssociation # @param user_id [String] User ID for the assocation between tenant and user # @param type [String] # @param tenant_id [String] Tenant ID for the assocation between tenant and user - # @param profile [Hash{String => String}] + # @param profile [Hash{String => String}] Additional metadata to be applied to a user profile when used in a tenant context # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Commons::UserTenantAssociation] - def initialize(user_id:, type:, tenant_id:, profile:, additional_properties: nil) + def initialize(tenant_id:, user_id: nil, type: nil, profile: nil, additional_properties: nil) # @type [String] User ID for the assocation between tenant and user @user_id = user_id # @type [String] @type = type # @type [String] Tenant ID for the assocation between tenant and user @tenant_id = tenant_id - # @type [Hash{String => String}] + # @type [Hash{String => String}] Additional metadata to be applied to a user profile when used in a tenant context @profile = profile # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -52,10 +52,10 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - obj.user_id.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.") - obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.user_id&.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.") + obj.type&.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.tenant_id.is_a?(String) != false || raise("Passed value for field obj.tenant_id is not the expected type, validation failed.") - obj.profile.is_a?(Hash) != false || raise("Passed value for field obj.profile is not the expected type, validation failed.") + obj.profile&.is_a?(Hash) != false || raise("Passed value for field obj.profile is not the expected type, validation failed.") end end end diff --git a/lib/courier/inbound/client.rb b/lib/courier/inbound/client.rb new file mode 100644 index 0000000..fd01810 --- /dev/null +++ b/lib/courier/inbound/client.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +require_relative "../../requests" +require_relative "types/inbound_track_event" +require_relative "types/track_accepted_response" +require "async" + +module Courier + class InboundClient + attr_reader :request_client + + # @param request_client [RequestClient] + # @return [InboundClient] + def initialize(request_client:) + # @type [RequestClient] + @request_client = request_client + end + + # @param request [Hash] Request of type Inbound::InboundTrackEvent, as a Hash + # * :event (String) + # * :message_id (String) + # * :properties (Hash{String => String}) + # * :type (String) + # * :user_id (String) + # @param request_options [RequestOptions] + # @return [Inbound::TrackAcceptedResponse] + def track(request:, request_options: nil) + response = @request_client.conn.post("/inbound/courier") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + unless request_options&.authorization_token.nil? + req.headers["Authorization"] = + request_options.authorization_token + end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + Inbound::TrackAcceptedResponse.from_json(json_object: response.body) + end + end + + class AsyncInboundClient + attr_reader :request_client + + # @param request_client [AsyncRequestClient] + # @return [AsyncInboundClient] + def initialize(request_client:) + # @type [AsyncRequestClient] + @request_client = request_client + end + + # @param request [Hash] Request of type Inbound::InboundTrackEvent, as a Hash + # * :event (String) + # * :message_id (String) + # * :properties (Hash{String => String}) + # * :type (String) + # * :user_id (String) + # @param request_options [RequestOptions] + # @return [Inbound::TrackAcceptedResponse] + def track(request:, request_options: nil) + Async do + response = @request_client.conn.post("/inbound/courier") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + unless request_options&.authorization_token.nil? + req.headers["Authorization"] = + request_options.authorization_token + end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + Inbound::TrackAcceptedResponse.from_json(json_object: response.body) + end + end + end +end diff --git a/lib/courier/inbound/types/inbound_track_event.rb b/lib/courier/inbound/types/inbound_track_event.rb new file mode 100644 index 0000000..ed89916 --- /dev/null +++ b/lib/courier/inbound/types/inbound_track_event.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +require "json" + +module Courier + class Inbound + class InboundTrackEvent + attr_reader :event, :message_id, :properties, :type, :user_id, :additional_properties + + # @param event [String] A descriptive name of the event. This name will appear as a trigger in the Courier Automation Trigger node. + # @param message_id [String] A required unique identifier that will be used to de-duplicate requests. If not unique, will respond with 409 Conflict status + # @param properties [Hash{String => String}] + # @param type [String] + # @param user_id [String] The user id assocatiated with the track + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Inbound::InboundTrackEvent] + def initialize(event:, message_id:, properties:, type:, user_id: nil, additional_properties: nil) + # @type [String] A descriptive name of the event. This name will appear as a trigger in the Courier Automation Trigger node. + @event = event + # @type [String] A required unique identifier that will be used to de-duplicate requests. If not unique, will respond with 409 Conflict status + @message_id = message_id + # @type [Hash{String => String}] + @properties = properties + # @type [String] + @type = type + # @type [String] The user id assocatiated with the track + @user_id = user_id + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of InboundTrackEvent + # + # @param json_object [JSON] + # @return [Inbound::InboundTrackEvent] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + JSON.parse(json_object) + event = struct.event + message_id = struct.messageId + properties = struct.properties + type = struct.type + user_id = struct.userId + new(event: event, message_id: message_id, properties: properties, type: type, user_id: user_id, + additional_properties: struct) + end + + # Serialize an instance of InboundTrackEvent to a JSON object + # + # @return [JSON] + def to_json(*_args) + { + "event": @event, + "messageId": @message_id, + "properties": @properties, + "type": @type, + "userId": @user_id + }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.event.is_a?(String) != false || raise("Passed value for field obj.event is not the expected type, validation failed.") + obj.message_id.is_a?(String) != false || raise("Passed value for field obj.message_id is not the expected type, validation failed.") + obj.properties.is_a?(Hash) != false || raise("Passed value for field obj.properties is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.user_id&.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/courier/inbound/types/track_accepted_response.rb b/lib/courier/inbound/types/track_accepted_response.rb new file mode 100644 index 0000000..b034f88 --- /dev/null +++ b/lib/courier/inbound/types/track_accepted_response.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require "json" + +module Courier + class Inbound + class TrackAcceptedResponse + attr_reader :message_id, :additional_properties + + # @param message_id [String] A successful call returns a `202` status code along with a `requestId` in the response body. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Inbound::TrackAcceptedResponse] + def initialize(message_id:, additional_properties: nil) + # @type [String] A successful call returns a `202` status code along with a `requestId` in the response body. + @message_id = message_id + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of TrackAcceptedResponse + # + # @param json_object [JSON] + # @return [Inbound::TrackAcceptedResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + JSON.parse(json_object) + message_id = struct.messageId + new(message_id: message_id, additional_properties: struct) + end + + # Serialize an instance of TrackAcceptedResponse to a JSON object + # + # @return [JSON] + def to_json(*_args) + { "messageId": @message_id }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.message_id.is_a?(String) != false || raise("Passed value for field obj.message_id is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/trycourier/lists/client.rb b/lib/courier/lists/client.rb similarity index 94% rename from lib/trycourier/lists/client.rb rename to lib/courier/lists/client.rb index 22c37cf..38436bc 100644 --- a/lib/trycourier/lists/client.rb +++ b/lib/courier/lists/client.rb @@ -137,14 +137,14 @@ def get_subscribers(list_id:, cursor: nil, request_options: nil) # Subscribes the users to the list, overwriting existing subscriptions. If the list does not exist, it will be automatically created. # # @param list_id [String] A unique identifier representing the list you wish to retrieve. - # @param request [Array] Request of type Array, as a Hash + # @param recipients [Array] Request of type Array, as a Hash # * :recipient_id (String) # * :preferences (Hash) # * :categories (Commons::NOTIFICATION_PREFERENCES) # * :notifications (Commons::NOTIFICATION_PREFERENCES) # @param request_options [RequestOptions] # @return [Void] - def update_subscribers(list_id:, request:, request_options: nil) + def update_subscribers(list_id:, recipients:, request_options: nil) @request_client.conn.put("/lists/#{list_id}/subscriptions") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? unless request_options&.authorization_token.nil? @@ -152,21 +152,21 @@ def update_subscribers(list_id:, request:, request_options: nil) request_options.authorization_token end req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact - req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), recipients: recipients }.compact end end # Subscribes additional users to the list, without modifying existing subscriptions. If the list does not exist, it will be automatically created. # # @param list_id [String] A unique identifier representing the list you wish to retrieve. - # @param request [Array] Request of type Array, as a Hash + # @param recipients [Array] Request of type Array, as a Hash # * :recipient_id (String) # * :preferences (Hash) # * :categories (Commons::NOTIFICATION_PREFERENCES) # * :notifications (Commons::NOTIFICATION_PREFERENCES) # @param request_options [IdempotencyRequestOptions] # @return [Void] - def add_subscribers(list_id:, request:, request_options: nil) + def add_subscribers(list_id:, recipients:, request_options: nil) @request_client.conn.post("/lists/#{list_id}/subscriptions") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? unless request_options&.authorization_token.nil? @@ -178,7 +178,7 @@ def add_subscribers(list_id:, request:, request_options: nil) req.headers["X-Idempotency-Expiration"] = request_options.idempotency_expiry end req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact - req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), recipients: recipients }.compact end end @@ -360,14 +360,14 @@ def get_subscribers(list_id:, cursor: nil, request_options: nil) # Subscribes the users to the list, overwriting existing subscriptions. If the list does not exist, it will be automatically created. # # @param list_id [String] A unique identifier representing the list you wish to retrieve. - # @param request [Array] Request of type Array, as a Hash + # @param recipients [Array] Request of type Array, as a Hash # * :recipient_id (String) # * :preferences (Hash) # * :categories (Commons::NOTIFICATION_PREFERENCES) # * :notifications (Commons::NOTIFICATION_PREFERENCES) # @param request_options [RequestOptions] # @return [Void] - def update_subscribers(list_id:, request:, request_options: nil) + def update_subscribers(list_id:, recipients:, request_options: nil) Async do @request_client.conn.put("/lists/#{list_id}/subscriptions") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? @@ -376,7 +376,7 @@ def update_subscribers(list_id:, request:, request_options: nil) request_options.authorization_token end req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact - req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), recipients: recipients }.compact end end end @@ -384,14 +384,14 @@ def update_subscribers(list_id:, request:, request_options: nil) # Subscribes additional users to the list, without modifying existing subscriptions. If the list does not exist, it will be automatically created. # # @param list_id [String] A unique identifier representing the list you wish to retrieve. - # @param request [Array] Request of type Array, as a Hash + # @param recipients [Array] Request of type Array, as a Hash # * :recipient_id (String) # * :preferences (Hash) # * :categories (Commons::NOTIFICATION_PREFERENCES) # * :notifications (Commons::NOTIFICATION_PREFERENCES) # @param request_options [IdempotencyRequestOptions] # @return [Void] - def add_subscribers(list_id:, request:, request_options: nil) + def add_subscribers(list_id:, recipients:, request_options: nil) Async do @request_client.conn.post("/lists/#{list_id}/subscriptions") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? @@ -404,7 +404,7 @@ def add_subscribers(list_id:, request:, request_options: nil) req.headers["X-Idempotency-Expiration"] = request_options.idempotency_expiry end req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact - req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.body = { **(request_options&.additional_body_parameters || {}), recipients: recipients }.compact end end end diff --git a/lib/trycourier/lists/types/list.rb b/lib/courier/lists/types/list.rb similarity index 100% rename from lib/trycourier/lists/types/list.rb rename to lib/courier/lists/types/list.rb diff --git a/lib/trycourier/lists/types/list_get_all_response.rb b/lib/courier/lists/types/list_get_all_response.rb similarity index 100% rename from lib/trycourier/lists/types/list_get_all_response.rb rename to lib/courier/lists/types/list_get_all_response.rb diff --git a/lib/trycourier/lists/types/list_get_subscriptions_response.rb b/lib/courier/lists/types/list_get_subscriptions_response.rb similarity index 100% rename from lib/trycourier/lists/types/list_get_subscriptions_response.rb rename to lib/courier/lists/types/list_get_subscriptions_response.rb diff --git a/lib/trycourier/lists/types/list_put_params.rb b/lib/courier/lists/types/list_put_params.rb similarity index 100% rename from lib/trycourier/lists/types/list_put_params.rb rename to lib/courier/lists/types/list_put_params.rb diff --git a/lib/trycourier/lists/types/list_subscription_recipient.rb b/lib/courier/lists/types/list_subscription_recipient.rb similarity index 100% rename from lib/trycourier/lists/types/list_subscription_recipient.rb rename to lib/courier/lists/types/list_subscription_recipient.rb diff --git a/lib/trycourier/lists/types/put_subscriptions_recipient.rb b/lib/courier/lists/types/put_subscriptions_recipient.rb similarity index 100% rename from lib/trycourier/lists/types/put_subscriptions_recipient.rb rename to lib/courier/lists/types/put_subscriptions_recipient.rb diff --git a/lib/trycourier/messages/client.rb b/lib/courier/messages/client.rb similarity index 90% rename from lib/trycourier/messages/client.rb rename to lib/courier/messages/client.rb index b337025..a0b2345 100644 --- a/lib/trycourier/messages/client.rb +++ b/lib/courier/messages/client.rb @@ -21,20 +21,23 @@ def initialize(request_client:) # Fetch the statuses of messages you've previously sent. # # @param archived [Boolean] A boolean value that indicates whether archived messages should be included in the response. - # @param cursor [String] A unique identifier that allows for fetching the next set of message statuses. + # @param cursor [String] A unique identifier that allows for fetching the next set of messages. # @param event [String] A unique identifier representing the event that was used to send the event. # @param list [String] A unique identifier representing the list the message was sent to. # @param message_id [String] A unique identifier representing the message_id returned from either /send or /send/list. # @param notification [String] A unique identifier representing the notification that was used to send the event. + # @param provider [String] The key assocated to the provider you want to filter on. E.g., sendgrid, inbox, twilio, slack, msteams, etc. Allows multiple values to be set in query parameters. # @param recipient [String] A unique identifier representing the recipient associated with the requested profile. - # @param status [String] An indicator of the current status of the message. Multiple status values can be passed in. + # @param status [String] An indicator of the current status of the message. Allows multiple values to be set in query parameters. + # @param tag [String] A tag placed in the metadata.tags during a notification send. Allows multiple values to be set in query parameters. # @param tags [String] A comma delimited list of 'tags'. Messages will be returned if they match any of the tags passed in. + # @param tenant_id [String] Messages sent with the context of a Tenant # @param enqueued_after [String] The enqueued datetime of a message to filter out messages received before. # @param trace_id [String] The unique identifier used to trace the requests # @param request_options [RequestOptions] # @return [Messages::ListMessagesResponse] - def list(archived: nil, cursor: nil, event: nil, list: nil, message_id: nil, notification: nil, recipient: nil, - status: nil, tags: nil, enqueued_after: nil, trace_id: nil, request_options: nil) + def list(archived: nil, cursor: nil, event: nil, list: nil, message_id: nil, notification: nil, provider: nil, + recipient: nil, status: nil, tag: nil, tags: nil, tenant_id: nil, enqueued_after: nil, trace_id: nil, request_options: nil) response = @request_client.conn.get("/messages") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? unless request_options&.authorization_token.nil? @@ -50,9 +53,12 @@ def list(archived: nil, cursor: nil, event: nil, list: nil, message_id: nil, not "list": list, "messageId": message_id, "notification": notification, + "provider": provider, "recipient": recipient, "status": status, + "tag": tag, "tags": tags, + "tenant_id": tenant_id, "enqueued_after": enqueued_after, "traceId": trace_id }.compact @@ -160,20 +166,23 @@ def initialize(request_client:) # Fetch the statuses of messages you've previously sent. # # @param archived [Boolean] A boolean value that indicates whether archived messages should be included in the response. - # @param cursor [String] A unique identifier that allows for fetching the next set of message statuses. + # @param cursor [String] A unique identifier that allows for fetching the next set of messages. # @param event [String] A unique identifier representing the event that was used to send the event. # @param list [String] A unique identifier representing the list the message was sent to. # @param message_id [String] A unique identifier representing the message_id returned from either /send or /send/list. # @param notification [String] A unique identifier representing the notification that was used to send the event. + # @param provider [String] The key assocated to the provider you want to filter on. E.g., sendgrid, inbox, twilio, slack, msteams, etc. Allows multiple values to be set in query parameters. # @param recipient [String] A unique identifier representing the recipient associated with the requested profile. - # @param status [String] An indicator of the current status of the message. Multiple status values can be passed in. + # @param status [String] An indicator of the current status of the message. Allows multiple values to be set in query parameters. + # @param tag [String] A tag placed in the metadata.tags during a notification send. Allows multiple values to be set in query parameters. # @param tags [String] A comma delimited list of 'tags'. Messages will be returned if they match any of the tags passed in. + # @param tenant_id [String] Messages sent with the context of a Tenant # @param enqueued_after [String] The enqueued datetime of a message to filter out messages received before. # @param trace_id [String] The unique identifier used to trace the requests # @param request_options [RequestOptions] # @return [Messages::ListMessagesResponse] - def list(archived: nil, cursor: nil, event: nil, list: nil, message_id: nil, notification: nil, recipient: nil, - status: nil, tags: nil, enqueued_after: nil, trace_id: nil, request_options: nil) + def list(archived: nil, cursor: nil, event: nil, list: nil, message_id: nil, notification: nil, provider: nil, + recipient: nil, status: nil, tag: nil, tags: nil, tenant_id: nil, enqueued_after: nil, trace_id: nil, request_options: nil) Async do response = @request_client.conn.get("/messages") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? @@ -190,9 +199,12 @@ def list(archived: nil, cursor: nil, event: nil, list: nil, message_id: nil, not "list": list, "messageId": message_id, "notification": notification, + "provider": provider, "recipient": recipient, "status": status, + "tag": tag, "tags": tags, + "tenant_id": tenant_id, "enqueued_after": enqueued_after, "traceId": trace_id }.compact diff --git a/lib/trycourier/messages/types/list_messages_response.rb b/lib/courier/messages/types/list_messages_response.rb similarity index 100% rename from lib/trycourier/messages/types/list_messages_response.rb rename to lib/courier/messages/types/list_messages_response.rb diff --git a/lib/trycourier/messages/types/message_details.rb b/lib/courier/messages/types/message_details.rb similarity index 70% rename from lib/trycourier/messages/types/message_details.rb rename to lib/courier/messages/types/message_details.rb index a72bcc3..9fdccf8 100644 --- a/lib/trycourier/messages/types/message_details.rb +++ b/lib/courier/messages/types/message_details.rb @@ -12,11 +12,11 @@ class MessageDetails # @param id [String] A unique identifier associated with the message you wish to retrieve (results from a send). # @param status [Messages::MessageStatus] The current status of the message. - # @param enqueued [Integer] A UTC timestamp at which Courier received the message request. Stored as a millisecond representation of the Unix epoch. - # @param sent [Integer] A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a millisecond representation of the Unix epoch. - # @param delivered [Integer] A UTC timestamp at which the Integration provider delivered the message. Stored as a millisecond representation of the Unix epoch. - # @param opened [Integer] A UTC timestamp at which the recipient opened a message for the first time. Stored as a millisecond representation of the Unix epoch. - # @param clicked [Integer] A UTC timestamp at which the recipient clicked on a tracked link for the first time. Stored as a millisecond representation of the Unix epoch. + # @param enqueued [Long] A UTC timestamp at which Courier received the message request. Stored as a millisecond representation of the Unix epoch. + # @param sent [Long] A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a millisecond representation of the Unix epoch. + # @param delivered [Long] A UTC timestamp at which the Integration provider delivered the message. Stored as a millisecond representation of the Unix epoch. + # @param opened [Long] A UTC timestamp at which the recipient opened a message for the first time. Stored as a millisecond representation of the Unix epoch. + # @param clicked [Long] A UTC timestamp at which the recipient clicked on a tracked link for the first time. Stored as a millisecond representation of the Unix epoch. # @param recipient [String] A unique identifier associated with the recipient of the delivered message. # @param event [String] A unique identifier associated with the event of the delivered message. # @param notification [String] A unique identifier associated with the notification of the delivered message. @@ -30,15 +30,15 @@ def initialize(id:, status:, enqueued:, sent:, delivered:, opened:, clicked:, re @id = id # @type [Messages::MessageStatus] The current status of the message. @status = status - # @type [Integer] A UTC timestamp at which Courier received the message request. Stored as a millisecond representation of the Unix epoch. + # @type [Long] A UTC timestamp at which Courier received the message request. Stored as a millisecond representation of the Unix epoch. @enqueued = enqueued - # @type [Integer] A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a millisecond representation of the Unix epoch. + # @type [Long] A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a millisecond representation of the Unix epoch. @sent = sent - # @type [Integer] A UTC timestamp at which the Integration provider delivered the message. Stored as a millisecond representation of the Unix epoch. + # @type [Long] A UTC timestamp at which the Integration provider delivered the message. Stored as a millisecond representation of the Unix epoch. @delivered = delivered - # @type [Integer] A UTC timestamp at which the recipient opened a message for the first time. Stored as a millisecond representation of the Unix epoch. + # @type [Long] A UTC timestamp at which the recipient opened a message for the first time. Stored as a millisecond representation of the Unix epoch. @opened = opened - # @type [Integer] A UTC timestamp at which the recipient clicked on a tracked link for the first time. Stored as a millisecond representation of the Unix epoch. + # @type [Long] A UTC timestamp at which the recipient clicked on a tracked link for the first time. Stored as a millisecond representation of the Unix epoch. @clicked = clicked # @type [String] A unique identifier associated with the recipient of the delivered message. @recipient = recipient @@ -104,11 +104,11 @@ def to_json(*_args) def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.status.is_a?(Messages::MessageStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") - obj.enqueued.is_a?(Integer) != false || raise("Passed value for field obj.enqueued is not the expected type, validation failed.") - obj.sent.is_a?(Integer) != false || raise("Passed value for field obj.sent is not the expected type, validation failed.") - obj.delivered.is_a?(Integer) != false || raise("Passed value for field obj.delivered is not the expected type, validation failed.") - obj.opened.is_a?(Integer) != false || raise("Passed value for field obj.opened is not the expected type, validation failed.") - obj.clicked.is_a?(Integer) != false || raise("Passed value for field obj.clicked is not the expected type, validation failed.") + obj.enqueued.is_a?(Long) != false || raise("Passed value for field obj.enqueued is not the expected type, validation failed.") + obj.sent.is_a?(Long) != false || raise("Passed value for field obj.sent is not the expected type, validation failed.") + obj.delivered.is_a?(Long) != false || raise("Passed value for field obj.delivered is not the expected type, validation failed.") + obj.opened.is_a?(Long) != false || raise("Passed value for field obj.opened is not the expected type, validation failed.") + obj.clicked.is_a?(Long) != false || raise("Passed value for field obj.clicked is not the expected type, validation failed.") obj.recipient.is_a?(String) != false || raise("Passed value for field obj.recipient is not the expected type, validation failed.") obj.event.is_a?(String) != false || raise("Passed value for field obj.event is not the expected type, validation failed.") obj.notification.is_a?(String) != false || raise("Passed value for field obj.notification is not the expected type, validation failed.") diff --git a/lib/trycourier/messages/types/message_history_response.rb b/lib/courier/messages/types/message_history_response.rb similarity index 81% rename from lib/trycourier/messages/types/message_history_response.rb rename to lib/courier/messages/types/message_history_response.rb index bcfadc2..bbd01f7 100644 --- a/lib/trycourier/messages/types/message_history_response.rb +++ b/lib/courier/messages/types/message_history_response.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require_relative "message_details" require "json" module Courier @@ -8,11 +7,11 @@ class Messages class MessageHistoryResponse attr_reader :results, :additional_properties - # @param results [Array] + # @param results [Array String}>] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Messages::MessageHistoryResponse] def initialize(results:, additional_properties: nil) - # @type [Array] + # @type [Array String}>] @results = results # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -24,11 +23,8 @@ def initialize(results:, additional_properties: nil) # @return [Messages::MessageHistoryResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - parsed_json = JSON.parse(json_object) - results = parsed_json["results"]&.map do |v| - v = v.to_json - Messages::MessageDetails.from_json(json_object: v) - end + JSON.parse(json_object) + results = struct.results new(results: results, additional_properties: struct) end diff --git a/lib/trycourier/messages/types/message_status.rb b/lib/courier/messages/types/message_status.rb similarity index 92% rename from lib/trycourier/messages/types/message_status.rb rename to lib/courier/messages/types/message_status.rb index 30260fe..6dc8c4a 100644 --- a/lib/trycourier/messages/types/message_status.rb +++ b/lib/courier/messages/types/message_status.rb @@ -9,6 +9,7 @@ class MessageStatus OPENED = "OPENED" CANCELED = "CANCELED" SENT = "SENT" + THROTTLED = "THROTTLED" UNDELIVERABLE = "UNDELIVERABLE" UNMAPPED = "UNMAPPED" UNROUTABLE = "UNROUTABLE" diff --git a/lib/trycourier/messages/types/reason.rb b/lib/courier/messages/types/reason.rb similarity index 100% rename from lib/trycourier/messages/types/reason.rb rename to lib/courier/messages/types/reason.rb diff --git a/lib/trycourier/messages/types/render_output.rb b/lib/courier/messages/types/render_output.rb similarity index 100% rename from lib/trycourier/messages/types/render_output.rb rename to lib/courier/messages/types/render_output.rb diff --git a/lib/trycourier/messages/types/render_output_response.rb b/lib/courier/messages/types/render_output_response.rb similarity index 100% rename from lib/trycourier/messages/types/render_output_response.rb rename to lib/courier/messages/types/render_output_response.rb diff --git a/lib/trycourier/messages/types/rendered_message_block.rb b/lib/courier/messages/types/rendered_message_block.rb similarity index 100% rename from lib/trycourier/messages/types/rendered_message_block.rb rename to lib/courier/messages/types/rendered_message_block.rb diff --git a/lib/trycourier/messages/types/rendered_message_content.rb b/lib/courier/messages/types/rendered_message_content.rb similarity index 100% rename from lib/trycourier/messages/types/rendered_message_content.rb rename to lib/courier/messages/types/rendered_message_content.rb diff --git a/lib/trycourier/notifications/client.rb b/lib/courier/notifications/client.rb similarity index 63% rename from lib/trycourier/notifications/client.rb rename to lib/courier/notifications/client.rb index 9baf250..ad02052 100644 --- a/lib/trycourier/notifications/client.rb +++ b/lib/courier/notifications/client.rb @@ -3,8 +3,6 @@ require_relative "../../requests" require_relative "types/notification_list_response" require_relative "types/notification_get_content_response" -require_relative "types/notification_block" -require_relative "types/notification_channel" require_relative "types/submission_checks_get_response" require_relative "types/base_check" require_relative "types/submission_checks_replace_response" @@ -22,9 +20,10 @@ def initialize(request_client:) end # @param cursor [String] + # @param notes [Boolean] Retrieve the notes from the Notification template settings. # @param request_options [RequestOptions] # @return [Notifications::NotificationListResponse] - def list(cursor: nil, request_options: nil) + def list(cursor: nil, notes: nil, request_options: nil) response = @request_client.conn.get("/notifications") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? unless request_options&.authorization_token.nil? @@ -32,7 +31,11 @@ def list(cursor: nil, request_options: nil) request_options.authorization_token end req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact - req.params = { **(request_options&.additional_query_parameters || {}), "cursor": cursor }.compact + req.params = { + **(request_options&.additional_query_parameters || {}), + "cursor": cursor, + "notes": notes + }.compact end Notifications::NotificationListResponse.from_json(json_object: response.body) end @@ -67,68 +70,6 @@ def get_draft_content(id:, request_options: nil) Notifications::NotificationGetContentResponse.from_json(json_object: response.body) end - # @param id [String] - # @param blocks [Array] Request of type Array, as a Hash - # * :alias_ (String) - # * :context (String) - # * :id (String) - # * :type (Notifications::BlockType) - # * :content (Hash) - # * :locales (Hash{String => String}) - # * :checksum (String) - # @param channels [Array] Request of type Array, as a Hash - # * :id (String) - # * :type (String) - # * :content (Hash) - # * :subject (String) - # * :title (String) - # * :locales (Hash{String => String}) - # * :checksum (String) - # @param request_options [RequestOptions] - # @return [Void] - def update_variations(id:, blocks: nil, channels: nil, request_options: nil) - @request_client.conn.post("/notifications/#{id}/variations") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? - unless request_options&.authorization_token.nil? - req.headers["Authorization"] = - request_options.authorization_token - end - req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact - req.body = { **(request_options&.additional_body_parameters || {}), blocks: blocks, channels: channels }.compact - end - end - - # @param id [String] - # @param blocks [Array] Request of type Array, as a Hash - # * :alias_ (String) - # * :context (String) - # * :id (String) - # * :type (Notifications::BlockType) - # * :content (Hash) - # * :locales (Hash{String => String}) - # * :checksum (String) - # @param channels [Array] Request of type Array, as a Hash - # * :id (String) - # * :type (String) - # * :content (Hash) - # * :subject (String) - # * :title (String) - # * :locales (Hash{String => String}) - # * :checksum (String) - # @param request_options [RequestOptions] - # @return [Void] - def update_draft_variations(id:, blocks: nil, channels: nil, request_options: nil) - @request_client.conn.post("/notifications/#{id}/draft/variations") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? - unless request_options&.authorization_token.nil? - req.headers["Authorization"] = - request_options.authorization_token - end - req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact - req.body = { **(request_options&.additional_body_parameters || {}), blocks: blocks, channels: channels }.compact - end - end - # @param id [String] # @param submission_id [String] # @param request_options [RequestOptions] @@ -193,9 +134,10 @@ def initialize(request_client:) end # @param cursor [String] + # @param notes [Boolean] Retrieve the notes from the Notification template settings. # @param request_options [RequestOptions] # @return [Notifications::NotificationListResponse] - def list(cursor: nil, request_options: nil) + def list(cursor: nil, notes: nil, request_options: nil) Async do response = @request_client.conn.get("/notifications") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? @@ -204,7 +146,11 @@ def list(cursor: nil, request_options: nil) request_options.authorization_token end req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact - req.params = { **(request_options&.additional_query_parameters || {}), "cursor": cursor }.compact + req.params = { + **(request_options&.additional_query_parameters || {}), + "cursor": cursor, + "notes": notes + }.compact end Notifications::NotificationListResponse.from_json(json_object: response.body) end @@ -244,80 +190,6 @@ def get_draft_content(id:, request_options: nil) end end - # @param id [String] - # @param blocks [Array] Request of type Array, as a Hash - # * :alias_ (String) - # * :context (String) - # * :id (String) - # * :type (Notifications::BlockType) - # * :content (Hash) - # * :locales (Hash{String => String}) - # * :checksum (String) - # @param channels [Array] Request of type Array, as a Hash - # * :id (String) - # * :type (String) - # * :content (Hash) - # * :subject (String) - # * :title (String) - # * :locales (Hash{String => String}) - # * :checksum (String) - # @param request_options [RequestOptions] - # @return [Void] - def update_variations(id:, blocks: nil, channels: nil, request_options: nil) - Async do - @request_client.conn.post("/notifications/#{id}/variations") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? - unless request_options&.authorization_token.nil? - req.headers["Authorization"] = - request_options.authorization_token - end - req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact - req.body = { - **(request_options&.additional_body_parameters || {}), - blocks: blocks, - channels: channels - }.compact - end - end - end - - # @param id [String] - # @param blocks [Array] Request of type Array, as a Hash - # * :alias_ (String) - # * :context (String) - # * :id (String) - # * :type (Notifications::BlockType) - # * :content (Hash) - # * :locales (Hash{String => String}) - # * :checksum (String) - # @param channels [Array] Request of type Array, as a Hash - # * :id (String) - # * :type (String) - # * :content (Hash) - # * :subject (String) - # * :title (String) - # * :locales (Hash{String => String}) - # * :checksum (String) - # @param request_options [RequestOptions] - # @return [Void] - def update_draft_variations(id:, blocks: nil, channels: nil, request_options: nil) - Async do - @request_client.conn.post("/notifications/#{id}/draft/variations") do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? - unless request_options&.authorization_token.nil? - req.headers["Authorization"] = - request_options.authorization_token - end - req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact - req.body = { - **(request_options&.additional_body_parameters || {}), - blocks: blocks, - channels: channels - }.compact - end - end - end - # @param id [String] # @param submission_id [String] # @param request_options [RequestOptions] diff --git a/lib/trycourier/notifications/types/base_check.rb b/lib/courier/notifications/types/base_check.rb similarity index 100% rename from lib/trycourier/notifications/types/base_check.rb rename to lib/courier/notifications/types/base_check.rb diff --git a/lib/trycourier/notifications/types/block_type.rb b/lib/courier/notifications/types/block_type.rb similarity index 100% rename from lib/trycourier/notifications/types/block_type.rb rename to lib/courier/notifications/types/block_type.rb diff --git a/lib/trycourier/notifications/types/check.rb b/lib/courier/notifications/types/check.rb similarity index 100% rename from lib/trycourier/notifications/types/check.rb rename to lib/courier/notifications/types/check.rb diff --git a/lib/trycourier/notifications/types/check_status.rb b/lib/courier/notifications/types/check_status.rb similarity index 100% rename from lib/trycourier/notifications/types/check_status.rb rename to lib/courier/notifications/types/check_status.rb diff --git a/lib/trycourier/notifications/types/message_routing.rb b/lib/courier/notifications/types/message_routing.rb similarity index 100% rename from lib/trycourier/notifications/types/message_routing.rb rename to lib/courier/notifications/types/message_routing.rb diff --git a/lib/trycourier/notifications/types/message_routing_channel.rb b/lib/courier/notifications/types/message_routing_channel.rb similarity index 100% rename from lib/trycourier/notifications/types/message_routing_channel.rb rename to lib/courier/notifications/types/message_routing_channel.rb diff --git a/lib/trycourier/notifications/types/message_routing_method.rb b/lib/courier/notifications/types/message_routing_method.rb similarity index 100% rename from lib/trycourier/notifications/types/message_routing_method.rb rename to lib/courier/notifications/types/message_routing_method.rb diff --git a/lib/courier/notifications/types/notification.rb b/lib/courier/notifications/types/notification.rb new file mode 100644 index 0000000..d9b4e5b --- /dev/null +++ b/lib/courier/notifications/types/notification.rb @@ -0,0 +1,105 @@ +# frozen_string_literal: true + +require_relative "message_routing" +require_relative "notification_tag" +require "json" + +module Courier + class Notifications + class Notification + attr_reader :created_at, :updated_at, :id, :routing, :tags, :title, :topic_id, :note, :additional_properties + + # @param created_at [Long] + # @param updated_at [Long] + # @param id [String] + # @param routing [Notifications::MessageRouting] + # @param tags [Notifications::NotificationTag] + # @param title [String] + # @param topic_id [String] + # @param note [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Notifications::Notification] + def initialize(created_at:, updated_at:, id:, routing:, topic_id:, note:, tags: nil, title: nil, + additional_properties: nil) + # @type [Long] + @created_at = created_at + # @type [Long] + @updated_at = updated_at + # @type [String] + @id = id + # @type [Notifications::MessageRouting] + @routing = routing + # @type [Notifications::NotificationTag] + @tags = tags + # @type [String] + @title = title + # @type [String] + @topic_id = topic_id + # @type [String] + @note = note + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of Notification + # + # @param json_object [JSON] + # @return [Notifications::Notification] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + created_at = struct.created_at + updated_at = struct.updated_at + id = struct.id + if parsed_json["routing"].nil? + routing = nil + else + routing = parsed_json["routing"].to_json + routing = Notifications::MessageRouting.from_json(json_object: routing) + end + if parsed_json["tags"].nil? + tags = nil + else + tags = parsed_json["tags"].to_json + tags = Notifications::NotificationTag.from_json(json_object: tags) + end + title = struct.title + topic_id = struct.topic_id + note = struct.note + new(created_at: created_at, updated_at: updated_at, id: id, routing: routing, tags: tags, title: title, + topic_id: topic_id, note: note, additional_properties: struct) + end + + # Serialize an instance of Notification to a JSON object + # + # @return [JSON] + def to_json(*_args) + { + "created_at": @created_at, + "updated_at": @updated_at, + "id": @id, + "routing": @routing, + "tags": @tags, + "title": @title, + "topic_id": @topic_id, + "note": @note + }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.created_at.is_a?(Long) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(Long) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + Notifications::MessageRouting.validate_raw(obj: obj.routing) + obj.tags.nil? || Notifications::NotificationTag.validate_raw(obj: obj.tags) + obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") + obj.topic_id.is_a?(String) != false || raise("Passed value for field obj.topic_id is not the expected type, validation failed.") + obj.note.is_a?(String) != false || raise("Passed value for field obj.note is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/trycourier/notifications/types/notification_block.rb b/lib/courier/notifications/types/notification_block.rb similarity index 100% rename from lib/trycourier/notifications/types/notification_block.rb rename to lib/courier/notifications/types/notification_block.rb diff --git a/lib/trycourier/notifications/types/notification_channel.rb b/lib/courier/notifications/types/notification_channel.rb similarity index 100% rename from lib/trycourier/notifications/types/notification_channel.rb rename to lib/courier/notifications/types/notification_channel.rb diff --git a/lib/trycourier/notifications/types/notification_channel_content.rb b/lib/courier/notifications/types/notification_channel_content.rb similarity index 100% rename from lib/trycourier/notifications/types/notification_channel_content.rb rename to lib/courier/notifications/types/notification_channel_content.rb diff --git a/lib/trycourier/notifications/types/notification_content.rb b/lib/courier/notifications/types/notification_content.rb similarity index 100% rename from lib/trycourier/notifications/types/notification_content.rb rename to lib/courier/notifications/types/notification_content.rb diff --git a/lib/trycourier/notifications/types/notification_content_hierarchy.rb b/lib/courier/notifications/types/notification_content_hierarchy.rb similarity index 100% rename from lib/trycourier/notifications/types/notification_content_hierarchy.rb rename to lib/courier/notifications/types/notification_content_hierarchy.rb diff --git a/lib/trycourier/notifications/types/notification_get_content_response.rb b/lib/courier/notifications/types/notification_get_content_response.rb similarity index 100% rename from lib/trycourier/notifications/types/notification_get_content_response.rb rename to lib/courier/notifications/types/notification_get_content_response.rb diff --git a/lib/trycourier/notifications/types/notification_list_response.rb b/lib/courier/notifications/types/notification_list_response.rb similarity index 100% rename from lib/trycourier/notifications/types/notification_list_response.rb rename to lib/courier/notifications/types/notification_list_response.rb diff --git a/lib/courier/notifications/types/notification_tag.rb b/lib/courier/notifications/types/notification_tag.rb new file mode 100644 index 0000000..8cce4d1 --- /dev/null +++ b/lib/courier/notifications/types/notification_tag.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +require_relative "notification_tag_data" +require "json" + +module Courier + class Notifications + class NotificationTag + attr_reader :data, :additional_properties + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Notifications::NotificationTag] + def initialize(data:, additional_properties: nil) + # @type [Array] + @data = data + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of NotificationTag + # + # @param json_object [JSON] + # @return [Notifications::NotificationTag] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do |v| + v = v.to_json + Notifications::NotificationTagData.from_json(json_object: v) + end + new(data: data, additional_properties: struct) + end + + # Serialize an instance of NotificationTag to a JSON object + # + # @return [JSON] + def to_json(*_args) + { "data": @data }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/trycourier/tenants/types/subscription_topic.rb b/lib/courier/notifications/types/notification_tag_data.rb similarity index 52% rename from lib/trycourier/tenants/types/subscription_topic.rb rename to lib/courier/notifications/types/notification_tag_data.rb index f533bdc..669722b 100644 --- a/lib/trycourier/tenants/types/subscription_topic.rb +++ b/lib/courier/notifications/types/notification_tag_data.rb @@ -1,43 +1,42 @@ # frozen_string_literal: true -require_relative "subscription_topic_status" require "json" module Courier - class Tenants - class SubscriptionTopic - attr_reader :id, :status, :additional_properties + class Notifications + class NotificationTagData + attr_reader :id, :name, :additional_properties - # @param id [String] Topic ID - # @param status [Tenants::SubscriptionTopicStatus] + # @param id [String] + # @param name [String] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition - # @return [Tenants::SubscriptionTopic] - def initialize(id:, status:, additional_properties: nil) - # @type [String] Topic ID + # @return [Notifications::NotificationTagData] + def initialize(id:, name:, additional_properties: nil) + # @type [String] @id = id - # @type [Tenants::SubscriptionTopicStatus] - @status = status + # @type [String] + @name = name # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end - # Deserialize a JSON object to an instance of SubscriptionTopic + # Deserialize a JSON object to an instance of NotificationTagData # # @param json_object [JSON] - # @return [Tenants::SubscriptionTopic] + # @return [Notifications::NotificationTagData] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) JSON.parse(json_object) id = struct.id - status = struct.status - new(id: id, status: status, additional_properties: struct) + name = struct.name + new(id: id, name: name, additional_properties: struct) end - # Serialize an instance of SubscriptionTopic to a JSON object + # Serialize an instance of NotificationTagData to a JSON object # # @return [JSON] def to_json(*_args) - { "id": @id, "status": @status }.to_json + { "id": @id, "name": @name }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -46,7 +45,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") - obj.status.is_a?(Tenants::SubscriptionTopicStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") end end end diff --git a/lib/trycourier/notifications/types/submission_checks_get_response.rb b/lib/courier/notifications/types/submission_checks_get_response.rb similarity index 100% rename from lib/trycourier/notifications/types/submission_checks_get_response.rb rename to lib/courier/notifications/types/submission_checks_get_response.rb diff --git a/lib/trycourier/notifications/types/submission_checks_replace_response.rb b/lib/courier/notifications/types/submission_checks_replace_response.rb similarity index 100% rename from lib/trycourier/notifications/types/submission_checks_replace_response.rb rename to lib/courier/notifications/types/submission_checks_replace_response.rb diff --git a/lib/trycourier/profiles/client.rb b/lib/courier/profiles/client.rb similarity index 89% rename from lib/trycourier/profiles/client.rb rename to lib/courier/profiles/client.rb index 0f3aceb..ae65b69 100644 --- a/lib/trycourier/profiles/client.rb +++ b/lib/courier/profiles/client.rb @@ -4,6 +4,7 @@ require_relative "types/profile_get_response" require_relative "types/merge_profile_response" require_relative "types/replace_profile_response" +require_relative "types/user_profile_patch" require_relative "types/get_list_subscriptions_response" require_relative "types/subscribe_to_lists_request" require_relative "types/subscribe_to_lists_response" @@ -83,6 +84,25 @@ def replace(user_id:, profile:, request_options: nil) Profiles::ReplaceProfileResponse.from_json(json_object: response.body) end + # @param user_id [String] A unique identifier representing the user associated with the requested profile. + # @param request [Array] Request of type Array, as a Hash + # * :op (String) + # * :path (String) + # * :value (String) + # @param request_options [RequestOptions] + # @return [Void] + def merge_profile(user_id:, request:, request_options: nil) + @request_client.conn.patch("/profiles/#{user_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + unless request_options&.authorization_token.nil? + req.headers["Authorization"] = + request_options.authorization_token + end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + end + # Deletes the specified user profile. # # @param user_id [String] A unique identifier representing the user associated with the requested profile. @@ -238,6 +258,27 @@ def replace(user_id:, profile:, request_options: nil) end end + # @param user_id [String] A unique identifier representing the user associated with the requested profile. + # @param request [Array] Request of type Array, as a Hash + # * :op (String) + # * :path (String) + # * :value (String) + # @param request_options [RequestOptions] + # @return [Void] + def merge_profile(user_id:, request:, request_options: nil) + Async do + @request_client.conn.patch("/profiles/#{user_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + unless request_options&.authorization_token.nil? + req.headers["Authorization"] = + request_options.authorization_token + end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + end + end + # Deletes the specified user profile. # # @param user_id [String] A unique identifier representing the user associated with the requested profile. diff --git a/lib/trycourier/profiles/types/address.rb b/lib/courier/profiles/types/address.rb similarity index 100% rename from lib/trycourier/profiles/types/address.rb rename to lib/courier/profiles/types/address.rb diff --git a/lib/trycourier/profiles/types/airship_profile.rb b/lib/courier/profiles/types/airship_profile.rb similarity index 100% rename from lib/trycourier/profiles/types/airship_profile.rb rename to lib/courier/profiles/types/airship_profile.rb diff --git a/lib/trycourier/profiles/types/airship_profile_audience.rb b/lib/courier/profiles/types/airship_profile_audience.rb similarity index 100% rename from lib/trycourier/profiles/types/airship_profile_audience.rb rename to lib/courier/profiles/types/airship_profile_audience.rb diff --git a/lib/trycourier/profiles/types/delete_list_subscription_response.rb b/lib/courier/profiles/types/delete_list_subscription_response.rb similarity index 100% rename from lib/trycourier/profiles/types/delete_list_subscription_response.rb rename to lib/courier/profiles/types/delete_list_subscription_response.rb diff --git a/lib/trycourier/profiles/types/device_type.rb b/lib/courier/profiles/types/device_type.rb similarity index 100% rename from lib/trycourier/profiles/types/device_type.rb rename to lib/courier/profiles/types/device_type.rb diff --git a/lib/trycourier/profiles/types/discord.rb b/lib/courier/profiles/types/discord.rb similarity index 100% rename from lib/trycourier/profiles/types/discord.rb rename to lib/courier/profiles/types/discord.rb diff --git a/lib/trycourier/profiles/types/expo.rb b/lib/courier/profiles/types/expo.rb similarity index 100% rename from lib/trycourier/profiles/types/expo.rb rename to lib/courier/profiles/types/expo.rb diff --git a/lib/trycourier/profiles/types/get_list_subscriptions_list.rb b/lib/courier/profiles/types/get_list_subscriptions_list.rb similarity index 100% rename from lib/trycourier/profiles/types/get_list_subscriptions_list.rb rename to lib/courier/profiles/types/get_list_subscriptions_list.rb diff --git a/lib/trycourier/profiles/types/get_list_subscriptions_response.rb b/lib/courier/profiles/types/get_list_subscriptions_response.rb similarity index 100% rename from lib/trycourier/profiles/types/get_list_subscriptions_response.rb rename to lib/courier/profiles/types/get_list_subscriptions_response.rb diff --git a/lib/trycourier/profiles/types/intercom.rb b/lib/courier/profiles/types/intercom.rb similarity index 100% rename from lib/trycourier/profiles/types/intercom.rb rename to lib/courier/profiles/types/intercom.rb diff --git a/lib/trycourier/profiles/types/intercom_recipient.rb b/lib/courier/profiles/types/intercom_recipient.rb similarity index 100% rename from lib/trycourier/profiles/types/intercom_recipient.rb rename to lib/courier/profiles/types/intercom_recipient.rb diff --git a/lib/trycourier/profiles/types/merge_profile_response.rb b/lib/courier/profiles/types/merge_profile_response.rb similarity index 100% rename from lib/trycourier/profiles/types/merge_profile_response.rb rename to lib/courier/profiles/types/merge_profile_response.rb diff --git a/lib/trycourier/profiles/types/ms_teams.rb b/lib/courier/profiles/types/ms_teams.rb similarity index 100% rename from lib/trycourier/profiles/types/ms_teams.rb rename to lib/courier/profiles/types/ms_teams.rb diff --git a/lib/trycourier/profiles/types/ms_teams_base_properties.rb b/lib/courier/profiles/types/ms_teams_base_properties.rb similarity index 100% rename from lib/trycourier/profiles/types/ms_teams_base_properties.rb rename to lib/courier/profiles/types/ms_teams_base_properties.rb diff --git a/lib/trycourier/profiles/types/multiple_tokens.rb b/lib/courier/profiles/types/multiple_tokens.rb similarity index 100% rename from lib/trycourier/profiles/types/multiple_tokens.rb rename to lib/courier/profiles/types/multiple_tokens.rb diff --git a/lib/courier/profiles/types/pagerduty.rb b/lib/courier/profiles/types/pagerduty.rb new file mode 100644 index 0000000..2564297 --- /dev/null +++ b/lib/courier/profiles/types/pagerduty.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require "json" + +module Courier + class Profiles + class Pagerduty + attr_reader :routing_key, :event_action, :severity, :source, :additional_properties + + # @param routing_key [String] + # @param event_action [String] + # @param severity [String] + # @param source [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Profiles::Pagerduty] + def initialize(routing_key: nil, event_action: nil, severity: nil, source: nil, additional_properties: nil) + # @type [String] + @routing_key = routing_key + # @type [String] + @event_action = event_action + # @type [String] + @severity = severity + # @type [String] + @source = source + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of Pagerduty + # + # @param json_object [JSON] + # @return [Profiles::Pagerduty] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + JSON.parse(json_object) + routing_key = struct.routing_key + event_action = struct.event_action + severity = struct.severity + source = struct.source + new(routing_key: routing_key, event_action: event_action, severity: severity, source: source, + additional_properties: struct) + end + + # Serialize an instance of Pagerduty to a JSON object + # + # @return [JSON] + def to_json(*_args) + { "routing_key": @routing_key, "event_action": @event_action, "severity": @severity, "source": @source }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.routing_key&.is_a?(String) != false || raise("Passed value for field obj.routing_key is not the expected type, validation failed.") + obj.event_action&.is_a?(String) != false || raise("Passed value for field obj.event_action is not the expected type, validation failed.") + obj.severity&.is_a?(String) != false || raise("Passed value for field obj.severity is not the expected type, validation failed.") + obj.source&.is_a?(String) != false || raise("Passed value for field obj.source is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/trycourier/profiles/types/profile_get_parameters.rb b/lib/courier/profiles/types/profile_get_parameters.rb similarity index 100% rename from lib/trycourier/profiles/types/profile_get_parameters.rb rename to lib/courier/profiles/types/profile_get_parameters.rb diff --git a/lib/trycourier/profiles/types/profile_get_response.rb b/lib/courier/profiles/types/profile_get_response.rb similarity index 100% rename from lib/trycourier/profiles/types/profile_get_response.rb rename to lib/courier/profiles/types/profile_get_response.rb diff --git a/lib/trycourier/profiles/types/replace_profile_response.rb b/lib/courier/profiles/types/replace_profile_response.rb similarity index 100% rename from lib/trycourier/profiles/types/replace_profile_response.rb rename to lib/courier/profiles/types/replace_profile_response.rb diff --git a/lib/trycourier/profiles/types/send_direct_message.rb b/lib/courier/profiles/types/send_direct_message.rb similarity index 100% rename from lib/trycourier/profiles/types/send_direct_message.rb rename to lib/courier/profiles/types/send_direct_message.rb diff --git a/lib/trycourier/profiles/types/send_to_channel.rb b/lib/courier/profiles/types/send_to_channel.rb similarity index 100% rename from lib/trycourier/profiles/types/send_to_channel.rb rename to lib/courier/profiles/types/send_to_channel.rb diff --git a/lib/trycourier/profiles/types/send_to_ms_teams_channel_id.rb b/lib/courier/profiles/types/send_to_ms_teams_channel_id.rb similarity index 100% rename from lib/trycourier/profiles/types/send_to_ms_teams_channel_id.rb rename to lib/courier/profiles/types/send_to_ms_teams_channel_id.rb diff --git a/lib/trycourier/profiles/types/send_to_ms_teams_channel_name.rb b/lib/courier/profiles/types/send_to_ms_teams_channel_name.rb similarity index 100% rename from lib/trycourier/profiles/types/send_to_ms_teams_channel_name.rb rename to lib/courier/profiles/types/send_to_ms_teams_channel_name.rb diff --git a/lib/trycourier/profiles/types/send_to_ms_teams_conversation_id.rb b/lib/courier/profiles/types/send_to_ms_teams_conversation_id.rb similarity index 100% rename from lib/trycourier/profiles/types/send_to_ms_teams_conversation_id.rb rename to lib/courier/profiles/types/send_to_ms_teams_conversation_id.rb diff --git a/lib/trycourier/profiles/types/send_to_ms_teams_email.rb b/lib/courier/profiles/types/send_to_ms_teams_email.rb similarity index 100% rename from lib/trycourier/profiles/types/send_to_ms_teams_email.rb rename to lib/courier/profiles/types/send_to_ms_teams_email.rb diff --git a/lib/trycourier/profiles/types/send_to_ms_teams_user_id.rb b/lib/courier/profiles/types/send_to_ms_teams_user_id.rb similarity index 100% rename from lib/trycourier/profiles/types/send_to_ms_teams_user_id.rb rename to lib/courier/profiles/types/send_to_ms_teams_user_id.rb diff --git a/lib/trycourier/profiles/types/send_to_slack_channel.rb b/lib/courier/profiles/types/send_to_slack_channel.rb similarity index 100% rename from lib/trycourier/profiles/types/send_to_slack_channel.rb rename to lib/courier/profiles/types/send_to_slack_channel.rb diff --git a/lib/trycourier/profiles/types/send_to_slack_email.rb b/lib/courier/profiles/types/send_to_slack_email.rb similarity index 100% rename from lib/trycourier/profiles/types/send_to_slack_email.rb rename to lib/courier/profiles/types/send_to_slack_email.rb diff --git a/lib/trycourier/profiles/types/send_to_slack_user_id.rb b/lib/courier/profiles/types/send_to_slack_user_id.rb similarity index 100% rename from lib/trycourier/profiles/types/send_to_slack_user_id.rb rename to lib/courier/profiles/types/send_to_slack_user_id.rb diff --git a/lib/trycourier/profiles/types/slack.rb b/lib/courier/profiles/types/slack.rb similarity index 100% rename from lib/trycourier/profiles/types/slack.rb rename to lib/courier/profiles/types/slack.rb diff --git a/lib/trycourier/profiles/types/slack_base_properties.rb b/lib/courier/profiles/types/slack_base_properties.rb similarity index 100% rename from lib/trycourier/profiles/types/slack_base_properties.rb rename to lib/courier/profiles/types/slack_base_properties.rb diff --git a/lib/trycourier/profiles/types/snooze_rule.rb b/lib/courier/profiles/types/snooze_rule.rb similarity index 100% rename from lib/trycourier/profiles/types/snooze_rule.rb rename to lib/courier/profiles/types/snooze_rule.rb diff --git a/lib/trycourier/profiles/types/snooze_rule_type.rb b/lib/courier/profiles/types/snooze_rule_type.rb similarity index 100% rename from lib/trycourier/profiles/types/snooze_rule_type.rb rename to lib/courier/profiles/types/snooze_rule_type.rb diff --git a/lib/trycourier/profiles/types/subscribe_to_lists_request.rb b/lib/courier/profiles/types/subscribe_to_lists_request.rb similarity index 100% rename from lib/trycourier/profiles/types/subscribe_to_lists_request.rb rename to lib/courier/profiles/types/subscribe_to_lists_request.rb diff --git a/lib/trycourier/profiles/types/subscribe_to_lists_request_list_object.rb b/lib/courier/profiles/types/subscribe_to_lists_request_list_object.rb similarity index 100% rename from lib/trycourier/profiles/types/subscribe_to_lists_request_list_object.rb rename to lib/courier/profiles/types/subscribe_to_lists_request_list_object.rb diff --git a/lib/trycourier/profiles/types/subscribe_to_lists_response.rb b/lib/courier/profiles/types/subscribe_to_lists_response.rb similarity index 100% rename from lib/trycourier/profiles/types/subscribe_to_lists_response.rb rename to lib/courier/profiles/types/subscribe_to_lists_response.rb diff --git a/lib/trycourier/profiles/types/token.rb b/lib/courier/profiles/types/token.rb similarity index 100% rename from lib/trycourier/profiles/types/token.rb rename to lib/courier/profiles/types/token.rb diff --git a/lib/trycourier/profiles/types/user_profile.rb b/lib/courier/profiles/types/user_profile.rb similarity index 96% rename from lib/trycourier/profiles/types/user_profile.rb rename to lib/courier/profiles/types/user_profile.rb index c16832d..d3639dc 100644 --- a/lib/trycourier/profiles/types/user_profile.rb +++ b/lib/courier/profiles/types/user_profile.rb @@ -4,6 +4,7 @@ require_relative "airship_profile" require_relative "discord" require_relative "expo" +require_relative "user_profile_firebase_token" require_relative "intercom" require_relative "slack" require_relative "ms_teams" @@ -42,7 +43,7 @@ class UserProfile # @param discord [Profiles::Discord] # @param expo [Profiles::Expo] # @param facebook_psid [String] - # @param firebase_token [String] + # @param firebase_token [Profiles::UserProfileFirebaseToken] # @param intercom [Profiles::Intercom] # @param slack [Profiles::Slack] # @param ms_teams [Profiles::MsTeams] @@ -104,7 +105,7 @@ def initialize(address:, birthdate:, email:, email_verified:, family_name:, gend @expo = expo # @type [String] @facebook_psid = facebook_psid - # @type [String] + # @type [Profiles::UserProfileFirebaseToken] @firebase_token = firebase_token # @type [Profiles::Intercom] @intercom = intercom @@ -170,7 +171,12 @@ def self.from_json(json_object:) expo = Profiles::Expo.from_json(json_object: expo) end facebook_psid = struct.facebookPSID - firebase_token = struct.firebaseToken + if parsed_json["firebaseToken"].nil? + firebase_token = nil + else + firebase_token = parsed_json["firebaseToken"].to_json + firebase_token = Profiles::UserProfileFirebaseToken.from_json(json_object: firebase_token) + end if parsed_json["intercom"].nil? intercom = nil else @@ -264,7 +270,7 @@ def self.validate_raw(obj:) Profiles::Discord.validate_raw(obj: obj.discord) Profiles::Expo.validate_raw(obj: obj.expo) obj.facebook_psid.is_a?(String) != false || raise("Passed value for field obj.facebook_psid is not the expected type, validation failed.") - obj.firebase_token.is_a?(String) != false || raise("Passed value for field obj.firebase_token is not the expected type, validation failed.") + Profiles::UserProfileFirebaseToken.validate_raw(obj: obj.firebase_token) Profiles::Intercom.validate_raw(obj: obj.intercom) Profiles::Slack.validate_raw(obj: obj.slack) Profiles::MsTeams.validate_raw(obj: obj.ms_teams) diff --git a/lib/courier/profiles/types/user_profile_firebase_token.rb b/lib/courier/profiles/types/user_profile_firebase_token.rb new file mode 100644 index 0000000..f309314 --- /dev/null +++ b/lib/courier/profiles/types/user_profile_firebase_token.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require "json" + +module Courier + class Profiles + class UserProfileFirebaseToken + # Deserialize a JSON object to an instance of UserProfileFirebaseToken + # + # @param json_object [JSON] + # @return [Profiles::UserProfileFirebaseToken] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") + return json_object + rescue StandardError + # noop + end + begin + struct.is_a?(Array) != false || raise("Passed value for field struct is not the expected type, validation failed.") + return json_object + rescue StandardError + # noop + end + struct + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Array) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end + end +end diff --git a/lib/courier/profiles/types/user_profile_patch.rb b/lib/courier/profiles/types/user_profile_patch.rb new file mode 100644 index 0000000..e946f3e --- /dev/null +++ b/lib/courier/profiles/types/user_profile_patch.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +require "json" + +module Courier + class Profiles + class UserProfilePatch + attr_reader :op, :path, :value, :additional_properties + + # @param op [String] The operation to perform. + # @param path [String] The JSON path specifying the part of the profile to operate on. + # @param value [String] The value for the operation. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Profiles::UserProfilePatch] + def initialize(op:, path:, value:, additional_properties: nil) + # @type [String] The operation to perform. + @op = op + # @type [String] The JSON path specifying the part of the profile to operate on. + @path = path + # @type [String] The value for the operation. + @value = value + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of UserProfilePatch + # + # @param json_object [JSON] + # @return [Profiles::UserProfilePatch] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + JSON.parse(json_object) + op = struct.op + path = struct.path + value = struct.value + new(op: op, path: path, value: value, additional_properties: struct) + end + + # Serialize an instance of UserProfilePatch to a JSON object + # + # @return [JSON] + def to_json(*_args) + { "op": @op, "path": @path, "value": @value }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.op.is_a?(String) != false || raise("Passed value for field obj.op is not the expected type, validation failed.") + obj.path.is_a?(String) != false || raise("Passed value for field obj.path is not the expected type, validation failed.") + obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/courier/profiles/types/webhook_auth_mode.rb b/lib/courier/profiles/types/webhook_auth_mode.rb new file mode 100644 index 0000000..51643bd --- /dev/null +++ b/lib/courier/profiles/types/webhook_auth_mode.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Courier + class Profiles + class WebhookAuthMode + NONE = "none" + BASIC = "basic" + BEARER = "bearer" + end + end +end diff --git a/lib/courier/profiles/types/webhook_authentication.rb b/lib/courier/profiles/types/webhook_authentication.rb new file mode 100644 index 0000000..8bf2b99 --- /dev/null +++ b/lib/courier/profiles/types/webhook_authentication.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require_relative "webhook_auth_mode" +require "json" + +module Courier + class Profiles + class WebhookAuthentication + attr_reader :mode, :username, :password, :token, :additional_properties + + # @param mode [Profiles::WebhookAuthMode] The authentication mode to use. Defaults to 'none' if not specified. + # @param username [String] Username for basic authentication. + # @param password [String] Password for basic authentication. + # @param token [String] Token for bearer authentication. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Profiles::WebhookAuthentication] + def initialize(mode:, username: nil, password: nil, token: nil, additional_properties: nil) + # @type [Profiles::WebhookAuthMode] The authentication mode to use. Defaults to 'none' if not specified. + @mode = mode + # @type [String] Username for basic authentication. + @username = username + # @type [String] Password for basic authentication. + @password = password + # @type [String] Token for bearer authentication. + @token = token + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of WebhookAuthentication + # + # @param json_object [JSON] + # @return [Profiles::WebhookAuthentication] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + JSON.parse(json_object) + mode = struct.mode + username = struct.username + password = struct.password + token = struct.token + new(mode: mode, username: username, password: password, token: token, additional_properties: struct) + end + + # Serialize an instance of WebhookAuthentication to a JSON object + # + # @return [JSON] + def to_json(*_args) + { "mode": @mode, "username": @username, "password": @password, "token": @token }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.mode.is_a?(Profiles::WebhookAuthMode) != false || raise("Passed value for field obj.mode is not the expected type, validation failed.") + obj.username&.is_a?(String) != false || raise("Passed value for field obj.username is not the expected type, validation failed.") + obj.password&.is_a?(String) != false || raise("Passed value for field obj.password is not the expected type, validation failed.") + obj.token&.is_a?(String) != false || raise("Passed value for field obj.token is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/courier/profiles/types/webhook_method.rb b/lib/courier/profiles/types/webhook_method.rb new file mode 100644 index 0000000..21bf6dc --- /dev/null +++ b/lib/courier/profiles/types/webhook_method.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Courier + class Profiles + class WebhookMethod + POST = "POST" + PUT = "PUT" + end + end +end diff --git a/lib/courier/profiles/types/webhook_profile.rb b/lib/courier/profiles/types/webhook_profile.rb new file mode 100644 index 0000000..aa437be --- /dev/null +++ b/lib/courier/profiles/types/webhook_profile.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +require_relative "webhook_method" +require_relative "webhook_authentication" +require_relative "webhook_profile_type" +require "json" + +module Courier + class Profiles + class WebhookProfile + attr_reader :url, :method, :headers, :authentication, :profile, :additional_properties + + # @param url [String] The URL to send the webhook request to. + # @param method [Profiles::WebhookMethod] The HTTP method to use for the webhook request. Defaults to POST if not specified. + # @param headers [Hash{String => String}] Custom headers to include in the webhook request. + # @param authentication [Profiles::WebhookAuthentication] Authentication configuration for the webhook request. + # @param profile [Profiles::WebhookProfileType] Specifies what profile information is included in the request payload. Defaults to 'limited' if not specified. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Profiles::WebhookProfile] + def initialize(url:, method: nil, headers: nil, authentication: nil, profile: nil, additional_properties: nil) + # @type [String] The URL to send the webhook request to. + @url = url + # @type [Profiles::WebhookMethod] The HTTP method to use for the webhook request. Defaults to POST if not specified. + @method = method + # @type [Hash{String => String}] Custom headers to include in the webhook request. + @headers = headers + # @type [Profiles::WebhookAuthentication] Authentication configuration for the webhook request. + @authentication = authentication + # @type [Profiles::WebhookProfileType] Specifies what profile information is included in the request payload. Defaults to 'limited' if not specified. + @profile = profile + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of WebhookProfile + # + # @param json_object [JSON] + # @return [Profiles::WebhookProfile] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + url = struct.url + method = struct.method + headers = struct.headers + if parsed_json["authentication"].nil? + authentication = nil + else + authentication = parsed_json["authentication"].to_json + authentication = Profiles::WebhookAuthentication.from_json(json_object: authentication) + end + profile = struct.profile + new(url: url, method: method, headers: headers, authentication: authentication, profile: profile, + additional_properties: struct) + end + + # Serialize an instance of WebhookProfile to a JSON object + # + # @return [JSON] + def to_json(*_args) + { + "url": @url, + "method": @method, + "headers": @headers, + "authentication": @authentication, + "profile": @profile + }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + obj.method&.is_a?(Profiles::WebhookMethod) != false || raise("Passed value for field obj.method is not the expected type, validation failed.") + obj.headers&.is_a?(Hash) != false || raise("Passed value for field obj.headers is not the expected type, validation failed.") + obj.authentication.nil? || Profiles::WebhookAuthentication.validate_raw(obj: obj.authentication) + obj.profile&.is_a?(Profiles::WebhookProfileType) != false || raise("Passed value for field obj.profile is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/courier/profiles/types/webhook_profile_type.rb b/lib/courier/profiles/types/webhook_profile_type.rb new file mode 100644 index 0000000..e33ac98 --- /dev/null +++ b/lib/courier/profiles/types/webhook_profile_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Courier + class Profiles + class WebhookProfileType + LIMITED = "limited" + EXPANDED = "expanded" + end + end +end diff --git a/lib/trycourier/send/types/attachment.rb b/lib/courier/send/types/attachment.rb similarity index 100% rename from lib/trycourier/send/types/attachment.rb rename to lib/courier/send/types/attachment.rb diff --git a/lib/trycourier/send/types/audience_filter.rb b/lib/courier/send/types/audience_filter.rb similarity index 100% rename from lib/trycourier/send/types/audience_filter.rb rename to lib/courier/send/types/audience_filter.rb diff --git a/lib/trycourier/send/types/audience_recipient.rb b/lib/courier/send/types/audience_recipient.rb similarity index 100% rename from lib/trycourier/send/types/audience_recipient.rb rename to lib/courier/send/types/audience_recipient.rb diff --git a/lib/trycourier/send/types/base_message.rb b/lib/courier/send/types/base_message.rb similarity index 80% rename from lib/trycourier/send/types/base_message.rb rename to lib/courier/send/types/base_message.rb index 8b0a275..d936e6d 100644 --- a/lib/trycourier/send/types/base_message.rb +++ b/lib/courier/send/types/base_message.rb @@ -4,6 +4,7 @@ require_relative "message_channels" require_relative "message_context" require_relative "message_metadata" +require_relative "message_preferences" require_relative "message_providers" require_relative "routing" require_relative "timeout" @@ -14,8 +15,8 @@ module Courier class Send class BaseMessage - attr_reader :data, :brand_id, :channels, :context, :metadata, :providers, :routing, :timeout, :delay, :expiry, - :additional_properties + attr_reader :data, :brand_id, :channels, :context, :metadata, :preferences, :providers, :routing, :timeout, + :delay, :expiry, :additional_properties # @param data [Send::MESSAGE_DATA] An arbitrary object that includes any data you want to pass to the message. # The data will populate the corresponding template or elements variables. @@ -23,16 +24,17 @@ class BaseMessage # @param channels [Send::MESSAGE_CHANNELS] "Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." # @param context [Send::MessageContext] Context to load with this recipient. Will override any context set on message.context. # @param metadata [Send::MessageMetadata] Metadata such as utm tracking attached with the notification through this channel. + # @param preferences [Send::MessagePreferences] # @param providers [Send::MESSAGE_PROVIDERS] An object whose keys are valid provider identifiers which map to an object. # @param routing [Send::Routing] # @param timeout [Send::Timeout] Time in ms to attempt the channel before failing over to the next available channel. - # @param delay [Send::Delay] Defines the time to wait before delivering the message. + # @param delay [Send::Delay] Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) (e.g., 'Mo-Fr 08:00-18:00pm') # @param expiry [Send::Expiry] "Expiry allows you to set an absolute or relative time in which a message expires. # Note: This is only valid for the Courier Inbox channel as of 12-08-2022." # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Send::BaseMessage] - def initialize(data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, providers: nil, - routing: nil, timeout: nil, delay: nil, expiry: nil, additional_properties: nil) + def initialize(data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, preferences: nil, + providers: nil, routing: nil, timeout: nil, delay: nil, expiry: nil, additional_properties: nil) # @type [Send::MESSAGE_DATA] An arbitrary object that includes any data you want to pass to the message. # The data will populate the corresponding template or elements variables. @data = data @@ -44,13 +46,15 @@ def initialize(data: nil, brand_id: nil, channels: nil, context: nil, metadata: @context = context # @type [Send::MessageMetadata] Metadata such as utm tracking attached with the notification through this channel. @metadata = metadata + # @type [Send::MessagePreferences] + @preferences = preferences # @type [Send::MESSAGE_PROVIDERS] An object whose keys are valid provider identifiers which map to an object. @providers = providers # @type [Send::Routing] @routing = routing # @type [Send::Timeout] Time in ms to attempt the channel before failing over to the next available channel. @timeout = timeout - # @type [Send::Delay] Defines the time to wait before delivering the message. + # @type [Send::Delay] Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) (e.g., 'Mo-Fr 08:00-18:00pm') @delay = delay # @type [Send::Expiry] "Expiry allows you to set an absolute or relative time in which a message expires. # Note: This is only valid for the Courier Inbox channel as of 12-08-2022." @@ -81,6 +85,12 @@ def self.from_json(json_object:) metadata = parsed_json["metadata"].to_json metadata = Send::MessageMetadata.from_json(json_object: metadata) end + if parsed_json["preferences"].nil? + preferences = nil + else + preferences = parsed_json["preferences"].to_json + preferences = Send::MessagePreferences.from_json(json_object: preferences) + end providers = struct.providers if parsed_json["routing"].nil? routing = nil @@ -107,7 +117,7 @@ def self.from_json(json_object:) expiry = Send::Expiry.from_json(json_object: expiry) end new(data: data, brand_id: brand_id, channels: channels, context: context, metadata: metadata, - providers: providers, routing: routing, timeout: timeout, delay: delay, expiry: expiry, additional_properties: struct) + preferences: preferences, providers: providers, routing: routing, timeout: timeout, delay: delay, expiry: expiry, additional_properties: struct) end # Serialize an instance of BaseMessage to a JSON object @@ -120,6 +130,7 @@ def to_json(*_args) "channels": @channels, "context": @context, "metadata": @metadata, + "preferences": @preferences, "providers": @providers, "routing": @routing, "timeout": @timeout, @@ -138,6 +149,7 @@ def self.validate_raw(obj:) obj.channels&.is_a?(Hash) != false || raise("Passed value for field obj.channels is not the expected type, validation failed.") obj.context.nil? || Send::MessageContext.validate_raw(obj: obj.context) obj.metadata.nil? || Send::MessageMetadata.validate_raw(obj: obj.metadata) + obj.preferences.nil? || Send::MessagePreferences.validate_raw(obj: obj.preferences) obj.providers&.is_a?(Hash) != false || raise("Passed value for field obj.providers is not the expected type, validation failed.") obj.routing.nil? || Send::Routing.validate_raw(obj: obj.routing) obj.timeout.nil? || Send::Timeout.validate_raw(obj: obj.timeout) diff --git a/lib/courier/send/types/base_message_send_to.rb b/lib/courier/send/types/base_message_send_to.rb new file mode 100644 index 0000000..57407ea --- /dev/null +++ b/lib/courier/send/types/base_message_send_to.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +require_relative "message_recipient" +require "json" + +module Courier + class Send + class BaseMessageSendTo + attr_reader :to, :additional_properties + + # @param to [Send::MessageRecipient] The recipient or a list of recipients of the message + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Send::BaseMessageSendTo] + def initialize(to: nil, additional_properties: nil) + # @type [Send::MessageRecipient] The recipient or a list of recipients of the message + @to = to + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of BaseMessageSendTo + # + # @param json_object [JSON] + # @return [Send::BaseMessageSendTo] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + if parsed_json["to"].nil? + to = nil + else + to = parsed_json["to"].to_json + to = Send::MessageRecipient.from_json(json_object: to) + end + new(to: to, additional_properties: struct) + end + + # Serialize an instance of BaseMessageSendTo to a JSON object + # + # @return [JSON] + def to_json(*_args) + { "to": @to }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.to.nil? || Send::MessageRecipient.validate_raw(obj: obj.to) + end + end + end +end diff --git a/lib/trycourier/send/types/base_social_presence.rb b/lib/courier/send/types/base_social_presence.rb similarity index 100% rename from lib/trycourier/send/types/base_social_presence.rb rename to lib/courier/send/types/base_social_presence.rb diff --git a/lib/trycourier/send/types/brand_settings_email.rb b/lib/courier/send/types/brand_settings_email.rb similarity index 100% rename from lib/trycourier/send/types/brand_settings_email.rb rename to lib/courier/send/types/brand_settings_email.rb diff --git a/lib/trycourier/send/types/brand_settings_in_app.rb b/lib/courier/send/types/brand_settings_in_app.rb similarity index 100% rename from lib/trycourier/send/types/brand_settings_in_app.rb rename to lib/courier/send/types/brand_settings_in_app.rb diff --git a/lib/trycourier/send/types/brand_settings_social_presence.rb b/lib/courier/send/types/brand_settings_social_presence.rb similarity index 100% rename from lib/trycourier/send/types/brand_settings_social_presence.rb rename to lib/courier/send/types/brand_settings_social_presence.rb diff --git a/lib/trycourier/send/types/brand_template.rb b/lib/courier/send/types/brand_template.rb similarity index 100% rename from lib/trycourier/send/types/brand_template.rb rename to lib/courier/send/types/brand_template.rb diff --git a/lib/trycourier/send/types/brand_template_override.rb b/lib/courier/send/types/brand_template_override.rb similarity index 100% rename from lib/trycourier/send/types/brand_template_override.rb rename to lib/courier/send/types/brand_template_override.rb diff --git a/lib/trycourier/send/types/channel.rb b/lib/courier/send/types/channel.rb similarity index 94% rename from lib/trycourier/send/types/channel.rb rename to lib/courier/send/types/channel.rb index c06c98b..f3f7f86 100644 --- a/lib/trycourier/send/types/channel.rb +++ b/lib/courier/send/types/channel.rb @@ -2,7 +2,6 @@ require_relative "routing_method" require_relative "timeouts" -require_relative "override" require_relative "channel_metadata" require "json" @@ -22,7 +21,7 @@ class Channel # be sent through the channel. Has access to the data and profile object. # For example, `data.name === profile.name` # @param timeouts [Send::Timeouts] - # @param override [Send::Override] Channel specific overrides. + # @param override [Hash{String => String}] Channel specific overrides. # @param metadata [Send::ChannelMetadata] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Send::Channel] @@ -44,7 +43,7 @@ def initialize(brand_id: nil, providers: nil, routing_method: nil, if_: nil, tim @if_ = if_ # @type [Send::Timeouts] @timeouts = timeouts - # @type [Send::Override] Channel specific overrides. + # @type [Hash{String => String}] Channel specific overrides. @override = override # @type [Send::ChannelMetadata] @metadata = metadata @@ -105,7 +104,7 @@ def self.validate_raw(obj:) obj.routing_method&.is_a?(Send::RoutingMethod) != false || raise("Passed value for field obj.routing_method is not the expected type, validation failed.") obj.if_&.is_a?(String) != false || raise("Passed value for field obj.if_ is not the expected type, validation failed.") obj.timeouts.nil? || Send::Timeouts.validate_raw(obj: obj.timeouts) - obj.override&.is_a?(Send::Override) != false || raise("Passed value for field obj.override is not the expected type, validation failed.") + obj.override&.is_a?(Hash) != false || raise("Passed value for field obj.override is not the expected type, validation failed.") obj.metadata.nil? || Send::ChannelMetadata.validate_raw(obj: obj.metadata) end end diff --git a/lib/trycourier/send/types/channel_metadata.rb b/lib/courier/send/types/channel_metadata.rb similarity index 100% rename from lib/trycourier/send/types/channel_metadata.rb rename to lib/courier/send/types/channel_metadata.rb diff --git a/lib/trycourier/send/types/channel_source.rb b/lib/courier/send/types/channel_source.rb similarity index 100% rename from lib/trycourier/send/types/channel_source.rb rename to lib/courier/send/types/channel_source.rb diff --git a/lib/trycourier/send/types/content.rb b/lib/courier/send/types/content.rb similarity index 100% rename from lib/trycourier/send/types/content.rb rename to lib/courier/send/types/content.rb diff --git a/lib/trycourier/send/types/content_message.rb b/lib/courier/send/types/content_message.rb similarity index 80% rename from lib/trycourier/send/types/content_message.rb rename to lib/courier/send/types/content_message.rb index 7537d24..d333760 100644 --- a/lib/trycourier/send/types/content_message.rb +++ b/lib/courier/send/types/content_message.rb @@ -1,16 +1,17 @@ # frozen_string_literal: true require_relative "content" -require_relative "message_recipient" require_relative "message_data" require_relative "message_channels" require_relative "message_context" require_relative "message_metadata" +require_relative "message_preferences" require_relative "message_providers" require_relative "routing" require_relative "timeout" require_relative "delay" require_relative "expiry" +require_relative "message_recipient" require "json" module Courier @@ -18,33 +19,32 @@ class Send # The message property has the following primary top-level properties. They define the destination and content of the message. # Additional advanced configuration fields [are defined below](https://www.courier.com/docs/reference/send/message/#other-message-properties). class ContentMessage - attr_reader :content, :to, :data, :brand_id, :channels, :context, :metadata, :providers, :routing, :timeout, - :delay, :expiry, :additional_properties + attr_reader :content, :data, :brand_id, :channels, :context, :metadata, :preferences, :providers, :routing, + :timeout, :delay, :expiry, :to, :additional_properties # @param content [Send::Content] Describes the content of the message in a way that will work for email, push, # chat, or any channel. Either this or template must be specified. - # @param to [Send::MessageRecipient] The recipient or a list of recipients of the message # @param data [Send::MESSAGE_DATA] An arbitrary object that includes any data you want to pass to the message. # The data will populate the corresponding template or elements variables. # @param brand_id [String] # @param channels [Send::MESSAGE_CHANNELS] "Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." # @param context [Send::MessageContext] Context to load with this recipient. Will override any context set on message.context. # @param metadata [Send::MessageMetadata] Metadata such as utm tracking attached with the notification through this channel. + # @param preferences [Send::MessagePreferences] # @param providers [Send::MESSAGE_PROVIDERS] An object whose keys are valid provider identifiers which map to an object. # @param routing [Send::Routing] # @param timeout [Send::Timeout] Time in ms to attempt the channel before failing over to the next available channel. - # @param delay [Send::Delay] Defines the time to wait before delivering the message. + # @param delay [Send::Delay] Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) (e.g., 'Mo-Fr 08:00-18:00pm') # @param expiry [Send::Expiry] "Expiry allows you to set an absolute or relative time in which a message expires. # Note: This is only valid for the Courier Inbox channel as of 12-08-2022." + # @param to [Send::MessageRecipient] The recipient or a list of recipients of the message # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Send::ContentMessage] - def initialize(content:, to:, data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, - providers: nil, routing: nil, timeout: nil, delay: nil, expiry: nil, additional_properties: nil) + def initialize(content:, data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, preferences: nil, + providers: nil, routing: nil, timeout: nil, delay: nil, expiry: nil, to: nil, additional_properties: nil) # @type [Send::Content] Describes the content of the message in a way that will work for email, push, # chat, or any channel. Either this or template must be specified. @content = content - # @type [Send::MessageRecipient] The recipient or a list of recipients of the message - @to = to # @type [Send::MESSAGE_DATA] An arbitrary object that includes any data you want to pass to the message. # The data will populate the corresponding template or elements variables. @data = data @@ -56,17 +56,21 @@ def initialize(content:, to:, data: nil, brand_id: nil, channels: nil, context: @context = context # @type [Send::MessageMetadata] Metadata such as utm tracking attached with the notification through this channel. @metadata = metadata + # @type [Send::MessagePreferences] + @preferences = preferences # @type [Send::MESSAGE_PROVIDERS] An object whose keys are valid provider identifiers which map to an object. @providers = providers # @type [Send::Routing] @routing = routing # @type [Send::Timeout] Time in ms to attempt the channel before failing over to the next available channel. @timeout = timeout - # @type [Send::Delay] Defines the time to wait before delivering the message. + # @type [Send::Delay] Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) (e.g., 'Mo-Fr 08:00-18:00pm') @delay = delay # @type [Send::Expiry] "Expiry allows you to set an absolute or relative time in which a message expires. # Note: This is only valid for the Courier Inbox channel as of 12-08-2022." @expiry = expiry + # @type [Send::MessageRecipient] The recipient or a list of recipients of the message + @to = to # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end @@ -84,12 +88,6 @@ def self.from_json(json_object:) content = parsed_json["content"].to_json content = Send::Content.from_json(json_object: content) end - if parsed_json["to"].nil? - to = nil - else - to = parsed_json["to"].to_json - to = Send::MessageRecipient.from_json(json_object: to) - end data = struct.data brand_id = struct.brand_id channels = struct.channels @@ -105,6 +103,12 @@ def self.from_json(json_object:) metadata = parsed_json["metadata"].to_json metadata = Send::MessageMetadata.from_json(json_object: metadata) end + if parsed_json["preferences"].nil? + preferences = nil + else + preferences = parsed_json["preferences"].to_json + preferences = Send::MessagePreferences.from_json(json_object: preferences) + end providers = struct.providers if parsed_json["routing"].nil? routing = nil @@ -130,8 +134,14 @@ def self.from_json(json_object:) expiry = parsed_json["expiry"].to_json expiry = Send::Expiry.from_json(json_object: expiry) end - new(content: content, to: to, data: data, brand_id: brand_id, channels: channels, context: context, - metadata: metadata, providers: providers, routing: routing, timeout: timeout, delay: delay, expiry: expiry, additional_properties: struct) + if parsed_json["to"].nil? + to = nil + else + to = parsed_json["to"].to_json + to = Send::MessageRecipient.from_json(json_object: to) + end + new(content: content, data: data, brand_id: brand_id, channels: channels, context: context, metadata: metadata, + preferences: preferences, providers: providers, routing: routing, timeout: timeout, delay: delay, expiry: expiry, to: to, additional_properties: struct) end # Serialize an instance of ContentMessage to a JSON object @@ -140,17 +150,18 @@ def self.from_json(json_object:) def to_json(*_args) { "content": @content, - "to": @to, "data": @data, "brand_id": @brand_id, "channels": @channels, "context": @context, "metadata": @metadata, + "preferences": @preferences, "providers": @providers, "routing": @routing, "timeout": @timeout, "delay": @delay, - "expiry": @expiry + "expiry": @expiry, + "to": @to }.to_json end @@ -160,17 +171,18 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) Send::Content.validate_raw(obj: obj.content) - Send::MessageRecipient.validate_raw(obj: obj.to) obj.data&.is_a?(Hash) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") obj.brand_id&.is_a?(String) != false || raise("Passed value for field obj.brand_id is not the expected type, validation failed.") obj.channels&.is_a?(Hash) != false || raise("Passed value for field obj.channels is not the expected type, validation failed.") obj.context.nil? || Send::MessageContext.validate_raw(obj: obj.context) obj.metadata.nil? || Send::MessageMetadata.validate_raw(obj: obj.metadata) + obj.preferences.nil? || Send::MessagePreferences.validate_raw(obj: obj.preferences) obj.providers&.is_a?(Hash) != false || raise("Passed value for field obj.providers is not the expected type, validation failed.") obj.routing.nil? || Send::Routing.validate_raw(obj: obj.routing) obj.timeout.nil? || Send::Timeout.validate_raw(obj: obj.timeout) obj.delay.nil? || Send::Delay.validate_raw(obj: obj.delay) obj.expiry.nil? || Send::Expiry.validate_raw(obj: obj.expiry) + obj.to.nil? || Send::MessageRecipient.validate_raw(obj: obj.to) end end end diff --git a/lib/trycourier/send/types/criteria.rb b/lib/courier/send/types/criteria.rb similarity index 100% rename from lib/trycourier/send/types/criteria.rb rename to lib/courier/send/types/criteria.rb diff --git a/lib/trycourier/send/types/delay.rb b/lib/courier/send/types/delay.rb similarity index 52% rename from lib/trycourier/send/types/delay.rb rename to lib/courier/send/types/delay.rb index d560413..c4b593d 100644 --- a/lib/trycourier/send/types/delay.rb +++ b/lib/courier/send/types/delay.rb @@ -5,14 +5,17 @@ module Courier class Send class Delay - attr_reader :duration, :additional_properties + attr_reader :duration, :until_, :additional_properties # @param duration [Integer] The duration of the delay in milliseconds. + # @param until_ [String] An ISO 8601 timestamp that specifies when it should be delivered or an OpenStreetMap opening_hours-like format that specifies the [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) (e.g., 'Mo-Fr 08:00-18:00pm') # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Send::Delay] - def initialize(duration:, additional_properties: nil) + def initialize(duration: nil, until_: nil, additional_properties: nil) # @type [Integer] The duration of the delay in milliseconds. @duration = duration + # @type [String] An ISO 8601 timestamp that specifies when it should be delivered or an OpenStreetMap opening_hours-like format that specifies the [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) (e.g., 'Mo-Fr 08:00-18:00pm') + @until_ = until_ # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end @@ -25,14 +28,15 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) JSON.parse(json_object) duration = struct.duration - new(duration: duration, additional_properties: struct) + until_ = struct.until + new(duration: duration, until_: until_, additional_properties: struct) end # Serialize an instance of Delay to a JSON object # # @return [JSON] def to_json(*_args) - { "duration": @duration }.to_json + { "duration": @duration, "until": @until_ }.to_json end # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. @@ -40,7 +44,8 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - obj.duration.is_a?(Integer) != false || raise("Passed value for field obj.duration is not the expected type, validation failed.") + obj.duration&.is_a?(Integer) != false || raise("Passed value for field obj.duration is not the expected type, validation failed.") + obj.until_&.is_a?(String) != false || raise("Passed value for field obj.until_ is not the expected type, validation failed.") end end end diff --git a/lib/trycourier/send/types/elemental_action_node.rb b/lib/courier/send/types/elemental_action_node.rb similarity index 100% rename from lib/trycourier/send/types/elemental_action_node.rb rename to lib/courier/send/types/elemental_action_node.rb diff --git a/lib/trycourier/send/types/elemental_base_node.rb b/lib/courier/send/types/elemental_base_node.rb similarity index 100% rename from lib/trycourier/send/types/elemental_base_node.rb rename to lib/courier/send/types/elemental_base_node.rb diff --git a/lib/trycourier/send/types/elemental_channel_node.rb b/lib/courier/send/types/elemental_channel_node.rb similarity index 100% rename from lib/trycourier/send/types/elemental_channel_node.rb rename to lib/courier/send/types/elemental_channel_node.rb diff --git a/lib/trycourier/send/types/elemental_content.rb b/lib/courier/send/types/elemental_content.rb similarity index 100% rename from lib/trycourier/send/types/elemental_content.rb rename to lib/courier/send/types/elemental_content.rb diff --git a/lib/trycourier/send/types/elemental_content_sugar.rb b/lib/courier/send/types/elemental_content_sugar.rb similarity index 100% rename from lib/trycourier/send/types/elemental_content_sugar.rb rename to lib/courier/send/types/elemental_content_sugar.rb diff --git a/lib/trycourier/send/types/elemental_divider_node.rb b/lib/courier/send/types/elemental_divider_node.rb similarity index 100% rename from lib/trycourier/send/types/elemental_divider_node.rb rename to lib/courier/send/types/elemental_divider_node.rb diff --git a/lib/trycourier/send/types/elemental_group_node.rb b/lib/courier/send/types/elemental_group_node.rb similarity index 100% rename from lib/trycourier/send/types/elemental_group_node.rb rename to lib/courier/send/types/elemental_group_node.rb diff --git a/lib/trycourier/send/types/elemental_image_node.rb b/lib/courier/send/types/elemental_image_node.rb similarity index 100% rename from lib/trycourier/send/types/elemental_image_node.rb rename to lib/courier/send/types/elemental_image_node.rb diff --git a/lib/trycourier/send/types/elemental_meta_node.rb b/lib/courier/send/types/elemental_meta_node.rb similarity index 100% rename from lib/trycourier/send/types/elemental_meta_node.rb rename to lib/courier/send/types/elemental_meta_node.rb diff --git a/lib/trycourier/send/types/elemental_node.rb b/lib/courier/send/types/elemental_node.rb similarity index 100% rename from lib/trycourier/send/types/elemental_node.rb rename to lib/courier/send/types/elemental_node.rb diff --git a/lib/trycourier/send/types/elemental_quote_node.rb b/lib/courier/send/types/elemental_quote_node.rb similarity index 100% rename from lib/trycourier/send/types/elemental_quote_node.rb rename to lib/courier/send/types/elemental_quote_node.rb diff --git a/lib/trycourier/send/types/elemental_text_node.rb b/lib/courier/send/types/elemental_text_node.rb similarity index 100% rename from lib/trycourier/send/types/elemental_text_node.rb rename to lib/courier/send/types/elemental_text_node.rb diff --git a/lib/trycourier/send/types/email_footer.rb b/lib/courier/send/types/email_footer.rb similarity index 100% rename from lib/trycourier/send/types/email_footer.rb rename to lib/courier/send/types/email_footer.rb diff --git a/lib/trycourier/send/types/email_head.rb b/lib/courier/send/types/email_head.rb similarity index 100% rename from lib/trycourier/send/types/email_head.rb rename to lib/courier/send/types/email_head.rb diff --git a/lib/trycourier/send/types/email_header.rb b/lib/courier/send/types/email_header.rb similarity index 100% rename from lib/trycourier/send/types/email_header.rb rename to lib/courier/send/types/email_header.rb diff --git a/lib/trycourier/send/types/expires_in_type.rb b/lib/courier/send/types/expires_in_type.rb similarity index 100% rename from lib/trycourier/send/types/expires_in_type.rb rename to lib/courier/send/types/expires_in_type.rb diff --git a/lib/trycourier/send/types/expiry.rb b/lib/courier/send/types/expiry.rb similarity index 100% rename from lib/trycourier/send/types/expiry.rb rename to lib/courier/send/types/expiry.rb diff --git a/lib/trycourier/send/types/i_action_button_style.rb b/lib/courier/send/types/i_action_button_style.rb similarity index 100% rename from lib/trycourier/send/types/i_action_button_style.rb rename to lib/courier/send/types/i_action_button_style.rb diff --git a/lib/trycourier/send/types/i_alignment.rb b/lib/courier/send/types/i_alignment.rb similarity index 100% rename from lib/trycourier/send/types/i_alignment.rb rename to lib/courier/send/types/i_alignment.rb diff --git a/lib/trycourier/send/types/i_preferences.rb b/lib/courier/send/types/i_preferences.rb similarity index 100% rename from lib/trycourier/send/types/i_preferences.rb rename to lib/courier/send/types/i_preferences.rb diff --git a/lib/trycourier/send/types/i_profile_preferences.rb b/lib/courier/send/types/i_profile_preferences.rb similarity index 100% rename from lib/trycourier/send/types/i_profile_preferences.rb rename to lib/courier/send/types/i_profile_preferences.rb diff --git a/lib/trycourier/send/types/icons.rb b/lib/courier/send/types/icons.rb similarity index 100% rename from lib/trycourier/send/types/icons.rb rename to lib/courier/send/types/icons.rb diff --git a/lib/trycourier/send/types/in_app_placement.rb b/lib/courier/send/types/in_app_placement.rb similarity index 100% rename from lib/trycourier/send/types/in_app_placement.rb rename to lib/courier/send/types/in_app_placement.rb diff --git a/lib/trycourier/send/types/invalid_list_pattern_recipient.rb b/lib/courier/send/types/invalid_list_pattern_recipient.rb similarity index 100% rename from lib/trycourier/send/types/invalid_list_pattern_recipient.rb rename to lib/courier/send/types/invalid_list_pattern_recipient.rb diff --git a/lib/trycourier/send/types/invalid_list_recipient.rb b/lib/courier/send/types/invalid_list_recipient.rb similarity index 100% rename from lib/trycourier/send/types/invalid_list_recipient.rb rename to lib/courier/send/types/invalid_list_recipient.rb diff --git a/lib/trycourier/send/types/invalid_user_recipient.rb b/lib/courier/send/types/invalid_user_recipient.rb similarity index 100% rename from lib/trycourier/send/types/invalid_user_recipient.rb rename to lib/courier/send/types/invalid_user_recipient.rb diff --git a/lib/trycourier/send/types/list_filter.rb b/lib/courier/send/types/list_filter.rb similarity index 100% rename from lib/trycourier/send/types/list_filter.rb rename to lib/courier/send/types/list_filter.rb diff --git a/lib/trycourier/send/types/list_pattern_recipient.rb b/lib/courier/send/types/list_pattern_recipient.rb similarity index 100% rename from lib/trycourier/send/types/list_pattern_recipient.rb rename to lib/courier/send/types/list_pattern_recipient.rb diff --git a/lib/trycourier/send/types/list_pattern_recipient_type.rb b/lib/courier/send/types/list_pattern_recipient_type.rb similarity index 100% rename from lib/trycourier/send/types/list_pattern_recipient_type.rb rename to lib/courier/send/types/list_pattern_recipient_type.rb diff --git a/lib/trycourier/send/types/list_recipient.rb b/lib/courier/send/types/list_recipient.rb similarity index 100% rename from lib/trycourier/send/types/list_recipient.rb rename to lib/courier/send/types/list_recipient.rb diff --git a/lib/trycourier/send/types/list_recipient_type.rb b/lib/courier/send/types/list_recipient_type.rb similarity index 100% rename from lib/trycourier/send/types/list_recipient_type.rb rename to lib/courier/send/types/list_recipient_type.rb diff --git a/lib/trycourier/send/types/locale.rb b/lib/courier/send/types/locale.rb similarity index 100% rename from lib/trycourier/send/types/locale.rb rename to lib/courier/send/types/locale.rb diff --git a/lib/trycourier/send/types/locales.rb b/lib/courier/send/types/locales.rb similarity index 100% rename from lib/trycourier/send/types/locales.rb rename to lib/courier/send/types/locales.rb diff --git a/lib/trycourier/send/types/logo.rb b/lib/courier/send/types/logo.rb similarity index 100% rename from lib/trycourier/send/types/logo.rb rename to lib/courier/send/types/logo.rb diff --git a/lib/trycourier/send/types/message.rb b/lib/courier/send/types/message.rb similarity index 100% rename from lib/trycourier/send/types/message.rb rename to lib/courier/send/types/message.rb diff --git a/lib/trycourier/send/types/message_channels.rb b/lib/courier/send/types/message_channels.rb similarity index 100% rename from lib/trycourier/send/types/message_channels.rb rename to lib/courier/send/types/message_channels.rb diff --git a/lib/trycourier/send/types/message_context.rb b/lib/courier/send/types/message_context.rb similarity index 100% rename from lib/trycourier/send/types/message_context.rb rename to lib/courier/send/types/message_context.rb diff --git a/lib/trycourier/send/types/message_data.rb b/lib/courier/send/types/message_data.rb similarity index 100% rename from lib/trycourier/send/types/message_data.rb rename to lib/courier/send/types/message_data.rb diff --git a/lib/trycourier/send/types/message_metadata.rb b/lib/courier/send/types/message_metadata.rb similarity index 100% rename from lib/trycourier/send/types/message_metadata.rb rename to lib/courier/send/types/message_metadata.rb diff --git a/lib/courier/send/types/message_preferences.rb b/lib/courier/send/types/message_preferences.rb new file mode 100644 index 0000000..870b854 --- /dev/null +++ b/lib/courier/send/types/message_preferences.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require "json" + +module Courier + class Send + class MessagePreferences + attr_reader :subscription_topic_id, :additional_properties + + # @param subscription_topic_id [String] The ID of the subscription topic you want to apply to the message. If this is a templated message, it will override the subscription topic if already associated + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Send::MessagePreferences] + def initialize(subscription_topic_id:, additional_properties: nil) + # @type [String] The ID of the subscription topic you want to apply to the message. If this is a templated message, it will override the subscription topic if already associated + @subscription_topic_id = subscription_topic_id + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of MessagePreferences + # + # @param json_object [JSON] + # @return [Send::MessagePreferences] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + JSON.parse(json_object) + subscription_topic_id = struct.subscription_topic_id + new(subscription_topic_id: subscription_topic_id, additional_properties: struct) + end + + # Serialize an instance of MessagePreferences to a JSON object + # + # @return [JSON] + def to_json(*_args) + { "subscription_topic_id": @subscription_topic_id }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.subscription_topic_id.is_a?(String) != false || raise("Passed value for field obj.subscription_topic_id is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/trycourier/send/types/message_providers.rb b/lib/courier/send/types/message_providers.rb similarity index 100% rename from lib/trycourier/send/types/message_providers.rb rename to lib/courier/send/types/message_providers.rb diff --git a/lib/trycourier/send/types/message_providers_type.rb b/lib/courier/send/types/message_providers_type.rb similarity index 100% rename from lib/trycourier/send/types/message_providers_type.rb rename to lib/courier/send/types/message_providers_type.rb diff --git a/lib/trycourier/send/types/message_recipient.rb b/lib/courier/send/types/message_recipient.rb similarity index 100% rename from lib/trycourier/send/types/message_recipient.rb rename to lib/courier/send/types/message_recipient.rb diff --git a/lib/trycourier/send/types/metadata.rb b/lib/courier/send/types/metadata.rb similarity index 100% rename from lib/trycourier/send/types/metadata.rb rename to lib/courier/send/types/metadata.rb diff --git a/lib/trycourier/send/types/ms_teams_recipient.rb b/lib/courier/send/types/ms_teams_recipient.rb similarity index 100% rename from lib/trycourier/send/types/ms_teams_recipient.rb rename to lib/courier/send/types/ms_teams_recipient.rb diff --git a/lib/courier/send/types/pagerduty_recipient.rb b/lib/courier/send/types/pagerduty_recipient.rb new file mode 100644 index 0000000..5a65e33 --- /dev/null +++ b/lib/courier/send/types/pagerduty_recipient.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +require_relative "../../profiles/types/pagerduty" +require "json" + +module Courier + class Send + class PagerdutyRecipient + attr_reader :pagerduty, :additional_properties + + # @param pagerduty [Profiles::Pagerduty] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Send::PagerdutyRecipient] + def initialize(pagerduty:, additional_properties: nil) + # @type [Profiles::Pagerduty] + @pagerduty = pagerduty + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of PagerdutyRecipient + # + # @param json_object [JSON] + # @return [Send::PagerdutyRecipient] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + if parsed_json["pagerduty"].nil? + pagerduty = nil + else + pagerduty = parsed_json["pagerduty"].to_json + pagerduty = Profiles::Pagerduty.from_json(json_object: pagerduty) + end + new(pagerduty: pagerduty, additional_properties: struct) + end + + # Serialize an instance of PagerdutyRecipient to a JSON object + # + # @return [JSON] + def to_json(*_args) + { "pagerduty": @pagerduty }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Profiles::Pagerduty.validate_raw(obj: obj.pagerduty) + end + end + end +end diff --git a/lib/trycourier/send/types/preference.rb b/lib/courier/send/types/preference.rb similarity index 100% rename from lib/trycourier/send/types/preference.rb rename to lib/courier/send/types/preference.rb diff --git a/lib/trycourier/send/types/preferences.rb b/lib/courier/send/types/preferences.rb similarity index 100% rename from lib/trycourier/send/types/preferences.rb rename to lib/courier/send/types/preferences.rb diff --git a/lib/trycourier/send/types/recipient.rb b/lib/courier/send/types/recipient.rb similarity index 71% rename from lib/trycourier/send/types/recipient.rb rename to lib/courier/send/types/recipient.rb index aa9c429..f00e623 100644 --- a/lib/trycourier/send/types/recipient.rb +++ b/lib/courier/send/types/recipient.rb @@ -7,6 +7,8 @@ require_relative "user_recipient" require_relative "slack_recipient" require_relative "ms_teams_recipient" +require_relative "pagerduty_recipient" +require_relative "webhook_recipient" module Courier class Send @@ -53,6 +55,24 @@ def self.from_json(json_object:) rescue StandardError # noop end + begin + struct.is_a?(Hash) != false || raise("Passed value for field struct is not the expected type, validation failed.") + return json_object + rescue StandardError + # noop + end + begin + Send::PagerdutyRecipient.validate_raw(obj: struct) + return Send::PagerdutyRecipient.from_json(json_object: json_object) + rescue StandardError + # noop + end + begin + Send::WebhookRecipient.validate_raw(obj: struct) + return Send::WebhookRecipient.from_json(json_object: json_object) + rescue StandardError + # noop + end struct end @@ -91,6 +111,21 @@ def self.validate_raw(obj:) rescue StandardError # noop end + begin + return obj.is_a?(Hash) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return Send::PagerdutyRecipient.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Send::WebhookRecipient.validate_raw(obj: obj) + rescue StandardError + # noop + end raise("Passed value matched no type within the union, validation failed.") end end diff --git a/lib/courier/send/types/recipient_data.rb b/lib/courier/send/types/recipient_data.rb new file mode 100644 index 0000000..af148e0 --- /dev/null +++ b/lib/courier/send/types/recipient_data.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Courier + class Send + RECIPIENT_DATA = Hash + end +end diff --git a/lib/trycourier/send/types/routing.rb b/lib/courier/send/types/routing.rb similarity index 100% rename from lib/trycourier/send/types/routing.rb rename to lib/courier/send/types/routing.rb diff --git a/lib/trycourier/send/types/routing_channel.rb b/lib/courier/send/types/routing_channel.rb similarity index 100% rename from lib/trycourier/send/types/routing_channel.rb rename to lib/courier/send/types/routing_channel.rb diff --git a/lib/trycourier/send/types/routing_method.rb b/lib/courier/send/types/routing_method.rb similarity index 100% rename from lib/trycourier/send/types/routing_method.rb rename to lib/courier/send/types/routing_method.rb diff --git a/lib/trycourier/send/types/routing_strategy_channel.rb b/lib/courier/send/types/routing_strategy_channel.rb similarity index 100% rename from lib/trycourier/send/types/routing_strategy_channel.rb rename to lib/courier/send/types/routing_strategy_channel.rb diff --git a/lib/trycourier/send/types/routing_strategy_provider.rb b/lib/courier/send/types/routing_strategy_provider.rb similarity index 100% rename from lib/trycourier/send/types/routing_strategy_provider.rb rename to lib/courier/send/types/routing_strategy_provider.rb diff --git a/lib/trycourier/send/types/rule_type.rb b/lib/courier/send/types/rule_type.rb similarity index 100% rename from lib/trycourier/send/types/rule_type.rb rename to lib/courier/send/types/rule_type.rb diff --git a/lib/trycourier/send/types/slack_recipient.rb b/lib/courier/send/types/slack_recipient.rb similarity index 100% rename from lib/trycourier/send/types/slack_recipient.rb rename to lib/courier/send/types/slack_recipient.rb diff --git a/lib/trycourier/send/types/template_message.rb b/lib/courier/send/types/template_message.rb similarity index 79% rename from lib/trycourier/send/types/template_message.rb rename to lib/courier/send/types/template_message.rb index 1dd7d44..886769a 100644 --- a/lib/trycourier/send/types/template_message.rb +++ b/lib/courier/send/types/template_message.rb @@ -1,47 +1,47 @@ # frozen_string_literal: true -require_relative "message_recipient" require_relative "message_data" require_relative "message_channels" require_relative "message_context" require_relative "message_metadata" +require_relative "message_preferences" require_relative "message_providers" require_relative "routing" require_relative "timeout" require_relative "delay" require_relative "expiry" +require_relative "message_recipient" require "json" module Courier class Send class TemplateMessage - attr_reader :template, :to, :data, :brand_id, :channels, :context, :metadata, :providers, :routing, :timeout, - :delay, :expiry, :additional_properties + attr_reader :template, :data, :brand_id, :channels, :context, :metadata, :preferences, :providers, :routing, + :timeout, :delay, :expiry, :to, :additional_properties # @param template [String] The id of the notification template to be rendered and sent to the recipient(s). # This field or the content field must be supplied. - # @param to [Send::MessageRecipient] The recipient or a list of recipients of the message # @param data [Send::MESSAGE_DATA] An arbitrary object that includes any data you want to pass to the message. # The data will populate the corresponding template or elements variables. # @param brand_id [String] # @param channels [Send::MESSAGE_CHANNELS] "Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." # @param context [Send::MessageContext] Context to load with this recipient. Will override any context set on message.context. # @param metadata [Send::MessageMetadata] Metadata such as utm tracking attached with the notification through this channel. + # @param preferences [Send::MessagePreferences] # @param providers [Send::MESSAGE_PROVIDERS] An object whose keys are valid provider identifiers which map to an object. # @param routing [Send::Routing] # @param timeout [Send::Timeout] Time in ms to attempt the channel before failing over to the next available channel. - # @param delay [Send::Delay] Defines the time to wait before delivering the message. + # @param delay [Send::Delay] Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) (e.g., 'Mo-Fr 08:00-18:00pm') # @param expiry [Send::Expiry] "Expiry allows you to set an absolute or relative time in which a message expires. # Note: This is only valid for the Courier Inbox channel as of 12-08-2022." + # @param to [Send::MessageRecipient] The recipient or a list of recipients of the message # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Send::TemplateMessage] - def initialize(template:, to:, data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, - providers: nil, routing: nil, timeout: nil, delay: nil, expiry: nil, additional_properties: nil) + def initialize(template:, data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, preferences: nil, + providers: nil, routing: nil, timeout: nil, delay: nil, expiry: nil, to: nil, additional_properties: nil) # @type [String] The id of the notification template to be rendered and sent to the recipient(s). # This field or the content field must be supplied. @template = template - # @type [Send::MessageRecipient] The recipient or a list of recipients of the message - @to = to # @type [Send::MESSAGE_DATA] An arbitrary object that includes any data you want to pass to the message. # The data will populate the corresponding template or elements variables. @data = data @@ -53,17 +53,21 @@ def initialize(template:, to:, data: nil, brand_id: nil, channels: nil, context: @context = context # @type [Send::MessageMetadata] Metadata such as utm tracking attached with the notification through this channel. @metadata = metadata + # @type [Send::MessagePreferences] + @preferences = preferences # @type [Send::MESSAGE_PROVIDERS] An object whose keys are valid provider identifiers which map to an object. @providers = providers # @type [Send::Routing] @routing = routing # @type [Send::Timeout] Time in ms to attempt the channel before failing over to the next available channel. @timeout = timeout - # @type [Send::Delay] Defines the time to wait before delivering the message. + # @type [Send::Delay] Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) (e.g., 'Mo-Fr 08:00-18:00pm') @delay = delay # @type [Send::Expiry] "Expiry allows you to set an absolute or relative time in which a message expires. # Note: This is only valid for the Courier Inbox channel as of 12-08-2022." @expiry = expiry + # @type [Send::MessageRecipient] The recipient or a list of recipients of the message + @to = to # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end @@ -76,12 +80,6 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) template = struct.template - if parsed_json["to"].nil? - to = nil - else - to = parsed_json["to"].to_json - to = Send::MessageRecipient.from_json(json_object: to) - end data = struct.data brand_id = struct.brand_id channels = struct.channels @@ -97,6 +95,12 @@ def self.from_json(json_object:) metadata = parsed_json["metadata"].to_json metadata = Send::MessageMetadata.from_json(json_object: metadata) end + if parsed_json["preferences"].nil? + preferences = nil + else + preferences = parsed_json["preferences"].to_json + preferences = Send::MessagePreferences.from_json(json_object: preferences) + end providers = struct.providers if parsed_json["routing"].nil? routing = nil @@ -122,8 +126,14 @@ def self.from_json(json_object:) expiry = parsed_json["expiry"].to_json expiry = Send::Expiry.from_json(json_object: expiry) end - new(template: template, to: to, data: data, brand_id: brand_id, channels: channels, context: context, - metadata: metadata, providers: providers, routing: routing, timeout: timeout, delay: delay, expiry: expiry, additional_properties: struct) + if parsed_json["to"].nil? + to = nil + else + to = parsed_json["to"].to_json + to = Send::MessageRecipient.from_json(json_object: to) + end + new(template: template, data: data, brand_id: brand_id, channels: channels, context: context, + metadata: metadata, preferences: preferences, providers: providers, routing: routing, timeout: timeout, delay: delay, expiry: expiry, to: to, additional_properties: struct) end # Serialize an instance of TemplateMessage to a JSON object @@ -132,17 +142,18 @@ def self.from_json(json_object:) def to_json(*_args) { "template": @template, - "to": @to, "data": @data, "brand_id": @brand_id, "channels": @channels, "context": @context, "metadata": @metadata, + "preferences": @preferences, "providers": @providers, "routing": @routing, "timeout": @timeout, "delay": @delay, - "expiry": @expiry + "expiry": @expiry, + "to": @to }.to_json end @@ -152,17 +163,18 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.template.is_a?(String) != false || raise("Passed value for field obj.template is not the expected type, validation failed.") - Send::MessageRecipient.validate_raw(obj: obj.to) obj.data&.is_a?(Hash) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") obj.brand_id&.is_a?(String) != false || raise("Passed value for field obj.brand_id is not the expected type, validation failed.") obj.channels&.is_a?(Hash) != false || raise("Passed value for field obj.channels is not the expected type, validation failed.") obj.context.nil? || Send::MessageContext.validate_raw(obj: obj.context) obj.metadata.nil? || Send::MessageMetadata.validate_raw(obj: obj.metadata) + obj.preferences.nil? || Send::MessagePreferences.validate_raw(obj: obj.preferences) obj.providers&.is_a?(Hash) != false || raise("Passed value for field obj.providers is not the expected type, validation failed.") obj.routing.nil? || Send::Routing.validate_raw(obj: obj.routing) obj.timeout.nil? || Send::Timeout.validate_raw(obj: obj.timeout) obj.delay.nil? || Send::Delay.validate_raw(obj: obj.delay) obj.expiry.nil? || Send::Expiry.validate_raw(obj: obj.expiry) + obj.to.nil? || Send::MessageRecipient.validate_raw(obj: obj.to) end end end diff --git a/lib/trycourier/send/types/text_align.rb b/lib/courier/send/types/text_align.rb similarity index 100% rename from lib/trycourier/send/types/text_align.rb rename to lib/courier/send/types/text_align.rb diff --git a/lib/trycourier/send/types/text_style.rb b/lib/courier/send/types/text_style.rb similarity index 100% rename from lib/trycourier/send/types/text_style.rb rename to lib/courier/send/types/text_style.rb diff --git a/lib/trycourier/send/types/timeout.rb b/lib/courier/send/types/timeout.rb similarity index 100% rename from lib/trycourier/send/types/timeout.rb rename to lib/courier/send/types/timeout.rb diff --git a/lib/trycourier/send/types/timeouts.rb b/lib/courier/send/types/timeouts.rb similarity index 100% rename from lib/trycourier/send/types/timeouts.rb rename to lib/courier/send/types/timeouts.rb diff --git a/lib/trycourier/send/types/tracking_override.rb b/lib/courier/send/types/tracking_override.rb similarity index 100% rename from lib/trycourier/send/types/tracking_override.rb rename to lib/courier/send/types/tracking_override.rb diff --git a/lib/trycourier/send/types/user_recipient.rb b/lib/courier/send/types/user_recipient.rb similarity index 100% rename from lib/trycourier/send/types/user_recipient.rb rename to lib/courier/send/types/user_recipient.rb diff --git a/lib/trycourier/send/types/user_recipient_type.rb b/lib/courier/send/types/user_recipient_type.rb similarity index 100% rename from lib/trycourier/send/types/user_recipient_type.rb rename to lib/courier/send/types/user_recipient_type.rb diff --git a/lib/trycourier/send/types/utm.rb b/lib/courier/send/types/utm.rb similarity index 100% rename from lib/trycourier/send/types/utm.rb rename to lib/courier/send/types/utm.rb diff --git a/lib/courier/send/types/webhook_recipient.rb b/lib/courier/send/types/webhook_recipient.rb new file mode 100644 index 0000000..18d5a3b --- /dev/null +++ b/lib/courier/send/types/webhook_recipient.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +require_relative "../../profiles/types/webhook_profile" +require "json" + +module Courier + class Send + class WebhookRecipient + attr_reader :webhook, :additional_properties + + # @param webhook [Profiles::WebhookProfile] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Send::WebhookRecipient] + def initialize(webhook:, additional_properties: nil) + # @type [Profiles::WebhookProfile] + @webhook = webhook + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of WebhookRecipient + # + # @param json_object [JSON] + # @return [Send::WebhookRecipient] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + if parsed_json["webhook"].nil? + webhook = nil + else + webhook = parsed_json["webhook"].to_json + webhook = Profiles::WebhookProfile.from_json(json_object: webhook) + end + new(webhook: webhook, additional_properties: struct) + end + + # Serialize an instance of WebhookRecipient to a JSON object + # + # @return [JSON] + def to_json(*_args) + { "webhook": @webhook }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Profiles::WebhookProfile.validate_raw(obj: obj.webhook) + end + end + end +end diff --git a/lib/trycourier/send/types/widget_background.rb b/lib/courier/send/types/widget_background.rb similarity index 100% rename from lib/trycourier/send/types/widget_background.rb rename to lib/courier/send/types/widget_background.rb diff --git a/lib/trycourier/templates/client.rb b/lib/courier/templates/client.rb similarity index 100% rename from lib/trycourier/templates/client.rb rename to lib/courier/templates/client.rb diff --git a/lib/trycourier/templates/types/channel_identifier.rb b/lib/courier/templates/types/channel_identifier.rb similarity index 100% rename from lib/trycourier/templates/types/channel_identifier.rb rename to lib/courier/templates/types/channel_identifier.rb diff --git a/lib/trycourier/templates/types/list_templates_response.rb b/lib/courier/templates/types/list_templates_response.rb similarity index 100% rename from lib/trycourier/templates/types/list_templates_response.rb rename to lib/courier/templates/types/list_templates_response.rb diff --git a/lib/trycourier/templates/types/notification_templates.rb b/lib/courier/templates/types/notification_templates.rb similarity index 77% rename from lib/trycourier/templates/types/notification_templates.rb rename to lib/courier/templates/types/notification_templates.rb index df74099..8394d5b 100644 --- a/lib/trycourier/templates/types/notification_templates.rb +++ b/lib/courier/templates/types/notification_templates.rb @@ -9,16 +9,16 @@ class Templates class NotificationTemplates attr_reader :created_at, :id, :routing, :tags, :title, :updated_at, :additional_properties - # @param created_at [Integer] A UTC timestamp at which notification was created. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970). + # @param created_at [Long] A UTC timestamp at which notification was created. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970). # @param id [String] A unique identifier associated with the notification. # @param routing [Templates::RoutingStrategy] Routing strategy used by this notification. # @param tags [Array] A list of tags attached to the notification. # @param title [String] The title of the notification. - # @param updated_at [Integer] A UTC timestamp at which notification was updated. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970). + # @param updated_at [Long] A UTC timestamp at which notification was updated. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970). # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Templates::NotificationTemplates] def initialize(created_at:, id:, routing:, tags:, title:, updated_at:, additional_properties: nil) - # @type [Integer] A UTC timestamp at which notification was created. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970). + # @type [Long] A UTC timestamp at which notification was created. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970). @created_at = created_at # @type [String] A unique identifier associated with the notification. @id = id @@ -28,7 +28,7 @@ def initialize(created_at:, id:, routing:, tags:, title:, updated_at:, additiona @tags = tags # @type [String] The title of the notification. @title = title - # @type [Integer] A UTC timestamp at which notification was updated. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970). + # @type [Long] A UTC timestamp at which notification was updated. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970). @updated_at = updated_at # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties @@ -78,12 +78,12 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - obj.created_at.is_a?(Integer) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.created_at.is_a?(Long) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") Templates::RoutingStrategy.validate_raw(obj: obj.routing) obj.tags.is_a?(Array) != false || raise("Passed value for field obj.tags is not the expected type, validation failed.") obj.title.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") - obj.updated_at.is_a?(Integer) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.updated_at.is_a?(Long) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") end end end diff --git a/lib/trycourier/templates/types/routing_strategy.rb b/lib/courier/templates/types/routing_strategy.rb similarity index 100% rename from lib/trycourier/templates/types/routing_strategy.rb rename to lib/courier/templates/types/routing_strategy.rb diff --git a/lib/trycourier/templates/types/routing_strategy_method.rb b/lib/courier/templates/types/routing_strategy_method.rb similarity index 100% rename from lib/trycourier/templates/types/routing_strategy_method.rb rename to lib/courier/templates/types/routing_strategy_method.rb diff --git a/lib/trycourier/templates/types/tag.rb b/lib/courier/templates/types/tag.rb similarity index 100% rename from lib/trycourier/templates/types/tag.rb rename to lib/courier/templates/types/tag.rb diff --git a/lib/trycourier/templates/types/tag_data.rb b/lib/courier/templates/types/tag_data.rb similarity index 100% rename from lib/trycourier/templates/types/tag_data.rb rename to lib/courier/templates/types/tag_data.rb diff --git a/lib/trycourier/tenants/client.rb b/lib/courier/tenants/client.rb similarity index 69% rename from lib/trycourier/tenants/client.rb rename to lib/courier/tenants/client.rb index ab7ec83..49ba667 100644 --- a/lib/trycourier/tenants/client.rb +++ b/lib/courier/tenants/client.rb @@ -2,10 +2,10 @@ require_relative "../../requests" require_relative "types/default_preferences" -require_relative "types/template_property" require_relative "types/tenant" require_relative "types/tenant_list_response" require_relative "types/list_users_for_tenant_response" +require_relative "types/subscription_topic_new" require "async" module Courier @@ -24,7 +24,7 @@ def initialize(request_client:) # @param parent_tenant_id [String] Tenant's parent id (if any). # @param default_preferences [Hash] Defines the preferences used for the tenant when the user hasn't specified their own.Request of type Tenants::DefaultPreferences, as a Hash # * :items (Array) - # @param properties [Array] Arbitrary properties accessible to a template. + # @param properties [Hash{String => String}] Arbitrary properties accessible to a template. # @param user_profile [Hash{String => String}] A user profile object merged with user profile on send. # @param brand_id [String] Brand to be used for the account when one is not specified by the send call. # @param request_options [RequestOptions] @@ -66,12 +66,13 @@ def get(tenant_id:, request_options: nil) Tenants::Tenant.from_json(json_object: response.body) end - # @param limit [Integer] The number of accousnts to return + # @param parent_tenant_id [String] Filter the list of tenants by parent_id + # @param limit [Integer] The number of tenants to return # (defaults to 20, maximum value of 100) # @param cursor [String] Continue the pagination with the next cursor # @param request_options [RequestOptions] # @return [Tenants::TenantListResponse] - def list(limit: nil, cursor: nil, request_options: nil) + def list(parent_tenant_id: nil, limit: nil, cursor: nil, request_options: nil) response = @request_client.conn.get("/tenants") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? unless request_options&.authorization_token.nil? @@ -81,6 +82,7 @@ def list(limit: nil, cursor: nil, request_options: nil) req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact req.params = { **(request_options&.additional_query_parameters || {}), + "parent_tenant_id": parent_tenant_id, "limit": limit, "cursor": cursor }.compact @@ -124,6 +126,41 @@ def get_users_by_tenant(tenant_id:, limit: nil, cursor: nil, request_options: ni end Tenants::ListUsersForTenantResponse.from_json(json_object: response.body) end + + # @param tenant_id [String] Id of the tenant to update the default preferences for. + # @param topic_id [String] Id fo the susbcription topic you want to have a default preference for. + # @param request [Hash] Request of type Tenants::SubscriptionTopicNew, as a Hash + # * :status (Tenants::SubscriptionTopicStatus) + # * :has_custom_routing (Boolean) + # * :custom_routing (Array) + # @param request_options [RequestOptions] + # @return [Void] + def create_or_replace_default_preferences_for_topic(tenant_id:, topic_id:, request:, request_options: nil) + @request_client.conn.put("/tenants/#{tenant_id}/default_preferences/items/#{topic_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + unless request_options&.authorization_token.nil? + req.headers["Authorization"] = + request_options.authorization_token + end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + end + + # @param tenant_id [String] Id of the tenant to update the default preferences for. + # @param topic_id [String] Id fo the susbcription topic you want to have a default preference for. + # @param request_options [RequestOptions] + # @return [Void] + def remove_default_preferences_for_topic(tenant_id:, topic_id:, request_options: nil) + @request_client.conn.delete("/tenants/#{tenant_id}/default_preferences/items/#{topic_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + unless request_options&.authorization_token.nil? + req.headers["Authorization"] = + request_options.authorization_token + end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + end + end end class AsyncTenantsClient @@ -141,7 +178,7 @@ def initialize(request_client:) # @param parent_tenant_id [String] Tenant's parent id (if any). # @param default_preferences [Hash] Defines the preferences used for the tenant when the user hasn't specified their own.Request of type Tenants::DefaultPreferences, as a Hash # * :items (Array) - # @param properties [Array] Arbitrary properties accessible to a template. + # @param properties [Hash{String => String}] Arbitrary properties accessible to a template. # @param user_profile [Hash{String => String}] A user profile object merged with user profile on send. # @param brand_id [String] Brand to be used for the account when one is not specified by the send call. # @param request_options [RequestOptions] @@ -187,12 +224,13 @@ def get(tenant_id:, request_options: nil) end end - # @param limit [Integer] The number of accousnts to return + # @param parent_tenant_id [String] Filter the list of tenants by parent_id + # @param limit [Integer] The number of tenants to return # (defaults to 20, maximum value of 100) # @param cursor [String] Continue the pagination with the next cursor # @param request_options [RequestOptions] # @return [Tenants::TenantListResponse] - def list(limit: nil, cursor: nil, request_options: nil) + def list(parent_tenant_id: nil, limit: nil, cursor: nil, request_options: nil) Async do response = @request_client.conn.get("/tenants") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? @@ -203,6 +241,7 @@ def list(limit: nil, cursor: nil, request_options: nil) req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact req.params = { **(request_options&.additional_query_parameters || {}), + "parent_tenant_id": parent_tenant_id, "limit": limit, "cursor": cursor }.compact @@ -251,5 +290,44 @@ def get_users_by_tenant(tenant_id:, limit: nil, cursor: nil, request_options: ni Tenants::ListUsersForTenantResponse.from_json(json_object: response.body) end end + + # @param tenant_id [String] Id of the tenant to update the default preferences for. + # @param topic_id [String] Id fo the susbcription topic you want to have a default preference for. + # @param request [Hash] Request of type Tenants::SubscriptionTopicNew, as a Hash + # * :status (Tenants::SubscriptionTopicStatus) + # * :has_custom_routing (Boolean) + # * :custom_routing (Array) + # @param request_options [RequestOptions] + # @return [Void] + def create_or_replace_default_preferences_for_topic(tenant_id:, topic_id:, request:, request_options: nil) + Async do + @request_client.conn.put("/tenants/#{tenant_id}/default_preferences/items/#{topic_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + unless request_options&.authorization_token.nil? + req.headers["Authorization"] = + request_options.authorization_token + end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + end + end + end + + # @param tenant_id [String] Id of the tenant to update the default preferences for. + # @param topic_id [String] Id fo the susbcription topic you want to have a default preference for. + # @param request_options [RequestOptions] + # @return [Void] + def remove_default_preferences_for_topic(tenant_id:, topic_id:, request_options: nil) + Async do + @request_client.conn.delete("/tenants/#{tenant_id}/default_preferences/items/#{topic_id}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + unless request_options&.authorization_token.nil? + req.headers["Authorization"] = + request_options.authorization_token + end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + end + end + end end end diff --git a/lib/trycourier/tenants/types/default_preferences.rb b/lib/courier/tenants/types/default_preferences.rb similarity index 89% rename from lib/trycourier/tenants/types/default_preferences.rb rename to lib/courier/tenants/types/default_preferences.rb index 1c47057..f68ced2 100644 --- a/lib/trycourier/tenants/types/default_preferences.rb +++ b/lib/courier/tenants/types/default_preferences.rb @@ -11,7 +11,7 @@ class DefaultPreferences # @param items [Array] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Tenants::DefaultPreferences] - def initialize(items:, additional_properties: nil) + def initialize(items: nil, additional_properties: nil) # @type [Array] @items = items # @type [OpenStruct] Additional properties unmapped to the current class definition @@ -44,7 +44,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - obj.items.is_a?(Array) != false || raise("Passed value for field obj.items is not the expected type, validation failed.") + obj.items&.is_a?(Array) != false || raise("Passed value for field obj.items is not the expected type, validation failed.") end end end diff --git a/lib/trycourier/tenants/types/list_users_for_tenant_response.rb b/lib/courier/tenants/types/list_users_for_tenant_response.rb similarity index 100% rename from lib/trycourier/tenants/types/list_users_for_tenant_response.rb rename to lib/courier/tenants/types/list_users_for_tenant_response.rb diff --git a/lib/courier/tenants/types/subscription_topic.rb b/lib/courier/tenants/types/subscription_topic.rb new file mode 100644 index 0000000..c975335 --- /dev/null +++ b/lib/courier/tenants/types/subscription_topic.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +require_relative "subscription_topic_status" +require_relative "../../commons/types/channel_classification" +require "json" + +module Courier + class Tenants + class SubscriptionTopic + attr_reader :id, :status, :has_custom_routing, :custom_routing, :additional_properties + + # @param id [String] Topic ID + # @param status [Tenants::SubscriptionTopicStatus] + # @param has_custom_routing [Boolean] Override channel routing with custom preferences. This will override any template prefernces that are set, but a user can still customize their preferences + # @param custom_routing [Array] The default channels to send to this tenant when has_custom_routing is enabled + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Tenants::SubscriptionTopic] + def initialize(id:, status:, has_custom_routing: nil, custom_routing: nil, additional_properties: nil) + # @type [String] Topic ID + @id = id + # @type [Tenants::SubscriptionTopicStatus] + @status = status + # @type [Boolean] Override channel routing with custom preferences. This will override any template prefernces that are set, but a user can still customize their preferences + @has_custom_routing = has_custom_routing + # @type [Array] The default channels to send to this tenant when has_custom_routing is enabled + @custom_routing = custom_routing + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of SubscriptionTopic + # + # @param json_object [JSON] + # @return [Tenants::SubscriptionTopic] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + JSON.parse(json_object) + id = struct.id + status = struct.status + has_custom_routing = struct.has_custom_routing + custom_routing = struct.custom_routing + new(id: id, status: status, has_custom_routing: has_custom_routing, custom_routing: custom_routing, + additional_properties: struct) + end + + # Serialize an instance of SubscriptionTopic to a JSON object + # + # @return [JSON] + def to_json(*_args) + { + "id": @id, + "status": @status, + "has_custom_routing": @has_custom_routing, + "custom_routing": @custom_routing + }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.status.is_a?(Tenants::SubscriptionTopicStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.has_custom_routing&.is_a?(Boolean) != false || raise("Passed value for field obj.has_custom_routing is not the expected type, validation failed.") + obj.custom_routing&.is_a?(Array) != false || raise("Passed value for field obj.custom_routing is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/courier/tenants/types/subscription_topic_new.rb b/lib/courier/tenants/types/subscription_topic_new.rb new file mode 100644 index 0000000..78b4152 --- /dev/null +++ b/lib/courier/tenants/types/subscription_topic_new.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +require_relative "subscription_topic_status" +require_relative "../../commons/types/channel_classification" +require "json" + +module Courier + class Tenants + class SubscriptionTopicNew + attr_reader :status, :has_custom_routing, :custom_routing, :additional_properties + + # @param status [Tenants::SubscriptionTopicStatus] + # @param has_custom_routing [Boolean] Override channel routing with custom preferences. This will override any template prefernces that are set, but a user can still customize their preferences + # @param custom_routing [Array] The default channels to send to this tenant when has_custom_routing is enabled + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Tenants::SubscriptionTopicNew] + def initialize(status:, has_custom_routing: nil, custom_routing: nil, additional_properties: nil) + # @type [Tenants::SubscriptionTopicStatus] + @status = status + # @type [Boolean] Override channel routing with custom preferences. This will override any template prefernces that are set, but a user can still customize their preferences + @has_custom_routing = has_custom_routing + # @type [Array] The default channels to send to this tenant when has_custom_routing is enabled + @custom_routing = custom_routing + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of SubscriptionTopicNew + # + # @param json_object [JSON] + # @return [Tenants::SubscriptionTopicNew] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + JSON.parse(json_object) + status = struct.status + has_custom_routing = struct.has_custom_routing + custom_routing = struct.custom_routing + new(status: status, has_custom_routing: has_custom_routing, custom_routing: custom_routing, + additional_properties: struct) + end + + # Serialize an instance of SubscriptionTopicNew to a JSON object + # + # @return [JSON] + def to_json(*_args) + { "status": @status, "has_custom_routing": @has_custom_routing, "custom_routing": @custom_routing }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.status.is_a?(Tenants::SubscriptionTopicStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.has_custom_routing&.is_a?(Boolean) != false || raise("Passed value for field obj.has_custom_routing is not the expected type, validation failed.") + obj.custom_routing&.is_a?(Array) != false || raise("Passed value for field obj.custom_routing is not the expected type, validation failed.") + end + end + end +end diff --git a/lib/trycourier/tenants/types/subscription_topic_status.rb b/lib/courier/tenants/types/subscription_topic_status.rb similarity index 100% rename from lib/trycourier/tenants/types/subscription_topic_status.rb rename to lib/courier/tenants/types/subscription_topic_status.rb diff --git a/lib/trycourier/tenants/types/template_property.rb b/lib/courier/tenants/types/template_property.rb similarity index 100% rename from lib/trycourier/tenants/types/template_property.rb rename to lib/courier/tenants/types/template_property.rb diff --git a/lib/trycourier/tenants/types/tenant.rb b/lib/courier/tenants/types/tenant.rb similarity index 92% rename from lib/trycourier/tenants/types/tenant.rb rename to lib/courier/tenants/types/tenant.rb index 6944f0a..087f367 100644 --- a/lib/trycourier/tenants/types/tenant.rb +++ b/lib/courier/tenants/types/tenant.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require_relative "default_preferences" -require_relative "template_property" require "json" module Courier @@ -14,7 +13,7 @@ class Tenant # @param name [String] Name of the tenant. # @param parent_tenant_id [String] Tenant's parent id (if any). # @param default_preferences [Tenants::DefaultPreferences] Defines the preferences used for the account when the user hasn't specified their own. - # @param properties [Tenants::TEMPLATE_PROPERTY] Arbitrary properties accessible to a template. + # @param properties [Hash{String => String}] Arbitrary properties accessible to a template. # @param user_profile [Hash{String => String}] A user profile object merged with user profile on send. # @param brand_id [String] Brand to be used for the account when one is not specified by the send call. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition @@ -29,7 +28,7 @@ def initialize(id:, name:, parent_tenant_id: nil, default_preferences: nil, prop @parent_tenant_id = parent_tenant_id # @type [Tenants::DefaultPreferences] Defines the preferences used for the account when the user hasn't specified their own. @default_preferences = default_preferences - # @type [Tenants::TEMPLATE_PROPERTY] Arbitrary properties accessible to a template. + # @type [Hash{String => String}] Arbitrary properties accessible to a template. @properties = properties # @type [Hash{String => String}] A user profile object merged with user profile on send. @user_profile = user_profile @@ -86,7 +85,7 @@ def self.validate_raw(obj:) obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.parent_tenant_id&.is_a?(String) != false || raise("Passed value for field obj.parent_tenant_id is not the expected type, validation failed.") obj.default_preferences.nil? || Tenants::DefaultPreferences.validate_raw(obj: obj.default_preferences) - obj.properties&.is_a?(Object) != false || raise("Passed value for field obj.properties is not the expected type, validation failed.") + obj.properties&.is_a?(Hash) != false || raise("Passed value for field obj.properties is not the expected type, validation failed.") obj.user_profile&.is_a?(Hash) != false || raise("Passed value for field obj.user_profile is not the expected type, validation failed.") obj.brand_id&.is_a?(String) != false || raise("Passed value for field obj.brand_id is not the expected type, validation failed.") end diff --git a/lib/trycourier/tenants/types/tenant_list_response.rb b/lib/courier/tenants/types/tenant_list_response.rb similarity index 100% rename from lib/trycourier/tenants/types/tenant_list_response.rb rename to lib/courier/tenants/types/tenant_list_response.rb diff --git a/lib/trycourier/translations/client.rb b/lib/courier/translations/client.rb similarity index 100% rename from lib/trycourier/translations/client.rb rename to lib/courier/translations/client.rb diff --git a/lib/trycourier/types/send_message_response.rb b/lib/courier/types/send_message_response.rb similarity index 100% rename from lib/trycourier/types/send_message_response.rb rename to lib/courier/types/send_message_response.rb diff --git a/lib/trycourier/users/client.rb b/lib/courier/users/client.rb similarity index 100% rename from lib/trycourier/users/client.rb rename to lib/courier/users/client.rb diff --git a/lib/trycourier/users/preferences/client.rb b/lib/courier/users/preferences/client.rb similarity index 72% rename from lib/trycourier/users/preferences/client.rb rename to lib/courier/users/preferences/client.rb index 9bd0282..a4109df 100644 --- a/lib/trycourier/users/preferences/client.rb +++ b/lib/courier/users/preferences/client.rb @@ -3,8 +3,7 @@ require_relative "../../../requests" require_relative "types/user_preferences_list_response" require_relative "types/user_preferences_get_response" -require_relative "../../commons/types/preference_status" -require_relative "../../commons/types/channel_classification" +require_relative "types/topic_preference_update" require_relative "types/user_preferences_update_response" require "async" @@ -23,9 +22,10 @@ def initialize(request_client:) # Fetch all user preferences. # # @param user_id [String] A unique identifier associated with the user whose preferences you wish to retrieve. + # @param tenant_id [String] Query the preferences of a user for this specific tenant context. # @param request_options [RequestOptions] # @return [Users::Preferences::UserPreferencesListResponse] - def list(user_id:, request_options: nil) + def list(user_id:, tenant_id: nil, request_options: nil) response = @request_client.conn.get("/users/#{user_id}/preferences") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? unless request_options&.authorization_token.nil? @@ -33,6 +33,7 @@ def list(user_id:, request_options: nil) request_options.authorization_token end req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "tenant_id": tenant_id }.compact end Users::Preferences::UserPreferencesListResponse.from_json(json_object: response.body) end @@ -41,9 +42,10 @@ def list(user_id:, request_options: nil) # # @param user_id [String] A unique identifier associated with the user whose preferences you wish to retrieve. # @param topic_id [String] A unique identifier associated with a subscription topic. + # @param tenant_id [String] Query the preferences of a user for this specific tenant context. # @param request_options [RequestOptions] # @return [Users::Preferences::UserPreferencesGetResponse] - def get(user_id:, topic_id:, request_options: nil) + def get(user_id:, topic_id:, tenant_id: nil, request_options: nil) response = @request_client.conn.get("/users/#{user_id}/preferences/#{topic_id}") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? unless request_options&.authorization_token.nil? @@ -51,6 +53,7 @@ def get(user_id:, topic_id:, request_options: nil) request_options.authorization_token end req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "tenant_id": tenant_id }.compact end Users::Preferences::UserPreferencesGetResponse.from_json(json_object: response.body) end @@ -59,14 +62,14 @@ def get(user_id:, topic_id:, request_options: nil) # # @param user_id [String] A unique identifier associated with the user whose preferences you wish to retrieve. # @param topic_id [String] A unique identifier associated with a subscription topic. - # @param status [Commons::PreferenceStatus] - # @param custom_routing [Array] The Channels a user has chosen to receive notifications through for this topic - # @param default_status [Commons::PreferenceStatus] - # @param has_custom_routing [Boolean] + # @param tenant_id [String] Update the preferences of a user for this specific tenant context. + # @param topic [Hash] Request of type Users::Preferences::TopicPreferenceUpdate, as a Hash + # * :status (Commons::PreferenceStatus) + # * :custom_routing (Array) + # * :has_custom_routing (Boolean) # @param request_options [RequestOptions] # @return [Users::Preferences::UserPreferencesUpdateResponse] - def update(user_id:, topic_id:, status:, default_status:, custom_routing: nil, has_custom_routing: nil, - request_options: nil) + def update(user_id:, topic_id:, topic:, tenant_id: nil, request_options: nil) response = @request_client.conn.put("/users/#{user_id}/preferences/#{topic_id}") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? unless request_options&.authorization_token.nil? @@ -74,13 +77,8 @@ def update(user_id:, topic_id:, status:, default_status:, custom_routing: nil, h request_options.authorization_token end req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact - req.body = { - **(request_options&.additional_body_parameters || {}), - status: status, - custom_routing: custom_routing, - default_status: default_status, - has_custom_routing: has_custom_routing - }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "tenant_id": tenant_id }.compact + req.body = { **(request_options&.additional_body_parameters || {}), topic: topic }.compact end Users::Preferences::UserPreferencesUpdateResponse.from_json(json_object: response.body) end @@ -99,9 +97,10 @@ def initialize(request_client:) # Fetch all user preferences. # # @param user_id [String] A unique identifier associated with the user whose preferences you wish to retrieve. + # @param tenant_id [String] Query the preferences of a user for this specific tenant context. # @param request_options [RequestOptions] # @return [Users::Preferences::UserPreferencesListResponse] - def list(user_id:, request_options: nil) + def list(user_id:, tenant_id: nil, request_options: nil) Async do response = @request_client.conn.get("/users/#{user_id}/preferences") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? @@ -110,6 +109,7 @@ def list(user_id:, request_options: nil) request_options.authorization_token end req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "tenant_id": tenant_id }.compact end Users::Preferences::UserPreferencesListResponse.from_json(json_object: response.body) end @@ -119,9 +119,10 @@ def list(user_id:, request_options: nil) # # @param user_id [String] A unique identifier associated with the user whose preferences you wish to retrieve. # @param topic_id [String] A unique identifier associated with a subscription topic. + # @param tenant_id [String] Query the preferences of a user for this specific tenant context. # @param request_options [RequestOptions] # @return [Users::Preferences::UserPreferencesGetResponse] - def get(user_id:, topic_id:, request_options: nil) + def get(user_id:, topic_id:, tenant_id: nil, request_options: nil) Async do response = @request_client.conn.get("/users/#{user_id}/preferences/#{topic_id}") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? @@ -130,6 +131,7 @@ def get(user_id:, topic_id:, request_options: nil) request_options.authorization_token end req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "tenant_id": tenant_id }.compact end Users::Preferences::UserPreferencesGetResponse.from_json(json_object: response.body) end @@ -139,14 +141,14 @@ def get(user_id:, topic_id:, request_options: nil) # # @param user_id [String] A unique identifier associated with the user whose preferences you wish to retrieve. # @param topic_id [String] A unique identifier associated with a subscription topic. - # @param status [Commons::PreferenceStatus] - # @param custom_routing [Array] The Channels a user has chosen to receive notifications through for this topic - # @param default_status [Commons::PreferenceStatus] - # @param has_custom_routing [Boolean] + # @param tenant_id [String] Update the preferences of a user for this specific tenant context. + # @param topic [Hash] Request of type Users::Preferences::TopicPreferenceUpdate, as a Hash + # * :status (Commons::PreferenceStatus) + # * :custom_routing (Array) + # * :has_custom_routing (Boolean) # @param request_options [RequestOptions] # @return [Users::Preferences::UserPreferencesUpdateResponse] - def update(user_id:, topic_id:, status:, default_status:, custom_routing: nil, has_custom_routing: nil, - request_options: nil) + def update(user_id:, topic_id:, topic:, tenant_id: nil, request_options: nil) Async do response = @request_client.conn.put("/users/#{user_id}/preferences/#{topic_id}") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? @@ -155,13 +157,8 @@ def update(user_id:, topic_id:, status:, default_status:, custom_routing: nil, h request_options.authorization_token end req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact - req.body = { - **(request_options&.additional_body_parameters || {}), - status: status, - custom_routing: custom_routing, - default_status: default_status, - has_custom_routing: has_custom_routing - }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "tenant_id": tenant_id }.compact + req.body = { **(request_options&.additional_body_parameters || {}), topic: topic }.compact end Users::Preferences::UserPreferencesUpdateResponse.from_json(json_object: response.body) end diff --git a/lib/trycourier/users/preferences/types/topic_preference.rb b/lib/courier/users/preferences/types/topic_preference.rb similarity index 100% rename from lib/trycourier/users/preferences/types/topic_preference.rb rename to lib/courier/users/preferences/types/topic_preference.rb diff --git a/lib/courier/users/preferences/types/topic_preference_update.rb b/lib/courier/users/preferences/types/topic_preference_update.rb new file mode 100644 index 0000000..0b5a3b0 --- /dev/null +++ b/lib/courier/users/preferences/types/topic_preference_update.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require_relative "../../../commons/types/preference_status" +require_relative "../../../commons/types/channel_classification" +require "json" + +module Courier + module Users + class Preferences + class TopicPreferenceUpdate + attr_reader :status, :custom_routing, :has_custom_routing, :additional_properties + + # @param status [Commons::PreferenceStatus] + # @param custom_routing [Array] The Channels a user has chosen to receive notifications through for this topic + # @param has_custom_routing [Boolean] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Users::Preferences::TopicPreferenceUpdate] + def initialize(status:, custom_routing: nil, has_custom_routing: nil, additional_properties: nil) + # @type [Commons::PreferenceStatus] + @status = status + # @type [Array] The Channels a user has chosen to receive notifications through for this topic + @custom_routing = custom_routing + # @type [Boolean] + @has_custom_routing = has_custom_routing + # @type [OpenStruct] Additional properties unmapped to the current class definition + @additional_properties = additional_properties + end + + # Deserialize a JSON object to an instance of TopicPreferenceUpdate + # + # @param json_object [JSON] + # @return [Users::Preferences::TopicPreferenceUpdate] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + JSON.parse(json_object) + status = struct.status + custom_routing = struct.custom_routing + has_custom_routing = struct.has_custom_routing + new(status: status, custom_routing: custom_routing, has_custom_routing: has_custom_routing, + additional_properties: struct) + end + + # Serialize an instance of TopicPreferenceUpdate to a JSON object + # + # @return [JSON] + def to_json(*_args) + { "status": @status, "custom_routing": @custom_routing, "has_custom_routing": @has_custom_routing }.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.status.is_a?(Commons::PreferenceStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.custom_routing&.is_a?(Array) != false || raise("Passed value for field obj.custom_routing is not the expected type, validation failed.") + obj.has_custom_routing&.is_a?(Boolean) != false || raise("Passed value for field obj.has_custom_routing is not the expected type, validation failed.") + end + end + end + end +end diff --git a/lib/trycourier/users/preferences/types/user_preferences_get_response.rb b/lib/courier/users/preferences/types/user_preferences_get_response.rb similarity index 100% rename from lib/trycourier/users/preferences/types/user_preferences_get_response.rb rename to lib/courier/users/preferences/types/user_preferences_get_response.rb diff --git a/lib/trycourier/users/preferences/types/user_preferences_list_response.rb b/lib/courier/users/preferences/types/user_preferences_list_response.rb similarity index 93% rename from lib/trycourier/users/preferences/types/user_preferences_list_response.rb rename to lib/courier/users/preferences/types/user_preferences_list_response.rb index 3e1af59..a76117d 100644 --- a/lib/trycourier/users/preferences/types/user_preferences_list_response.rb +++ b/lib/courier/users/preferences/types/user_preferences_list_response.rb @@ -10,12 +10,12 @@ class Preferences class UserPreferencesListResponse attr_reader :paging, :items, :additional_properties - # @param paging [Commons::Paging] + # @param paging [Commons::Paging] Deprecated - Paging not implemented on this endpoint # @param items [Array] The Preferences associated with the user_id. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Users::Preferences::UserPreferencesListResponse] def initialize(paging:, items:, additional_properties: nil) - # @type [Commons::Paging] + # @type [Commons::Paging] Deprecated - Paging not implemented on this endpoint @paging = paging # @type [Array] The Preferences associated with the user_id. @items = items diff --git a/lib/trycourier/users/preferences/types/user_preferences_update_response.rb b/lib/courier/users/preferences/types/user_preferences_update_response.rb similarity index 100% rename from lib/trycourier/users/preferences/types/user_preferences_update_response.rb rename to lib/courier/users/preferences/types/user_preferences_update_response.rb diff --git a/lib/trycourier/users/tenants/client.rb b/lib/courier/users/tenants/client.rb similarity index 93% rename from lib/trycourier/users/tenants/client.rb rename to lib/courier/users/tenants/client.rb index 31e4ebc..0384c4b 100644 --- a/lib/trycourier/users/tenants/client.rb +++ b/lib/courier/users/tenants/client.rb @@ -2,7 +2,6 @@ require_relative "../../../requests" require_relative "../../commons/types/user_tenant_association" -require_relative "types/add_user_to_single_tenants_params_profile" require_relative "types/list_tenants_for_user_response" require "async" @@ -52,15 +51,10 @@ def add_multple(user_id:, tenants:, request_options: nil) # # @param user_id [String] Id of the user to be added to the supplied tenant. # @param tenant_id [String] Id of the tenant the user should be added to. - # @param profile [Hash] Request of type Users::Tenants::AddUserToSingleTenantsParamsProfile, as a Hash - # * :title (String) - # * :email (String) - # * :phone_number (String) - # * :locale (String) - # * :additional_fields (Hash{String => String}) + # @param profile [Hash{String => String}] # @param request_options [RequestOptions] # @return [Void] - def add(user_id:, tenant_id:, profile:, request_options: nil) + def add(user_id:, tenant_id:, profile: nil, request_options: nil) @request_client.conn.put("/users/#{user_id}/tenants/#{tenant_id}") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? unless request_options&.authorization_token.nil? @@ -177,15 +171,10 @@ def add_multple(user_id:, tenants:, request_options: nil) # # @param user_id [String] Id of the user to be added to the supplied tenant. # @param tenant_id [String] Id of the tenant the user should be added to. - # @param profile [Hash] Request of type Users::Tenants::AddUserToSingleTenantsParamsProfile, as a Hash - # * :title (String) - # * :email (String) - # * :phone_number (String) - # * :locale (String) - # * :additional_fields (Hash{String => String}) + # @param profile [Hash{String => String}] # @param request_options [RequestOptions] # @return [Void] - def add(user_id:, tenant_id:, profile:, request_options: nil) + def add(user_id:, tenant_id:, profile: nil, request_options: nil) Async do @request_client.conn.put("/users/#{user_id}/tenants/#{tenant_id}") do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? diff --git a/lib/trycourier/users/tenants/types/add_user_to_single_tenants_params_profile.rb b/lib/courier/users/tenants/types/add_user_to_single_tenants_params_profile.rb similarity index 97% rename from lib/trycourier/users/tenants/types/add_user_to_single_tenants_params_profile.rb rename to lib/courier/users/tenants/types/add_user_to_single_tenants_params_profile.rb index b5d6a8f..18fa7a5 100644 --- a/lib/trycourier/users/tenants/types/add_user_to_single_tenants_params_profile.rb +++ b/lib/courier/users/tenants/types/add_user_to_single_tenants_params_profile.rb @@ -5,6 +5,7 @@ module Courier module Users class Tenants + # AddUserToSingleTenantsParamsProfile is no longer used for Add a User to a Single Tenant class AddUserToSingleTenantsParamsProfile attr_reader :title, :email, :phone_number, :locale, :additional_fields, :additional_properties diff --git a/lib/trycourier/users/tenants/types/list_tenants_for_user_response.rb b/lib/courier/users/tenants/types/list_tenants_for_user_response.rb similarity index 100% rename from lib/trycourier/users/tenants/types/list_tenants_for_user_response.rb rename to lib/courier/users/tenants/types/list_tenants_for_user_response.rb diff --git a/lib/trycourier/users/tokens/client.rb b/lib/courier/users/tokens/client.rb similarity index 88% rename from lib/trycourier/users/tokens/client.rb rename to lib/courier/users/tokens/client.rb index c3d6c24..da2475f 100644 --- a/lib/trycourier/users/tokens/client.rb +++ b/lib/courier/users/tokens/client.rb @@ -129,6 +129,21 @@ def list(user_id:, request_options: nil) Users::Tokens::UserToken.from_json(json_object: v) end end + + # @param user_id [String] The user's ID. This can be any uniquely identifiable string. + # @param token [String] The full token string. + # @param request_options [RequestOptions] + # @return [Void] + def delete(user_id:, token:, request_options: nil) + @request_client.conn.delete("/users/#{user_id}/tokens/#{token}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + unless request_options&.authorization_token.nil? + req.headers["Authorization"] = + request_options.authorization_token + end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + end + end end class AsyncTokensClient @@ -259,6 +274,23 @@ def list(user_id:, request_options: nil) end end end + + # @param user_id [String] The user's ID. This can be any uniquely identifiable string. + # @param token [String] The full token string. + # @param request_options [RequestOptions] + # @return [Void] + def delete(user_id:, token:, request_options: nil) + Async do + @request_client.conn.delete("/users/#{user_id}/tokens/#{token}") do |req| + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? + unless request_options&.authorization_token.nil? + req.headers["Authorization"] = + request_options.authorization_token + end + req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact + end + end + end end end end diff --git a/lib/trycourier/users/tokens/types/delete_user_token_opts.rb b/lib/courier/users/tokens/types/delete_user_token_opts.rb similarity index 100% rename from lib/trycourier/users/tokens/types/delete_user_token_opts.rb rename to lib/courier/users/tokens/types/delete_user_token_opts.rb diff --git a/lib/trycourier/users/tokens/types/device.rb b/lib/courier/users/tokens/types/device.rb similarity index 100% rename from lib/trycourier/users/tokens/types/device.rb rename to lib/courier/users/tokens/types/device.rb diff --git a/lib/trycourier/users/tokens/types/expiry_date.rb b/lib/courier/users/tokens/types/expiry_date.rb similarity index 100% rename from lib/trycourier/users/tokens/types/expiry_date.rb rename to lib/courier/users/tokens/types/expiry_date.rb diff --git a/lib/trycourier/users/tokens/types/get_all_tokens_response.rb b/lib/courier/users/tokens/types/get_all_tokens_response.rb similarity index 100% rename from lib/trycourier/users/tokens/types/get_all_tokens_response.rb rename to lib/courier/users/tokens/types/get_all_tokens_response.rb diff --git a/lib/trycourier/users/tokens/types/get_user_token_opts.rb b/lib/courier/users/tokens/types/get_user_token_opts.rb similarity index 100% rename from lib/trycourier/users/tokens/types/get_user_token_opts.rb rename to lib/courier/users/tokens/types/get_user_token_opts.rb diff --git a/lib/trycourier/users/tokens/types/get_user_token_response.rb b/lib/courier/users/tokens/types/get_user_token_response.rb similarity index 100% rename from lib/trycourier/users/tokens/types/get_user_token_response.rb rename to lib/courier/users/tokens/types/get_user_token_response.rb diff --git a/lib/trycourier/users/tokens/types/get_user_tokens_opts.rb b/lib/courier/users/tokens/types/get_user_tokens_opts.rb similarity index 100% rename from lib/trycourier/users/tokens/types/get_user_tokens_opts.rb rename to lib/courier/users/tokens/types/get_user_tokens_opts.rb diff --git a/lib/trycourier/users/tokens/types/patch_op.rb b/lib/courier/users/tokens/types/patch_op.rb similarity index 100% rename from lib/trycourier/users/tokens/types/patch_op.rb rename to lib/courier/users/tokens/types/patch_op.rb diff --git a/lib/trycourier/users/tokens/types/patch_operation.rb b/lib/courier/users/tokens/types/patch_operation.rb similarity index 100% rename from lib/trycourier/users/tokens/types/patch_operation.rb rename to lib/courier/users/tokens/types/patch_operation.rb diff --git a/lib/trycourier/users/tokens/types/patch_user_token_opts.rb b/lib/courier/users/tokens/types/patch_user_token_opts.rb similarity index 100% rename from lib/trycourier/users/tokens/types/patch_user_token_opts.rb rename to lib/courier/users/tokens/types/patch_user_token_opts.rb diff --git a/lib/trycourier/users/tokens/types/provider_key.rb b/lib/courier/users/tokens/types/provider_key.rb similarity index 100% rename from lib/trycourier/users/tokens/types/provider_key.rb rename to lib/courier/users/tokens/types/provider_key.rb diff --git a/lib/trycourier/users/tokens/types/put_user_token_opts.rb b/lib/courier/users/tokens/types/put_user_token_opts.rb similarity index 100% rename from lib/trycourier/users/tokens/types/put_user_token_opts.rb rename to lib/courier/users/tokens/types/put_user_token_opts.rb diff --git a/lib/trycourier/users/tokens/types/put_user_tokens_opts.rb b/lib/courier/users/tokens/types/put_user_tokens_opts.rb similarity index 100% rename from lib/trycourier/users/tokens/types/put_user_tokens_opts.rb rename to lib/courier/users/tokens/types/put_user_tokens_opts.rb diff --git a/lib/trycourier/users/tokens/types/token_status.rb b/lib/courier/users/tokens/types/token_status.rb similarity index 100% rename from lib/trycourier/users/tokens/types/token_status.rb rename to lib/courier/users/tokens/types/token_status.rb diff --git a/lib/trycourier/users/tokens/types/tracking.rb b/lib/courier/users/tokens/types/tracking.rb similarity index 100% rename from lib/trycourier/users/tokens/types/tracking.rb rename to lib/courier/users/tokens/types/tracking.rb diff --git a/lib/trycourier/users/tokens/types/user_token.rb b/lib/courier/users/tokens/types/user_token.rb similarity index 100% rename from lib/trycourier/users/tokens/types/user_token.rb rename to lib/courier/users/tokens/types/user_token.rb diff --git a/lib/requests.rb b/lib/requests.rb index 12e6767..d740033 100644 --- a/lib/requests.rb +++ b/lib/requests.rb @@ -21,7 +21,7 @@ def initialize(authorization_token:, environment: Environment::PRODUCTION, max_r @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "Courier", - "X-Fern-SDK-Version": "3.0.0-beta1", + "X-Fern-SDK-Version": "3.1.3", "Authorization": %(Bearer #{authorization_token || ENV["COURIER_AUTH_TOKEN"]}) } @conn = Faraday.new(@base_url, headers: @headers) do |faraday| @@ -48,7 +48,7 @@ def initialize(authorization_token:, environment: Environment::PRODUCTION, max_r @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "Courier", - "X-Fern-SDK-Version": "3.0.0-beta1", + "X-Fern-SDK-Version": "3.1.3", "Authorization": %(Bearer #{authorization_token || ENV["COURIER_AUTH_TOKEN"]}) } @conn = Faraday.new(@base_url, headers: @headers) do |faraday| @@ -98,7 +98,7 @@ class IdempotencyRequestOptions # @param additional_body_parameters [Hash{String => Object}] # @param timeout_in_seconds [Long] # @param idempotency_key [String] - # @param idempotency_expiry [Integer] + # @param idempotency_expiry [String] The expiry can either be an ISO8601 datetime or a duration like "1 Day". # @return [IdempotencyRequestOptions] def initialize(authorization_token: nil, additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, timeout_in_seconds: nil, idempotency_key: nil, idempotency_expiry: nil) @@ -114,7 +114,7 @@ def initialize(authorization_token: nil, additional_headers: nil, additional_que @timeout_in_seconds = timeout_in_seconds # @type [String] @idempotency_key = idempotency_key - # @type [Integer] + # @type [String] The expiry can either be an ISO8601 datetime or a duration like "1 Day". @idempotency_expiry = idempotency_expiry end end diff --git a/lib/trycourier/automations/types/automation_step_action.rb b/lib/trycourier/automations/types/automation_step_action.rb deleted file mode 100644 index f270cda..0000000 --- a/lib/trycourier/automations/types/automation_step_action.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -module Courier - class Automations - class AutomationStepAction - CANCEL = "cancel" - DELAY = "delay" - INVOKE = "invoke" - SEND = "send" - SEND_LIST = "send-list" - UPDATE_PROFILE = "update-profile" - end - end -end diff --git a/lib/trycourier/notifications/types/notification.rb b/lib/trycourier/notifications/types/notification.rb deleted file mode 100644 index d716351..0000000 --- a/lib/trycourier/notifications/types/notification.rb +++ /dev/null @@ -1,63 +0,0 @@ -# frozen_string_literal: true - -require_relative "message_routing" -require "json" - -module Courier - class Notifications - class Notification - attr_reader :created_at, :id, :routing, :additional_properties - - # @param created_at [Long] - # @param id [String] - # @param routing [Notifications::MessageRouting] - # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition - # @return [Notifications::Notification] - def initialize(created_at:, id:, routing:, additional_properties: nil) - # @type [Long] - @created_at = created_at - # @type [String] - @id = id - # @type [Notifications::MessageRouting] - @routing = routing - # @type [OpenStruct] Additional properties unmapped to the current class definition - @additional_properties = additional_properties - end - - # Deserialize a JSON object to an instance of Notification - # - # @param json_object [JSON] - # @return [Notifications::Notification] - def self.from_json(json_object:) - struct = JSON.parse(json_object, object_class: OpenStruct) - parsed_json = JSON.parse(json_object) - created_at = struct.created_at - id = struct.id - if parsed_json["routing"].nil? - routing = nil - else - routing = parsed_json["routing"].to_json - routing = Notifications::MessageRouting.from_json(json_object: routing) - end - new(created_at: created_at, id: id, routing: routing, additional_properties: struct) - end - - # Serialize an instance of Notification to a JSON object - # - # @return [JSON] - def to_json(*_args) - { "created_at": @created_at, "id": @id, "routing": @routing }.to_json - end - - # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. - # - # @param obj [Object] - # @return [Void] - def self.validate_raw(obj:) - obj.created_at.is_a?(Long) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") - obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") - Notifications::MessageRouting.validate_raw(obj: obj.routing) - end - end - end -end diff --git a/lib/trycourier/send/types/message_channel_email_override.rb b/lib/trycourier/send/types/message_channel_email_override.rb deleted file mode 100644 index 5701397..0000000 --- a/lib/trycourier/send/types/message_channel_email_override.rb +++ /dev/null @@ -1,119 +0,0 @@ -# frozen_string_literal: true - -require_relative "attachment" -require_relative "../../brands/types/brand" -require_relative "tracking_override" -require "json" - -module Courier - class Send - class MessageChannelEmailOverride - attr_reader :attachments, :bcc, :brand, :cc, :from, :html, :reply_to, :subject, :text, :tracking, - :additional_properties - - # @param attachments [Array] - # @param bcc [String] - # @param brand [Brands::Brand] - # @param cc [String] - # @param from [String] - # @param html [String] - # @param reply_to [String] - # @param subject [String] - # @param text [String] - # @param tracking [Send::TrackingOverride] - # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition - # @return [Send::MessageChannelEmailOverride] - def initialize(tracking:, attachments: nil, bcc: nil, brand: nil, cc: nil, from: nil, html: nil, reply_to: nil, - subject: nil, text: nil, additional_properties: nil) - # @type [Array] - @attachments = attachments - # @type [String] - @bcc = bcc - # @type [Brands::Brand] - @brand = brand - # @type [String] - @cc = cc - # @type [String] - @from = from - # @type [String] - @html = html - # @type [String] - @reply_to = reply_to - # @type [String] - @subject = subject - # @type [String] - @text = text - # @type [Send::TrackingOverride] - @tracking = tracking - # @type [OpenStruct] Additional properties unmapped to the current class definition - @additional_properties = additional_properties - end - - # Deserialize a JSON object to an instance of MessageChannelEmailOverride - # - # @param json_object [JSON] - # @return [Send::MessageChannelEmailOverride] - def self.from_json(json_object:) - struct = JSON.parse(json_object, object_class: OpenStruct) - parsed_json = JSON.parse(json_object) - attachments = struct.attachments - bcc = struct.bcc - if parsed_json["brand"].nil? - brand = nil - else - brand = parsed_json["brand"].to_json - brand = Brands::Brand.from_json(json_object: brand) - end - cc = struct.cc - from = struct.from - html = struct.html - reply_to = struct.reply_to - subject = struct.subject - text = struct.text - if parsed_json["tracking"].nil? - tracking = nil - else - tracking = parsed_json["tracking"].to_json - tracking = Send::TrackingOverride.from_json(json_object: tracking) - end - new(attachments: attachments, bcc: bcc, brand: brand, cc: cc, from: from, html: html, reply_to: reply_to, - subject: subject, text: text, tracking: tracking, additional_properties: struct) - end - - # Serialize an instance of MessageChannelEmailOverride to a JSON object - # - # @return [JSON] - def to_json(*_args) - { - "attachments": @attachments, - "bcc": @bcc, - "brand": @brand, - "cc": @cc, - "from": @from, - "html": @html, - "reply_to": @reply_to, - "subject": @subject, - "text": @text, - "tracking": @tracking - }.to_json - end - - # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions. - # - # @param obj [Object] - # @return [Void] - def self.validate_raw(obj:) - obj.attachments&.is_a?(Array) != false || raise("Passed value for field obj.attachments is not the expected type, validation failed.") - obj.bcc&.is_a?(String) != false || raise("Passed value for field obj.bcc is not the expected type, validation failed.") - obj.brand.nil? || Brands::Brand.validate_raw(obj: obj.brand) - obj.cc&.is_a?(String) != false || raise("Passed value for field obj.cc is not the expected type, validation failed.") - obj.from&.is_a?(String) != false || raise("Passed value for field obj.from is not the expected type, validation failed.") - obj.html&.is_a?(String) != false || raise("Passed value for field obj.html is not the expected type, validation failed.") - obj.reply_to&.is_a?(String) != false || raise("Passed value for field obj.reply_to is not the expected type, validation failed.") - obj.subject&.is_a?(String) != false || raise("Passed value for field obj.subject is not the expected type, validation failed.") - obj.text&.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.") - Send::TrackingOverride.validate_raw(obj: obj.tracking) - end - end - end -end diff --git a/lib/trycourier/send/types/override.rb b/lib/trycourier/send/types/override.rb deleted file mode 100644 index e7c31ee..0000000 --- a/lib/trycourier/send/types/override.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -module Courier - class Send - class Override - MESSAGE_CHANNEL_EMAIL_OVERRIDE = "MessageChannelEmailOverride" - MESSAGE_CHANNEL_PUSH_OVERRIDE = "MessageChannelPushOverride" - end - end -end diff --git a/lib/types_export.rb b/lib/types_export.rb index 968b6c9..79bf665 100644 --- a/lib/types_export.rb +++ b/lib/types_export.rb @@ -1,273 +1,302 @@ # frozen_string_literal: true -require_relative "trycourier/types/send_message_response" -require_relative "trycourier/audiences/types/single_filter_config" -require_relative "trycourier/audiences/types/nested_filter_config" -require_relative "trycourier/audiences/types/filter" -require_relative "trycourier/audiences/types/comparison_operator" -require_relative "trycourier/audiences/types/logical_operator" -require_relative "trycourier/audiences/types/operator" -require_relative "trycourier/audiences/types/base_filter_config" -require_relative "trycourier/audiences/types/filter_config" -require_relative "trycourier/audiences/types/audience" -require_relative "trycourier/audiences/types/audience_member" -require_relative "trycourier/audiences/types/audience_list_response" -require_relative "trycourier/audiences/types/audience_member_get_response" -require_relative "trycourier/audiences/types/audience_member_list_response" -require_relative "trycourier/audiences/types/audience_update_response" -require_relative "trycourier/audit_events/types/list_audit_events_params" -require_relative "trycourier/audit_events/types/get_audit_event_params" -require_relative "trycourier/audit_events/types/list_audit_events_response" -require_relative "trycourier/audit_events/types/actor" -require_relative "trycourier/audit_events/types/target" -require_relative "trycourier/audit_events/types/audit_event" -require_relative "trycourier/auth_tokens/types/issue_token_response" -require_relative "trycourier/automations/types/automation_step_action" -require_relative "trycourier/automations/types/merge_algorithm" -require_relative "trycourier/automations/types/automation_run_context" -require_relative "trycourier/automations/types/automation_step" -require_relative "trycourier/automations/types/automation_cancel_step" -require_relative "trycourier/automations/types/automation_delay_step" -require_relative "trycourier/automations/types/automation_invoke_step" -require_relative "trycourier/automations/types/automation_send_step" -require_relative "trycourier/automations/types/automation_v_2_send_step" -require_relative "trycourier/automations/types/automation_send_list_step" -require_relative "trycourier/automations/types/automation_update_profile_step" -require_relative "trycourier/automations/types/automation_step_option" -require_relative "trycourier/automations/types/automation" -require_relative "trycourier/automations/types/automation_invoke_params" -require_relative "trycourier/automations/types/automation_ad_hoc_invoke_params" -require_relative "trycourier/automations/types/automation_invoke_template_params" -require_relative "trycourier/automations/types/automation_invoke_response" -require_relative "trycourier/automations/types/profile" -require_relative "trycourier/brands/types/brand" -require_relative "trycourier/commons/types/paging" -require_relative "trycourier/brands/types/brand_parameters" -require_relative "trycourier/brands/types/brand_get_all_response" -require_relative "trycourier/brands/types/brands_response" -require_relative "trycourier/brands/types/brand_snippet" -require_relative "trycourier/brands/types/brand_snippets" -require_relative "trycourier/brands/types/brand_settings" -require_relative "trycourier/brands/types/brand_colors" -require_relative "trycourier/bulk/types/inbound_bulk_message_v_1" -require_relative "trycourier/bulk/types/inbound_bulk_message" -require_relative "trycourier/bulk/types/inbound_bulk_template_message" -require_relative "trycourier/bulk/types/inbound_bulk_content_message" -require_relative "trycourier/bulk/types/inbound_bulk_message_v_2" -require_relative "trycourier/bulk/types/bulk_create_job_response" -require_relative "trycourier/bulk/types/inbound_bulk_message_user" -require_relative "trycourier/bulk/types/bulk_ingest_users_params" -require_relative "trycourier/bulk/types/bulk_ingest_error" -require_relative "trycourier/bulk/types/bulk_ingest_users_response" -require_relative "trycourier/bulk/types/bulk_get_job_params" -require_relative "trycourier/bulk/types/bulk_job_status" -require_relative "trycourier/bulk/types/bulk_job_user_status" -require_relative "trycourier/bulk/types/bulk_get_job_response" -require_relative "trycourier/bulk/types/job_details" -require_relative "trycourier/bulk/types/bulk_get_job_users_params" -require_relative "trycourier/bulk/types/bulk_message_user_response" -require_relative "trycourier/bulk/types/bulk_get_job_users_response" -require_relative "trycourier/commons/types/base_error" -require_relative "trycourier/commons/types/bad_request" -require_relative "trycourier/commons/types/payment_required" -require_relative "trycourier/commons/types/already_exists" -require_relative "trycourier/commons/types/conflict" -require_relative "trycourier/commons/types/not_found" -require_relative "trycourier/commons/types/message_not_found" -require_relative "trycourier/commons/types/rule" -require_relative "trycourier/commons/types/preference_status" -require_relative "trycourier/commons/types/channel_classification" -require_relative "trycourier/commons/types/channel_preference" -require_relative "trycourier/commons/types/notification_preferences" -require_relative "trycourier/commons/types/notification_preference_details" -require_relative "trycourier/commons/types/recipient_preferences" -require_relative "trycourier/commons/types/email" -require_relative "trycourier/commons/types/user_tenant_association" -require_relative "trycourier/lists/types/list" -require_relative "trycourier/lists/types/list_put_params" -require_relative "trycourier/lists/types/list_get_all_response" -require_relative "trycourier/lists/types/list_subscription_recipient" -require_relative "trycourier/lists/types/list_get_subscriptions_response" -require_relative "trycourier/lists/types/put_subscriptions_recipient" -require_relative "trycourier/messages/types/message_status" -require_relative "trycourier/messages/types/message_details" -require_relative "trycourier/messages/types/reason" -require_relative "trycourier/messages/types/list_messages_response" -require_relative "trycourier/messages/types/message_history_response" -require_relative "trycourier/messages/types/render_output_response" -require_relative "trycourier/messages/types/rendered_message_block" -require_relative "trycourier/messages/types/rendered_message_content" -require_relative "trycourier/messages/types/render_output" -require_relative "trycourier/notifications/types/notification_list_response" -require_relative "trycourier/notifications/types/notification_get_content_response" -require_relative "trycourier/notifications/types/notification" -require_relative "trycourier/notifications/types/message_routing" -require_relative "trycourier/notifications/types/message_routing_method" -require_relative "trycourier/notifications/types/message_routing_channel" -require_relative "trycourier/notifications/types/notification_block" -require_relative "trycourier/notifications/types/notification_content_hierarchy" -require_relative "trycourier/notifications/types/notification_content" -require_relative "trycourier/notifications/types/block_type" -require_relative "trycourier/notifications/types/notification_channel" -require_relative "trycourier/notifications/types/notification_channel_content" -require_relative "trycourier/notifications/types/base_check" -require_relative "trycourier/notifications/types/check" -require_relative "trycourier/notifications/types/check_status" -require_relative "trycourier/notifications/types/submission_checks_get_response" -require_relative "trycourier/notifications/types/submission_checks_replace_response" -require_relative "trycourier/profiles/types/address" -require_relative "trycourier/profiles/types/user_profile" -require_relative "trycourier/profiles/types/airship_profile" -require_relative "trycourier/profiles/types/airship_profile_audience" -require_relative "trycourier/profiles/types/device_type" -require_relative "trycourier/profiles/types/snooze_rule_type" -require_relative "trycourier/profiles/types/snooze_rule" -require_relative "trycourier/profiles/types/send_to_channel" -require_relative "trycourier/profiles/types/send_direct_message" -require_relative "trycourier/profiles/types/discord" -require_relative "trycourier/profiles/types/token" -require_relative "trycourier/profiles/types/multiple_tokens" -require_relative "trycourier/profiles/types/expo" -require_relative "trycourier/profiles/types/intercom" -require_relative "trycourier/profiles/types/intercom_recipient" -require_relative "trycourier/profiles/types/send_to_slack_channel" -require_relative "trycourier/profiles/types/send_to_slack_email" -require_relative "trycourier/profiles/types/send_to_slack_user_id" -require_relative "trycourier/profiles/types/slack" -require_relative "trycourier/profiles/types/slack_base_properties" -require_relative "trycourier/profiles/types/send_to_ms_teams_user_id" -require_relative "trycourier/profiles/types/send_to_ms_teams_email" -require_relative "trycourier/profiles/types/send_to_ms_teams_channel_id" -require_relative "trycourier/profiles/types/send_to_ms_teams_conversation_id" -require_relative "trycourier/profiles/types/send_to_ms_teams_channel_name" -require_relative "trycourier/profiles/types/ms_teams" -require_relative "trycourier/profiles/types/ms_teams_base_properties" -require_relative "trycourier/profiles/types/profile_get_parameters" -require_relative "trycourier/profiles/types/profile_get_response" -require_relative "trycourier/profiles/types/merge_profile_response" -require_relative "trycourier/profiles/types/replace_profile_response" -require_relative "trycourier/profiles/types/subscribe_to_lists_request" -require_relative "trycourier/profiles/types/subscribe_to_lists_request_list_object" -require_relative "trycourier/profiles/types/subscribe_to_lists_response" -require_relative "trycourier/profiles/types/delete_list_subscription_response" -require_relative "trycourier/profiles/types/get_list_subscriptions_list" -require_relative "trycourier/profiles/types/get_list_subscriptions_response" -require_relative "trycourier/send/types/content_message" -require_relative "trycourier/send/types/template_message" -require_relative "trycourier/send/types/message" -require_relative "trycourier/send/types/base_message" -require_relative "trycourier/send/types/audience_recipient" -require_relative "trycourier/send/types/list_recipient" -require_relative "trycourier/send/types/list_pattern_recipient" -require_relative "trycourier/send/types/user_recipient" -require_relative "trycourier/send/types/slack_recipient" -require_relative "trycourier/send/types/ms_teams_recipient" -require_relative "trycourier/send/types/recipient" -require_relative "trycourier/send/types/message_recipient" -require_relative "trycourier/send/types/invalid_list_pattern_recipient" -require_relative "trycourier/send/types/list_pattern_recipient_type" -require_relative "trycourier/send/types/invalid_list_recipient" -require_relative "trycourier/send/types/list_recipient_type" -require_relative "trycourier/send/types/invalid_user_recipient" -require_relative "trycourier/send/types/user_recipient_type" -require_relative "trycourier/send/types/message_data" -require_relative "trycourier/send/types/audience_filter" -require_relative "trycourier/send/types/message_context" -require_relative "trycourier/send/types/list_filter" -require_relative "trycourier/send/types/expiry" -require_relative "trycourier/send/types/expires_in_type" -require_relative "trycourier/send/types/delay" -require_relative "trycourier/send/types/routing" -require_relative "trycourier/send/types/message_channels" -require_relative "trycourier/send/types/channel" -require_relative "trycourier/send/types/channel_metadata" -require_relative "trycourier/send/types/timeout" -require_relative "trycourier/send/types/criteria" -require_relative "trycourier/send/types/routing_method" -require_relative "trycourier/send/types/timeouts" -require_relative "trycourier/send/types/override" -require_relative "trycourier/send/types/message_channel_email_override" -require_relative "trycourier/send/types/attachment" -require_relative "trycourier/send/types/message_metadata" -require_relative "trycourier/send/types/utm" -require_relative "trycourier/send/types/tracking_override" -require_relative "trycourier/send/types/elemental_content" -require_relative "trycourier/send/types/elemental_content_sugar" -require_relative "trycourier/send/types/content" -require_relative "trycourier/send/types/elemental_node" -require_relative "trycourier/send/types/elemental_action_node" -require_relative "trycourier/send/types/locales" -require_relative "trycourier/send/types/locale" -require_relative "trycourier/send/types/i_action_button_style" -require_relative "trycourier/send/types/i_alignment" -require_relative "trycourier/send/types/elemental_divider_node" -require_relative "trycourier/send/types/elemental_group_node" -require_relative "trycourier/send/types/elemental_channel_node" -require_relative "trycourier/send/types/elemental_text_node" -require_relative "trycourier/send/types/elemental_quote_node" -require_relative "trycourier/send/types/text_style" -require_relative "trycourier/send/types/elemental_meta_node" -require_relative "trycourier/send/types/elemental_image_node" -require_relative "trycourier/send/types/elemental_base_node" -require_relative "trycourier/send/types/preference" -require_relative "trycourier/send/types/rule_type" -require_relative "trycourier/send/types/channel_source" -require_relative "trycourier/send/types/i_preferences" -require_relative "trycourier/send/types/i_profile_preferences" -require_relative "trycourier/send/types/brand_template" -require_relative "trycourier/send/types/brand_template_override" -require_relative "trycourier/send/types/brand_settings_social_presence" -require_relative "trycourier/send/types/base_social_presence" -require_relative "trycourier/send/types/brand_settings_email" -require_relative "trycourier/send/types/email_head" -require_relative "trycourier/send/types/email_footer" -require_relative "trycourier/send/types/email_header" -require_relative "trycourier/send/types/logo" -require_relative "trycourier/send/types/brand_settings_in_app" -require_relative "trycourier/send/types/in_app_placement" -require_relative "trycourier/send/types/text_align" -require_relative "trycourier/send/types/widget_background" -require_relative "trycourier/send/types/icons" -require_relative "trycourier/send/types/preferences" -require_relative "trycourier/send/types/routing_strategy_provider" -require_relative "trycourier/send/types/metadata" -require_relative "trycourier/send/types/routing_strategy_channel" -require_relative "trycourier/send/types/message_providers" -require_relative "trycourier/send/types/message_providers_type" -require_relative "trycourier/send/types/routing_channel" -require_relative "trycourier/templates/types/list_templates_response" -require_relative "trycourier/templates/types/notification_templates" -require_relative "trycourier/templates/types/routing_strategy" -require_relative "trycourier/templates/types/routing_strategy_method" -require_relative "trycourier/templates/types/channel_identifier" -require_relative "trycourier/templates/types/tag" -require_relative "trycourier/templates/types/tag_data" -require_relative "trycourier/tenants/types/default_preferences" -require_relative "trycourier/tenants/types/subscription_topic" -require_relative "trycourier/tenants/types/subscription_topic_status" -require_relative "trycourier/tenants/types/tenant" -require_relative "trycourier/tenants/types/tenant_list_response" -require_relative "trycourier/tenants/types/list_users_for_tenant_response" -require_relative "trycourier/tenants/types/template_property" -require_relative "trycourier/users/preferences/types/user_preferences_list_response" -require_relative "trycourier/users/preferences/types/user_preferences_get_response" -require_relative "trycourier/users/preferences/types/topic_preference" -require_relative "trycourier/users/preferences/types/user_preferences_update_response" -require_relative "trycourier/users/tenants/types/add_user_to_single_tenants_params_profile" -require_relative "trycourier/users/tenants/types/list_tenants_for_user_response" -require_relative "trycourier/users/tokens/types/provider_key" -require_relative "trycourier/users/tokens/types/token_status" -require_relative "trycourier/users/tokens/types/patch_op" -require_relative "trycourier/users/tokens/types/device" -require_relative "trycourier/users/tokens/types/tracking" -require_relative "trycourier/users/tokens/types/user_token" -require_relative "trycourier/users/tokens/types/get_user_token_response" -require_relative "trycourier/users/tokens/types/put_user_tokens_opts" -require_relative "trycourier/users/tokens/types/put_user_token_opts" -require_relative "trycourier/users/tokens/types/patch_user_token_opts" -require_relative "trycourier/users/tokens/types/patch_operation" -require_relative "trycourier/users/tokens/types/get_user_token_opts" -require_relative "trycourier/users/tokens/types/get_user_tokens_opts" -require_relative "trycourier/users/tokens/types/delete_user_token_opts" -require_relative "trycourier/users/tokens/types/expiry_date" -require_relative "trycourier/users/tokens/types/get_all_tokens_response" +require_relative "courier/types/send_message_response" +require_relative "courier/audiences/types/single_filter_config" +require_relative "courier/audiences/types/nested_filter_config" +require_relative "courier/audiences/types/filter" +require_relative "courier/audiences/types/comparison_operator" +require_relative "courier/audiences/types/logical_operator" +require_relative "courier/audiences/types/operator" +require_relative "courier/audiences/types/base_filter_config" +require_relative "courier/audiences/types/filter_config" +require_relative "courier/audiences/types/audience" +require_relative "courier/audiences/types/audience_member" +require_relative "courier/audiences/types/audience_list_response" +require_relative "courier/audiences/types/audience_member_get_response" +require_relative "courier/audiences/types/audience_member_list_response" +require_relative "courier/audiences/types/audience_update_response" +require_relative "courier/audit_events/types/list_audit_events_params" +require_relative "courier/audit_events/types/get_audit_event_params" +require_relative "courier/audit_events/types/list_audit_events_response" +require_relative "courier/audit_events/types/actor" +require_relative "courier/audit_events/types/target" +require_relative "courier/audit_events/types/audit_event" +require_relative "courier/auth_tokens/types/issue_token_response" +require_relative "courier/automations/types/accessor_type" +require_relative "courier/automations/types/merge_algorithm" +require_relative "courier/automations/types/automation_run_context" +require_relative "courier/automations/types/automation_step" +require_relative "courier/automations/types/automation_add_to_batch_scope" +require_relative "courier/automations/types/automation_add_to_batch_step" +require_relative "courier/automations/types/automation_add_to_batch_max_items_type" +require_relative "courier/automations/types/automation_add_to_batch_retain_type" +require_relative "courier/automations/types/automation_fetch_data_webhook_method" +require_relative "courier/automations/types/automation_fetch_data_webhook" +require_relative "courier/automations/types/automation_throttle_scope" +require_relative "courier/automations/types/automation_throttle_on_throttle" +require_relative "courier/automations/types/automation_add_to_batch_retain" +require_relative "courier/automations/types/automation_add_to_digest_step" +require_relative "courier/automations/types/automation_cancel_step" +require_relative "courier/automations/types/automation_delay_step" +require_relative "courier/automations/types/automation_fetch_data_step" +require_relative "courier/automations/types/automation_invoke_step" +require_relative "courier/automations/types/automation_send_step" +require_relative "courier/automations/types/automation_v_2_send_step" +require_relative "courier/automations/types/automation_send_list_step" +require_relative "courier/automations/types/automation_throttle_step" +require_relative "courier/automations/types/automation_update_profile_step" +require_relative "courier/automations/types/automation_step_option" +require_relative "courier/automations/types/automation" +require_relative "courier/automations/types/automation_invoke_params" +require_relative "courier/automations/types/automation_ad_hoc_invoke_params" +require_relative "courier/automations/types/automation_invoke_template_params" +require_relative "courier/automations/types/automation_invoke_response" +require_relative "courier/automations/types/profile" +require_relative "courier/brands/types/brand" +require_relative "courier/commons/types/paging" +require_relative "courier/brands/types/brand_parameters" +require_relative "courier/brands/types/brand_get_all_response" +require_relative "courier/brands/types/brands_response" +require_relative "courier/brands/types/brand_snippet" +require_relative "courier/brands/types/brand_snippets" +require_relative "courier/brands/types/brand_settings" +require_relative "courier/brands/types/brand_colors" +require_relative "courier/bulk/types/inbound_bulk_message_v_1" +require_relative "courier/bulk/types/inbound_bulk_message" +require_relative "courier/bulk/types/inbound_bulk_template_message" +require_relative "courier/bulk/types/inbound_bulk_content_message" +require_relative "courier/bulk/types/inbound_bulk_message_v_2" +require_relative "courier/bulk/types/bulk_create_job_response" +require_relative "courier/bulk/types/inbound_bulk_message_user" +require_relative "courier/bulk/types/bulk_ingest_users_params" +require_relative "courier/bulk/types/bulk_ingest_error" +require_relative "courier/bulk/types/bulk_ingest_users_response" +require_relative "courier/bulk/types/bulk_get_job_params" +require_relative "courier/bulk/types/bulk_job_status" +require_relative "courier/bulk/types/bulk_job_user_status" +require_relative "courier/bulk/types/bulk_get_job_response" +require_relative "courier/bulk/types/job_details" +require_relative "courier/bulk/types/bulk_get_job_users_params" +require_relative "courier/bulk/types/bulk_message_user_response" +require_relative "courier/bulk/types/bulk_get_job_users_response" +require_relative "courier/commons/types/base_error" +require_relative "courier/commons/types/bad_request" +require_relative "courier/commons/types/payment_required" +require_relative "courier/commons/types/already_exists" +require_relative "courier/commons/types/conflict" +require_relative "courier/commons/types/not_found" +require_relative "courier/commons/types/message_not_found" +require_relative "courier/commons/types/rule" +require_relative "courier/commons/types/preference_status" +require_relative "courier/commons/types/channel_classification" +require_relative "courier/commons/types/channel_preference" +require_relative "courier/commons/types/notification_preferences" +require_relative "courier/commons/types/notification_preference_details" +require_relative "courier/commons/types/recipient_preferences" +require_relative "courier/commons/types/email" +require_relative "courier/commons/types/user_tenant_association" +require_relative "courier/inbound/types/inbound_track_event" +require_relative "courier/inbound/types/track_accepted_response" +require_relative "courier/lists/types/list" +require_relative "courier/lists/types/list_put_params" +require_relative "courier/lists/types/list_get_all_response" +require_relative "courier/lists/types/list_subscription_recipient" +require_relative "courier/lists/types/list_get_subscriptions_response" +require_relative "courier/lists/types/put_subscriptions_recipient" +require_relative "courier/messages/types/message_status" +require_relative "courier/messages/types/message_details" +require_relative "courier/messages/types/reason" +require_relative "courier/messages/types/list_messages_response" +require_relative "courier/messages/types/message_history_response" +require_relative "courier/messages/types/render_output_response" +require_relative "courier/messages/types/rendered_message_block" +require_relative "courier/messages/types/rendered_message_content" +require_relative "courier/messages/types/render_output" +require_relative "courier/notifications/types/notification_list_response" +require_relative "courier/notifications/types/notification_get_content_response" +require_relative "courier/notifications/types/notification" +require_relative "courier/notifications/types/notification_tag" +require_relative "courier/notifications/types/notification_tag_data" +require_relative "courier/notifications/types/message_routing" +require_relative "courier/notifications/types/message_routing_method" +require_relative "courier/notifications/types/message_routing_channel" +require_relative "courier/notifications/types/notification_block" +require_relative "courier/notifications/types/notification_content_hierarchy" +require_relative "courier/notifications/types/notification_content" +require_relative "courier/notifications/types/block_type" +require_relative "courier/notifications/types/notification_channel" +require_relative "courier/notifications/types/notification_channel_content" +require_relative "courier/notifications/types/base_check" +require_relative "courier/notifications/types/check" +require_relative "courier/notifications/types/check_status" +require_relative "courier/notifications/types/submission_checks_get_response" +require_relative "courier/notifications/types/submission_checks_replace_response" +require_relative "courier/profiles/types/address" +require_relative "courier/profiles/types/user_profile" +require_relative "courier/profiles/types/user_profile_firebase_token" +require_relative "courier/profiles/types/airship_profile" +require_relative "courier/profiles/types/airship_profile_audience" +require_relative "courier/profiles/types/device_type" +require_relative "courier/profiles/types/snooze_rule_type" +require_relative "courier/profiles/types/snooze_rule" +require_relative "courier/profiles/types/send_to_channel" +require_relative "courier/profiles/types/send_direct_message" +require_relative "courier/profiles/types/discord" +require_relative "courier/profiles/types/token" +require_relative "courier/profiles/types/multiple_tokens" +require_relative "courier/profiles/types/expo" +require_relative "courier/profiles/types/intercom" +require_relative "courier/profiles/types/intercom_recipient" +require_relative "courier/profiles/types/send_to_slack_channel" +require_relative "courier/profiles/types/send_to_slack_email" +require_relative "courier/profiles/types/send_to_slack_user_id" +require_relative "courier/profiles/types/slack" +require_relative "courier/profiles/types/pagerduty" +require_relative "courier/profiles/types/slack_base_properties" +require_relative "courier/profiles/types/send_to_ms_teams_user_id" +require_relative "courier/profiles/types/send_to_ms_teams_email" +require_relative "courier/profiles/types/send_to_ms_teams_channel_id" +require_relative "courier/profiles/types/send_to_ms_teams_conversation_id" +require_relative "courier/profiles/types/send_to_ms_teams_channel_name" +require_relative "courier/profiles/types/ms_teams" +require_relative "courier/profiles/types/ms_teams_base_properties" +require_relative "courier/profiles/types/profile_get_parameters" +require_relative "courier/profiles/types/profile_get_response" +require_relative "courier/profiles/types/merge_profile_response" +require_relative "courier/profiles/types/replace_profile_response" +require_relative "courier/profiles/types/subscribe_to_lists_request" +require_relative "courier/profiles/types/subscribe_to_lists_request_list_object" +require_relative "courier/profiles/types/subscribe_to_lists_response" +require_relative "courier/profiles/types/delete_list_subscription_response" +require_relative "courier/profiles/types/get_list_subscriptions_list" +require_relative "courier/profiles/types/get_list_subscriptions_response" +require_relative "courier/profiles/types/webhook_profile" +require_relative "courier/profiles/types/webhook_method" +require_relative "courier/profiles/types/webhook_authentication" +require_relative "courier/profiles/types/webhook_auth_mode" +require_relative "courier/profiles/types/webhook_profile_type" +require_relative "courier/profiles/types/user_profile_patch" +require_relative "courier/send/types/content_message" +require_relative "courier/send/types/template_message" +require_relative "courier/send/types/message" +require_relative "courier/send/types/base_message_send_to" +require_relative "courier/send/types/base_message" +require_relative "courier/send/types/audience_recipient" +require_relative "courier/send/types/list_recipient" +require_relative "courier/send/types/list_pattern_recipient" +require_relative "courier/send/types/user_recipient" +require_relative "courier/send/types/slack_recipient" +require_relative "courier/send/types/ms_teams_recipient" +require_relative "courier/send/types/recipient_data" +require_relative "courier/send/types/pagerduty_recipient" +require_relative "courier/send/types/webhook_recipient" +require_relative "courier/send/types/recipient" +require_relative "courier/send/types/message_recipient" +require_relative "courier/send/types/invalid_list_pattern_recipient" +require_relative "courier/send/types/list_pattern_recipient_type" +require_relative "courier/send/types/invalid_list_recipient" +require_relative "courier/send/types/list_recipient_type" +require_relative "courier/send/types/invalid_user_recipient" +require_relative "courier/send/types/user_recipient_type" +require_relative "courier/send/types/message_data" +require_relative "courier/send/types/audience_filter" +require_relative "courier/send/types/message_context" +require_relative "courier/send/types/list_filter" +require_relative "courier/send/types/expiry" +require_relative "courier/send/types/expires_in_type" +require_relative "courier/send/types/delay" +require_relative "courier/send/types/routing" +require_relative "courier/send/types/message_channels" +require_relative "courier/send/types/channel" +require_relative "courier/send/types/channel_metadata" +require_relative "courier/send/types/timeout" +require_relative "courier/send/types/criteria" +require_relative "courier/send/types/routing_method" +require_relative "courier/send/types/timeouts" +require_relative "courier/send/types/attachment" +require_relative "courier/send/types/message_metadata" +require_relative "courier/send/types/utm" +require_relative "courier/send/types/tracking_override" +require_relative "courier/send/types/elemental_content" +require_relative "courier/send/types/elemental_content_sugar" +require_relative "courier/send/types/content" +require_relative "courier/send/types/elemental_node" +require_relative "courier/send/types/elemental_action_node" +require_relative "courier/send/types/locales" +require_relative "courier/send/types/locale" +require_relative "courier/send/types/i_action_button_style" +require_relative "courier/send/types/i_alignment" +require_relative "courier/send/types/elemental_divider_node" +require_relative "courier/send/types/elemental_group_node" +require_relative "courier/send/types/elemental_channel_node" +require_relative "courier/send/types/elemental_text_node" +require_relative "courier/send/types/elemental_quote_node" +require_relative "courier/send/types/text_style" +require_relative "courier/send/types/elemental_meta_node" +require_relative "courier/send/types/elemental_image_node" +require_relative "courier/send/types/elemental_base_node" +require_relative "courier/send/types/preference" +require_relative "courier/send/types/rule_type" +require_relative "courier/send/types/channel_source" +require_relative "courier/send/types/i_preferences" +require_relative "courier/send/types/i_profile_preferences" +require_relative "courier/send/types/brand_template" +require_relative "courier/send/types/brand_template_override" +require_relative "courier/send/types/brand_settings_social_presence" +require_relative "courier/send/types/base_social_presence" +require_relative "courier/send/types/brand_settings_email" +require_relative "courier/send/types/email_head" +require_relative "courier/send/types/email_footer" +require_relative "courier/send/types/email_header" +require_relative "courier/send/types/logo" +require_relative "courier/send/types/brand_settings_in_app" +require_relative "courier/send/types/in_app_placement" +require_relative "courier/send/types/text_align" +require_relative "courier/send/types/widget_background" +require_relative "courier/send/types/icons" +require_relative "courier/send/types/preferences" +require_relative "courier/send/types/routing_strategy_provider" +require_relative "courier/send/types/metadata" +require_relative "courier/send/types/routing_strategy_channel" +require_relative "courier/send/types/message_preferences" +require_relative "courier/send/types/message_providers" +require_relative "courier/send/types/message_providers_type" +require_relative "courier/send/types/routing_channel" +require_relative "courier/templates/types/list_templates_response" +require_relative "courier/templates/types/notification_templates" +require_relative "courier/templates/types/routing_strategy" +require_relative "courier/templates/types/routing_strategy_method" +require_relative "courier/templates/types/channel_identifier" +require_relative "courier/templates/types/tag" +require_relative "courier/templates/types/tag_data" +require_relative "courier/tenants/types/default_preferences" +require_relative "courier/tenants/types/subscription_topic_new" +require_relative "courier/tenants/types/subscription_topic" +require_relative "courier/tenants/types/subscription_topic_status" +require_relative "courier/tenants/types/tenant" +require_relative "courier/tenants/types/tenant_list_response" +require_relative "courier/tenants/types/list_users_for_tenant_response" +require_relative "courier/tenants/types/template_property" +require_relative "courier/users/preferences/types/user_preferences_list_response" +require_relative "courier/users/preferences/types/user_preferences_get_response" +require_relative "courier/users/preferences/types/topic_preference" +require_relative "courier/users/preferences/types/topic_preference_update" +require_relative "courier/users/preferences/types/user_preferences_update_response" +require_relative "courier/users/tenants/types/add_user_to_single_tenants_params_profile" +require_relative "courier/users/tenants/types/list_tenants_for_user_response" +require_relative "courier/users/tokens/types/provider_key" +require_relative "courier/users/tokens/types/token_status" +require_relative "courier/users/tokens/types/patch_op" +require_relative "courier/users/tokens/types/device" +require_relative "courier/users/tokens/types/tracking" +require_relative "courier/users/tokens/types/user_token" +require_relative "courier/users/tokens/types/get_user_token_response" +require_relative "courier/users/tokens/types/put_user_tokens_opts" +require_relative "courier/users/tokens/types/put_user_token_opts" +require_relative "courier/users/tokens/types/patch_user_token_opts" +require_relative "courier/users/tokens/types/patch_operation" +require_relative "courier/users/tokens/types/get_user_token_opts" +require_relative "courier/users/tokens/types/get_user_tokens_opts" +require_relative "courier/users/tokens/types/delete_user_token_opts" +require_relative "courier/users/tokens/types/expiry_date" +require_relative "courier/users/tokens/types/get_all_tokens_response"