trycourier 1.10.0 → 3.0.0.pre.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/environment.rb +7 -0
- data/lib/gemconfig.rb +14 -0
- data/lib/requests.rb +121 -0
- data/lib/trycourier/audiences/client.rb +235 -0
- data/lib/trycourier/audiences/types/audience.rb +86 -0
- data/lib/trycourier/audiences/types/audience_list_response.rb +62 -0
- data/lib/trycourier/audiences/types/audience_member.rb +74 -0
- data/lib/trycourier/audiences/types/audience_member_get_response.rb +53 -0
- data/lib/trycourier/audiences/types/audience_member_list_response.rb +62 -0
- data/lib/trycourier/audiences/types/audience_update_response.rb +53 -0
- data/lib/trycourier/audiences/types/base_filter_config.rb +53 -0
- data/lib/trycourier/audiences/types/comparison_operator.rb +21 -0
- data/lib/trycourier/audiences/types/filter.rb +50 -0
- data/lib/trycourier/audiences/types/filter_config.rb +50 -0
- data/lib/trycourier/audiences/types/logical_operator.rb +10 -0
- data/lib/trycourier/audiences/types/nested_filter_config.rb +63 -0
- data/lib/trycourier/audiences/types/operator.rb +48 -0
- data/lib/trycourier/audiences/types/single_filter_config.rb +64 -0
- data/lib/trycourier/audit_events/client.rb +104 -0
- data/lib/trycourier/audit_events/types/actor.rb +52 -0
- data/lib/trycourier/audit_events/types/audit_event.rb +92 -0
- data/lib/trycourier/audit_events/types/get_audit_event_params.rb +47 -0
- data/lib/trycourier/audit_events/types/list_audit_events_params.rb +47 -0
- data/lib/trycourier/audit_events/types/list_audit_events_response.rb +62 -0
- data/lib/trycourier/audit_events/types/target.rb +52 -0
- data/lib/trycourier/auth_tokens/client.rb +85 -0
- data/lib/trycourier/auth_tokens/types/issue_token_response.rb +47 -0
- data/lib/trycourier/automations/client.rb +151 -0
- data/lib/trycourier/automations/types/automation.rb +56 -0
- data/lib/trycourier/automations/types/automation_ad_hoc_invoke_params.rb +88 -0
- data/lib/trycourier/automations/types/automation_cancel_step.rb +62 -0
- data/lib/trycourier/automations/types/automation_delay_step.rb +62 -0
- data/lib/trycourier/automations/types/automation_invoke_params.rb +69 -0
- data/lib/trycourier/automations/types/automation_invoke_response.rb +47 -0
- data/lib/trycourier/automations/types/automation_invoke_step.rb +62 -0
- data/lib/trycourier/automations/types/automation_invoke_template_params.rb +82 -0
- data/lib/trycourier/automations/types/automation_run_context.rb +69 -0
- data/lib/trycourier/automations/types/automation_send_list_step.rb +93 -0
- data/lib/trycourier/automations/types/automation_send_step.rb +99 -0
- data/lib/trycourier/automations/types/automation_step.rb +52 -0
- data/lib/trycourier/automations/types/automation_step_action.rb +14 -0
- data/lib/trycourier/automations/types/automation_step_option.rb +110 -0
- data/lib/trycourier/automations/types/automation_update_profile_step.rb +64 -0
- data/lib/trycourier/automations/types/automation_v_2_send_step.rb +68 -0
- data/lib/trycourier/automations/types/merge_algorithm.rb +12 -0
- data/lib/trycourier/automations/types/profile.rb +7 -0
- data/lib/trycourier/brands/client.rb +281 -0
- data/lib/trycourier/brands/types/brand.rb +105 -0
- data/lib/trycourier/brands/types/brand_colors.rb +57 -0
- data/lib/trycourier/brands/types/brand_get_all_response.rb +62 -0
- data/lib/trycourier/brands/types/brand_parameters.rb +74 -0
- data/lib/trycourier/brands/types/brand_settings.rb +69 -0
- data/lib/trycourier/brands/types/brand_snippet.rb +57 -0
- data/lib/trycourier/brands/types/brand_snippets.rb +51 -0
- data/lib/trycourier/brands/types/brands_response.rb +62 -0
- data/lib/trycourier/bulk/client.rb +249 -0
- data/lib/trycourier/bulk/types/bulk_create_job_response.rb +47 -0
- data/lib/trycourier/bulk/types/bulk_get_job_params.rb +47 -0
- data/lib/trycourier/bulk/types/bulk_get_job_response.rb +53 -0
- data/lib/trycourier/bulk/types/bulk_get_job_users_params.rb +52 -0
- data/lib/trycourier/bulk/types/bulk_get_job_users_response.rb +62 -0
- data/lib/trycourier/bulk/types/bulk_ingest_error.rb +52 -0
- data/lib/trycourier/bulk/types/bulk_ingest_users_params.rb +51 -0
- data/lib/trycourier/bulk/types/bulk_ingest_users_response.rb +56 -0
- data/lib/trycourier/bulk/types/bulk_job_status.rb +12 -0
- data/lib/trycourier/bulk/types/bulk_job_user_status.rb +11 -0
- data/lib/trycourier/bulk/types/bulk_message_user_response.rb +100 -0
- data/lib/trycourier/bulk/types/inbound_bulk_content_message.rb +165 -0
- data/lib/trycourier/bulk/types/inbound_bulk_message.rb +95 -0
- data/lib/trycourier/bulk/types/inbound_bulk_message_user.rb +80 -0
- data/lib/trycourier/bulk/types/inbound_bulk_message_v_1.rb +75 -0
- data/lib/trycourier/bulk/types/inbound_bulk_message_v_2.rb +50 -0
- data/lib/trycourier/bulk/types/inbound_bulk_template_message.rb +157 -0
- data/lib/trycourier/bulk/types/job_details.rb +81 -0
- data/lib/trycourier/commons/types/already_exists.rb +52 -0
- data/lib/trycourier/commons/types/bad_request.rb +52 -0
- data/lib/trycourier/commons/types/base_error.rb +47 -0
- data/lib/trycourier/commons/types/channel_classification.rb +14 -0
- data/lib/trycourier/commons/types/channel_preference.rb +48 -0
- data/lib/trycourier/commons/types/conflict.rb +52 -0
- data/lib/trycourier/commons/types/email.rb +52 -0
- data/lib/trycourier/commons/types/message_not_found.rb +52 -0
- data/lib/trycourier/commons/types/not_found.rb +52 -0
- data/lib/trycourier/commons/types/notification_preference_details.rb +66 -0
- data/lib/trycourier/commons/types/notification_preferences.rb +7 -0
- data/lib/trycourier/commons/types/paging.rb +52 -0
- data/lib/trycourier/commons/types/payment_required.rb +52 -0
- data/lib/trycourier/commons/types/preference_status.rb +11 -0
- data/lib/trycourier/commons/types/recipient_preferences.rb +53 -0
- data/lib/trycourier/commons/types/rule.rb +52 -0
- data/lib/trycourier/commons/types/user_tenant_association.rb +62 -0
- data/lib/trycourier/lists/client.rb +454 -0
- data/lib/trycourier/lists/types/list.rb +62 -0
- data/lib/trycourier/lists/types/list_get_all_response.rb +62 -0
- data/lib/trycourier/lists/types/list_get_subscriptions_response.rb +62 -0
- data/lib/trycourier/lists/types/list_put_params.rb +58 -0
- data/lib/trycourier/lists/types/list_subscription_recipient.rb +63 -0
- data/lib/trycourier/lists/types/put_subscriptions_recipient.rb +58 -0
- data/lib/trycourier/messages/client.rb +300 -0
- data/lib/trycourier/messages/types/list_messages_response.rb +62 -0
- data/lib/trycourier/messages/types/message_details.rb +120 -0
- data/lib/trycourier/messages/types/message_history_response.rb +51 -0
- data/lib/trycourier/messages/types/message_status.rb +17 -0
- data/lib/trycourier/messages/types/reason.rb +14 -0
- data/lib/trycourier/messages/types/render_output.rb +63 -0
- data/lib/trycourier/messages/types/render_output_response.rb +51 -0
- data/lib/trycourier/messages/types/rendered_message_block.rb +52 -0
- data/lib/trycourier/messages/types/rendered_message_content.rb +77 -0
- data/lib/trycourier/notifications/client.rb +379 -0
- data/lib/trycourier/notifications/types/base_check.rb +58 -0
- data/lib/trycourier/notifications/types/block_type.rb +17 -0
- data/lib/trycourier/notifications/types/check.rb +63 -0
- data/lib/trycourier/notifications/types/check_status.rb +11 -0
- data/lib/trycourier/notifications/types/message_routing.rb +57 -0
- data/lib/trycourier/notifications/types/message_routing_channel.rb +49 -0
- data/lib/trycourier/notifications/types/message_routing_method.rb +10 -0
- data/lib/trycourier/notifications/types/notification.rb +63 -0
- data/lib/trycourier/notifications/types/notification_block.rb +94 -0
- data/lib/trycourier/notifications/types/notification_channel.rb +73 -0
- data/lib/trycourier/notifications/types/notification_channel_content.rb +52 -0
- data/lib/trycourier/notifications/types/notification_content.rb +49 -0
- data/lib/trycourier/notifications/types/notification_content_hierarchy.rb +52 -0
- data/lib/trycourier/notifications/types/notification_get_content_response.rb +65 -0
- data/lib/trycourier/notifications/types/notification_list_response.rb +62 -0
- data/lib/trycourier/notifications/types/submission_checks_get_response.rb +51 -0
- data/lib/trycourier/notifications/types/submission_checks_replace_response.rb +51 -0
- data/lib/trycourier/profiles/client.rb +325 -0
- data/lib/trycourier/profiles/types/address.rb +81 -0
- data/lib/trycourier/profiles/types/airship_profile.rb +59 -0
- data/lib/trycourier/profiles/types/airship_profile_audience.rb +47 -0
- data/lib/trycourier/profiles/types/delete_list_subscription_response.rb +47 -0
- data/lib/trycourier/profiles/types/device_type.rb +7 -0
- data/lib/trycourier/profiles/types/discord.rb +50 -0
- data/lib/trycourier/profiles/types/expo.rb +50 -0
- data/lib/trycourier/profiles/types/get_list_subscriptions_list.rb +74 -0
- data/lib/trycourier/profiles/types/get_list_subscriptions_response.rb +62 -0
- data/lib/trycourier/profiles/types/intercom.rb +58 -0
- data/lib/trycourier/profiles/types/intercom_recipient.rb +47 -0
- data/lib/trycourier/profiles/types/merge_profile_response.rb +47 -0
- data/lib/trycourier/profiles/types/ms_teams.rb +86 -0
- data/lib/trycourier/profiles/types/ms_teams_base_properties.rb +52 -0
- data/lib/trycourier/profiles/types/multiple_tokens.rb +51 -0
- data/lib/trycourier/profiles/types/profile_get_parameters.rb +47 -0
- data/lib/trycourier/profiles/types/profile_get_response.rb +58 -0
- data/lib/trycourier/profiles/types/replace_profile_response.rb +47 -0
- data/lib/trycourier/profiles/types/send_direct_message.rb +47 -0
- data/lib/trycourier/profiles/types/send_to_channel.rb +47 -0
- data/lib/trycourier/profiles/types/send_to_ms_teams_channel_id.rb +57 -0
- data/lib/trycourier/profiles/types/send_to_ms_teams_channel_name.rb +68 -0
- data/lib/trycourier/profiles/types/send_to_ms_teams_conversation_id.rb +58 -0
- data/lib/trycourier/profiles/types/send_to_ms_teams_email.rb +57 -0
- data/lib/trycourier/profiles/types/send_to_ms_teams_user_id.rb +57 -0
- data/lib/trycourier/profiles/types/send_to_slack_channel.rb +52 -0
- data/lib/trycourier/profiles/types/send_to_slack_email.rb +52 -0
- data/lib/trycourier/profiles/types/send_to_slack_user_id.rb +52 -0
- data/lib/trycourier/profiles/types/slack.rb +62 -0
- data/lib/trycourier/profiles/types/slack_base_properties.rb +47 -0
- data/lib/trycourier/profiles/types/snooze_rule.rb +58 -0
- data/lib/trycourier/profiles/types/snooze_rule_type.rb +9 -0
- data/lib/trycourier/profiles/types/subscribe_to_lists_request.rb +51 -0
- data/lib/trycourier/profiles/types/subscribe_to_lists_request_list_object.rb +58 -0
- data/lib/trycourier/profiles/types/subscribe_to_lists_response.rb +47 -0
- data/lib/trycourier/profiles/types/token.rb +47 -0
- data/lib/trycourier/profiles/types/user_profile.rb +274 -0
- data/lib/trycourier/send/types/attachment.rb +7 -0
- data/lib/trycourier/send/types/audience_filter.rb +57 -0
- data/lib/trycourier/send/types/audience_recipient.rb +62 -0
- data/lib/trycourier/send/types/base_message.rb +149 -0
- data/lib/trycourier/send/types/base_social_presence.rb +47 -0
- data/lib/trycourier/send/types/brand_settings_email.rb +87 -0
- data/lib/trycourier/send/types/brand_settings_in_app.rb +119 -0
- data/lib/trycourier/send/types/brand_settings_social_presence.rb +107 -0
- data/lib/trycourier/send/types/brand_template.rb +88 -0
- data/lib/trycourier/send/types/brand_template_override.rb +112 -0
- data/lib/trycourier/send/types/channel.rb +113 -0
- data/lib/trycourier/send/types/channel_metadata.rb +53 -0
- data/lib/trycourier/send/types/channel_source.rb +11 -0
- data/lib/trycourier/send/types/content.rb +50 -0
- data/lib/trycourier/send/types/content_message.rb +177 -0
- data/lib/trycourier/send/types/criteria.rb +12 -0
- data/lib/trycourier/send/types/delay.rb +47 -0
- data/lib/trycourier/send/types/elemental_action_node.rb +116 -0
- data/lib/trycourier/send/types/elemental_base_node.rb +62 -0
- data/lib/trycourier/send/types/elemental_channel_node.rb +105 -0
- data/lib/trycourier/send/types/elemental_content.rb +61 -0
- data/lib/trycourier/send/types/elemental_content_sugar.rb +53 -0
- data/lib/trycourier/send/types/elemental_divider_node.rb +68 -0
- data/lib/trycourier/send/types/elemental_group_node.rb +72 -0
- data/lib/trycourier/send/types/elemental_image_node.rb +101 -0
- data/lib/trycourier/send/types/elemental_meta_node.rb +70 -0
- data/lib/trycourier/send/types/elemental_node.rb +170 -0
- data/lib/trycourier/send/types/elemental_quote_node.rb +104 -0
- data/lib/trycourier/send/types/elemental_text_node.rb +136 -0
- data/lib/trycourier/send/types/email_footer.rb +52 -0
- data/lib/trycourier/send/types/email_head.rb +52 -0
- data/lib/trycourier/send/types/email_header.rb +63 -0
- data/lib/trycourier/send/types/expires_in_type.rb +48 -0
- data/lib/trycourier/send/types/expiry.rb +58 -0
- data/lib/trycourier/send/types/i_action_button_style.rb +10 -0
- data/lib/trycourier/send/types/i_alignment.rb +12 -0
- data/lib/trycourier/send/types/i_preferences.rb +7 -0
- data/lib/trycourier/send/types/i_profile_preferences.rb +59 -0
- data/lib/trycourier/send/types/icons.rb +52 -0
- data/lib/trycourier/send/types/in_app_placement.rb +12 -0
- data/lib/trycourier/send/types/invalid_list_pattern_recipient.rb +52 -0
- data/lib/trycourier/send/types/invalid_list_recipient.rb +52 -0
- data/lib/trycourier/send/types/invalid_user_recipient.rb +52 -0
- data/lib/trycourier/send/types/list_filter.rb +57 -0
- data/lib/trycourier/send/types/list_pattern_recipient.rb +53 -0
- data/lib/trycourier/send/types/list_pattern_recipient_type.rb +41 -0
- data/lib/trycourier/send/types/list_recipient.rb +62 -0
- data/lib/trycourier/send/types/list_recipient_type.rb +41 -0
- data/lib/trycourier/send/types/locale.rb +47 -0
- data/lib/trycourier/send/types/locales.rb +7 -0
- data/lib/trycourier/send/types/logo.rb +52 -0
- data/lib/trycourier/send/types/message.rb +50 -0
- data/lib/trycourier/send/types/message_channel_email_override.rb +119 -0
- data/lib/trycourier/send/types/message_channels.rb +7 -0
- data/lib/trycourier/send/types/message_context.rb +49 -0
- data/lib/trycourier/send/types/message_data.rb +7 -0
- data/lib/trycourier/send/types/message_metadata.rb +68 -0
- data/lib/trycourier/send/types/message_providers.rb +7 -0
- data/lib/trycourier/send/types/message_providers_type.rb +72 -0
- data/lib/trycourier/send/types/message_recipient.rb +54 -0
- data/lib/trycourier/send/types/metadata.rb +53 -0
- data/lib/trycourier/send/types/ms_teams_recipient.rb +53 -0
- data/lib/trycourier/send/types/override.rb +10 -0
- data/lib/trycourier/send/types/preference.rb +73 -0
- data/lib/trycourier/send/types/preferences.rb +47 -0
- data/lib/trycourier/send/types/recipient.rb +98 -0
- data/lib/trycourier/send/types/routing.rb +64 -0
- data/lib/trycourier/send/types/routing_channel.rb +61 -0
- data/lib/trycourier/send/types/routing_method.rb +10 -0
- data/lib/trycourier/send/types/routing_strategy_channel.rb +70 -0
- data/lib/trycourier/send/types/routing_strategy_provider.rb +68 -0
- data/lib/trycourier/send/types/rule_type.rb +11 -0
- data/lib/trycourier/send/types/slack_recipient.rb +53 -0
- data/lib/trycourier/send/types/template_message.rb +169 -0
- data/lib/trycourier/send/types/text_align.rb +11 -0
- data/lib/trycourier/send/types/text_style.rb +12 -0
- data/lib/trycourier/send/types/timeout.rb +76 -0
- data/lib/trycourier/send/types/timeouts.rb +52 -0
- data/lib/trycourier/send/types/tracking_override.rb +47 -0
- data/lib/trycourier/send/types/user_recipient.rb +115 -0
- data/lib/trycourier/send/types/user_recipient_type.rb +41 -0
- data/lib/trycourier/send/types/utm.rb +68 -0
- data/lib/trycourier/send/types/widget_background.rb +52 -0
- data/lib/trycourier/templates/client.rb +67 -0
- data/lib/trycourier/templates/types/channel_identifier.rb +7 -0
- data/lib/trycourier/templates/types/list_templates_response.rb +62 -0
- data/lib/trycourier/templates/types/notification_templates.rb +90 -0
- data/lib/trycourier/templates/types/routing_strategy.rb +54 -0
- data/lib/trycourier/templates/types/routing_strategy_method.rb +10 -0
- data/lib/trycourier/templates/types/tag.rb +51 -0
- data/lib/trycourier/templates/types/tag_data.rb +52 -0
- data/lib/trycourier/tenants/client.rb +255 -0
- data/lib/trycourier/tenants/types/default_preferences.rb +51 -0
- data/lib/trycourier/tenants/types/list_users_for_tenant_response.rb +88 -0
- data/lib/trycourier/tenants/types/subscription_topic.rb +53 -0
- data/lib/trycourier/tenants/types/subscription_topic_status.rb +11 -0
- data/lib/trycourier/tenants/types/template_property.rb +7 -0
- data/lib/trycourier/tenants/types/tenant.rb +95 -0
- data/lib/trycourier/tenants/types/tenant_list_response.rb +86 -0
- data/lib/trycourier/translations/client.rb +106 -0
- data/lib/trycourier/types/send_message_response.rb +49 -0
- data/lib/trycourier/users/client.rb +34 -0
- data/lib/trycourier/users/preferences/client.rb +171 -0
- data/lib/trycourier/users/preferences/types/topic_preference.rb +86 -0
- data/lib/trycourier/users/preferences/types/user_preferences_get_response.rb +55 -0
- data/lib/trycourier/users/preferences/types/user_preferences_list_response.rb +64 -0
- data/lib/trycourier/users/preferences/types/user_preferences_update_response.rb +49 -0
- data/lib/trycourier/users/tenants/client.rb +267 -0
- data/lib/trycourier/users/tenants/types/add_user_to_single_tenants_params_profile.rb +76 -0
- data/lib/trycourier/users/tenants/types/list_tenants_for_user_response.rb +90 -0
- data/lib/trycourier/users/tokens/client.rb +264 -0
- data/lib/trycourier/users/tokens/types/delete_user_token_opts.rb +54 -0
- data/lib/trycourier/users/tokens/types/device.rb +83 -0
- data/lib/trycourier/users/tokens/types/expiry_date.rb +50 -0
- data/lib/trycourier/users/tokens/types/get_all_tokens_response.rb +11 -0
- data/lib/trycourier/users/tokens/types/get_user_token_opts.rb +54 -0
- data/lib/trycourier/users/tokens/types/get_user_token_response.rb +116 -0
- data/lib/trycourier/users/tokens/types/get_user_tokens_opts.rb +49 -0
- data/lib/trycourier/users/tokens/types/patch_op.rb +16 -0
- data/lib/trycourier/users/tokens/types/patch_operation.rb +59 -0
- data/lib/trycourier/users/tokens/types/patch_user_token_opts.rb +53 -0
- data/lib/trycourier/users/tokens/types/provider_key.rb +14 -0
- data/lib/trycourier/users/tokens/types/put_user_token_opts.rb +60 -0
- data/lib/trycourier/users/tokens/types/put_user_tokens_opts.rb +58 -0
- data/lib/trycourier/users/tokens/types/token_status.rb +14 -0
- data/lib/trycourier/users/tokens/types/tracking.rb +64 -0
- data/lib/trycourier/users/tokens/types/user_token.rb +102 -0
- data/lib/trycourier.rb +114 -138
- data/lib/types_export.rb +273 -0
- metadata +362 -50
- data/.github/ISSUE_TEMPLATE.md +0 -17
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -27
- data/.github/workflows/gem-push.yml +0 -51
- data/.gitignore +0 -67
- data/.rspec +0 -3
- data/CHANGELOG.md +0 -126
- data/CONTRIBUTING.md +0 -28
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -72
- data/LICENSE +0 -21
- data/README.md +0 -610
- data/Rakefile +0 -7
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/trycourier/accounts.rb +0 -43
- data/lib/trycourier/audiences.rb +0 -45
- data/lib/trycourier/audit_events.rb +0 -27
- data/lib/trycourier/auth_tokens.rb +0 -23
- data/lib/trycourier/automations.rb +0 -67
- data/lib/trycourier/brands.rb +0 -70
- data/lib/trycourier/bulk.rb +0 -79
- data/lib/trycourier/events.rb +0 -35
- data/lib/trycourier/exceptions.rb +0 -39
- data/lib/trycourier/lists.rb +0 -109
- data/lib/trycourier/messages.rb +0 -57
- data/lib/trycourier/profiles.rb +0 -64
- data/lib/trycourier/session.rb +0 -80
- data/lib/trycourier/version.rb +0 -3
- data/trycourier.gemspec +0 -32
@@ -0,0 +1,264 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../../requests"
|
4
|
+
require_relative "types/user_token"
|
5
|
+
require_relative "types/patch_user_token_opts"
|
6
|
+
require_relative "types/get_user_token_response"
|
7
|
+
require_relative "types/get_all_tokens_response"
|
8
|
+
require "async"
|
9
|
+
|
10
|
+
module Courier
|
11
|
+
module Users
|
12
|
+
class TokensClient
|
13
|
+
attr_reader :request_client
|
14
|
+
|
15
|
+
# @param request_client [RequestClient]
|
16
|
+
# @return [Users::TokensClient]
|
17
|
+
def initialize(request_client:)
|
18
|
+
# @type [RequestClient]
|
19
|
+
@request_client = request_client
|
20
|
+
end
|
21
|
+
|
22
|
+
# Adds multiple tokens to a user and overwrites matching existing tokens.
|
23
|
+
#
|
24
|
+
# @param user_id [String] The user's ID. This can be any uniquely identifiable string.
|
25
|
+
# @param request_options [RequestOptions]
|
26
|
+
# @return [Void]
|
27
|
+
def add_multiple(user_id:, request_options: nil)
|
28
|
+
@request_client.conn.put("/users/#{user_id}/tokens") do |req|
|
29
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
30
|
+
unless request_options&.authorization_token.nil?
|
31
|
+
req.headers["Authorization"] =
|
32
|
+
request_options.authorization_token
|
33
|
+
end
|
34
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Adds a single token to a user and overwrites a matching existing token.
|
39
|
+
#
|
40
|
+
# @param user_id [String] The user's ID. This can be any uniquely identifiable string.
|
41
|
+
# @param token [String] The full token string.
|
42
|
+
# @param request [Hash] Request of type Users::Tokens::UserToken, as a Hash
|
43
|
+
# * :token (String)
|
44
|
+
# * :provider_key (Users::Tokens::ProviderKey)
|
45
|
+
# * :expiry_date (Hash)
|
46
|
+
# * :properties (Object)
|
47
|
+
# * :device (Hash)
|
48
|
+
# * :app_id (String)
|
49
|
+
# * :ad_id (String)
|
50
|
+
# * :device_id (String)
|
51
|
+
# * :platform (String)
|
52
|
+
# * :manufacturer (String)
|
53
|
+
# * :model (String)
|
54
|
+
# * :tracking (Hash)
|
55
|
+
# * :os_version (String)
|
56
|
+
# * :ip (String)
|
57
|
+
# * :lat (String)
|
58
|
+
# * :long (String)
|
59
|
+
# @param request_options [RequestOptions]
|
60
|
+
# @return [Void]
|
61
|
+
def add(user_id:, token:, request:, request_options: nil)
|
62
|
+
@request_client.conn.put("/users/#{user_id}/tokens/#{token}") do |req|
|
63
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
64
|
+
unless request_options&.authorization_token.nil?
|
65
|
+
req.headers["Authorization"] =
|
66
|
+
request_options.authorization_token
|
67
|
+
end
|
68
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
69
|
+
req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Apply a JSON Patch (RFC 6902) to the specified token.
|
74
|
+
#
|
75
|
+
# @param user_id [String] The user's ID. This can be any uniquely identifiable string.
|
76
|
+
# @param token [String] The full token string.
|
77
|
+
# @param request [Hash] Request of type Users::Tokens::PatchUserTokenOpts, as a Hash
|
78
|
+
# * :patch (Array<Users::Tokens::PatchOperation>)
|
79
|
+
# @param request_options [RequestOptions]
|
80
|
+
# @return [Void]
|
81
|
+
def update(user_id:, token:, request:, request_options: nil)
|
82
|
+
@request_client.conn.patch("/users/#{user_id}/tokens/#{token}") do |req|
|
83
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
84
|
+
unless request_options&.authorization_token.nil?
|
85
|
+
req.headers["Authorization"] =
|
86
|
+
request_options.authorization_token
|
87
|
+
end
|
88
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
89
|
+
req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Get single token available for a `:token`
|
94
|
+
#
|
95
|
+
# @param user_id [String] The user's ID. This can be any uniquely identifiable string.
|
96
|
+
# @param token [String] The full token string.
|
97
|
+
# @param request_options [RequestOptions]
|
98
|
+
# @return [Users::Tokens::GetUserTokenResponse]
|
99
|
+
def get(user_id:, token:, request_options: nil)
|
100
|
+
response = @request_client.conn.get("/users/#{user_id}/tokens/#{token}") do |req|
|
101
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
102
|
+
unless request_options&.authorization_token.nil?
|
103
|
+
req.headers["Authorization"] =
|
104
|
+
request_options.authorization_token
|
105
|
+
end
|
106
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
107
|
+
end
|
108
|
+
Users::Tokens::GetUserTokenResponse.from_json(json_object: response.body)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Gets all tokens available for a :user_id
|
112
|
+
#
|
113
|
+
# @param user_id [String] The user's ID. This can be any uniquely identifiable string.
|
114
|
+
# @param request_options [RequestOptions]
|
115
|
+
# @return [Users::Tokens::GET_ALL_TOKENS_RESPONSE]
|
116
|
+
def list(user_id:, request_options: nil)
|
117
|
+
response = @request_client.conn.get("/users/#{user_id}/tokens") do |req|
|
118
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
119
|
+
unless request_options&.authorization_token.nil?
|
120
|
+
req.headers["Authorization"] =
|
121
|
+
request_options.authorization_token
|
122
|
+
end
|
123
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
124
|
+
end
|
125
|
+
return if response.body.nil?
|
126
|
+
|
127
|
+
response.body.map do |v|
|
128
|
+
v = v.to_json
|
129
|
+
Users::Tokens::UserToken.from_json(json_object: v)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
class AsyncTokensClient
|
135
|
+
attr_reader :request_client
|
136
|
+
|
137
|
+
# @param request_client [AsyncRequestClient]
|
138
|
+
# @return [Users::AsyncTokensClient]
|
139
|
+
def initialize(request_client:)
|
140
|
+
# @type [AsyncRequestClient]
|
141
|
+
@request_client = request_client
|
142
|
+
end
|
143
|
+
|
144
|
+
# Adds multiple tokens to a user and overwrites matching existing tokens.
|
145
|
+
#
|
146
|
+
# @param user_id [String] The user's ID. This can be any uniquely identifiable string.
|
147
|
+
# @param request_options [RequestOptions]
|
148
|
+
# @return [Void]
|
149
|
+
def add_multiple(user_id:, request_options: nil)
|
150
|
+
Async do
|
151
|
+
@request_client.conn.put("/users/#{user_id}/tokens") do |req|
|
152
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
153
|
+
unless request_options&.authorization_token.nil?
|
154
|
+
req.headers["Authorization"] =
|
155
|
+
request_options.authorization_token
|
156
|
+
end
|
157
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Adds a single token to a user and overwrites a matching existing token.
|
163
|
+
#
|
164
|
+
# @param user_id [String] The user's ID. This can be any uniquely identifiable string.
|
165
|
+
# @param token [String] The full token string.
|
166
|
+
# @param request [Hash] Request of type Users::Tokens::UserToken, as a Hash
|
167
|
+
# * :token (String)
|
168
|
+
# * :provider_key (Users::Tokens::ProviderKey)
|
169
|
+
# * :expiry_date (Hash)
|
170
|
+
# * :properties (Object)
|
171
|
+
# * :device (Hash)
|
172
|
+
# * :app_id (String)
|
173
|
+
# * :ad_id (String)
|
174
|
+
# * :device_id (String)
|
175
|
+
# * :platform (String)
|
176
|
+
# * :manufacturer (String)
|
177
|
+
# * :model (String)
|
178
|
+
# * :tracking (Hash)
|
179
|
+
# * :os_version (String)
|
180
|
+
# * :ip (String)
|
181
|
+
# * :lat (String)
|
182
|
+
# * :long (String)
|
183
|
+
# @param request_options [RequestOptions]
|
184
|
+
# @return [Void]
|
185
|
+
def add(user_id:, token:, request:, request_options: nil)
|
186
|
+
Async do
|
187
|
+
@request_client.conn.put("/users/#{user_id}/tokens/#{token}") do |req|
|
188
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
189
|
+
unless request_options&.authorization_token.nil?
|
190
|
+
req.headers["Authorization"] =
|
191
|
+
request_options.authorization_token
|
192
|
+
end
|
193
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
194
|
+
req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
# Apply a JSON Patch (RFC 6902) to the specified token.
|
200
|
+
#
|
201
|
+
# @param user_id [String] The user's ID. This can be any uniquely identifiable string.
|
202
|
+
# @param token [String] The full token string.
|
203
|
+
# @param request [Hash] Request of type Users::Tokens::PatchUserTokenOpts, as a Hash
|
204
|
+
# * :patch (Array<Users::Tokens::PatchOperation>)
|
205
|
+
# @param request_options [RequestOptions]
|
206
|
+
# @return [Void]
|
207
|
+
def update(user_id:, token:, request:, request_options: nil)
|
208
|
+
Async do
|
209
|
+
@request_client.conn.patch("/users/#{user_id}/tokens/#{token}") do |req|
|
210
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
211
|
+
unless request_options&.authorization_token.nil?
|
212
|
+
req.headers["Authorization"] =
|
213
|
+
request_options.authorization_token
|
214
|
+
end
|
215
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
216
|
+
req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
# Get single token available for a `:token`
|
222
|
+
#
|
223
|
+
# @param user_id [String] The user's ID. This can be any uniquely identifiable string.
|
224
|
+
# @param token [String] The full token string.
|
225
|
+
# @param request_options [RequestOptions]
|
226
|
+
# @return [Users::Tokens::GetUserTokenResponse]
|
227
|
+
def get(user_id:, token:, request_options: nil)
|
228
|
+
Async do
|
229
|
+
response = @request_client.conn.get("/users/#{user_id}/tokens/#{token}") do |req|
|
230
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
231
|
+
unless request_options&.authorization_token.nil?
|
232
|
+
req.headers["Authorization"] =
|
233
|
+
request_options.authorization_token
|
234
|
+
end
|
235
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
236
|
+
end
|
237
|
+
Users::Tokens::GetUserTokenResponse.from_json(json_object: response.body)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
# Gets all tokens available for a :user_id
|
242
|
+
#
|
243
|
+
# @param user_id [String] The user's ID. This can be any uniquely identifiable string.
|
244
|
+
# @param request_options [RequestOptions]
|
245
|
+
# @return [Users::Tokens::GET_ALL_TOKENS_RESPONSE]
|
246
|
+
def list(user_id:, request_options: nil)
|
247
|
+
Async do
|
248
|
+
response = @request_client.conn.get("/users/#{user_id}/tokens") do |req|
|
249
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
250
|
+
unless request_options&.authorization_token.nil?
|
251
|
+
req.headers["Authorization"] =
|
252
|
+
request_options.authorization_token
|
253
|
+
end
|
254
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
255
|
+
end
|
256
|
+
response.body&.map do |v|
|
257
|
+
v = v.to_json
|
258
|
+
Users::Tokens::UserToken.from_json(json_object: v)
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Courier
|
6
|
+
module Users
|
7
|
+
class Tokens
|
8
|
+
class DeleteUserTokenOpts
|
9
|
+
attr_reader :user_id, :token, :additional_properties
|
10
|
+
|
11
|
+
# @param user_id [String]
|
12
|
+
# @param token [String]
|
13
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
14
|
+
# @return [Users::Tokens::DeleteUserTokenOpts]
|
15
|
+
def initialize(user_id:, token:, additional_properties: nil)
|
16
|
+
# @type [String]
|
17
|
+
@user_id = user_id
|
18
|
+
# @type [String]
|
19
|
+
@token = token
|
20
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
21
|
+
@additional_properties = additional_properties
|
22
|
+
end
|
23
|
+
|
24
|
+
# Deserialize a JSON object to an instance of DeleteUserTokenOpts
|
25
|
+
#
|
26
|
+
# @param json_object [JSON]
|
27
|
+
# @return [Users::Tokens::DeleteUserTokenOpts]
|
28
|
+
def self.from_json(json_object:)
|
29
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
30
|
+
JSON.parse(json_object)
|
31
|
+
user_id = struct.user_id
|
32
|
+
token = struct.token
|
33
|
+
new(user_id: user_id, token: token, additional_properties: struct)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Serialize an instance of DeleteUserTokenOpts to a JSON object
|
37
|
+
#
|
38
|
+
# @return [JSON]
|
39
|
+
def to_json(*_args)
|
40
|
+
{ "user_id": @user_id, "token": @token }.to_json
|
41
|
+
end
|
42
|
+
|
43
|
+
# 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.
|
44
|
+
#
|
45
|
+
# @param obj [Object]
|
46
|
+
# @return [Void]
|
47
|
+
def self.validate_raw(obj:)
|
48
|
+
obj.user_id.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.")
|
49
|
+
obj.token.is_a?(String) != false || raise("Passed value for field obj.token is not the expected type, validation failed.")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Courier
|
6
|
+
module Users
|
7
|
+
class Tokens
|
8
|
+
class Device
|
9
|
+
attr_reader :app_id, :ad_id, :device_id, :platform, :manufacturer, :model, :additional_properties
|
10
|
+
|
11
|
+
# @param app_id [String] Id of the application the token is used for
|
12
|
+
# @param ad_id [String] Id of the advertising identifier
|
13
|
+
# @param device_id [String] Id of the device the token is associated with
|
14
|
+
# @param platform [String] The device platform i.e. android, ios, web
|
15
|
+
# @param manufacturer [String] The device manufacturer
|
16
|
+
# @param model [String] The device model
|
17
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
18
|
+
# @return [Users::Tokens::Device]
|
19
|
+
def initialize(app_id: nil, ad_id: nil, device_id: nil, platform: nil, manufacturer: nil, model: nil,
|
20
|
+
additional_properties: nil)
|
21
|
+
# @type [String] Id of the application the token is used for
|
22
|
+
@app_id = app_id
|
23
|
+
# @type [String] Id of the advertising identifier
|
24
|
+
@ad_id = ad_id
|
25
|
+
# @type [String] Id of the device the token is associated with
|
26
|
+
@device_id = device_id
|
27
|
+
# @type [String] The device platform i.e. android, ios, web
|
28
|
+
@platform = platform
|
29
|
+
# @type [String] The device manufacturer
|
30
|
+
@manufacturer = manufacturer
|
31
|
+
# @type [String] The device model
|
32
|
+
@model = model
|
33
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
34
|
+
@additional_properties = additional_properties
|
35
|
+
end
|
36
|
+
|
37
|
+
# Deserialize a JSON object to an instance of Device
|
38
|
+
#
|
39
|
+
# @param json_object [JSON]
|
40
|
+
# @return [Users::Tokens::Device]
|
41
|
+
def self.from_json(json_object:)
|
42
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
43
|
+
JSON.parse(json_object)
|
44
|
+
app_id = struct.app_id
|
45
|
+
ad_id = struct.ad_id
|
46
|
+
device_id = struct.device_id
|
47
|
+
platform = struct.platform
|
48
|
+
manufacturer = struct.manufacturer
|
49
|
+
model = struct.model
|
50
|
+
new(app_id: app_id, ad_id: ad_id, device_id: device_id, platform: platform, manufacturer: manufacturer,
|
51
|
+
model: model, additional_properties: struct)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Serialize an instance of Device to a JSON object
|
55
|
+
#
|
56
|
+
# @return [JSON]
|
57
|
+
def to_json(*_args)
|
58
|
+
{
|
59
|
+
"app_id": @app_id,
|
60
|
+
"ad_id": @ad_id,
|
61
|
+
"device_id": @device_id,
|
62
|
+
"platform": @platform,
|
63
|
+
"manufacturer": @manufacturer,
|
64
|
+
"model": @model
|
65
|
+
}.to_json
|
66
|
+
end
|
67
|
+
|
68
|
+
# 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.
|
69
|
+
#
|
70
|
+
# @param obj [Object]
|
71
|
+
# @return [Void]
|
72
|
+
def self.validate_raw(obj:)
|
73
|
+
obj.app_id&.is_a?(String) != false || raise("Passed value for field obj.app_id is not the expected type, validation failed.")
|
74
|
+
obj.ad_id&.is_a?(String) != false || raise("Passed value for field obj.ad_id is not the expected type, validation failed.")
|
75
|
+
obj.device_id&.is_a?(String) != false || raise("Passed value for field obj.device_id is not the expected type, validation failed.")
|
76
|
+
obj.platform&.is_a?(String) != false || raise("Passed value for field obj.platform is not the expected type, validation failed.")
|
77
|
+
obj.manufacturer&.is_a?(String) != false || raise("Passed value for field obj.manufacturer is not the expected type, validation failed.")
|
78
|
+
obj.model&.is_a?(String) != false || raise("Passed value for field obj.model is not the expected type, validation failed.")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Courier
|
6
|
+
module Users
|
7
|
+
class Tokens
|
8
|
+
class ExpiryDate
|
9
|
+
# Deserialize a JSON object to an instance of ExpiryDate
|
10
|
+
#
|
11
|
+
# @param json_object [JSON]
|
12
|
+
# @return [Users::Tokens::ExpiryDate]
|
13
|
+
def self.from_json(json_object:)
|
14
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
15
|
+
begin
|
16
|
+
struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.")
|
17
|
+
return json_object
|
18
|
+
rescue StandardError
|
19
|
+
# noop
|
20
|
+
end
|
21
|
+
begin
|
22
|
+
struct.is_a?(Boolean) != false || raise("Passed value for field struct is not the expected type, validation failed.")
|
23
|
+
return json_object
|
24
|
+
rescue StandardError
|
25
|
+
# noop
|
26
|
+
end
|
27
|
+
struct
|
28
|
+
end
|
29
|
+
|
30
|
+
# 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.
|
31
|
+
#
|
32
|
+
# @param obj [Object]
|
33
|
+
# @return [Void]
|
34
|
+
def self.validate_raw(obj:)
|
35
|
+
begin
|
36
|
+
return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.")
|
37
|
+
rescue StandardError
|
38
|
+
# noop
|
39
|
+
end
|
40
|
+
begin
|
41
|
+
return obj.is_a?(Boolean) != false || raise("Passed value for field obj is not the expected type, validation failed.")
|
42
|
+
rescue StandardError
|
43
|
+
# noop
|
44
|
+
end
|
45
|
+
raise("Passed value matched no type within the union, validation failed.")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Courier
|
6
|
+
module Users
|
7
|
+
class Tokens
|
8
|
+
class GetUserTokenOpts
|
9
|
+
attr_reader :user_id, :token, :additional_properties
|
10
|
+
|
11
|
+
# @param user_id [String]
|
12
|
+
# @param token [String]
|
13
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
14
|
+
# @return [Users::Tokens::GetUserTokenOpts]
|
15
|
+
def initialize(user_id:, token:, additional_properties: nil)
|
16
|
+
# @type [String]
|
17
|
+
@user_id = user_id
|
18
|
+
# @type [String]
|
19
|
+
@token = token
|
20
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
21
|
+
@additional_properties = additional_properties
|
22
|
+
end
|
23
|
+
|
24
|
+
# Deserialize a JSON object to an instance of GetUserTokenOpts
|
25
|
+
#
|
26
|
+
# @param json_object [JSON]
|
27
|
+
# @return [Users::Tokens::GetUserTokenOpts]
|
28
|
+
def self.from_json(json_object:)
|
29
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
30
|
+
JSON.parse(json_object)
|
31
|
+
user_id = struct.user_id
|
32
|
+
token = struct.token
|
33
|
+
new(user_id: user_id, token: token, additional_properties: struct)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Serialize an instance of GetUserTokenOpts to a JSON object
|
37
|
+
#
|
38
|
+
# @return [JSON]
|
39
|
+
def to_json(*_args)
|
40
|
+
{ "user_id": @user_id, "token": @token }.to_json
|
41
|
+
end
|
42
|
+
|
43
|
+
# 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.
|
44
|
+
#
|
45
|
+
# @param obj [Object]
|
46
|
+
# @return [Void]
|
47
|
+
def self.validate_raw(obj:)
|
48
|
+
obj.user_id.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.")
|
49
|
+
obj.token.is_a?(String) != false || raise("Passed value for field obj.token is not the expected type, validation failed.")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "token_status"
|
4
|
+
require_relative "provider_key"
|
5
|
+
require_relative "expiry_date"
|
6
|
+
require_relative "device"
|
7
|
+
require_relative "tracking"
|
8
|
+
require "json"
|
9
|
+
|
10
|
+
module Courier
|
11
|
+
module Users
|
12
|
+
class Tokens
|
13
|
+
class GetUserTokenResponse
|
14
|
+
attr_reader :status, :status_reason, :token, :provider_key, :expiry_date, :properties, :device, :tracking,
|
15
|
+
:additional_properties
|
16
|
+
|
17
|
+
# @param status [Users::Tokens::TokenStatus]
|
18
|
+
# @param status_reason [String] The reason for the token status.
|
19
|
+
# @param token [String] Full body of the token. Must match token in URL.
|
20
|
+
# @param provider_key [Users::Tokens::ProviderKey]
|
21
|
+
# @param expiry_date [Users::Tokens::ExpiryDate] ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable expiration.
|
22
|
+
# @param properties [Object] Properties sent to the provider along with the token
|
23
|
+
# @param device [Users::Tokens::Device] Information about the device the token is associated with.
|
24
|
+
# @param tracking [Users::Tokens::Tracking] Information about the device the token is associated with.
|
25
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
26
|
+
# @return [Users::Tokens::GetUserTokenResponse]
|
27
|
+
def initialize(provider_key:, status: nil, status_reason: nil, token: nil, expiry_date: nil, properties: nil,
|
28
|
+
device: nil, tracking: nil, additional_properties: nil)
|
29
|
+
# @type [Users::Tokens::TokenStatus]
|
30
|
+
@status = status
|
31
|
+
# @type [String] The reason for the token status.
|
32
|
+
@status_reason = status_reason
|
33
|
+
# @type [String] Full body of the token. Must match token in URL.
|
34
|
+
@token = token
|
35
|
+
# @type [Users::Tokens::ProviderKey]
|
36
|
+
@provider_key = provider_key
|
37
|
+
# @type [Users::Tokens::ExpiryDate] ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable expiration.
|
38
|
+
@expiry_date = expiry_date
|
39
|
+
# @type [Object] Properties sent to the provider along with the token
|
40
|
+
@properties = properties
|
41
|
+
# @type [Users::Tokens::Device] Information about the device the token is associated with.
|
42
|
+
@device = device
|
43
|
+
# @type [Users::Tokens::Tracking] Information about the device the token is associated with.
|
44
|
+
@tracking = tracking
|
45
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
46
|
+
@additional_properties = additional_properties
|
47
|
+
end
|
48
|
+
|
49
|
+
# Deserialize a JSON object to an instance of GetUserTokenResponse
|
50
|
+
#
|
51
|
+
# @param json_object [JSON]
|
52
|
+
# @return [Users::Tokens::GetUserTokenResponse]
|
53
|
+
def self.from_json(json_object:)
|
54
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
55
|
+
parsed_json = JSON.parse(json_object)
|
56
|
+
status = struct.status
|
57
|
+
status_reason = struct.status_reason
|
58
|
+
token = struct.token
|
59
|
+
provider_key = struct.provider_key
|
60
|
+
if parsed_json["expiry_date"].nil?
|
61
|
+
expiry_date = nil
|
62
|
+
else
|
63
|
+
expiry_date = parsed_json["expiry_date"].to_json
|
64
|
+
expiry_date = Users::Tokens::ExpiryDate.from_json(json_object: expiry_date)
|
65
|
+
end
|
66
|
+
properties = struct.properties
|
67
|
+
if parsed_json["device"].nil?
|
68
|
+
device = nil
|
69
|
+
else
|
70
|
+
device = parsed_json["device"].to_json
|
71
|
+
device = Users::Tokens::Device.from_json(json_object: device)
|
72
|
+
end
|
73
|
+
if parsed_json["tracking"].nil?
|
74
|
+
tracking = nil
|
75
|
+
else
|
76
|
+
tracking = parsed_json["tracking"].to_json
|
77
|
+
tracking = Users::Tokens::Tracking.from_json(json_object: tracking)
|
78
|
+
end
|
79
|
+
new(status: status, status_reason: status_reason, token: token, provider_key: provider_key,
|
80
|
+
expiry_date: expiry_date, properties: properties, device: device, tracking: tracking, additional_properties: struct)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Serialize an instance of GetUserTokenResponse to a JSON object
|
84
|
+
#
|
85
|
+
# @return [JSON]
|
86
|
+
def to_json(*_args)
|
87
|
+
{
|
88
|
+
"status": @status,
|
89
|
+
"status_reason": @status_reason,
|
90
|
+
"token": @token,
|
91
|
+
"provider_key": @provider_key,
|
92
|
+
"expiry_date": @expiry_date,
|
93
|
+
"properties": @properties,
|
94
|
+
"device": @device,
|
95
|
+
"tracking": @tracking
|
96
|
+
}.to_json
|
97
|
+
end
|
98
|
+
|
99
|
+
# 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.
|
100
|
+
#
|
101
|
+
# @param obj [Object]
|
102
|
+
# @return [Void]
|
103
|
+
def self.validate_raw(obj:)
|
104
|
+
obj.status&.is_a?(Users::Tokens::TokenStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
105
|
+
obj.status_reason&.is_a?(String) != false || raise("Passed value for field obj.status_reason is not the expected type, validation failed.")
|
106
|
+
obj.token&.is_a?(String) != false || raise("Passed value for field obj.token is not the expected type, validation failed.")
|
107
|
+
obj.provider_key.is_a?(Users::Tokens::ProviderKey) != false || raise("Passed value for field obj.provider_key is not the expected type, validation failed.")
|
108
|
+
obj.expiry_date.nil? || Users::Tokens::ExpiryDate.validate_raw(obj: obj.expiry_date)
|
109
|
+
obj.properties&.is_a?(Object) != false || raise("Passed value for field obj.properties is not the expected type, validation failed.")
|
110
|
+
obj.device.nil? || Users::Tokens::Device.validate_raw(obj: obj.device)
|
111
|
+
obj.tracking.nil? || Users::Tokens::Tracking.validate_raw(obj: obj.tracking)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|