Module: PandaPal::DeepLinkingHelpers
- Defined in:
- app/lib/panda_pal/deep_linking_helpers.rb
Instance Method Summary collapse
-
#build_file_content_item(url:, title: nil, text: nil, media_type: nil, icon: nil, custom: {}, **options) ⇒ Object
Build a file content item.
-
#build_html_content_item(html:, title: nil, text: nil, custom: {}, **options) ⇒ Object
Build an HTML content item.
-
#build_link_content_item(url:, title: nil, text: nil, icon: nil, thumbnail: nil, custom: {}, **options) ⇒ Object
Build a link content item Example: build_link_content_item( url: panda_pal.v1p3_resource_link_request_url, title: ‘My Quiz’, custom: { quiz_id: 123, launch_type: :quiz_launch # REQUIRED for proper routing } ).
-
#render_deep_linking_response(content_items, custom_data: {}) ⇒ Object
Render the deep linking response This builds the JWT and renders the auto-submit form.
Instance Method Details
#build_file_content_item(url:, title: nil, text: nil, media_type: nil, icon: nil, custom: {}, **options) ⇒ Object
Build a file content item
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/lib/panda_pal/deep_linking_helpers.rb', line 44 def build_file_content_item(url:, title: nil, text: nil, media_type: nil, icon: nil, custom: {}, **) validate_custom_launch_type!(custom) content_item = { type: 'file', url: url, title: title } content_item[:text] = text if text.present? content_item[:mediaType] = media_type if media_type.present? content_item[:icon] = icon if icon.present? content_item[:custom] = custom if custom.present? content_item.merge() end |
#build_html_content_item(html:, title: nil, text: nil, custom: {}, **options) ⇒ Object
Build an HTML content item
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/lib/panda_pal/deep_linking_helpers.rb', line 65 def build_html_content_item(html:, title: nil, text: nil, custom: {}, **) validate_custom_launch_type!(custom) content_item = { type: 'html', html: html, title: title } content_item[:text] = text if text.present? content_item[:custom] = custom if custom.present? content_item.merge() end |
#build_link_content_item(url:, title: nil, text: nil, icon: nil, thumbnail: nil, custom: {}, **options) ⇒ Object
Build a link content item Example:
build_link_content_item(
url: panda_pal.v1p3_resource_link_request_url,
title: 'My Quiz',
custom: {
quiz_id: 123,
launch_type: :quiz_launch # REQUIRED for proper routing
}
)
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/lib/panda_pal/deep_linking_helpers.rb', line 21 def build_link_content_item(url:, title: nil, text: nil, icon: nil, thumbnail: nil, custom: {}, **) validate_custom_launch_type!(custom) content_item = { type: 'link', url: url, title: title } content_item[:text] = text if text.present? content_item[:icon] = icon if icon.present? content_item[:thumbnail] = thumbnail if thumbnail.present? content_item[:custom] = custom if custom.present? content_item.merge() end |
#render_deep_linking_response(content_items, custom_data: {}) ⇒ Object
Render the deep linking response This builds the JWT and renders the auto-submit form
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/lib/panda_pal/deep_linking_helpers.rb', line 80 def render_deep_linking_response(content_items, custom_data: {}) deep_link_return_url = current_session[:deep_link_return_url] deep_link_data = current_session[:deep_link_data] unless deep_link_return_url.present? render plain: 'No deep linking session found. Please ensure you accessed this through a proper deep linking flow.', status: :bad_request return end # Build custom deep link data - merge Canvas data with custom data launch_params = current_session[:launch_params] merged_custom_data = (deep_link_data || {}).merge({ selection_time: Time.now.iso8601, selected_by: launch_params&.dig('sub') || 'unknown' }).merge(custom_data) # Build the JWT response jwt = build_deep_link_jwt(content_items, merged_custom_data) # Set up the auto-submit form @form_action = deep_link_return_url @method = :post @form_data = { JWT: jwt } render partial: 'panda_pal/partials/auto_submit_form' end |