Class: Teams::Api::CitationAppearance
- Defined in:
- lib/teams/api/citation_appearance.rb
Constant Summary collapse
- ADAPTIVE_CARD_CONTENT_TYPE =
"application/vnd.microsoft.card.adaptive"
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
- #abstract ⇒ Object
- #icon ⇒ Object
-
#initialize(raw = nil, name: nil, text: nil, url: nil, abstract: nil, icon: nil, keywords: nil, usage_info: nil) ⇒ CitationAppearance
constructor
A new instance of CitationAppearance.
- #keywords ⇒ Object
- #name ⇒ Object
- #text ⇒ Object
- #to_h ⇒ Object
- #url ⇒ Object
- #usage_info ⇒ Object
Constructor Details
#initialize(raw = nil, name: nil, text: nil, url: nil, abstract: nil, icon: nil, keywords: nil, usage_info: nil) ⇒ CitationAppearance
Returns a new instance of CitationAppearance.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/teams/api/citation_appearance.rb', line 8 def initialize(raw = nil, name: nil, text: nil, url: nil, abstract: nil, icon: nil, keywords: nil, usage_info: nil) body = raw || {} body = body.to_h if body.respond_to?(:to_h) body = body.merge({ "name" => name, "text" => text, "url" => url, "abstract" => abstract, "icon" => icon, "keywords" => keywords, "usageInfo" => usage_info }.compact) super(body) end |
Instance Method Details
#abstract ⇒ Object
35 36 37 |
# File 'lib/teams/api/citation_appearance.rb', line 35 def abstract read("abstract") end |
#icon ⇒ Object
39 40 41 |
# File 'lib/teams/api/citation_appearance.rb', line 39 def icon read("icon") end |
#keywords ⇒ Object
43 44 45 |
# File 'lib/teams/api/citation_appearance.rb', line 43 def keywords read("keywords") end |
#name ⇒ Object
23 24 25 |
# File 'lib/teams/api/citation_appearance.rb', line 23 def name read("name") end |
#text ⇒ Object
27 28 29 |
# File 'lib/teams/api/citation_appearance.rb', line 27 def text read("text") end |
#to_h ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/teams/api/citation_appearance.rb', line 51 def to_h validate! body = { "@type" => "DigitalDocument", "name" => name, "abstract" => abstract } body["text"] = text if text body["url"] = url if url body["encodingFormat"] = ADAPTIVE_CARD_CONTENT_TYPE if text && !text.empty? body["image"] = { "@type" => "ImageObject", "name" => icon } if icon body["keywords"] = keywords if keywords body["usageInfo"] = usage_info.to_h if usage_info && usage_info.respond_to?(:to_h) body["usageInfo"] = usage_info if usage_info && !usage_info.respond_to?(:to_h) body end |
#url ⇒ Object
31 32 33 |
# File 'lib/teams/api/citation_appearance.rb', line 31 def url read("url") end |
#usage_info ⇒ Object
47 48 49 |
# File 'lib/teams/api/citation_appearance.rb', line 47 def usage_info read("usageInfo", "usage_info") end |