Class: AtomicLti::Params
- Inherits:
-
Object
- Object
- AtomicLti::Params
- Defined in:
- app/lib/atomic_lti/params.rb
Overview
This is for extracting data from the lti jwt in more human-readable ways
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #ags_data ⇒ Object
- #canvas_account_id ⇒ Object
- #canvas_assignment_id ⇒ Object
- #canvas_course_id ⇒ Object
- #canvas_course_name ⇒ Object
- #canvas_section_ids ⇒ Object
- #client_id ⇒ Object
- #context_data ⇒ Object
- #context_id ⇒ Object
-
#custom_data ⇒ Object
This extracts the custom parameters from the jwt token from the lti launch These values must be added to the developer key under “Custom Fields” for example: canvas_course_id=$Canvas.course.id.
- #deep_linking_claim ⇒ Object
- #deep_linking_data ⇒ Object
- #deployment_id ⇒ Object
-
#initialize(id_token_decoded) ⇒ Params
constructor
A new instance of Params.
- #is_deep_link ⇒ Object
- #iss ⇒ Object
- #launch_context ⇒ Object
- #launch_locale ⇒ Object
- #launch_presentation_data ⇒ Object
- #lis_data ⇒ Object
- #lti_advantage? ⇒ Boolean
- #message_type ⇒ Object
- #product_family_code ⇒ Object
- #resource_link_data ⇒ Object
- #resource_link_title ⇒ Object
- #tool_consumer_instance_guid ⇒ Object
- #tool_consumer_instance_name ⇒ Object
- #tool_platform_data ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(id_token_decoded) ⇒ Params
Returns a new instance of Params.
6 7 8 |
# File 'app/lib/atomic_lti/params.rb', line 6 def initialize(id_token_decoded) @token = id_token_decoded.with_indifferent_access end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
4 5 6 |
# File 'app/lib/atomic_lti/params.rb', line 4 def token @token end |
Instance Method Details
#ags_data ⇒ Object
87 88 89 |
# File 'app/lib/atomic_lti/params.rb', line 87 def ags_data token[AtomicLti::Definitions::AGS_CLAIM] || {} end |
#canvas_account_id ⇒ Object
122 123 124 |
# File 'app/lib/atomic_lti/params.rb', line 122 def canvas_account_id custom_data[:canvas_account_id] end |
#canvas_assignment_id ⇒ Object
130 131 132 |
# File 'app/lib/atomic_lti/params.rb', line 130 def canvas_assignment_id custom_data[:canvas_assignment_id] end |
#canvas_course_id ⇒ Object
114 115 116 |
# File 'app/lib/atomic_lti/params.rb', line 114 def canvas_course_id custom_data[:canvas_course_id] end |
#canvas_course_name ⇒ Object
126 127 128 |
# File 'app/lib/atomic_lti/params.rb', line 126 def canvas_course_name custom_data[:canvas_course_name] end |
#canvas_section_ids ⇒ Object
118 119 120 |
# File 'app/lib/atomic_lti/params.rb', line 118 def canvas_section_ids custom_data[:canvas_section_ids] end |
#client_id ⇒ Object
26 27 28 |
# File 'app/lib/atomic_lti/params.rb', line 26 def client_id token[:aud] end |
#context_data ⇒ Object
30 31 32 |
# File 'app/lib/atomic_lti/params.rb', line 30 def context_data token[AtomicLti::Definitions::CONTEXT_CLAIM] || {} end |
#context_id ⇒ Object
47 48 49 |
# File 'app/lib/atomic_lti/params.rb', line 47 def context_id context_data[:id] end |
#custom_data ⇒ Object
This extracts the custom parameters from the jwt token from the lti launch These values must be added to the developer key under “Custom Fields” for example: canvas_course_id=$Canvas.course.id
110 111 112 |
# File 'app/lib/atomic_lti/params.rb', line 110 def custom_data token[AtomicLti::Definitions::CUSTOM_CLAIM]&.reject { |_, s| s.to_s.start_with?("$Canvas") } || {} end |
#deep_linking_claim ⇒ Object
95 96 97 |
# File 'app/lib/atomic_lti/params.rb', line 95 def deep_linking_claim token[AtomicLti::Definitions::DEEP_LINKING_CLAIM] end |
#deep_linking_data ⇒ Object
91 92 93 |
# File 'app/lib/atomic_lti/params.rb', line 91 def deep_linking_data token[AtomicLti::Definitions::DEEP_LINKING_DATA_CLAIM] || {} end |
#deployment_id ⇒ Object
14 15 16 |
# File 'app/lib/atomic_lti/params.rb', line 14 def deployment_id token[AtomicLti::Definitions::DEPLOYMENT_ID] end |
#is_deep_link ⇒ Object
103 104 105 |
# File 'app/lib/atomic_lti/params.rb', line 103 def is_deep_link AtomicLti::Definitions.deep_link_launch?(token) end |
#iss ⇒ Object
18 19 20 |
# File 'app/lib/atomic_lti/params.rb', line 18 def iss token[:iss] end |
#launch_context ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/lib/atomic_lti/params.rb', line 34 def launch_context # This is an array, I'm not sure what it means to have more than one # value. In courses and accounts there's only one value contexts = context_data[:type] || [] if contexts.include? AtomicLti::Definitions::COURSE_CONTEXT "COURSE" elsif contexts.include? AtomicLti::Definitions::ACCOUNT_CONTEXT "ACCOUNT" else "UNKNOWN" end end |
#launch_locale ⇒ Object
83 84 85 |
# File 'app/lib/atomic_lti/params.rb', line 83 def launch_locale launch_presentation_data[:locale] end |
#launch_presentation_data ⇒ Object
79 80 81 |
# File 'app/lib/atomic_lti/params.rb', line 79 def launch_presentation_data token[AtomicLti::Definitions::LAUNCH_PRESENTATION] || {} end |
#lis_data ⇒ Object
59 60 61 |
# File 'app/lib/atomic_lti/params.rb', line 59 def lis_data token[AtomicLti::Definitions::LIS_CLAIM] || {} end |
#lti_advantage? ⇒ Boolean
10 11 12 |
# File 'app/lib/atomic_lti/params.rb', line 10 def lti_advantage? true end |
#message_type ⇒ Object
99 100 101 |
# File 'app/lib/atomic_lti/params.rb', line 99 def token[AtomicLti::Definitions::MESSAGE_TYPE] end |
#product_family_code ⇒ Object
67 68 69 |
# File 'app/lib/atomic_lti/params.rb', line 67 def product_family_code tool_platform_data[:product_family_code] end |
#resource_link_data ⇒ Object
51 52 53 |
# File 'app/lib/atomic_lti/params.rb', line 51 def resource_link_data token[AtomicLti::Definitions::RESOURCE_LINK_CLAIM] || {} end |
#resource_link_title ⇒ Object
55 56 57 |
# File 'app/lib/atomic_lti/params.rb', line 55 def resource_link_title resource_link_data[:title] end |
#tool_consumer_instance_guid ⇒ Object
71 72 73 |
# File 'app/lib/atomic_lti/params.rb', line 71 def tool_consumer_instance_guid tool_platform_data[:guid] end |
#tool_consumer_instance_name ⇒ Object
75 76 77 |
# File 'app/lib/atomic_lti/params.rb', line 75 def tool_consumer_instance_name tool_platform_data[:name] end |
#tool_platform_data ⇒ Object
63 64 65 |
# File 'app/lib/atomic_lti/params.rb', line 63 def tool_platform_data token[AtomicLti::Definitions::TOOL_PLATFORM_CLAIM] || {} end |
#version ⇒ Object
22 23 24 |
# File 'app/lib/atomic_lti/params.rb', line 22 def version token[AtomicLti::Definitions::LTI_VERSION] end |