Class: FlatApi::MediaAttachment
- Inherits:
-
Object
- Object
- FlatApi::MediaAttachment
- Defined in:
- lib/flat_api/models/media_attachment.rb
Overview
Media attachment. The API will automatically resolve the details, oEmbed, and media available if possible and return them in this object
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#author_name ⇒ Object
The resolved author name of the attachment.
-
#author_url ⇒ Object
The resolved author url of the attachment.
-
#dedicated ⇒ Object
True if the resource is dedicated for the assignment (for scores and worksheets), meaning on the user-side this one is stored in the assignment.
-
#description ⇒ Object
The resolved description of the attachment.
-
#google_drive_file_id ⇒ Object
The ID of the Google Drive File.
-
#html ⇒ Object
If the attachment type is ‘rich` or `video`, the HTML code of the media to display.
-
#html_height ⇒ Object
If the ‘html` is available, the height of the widget.
-
#html_width ⇒ Object
If the ‘html` is available, the width of the widget.
-
#icon_url ⇒ Object
The URL of the icon.
-
#lock_score_template ⇒ Object
To be used with a score attached in ‘sharingMode` `copy` (score used as template).
-
#mime_type ⇒ Object
The mine type of the file.
-
#revision ⇒ Object
An unique revision identifier of a score.
-
#score ⇒ Object
An unique Flat score identifier.
-
#sharing_mode ⇒ Object
Returns the value of attribute sharing_mode.
-
#thumbnail_height ⇒ Object
If the ‘thumbnailUrl` is available, the width of the thumbnail.
-
#thumbnail_url ⇒ Object
If the attachment type is ‘rich`, `video`, `photo` or `link`, a displayable thumbnail for this attachment.
-
#thumbnail_width ⇒ Object
If the ‘thumbnailUrl` is available, the width of the thumbnail.
-
#title ⇒ Object
The resolved title of the attachment.
-
#track ⇒ Object
A unique track identifier.
-
#type ⇒ Object
The type of the assignment resolved: * ‘rich`, `photo`, `video` are automatically resolved as `link` * A `flat` attachment is a score document where the unique identifier will be specified in the `score` property.
-
#url ⇒ Object
The url of the attachment.
-
#worksheet ⇒ Object
An unique worksheet identifier.
Class Method Summary collapse
-
._deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ MediaAttachment
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ MediaAttachment
Initializes the object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/flat_api/models/media_attachment.rb', line 175 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `FlatApi::MediaAttachment` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `FlatApi::MediaAttachment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'type') self.type = attributes[:'type'] else self.type = nil end if attributes.key?(:'score') self.score = attributes[:'score'] end if attributes.key?(:'revision') self.revision = attributes[:'revision'] end if attributes.key?(:'worksheet') self.worksheet = attributes[:'worksheet'] end if attributes.key?(:'dedicated') self.dedicated = attributes[:'dedicated'] end if attributes.key?(:'track') self.track = attributes[:'track'] end if attributes.key?(:'sharing_mode') self.sharing_mode = attributes[:'sharing_mode'] else self.sharing_mode = 'read' end if attributes.key?(:'lock_score_template') self.lock_score_template = attributes[:'lock_score_template'] end if attributes.key?(:'title') self.title = attributes[:'title'] end if attributes.key?(:'description') self.description = attributes[:'description'] end if attributes.key?(:'html') self.html = attributes[:'html'] end if attributes.key?(:'html_width') self.html_width = attributes[:'html_width'] end if attributes.key?(:'html_height') self.html_height = attributes[:'html_height'] end if attributes.key?(:'url') self.url = attributes[:'url'] end if attributes.key?(:'thumbnail_url') self.thumbnail_url = attributes[:'thumbnail_url'] end if attributes.key?(:'thumbnail_width') self.thumbnail_width = attributes[:'thumbnail_width'] end if attributes.key?(:'thumbnail_height') self.thumbnail_height = attributes[:'thumbnail_height'] end if attributes.key?(:'author_name') self. = attributes[:'author_name'] end if attributes.key?(:'author_url') self. = attributes[:'author_url'] end if attributes.key?(:'icon_url') self.icon_url = attributes[:'icon_url'] end if attributes.key?(:'mime_type') self.mime_type = attributes[:'mime_type'] end if attributes.key?(:'google_drive_file_id') self.google_drive_file_id = attributes[:'google_drive_file_id'] end end |
Instance Attribute Details
#author_name ⇒ Object
The resolved author name of the attachment
70 71 72 |
# File 'lib/flat_api/models/media_attachment.rb', line 70 def @author_name end |
#author_url ⇒ Object
The resolved author url of the attachment
73 74 75 |
# File 'lib/flat_api/models/media_attachment.rb', line 73 def @author_url end |
#dedicated ⇒ Object
True if the resource is dedicated for the assignment (for scores and worksheets), meaning on the user-side this one is stored in the assignment
32 33 34 |
# File 'lib/flat_api/models/media_attachment.rb', line 32 def dedicated @dedicated end |
#description ⇒ Object
The resolved description of the attachment
46 47 48 |
# File 'lib/flat_api/models/media_attachment.rb', line 46 def description @description end |
#google_drive_file_id ⇒ Object
The ID of the Google Drive File
82 83 84 |
# File 'lib/flat_api/models/media_attachment.rb', line 82 def google_drive_file_id @google_drive_file_id end |
#html ⇒ Object
If the attachment type is ‘rich` or `video`, the HTML code of the media to display
49 50 51 |
# File 'lib/flat_api/models/media_attachment.rb', line 49 def html @html end |
#html_height ⇒ Object
If the ‘html` is available, the height of the widget
55 56 57 |
# File 'lib/flat_api/models/media_attachment.rb', line 55 def html_height @html_height end |
#html_width ⇒ Object
If the ‘html` is available, the width of the widget
52 53 54 |
# File 'lib/flat_api/models/media_attachment.rb', line 52 def html_width @html_width end |
#icon_url ⇒ Object
The URL of the icon
76 77 78 |
# File 'lib/flat_api/models/media_attachment.rb', line 76 def icon_url @icon_url end |
#lock_score_template ⇒ Object
To be used with a score attached in ‘sharingMode` `copy` (score used as template). If true, students won’t be able to change the original notes of the template.
40 41 42 |
# File 'lib/flat_api/models/media_attachment.rb', line 40 def lock_score_template @lock_score_template end |
#mime_type ⇒ Object
The mine type of the file
79 80 81 |
# File 'lib/flat_api/models/media_attachment.rb', line 79 def mime_type @mime_type end |
#revision ⇒ Object
An unique revision identifier of a score
26 27 28 |
# File 'lib/flat_api/models/media_attachment.rb', line 26 def revision @revision end |
#score ⇒ Object
An unique Flat score identifier
23 24 25 |
# File 'lib/flat_api/models/media_attachment.rb', line 23 def score @score end |
#sharing_mode ⇒ Object
Returns the value of attribute sharing_mode.
37 38 39 |
# File 'lib/flat_api/models/media_attachment.rb', line 37 def sharing_mode @sharing_mode end |
#thumbnail_height ⇒ Object
If the ‘thumbnailUrl` is available, the width of the thumbnail
67 68 69 |
# File 'lib/flat_api/models/media_attachment.rb', line 67 def thumbnail_height @thumbnail_height end |
#thumbnail_url ⇒ Object
If the attachment type is ‘rich`, `video`, `photo` or `link`, a displayable thumbnail for this attachment
61 62 63 |
# File 'lib/flat_api/models/media_attachment.rb', line 61 def thumbnail_url @thumbnail_url end |
#thumbnail_width ⇒ Object
If the ‘thumbnailUrl` is available, the width of the thumbnail
64 65 66 |
# File 'lib/flat_api/models/media_attachment.rb', line 64 def thumbnail_width @thumbnail_width end |
#title ⇒ Object
The resolved title of the attachment
43 44 45 |
# File 'lib/flat_api/models/media_attachment.rb', line 43 def title @title end |
#track ⇒ Object
A unique track identifier
35 36 37 |
# File 'lib/flat_api/models/media_attachment.rb', line 35 def track @track end |
#type ⇒ Object
The type of the assignment resolved: * ‘rich`, `photo`, `video` are automatically resolved as `link` * A `flat` attachment is a score document where the unique identifier will be specified in the `score` property. Its sharing mode will be provided in the `sharingMode` property.
20 21 22 |
# File 'lib/flat_api/models/media_attachment.rb', line 20 def type @type end |
#url ⇒ Object
The url of the attachment
58 59 60 |
# File 'lib/flat_api/models/media_attachment.rb', line 58 def url @url end |
#worksheet ⇒ Object
An unique worksheet identifier
29 30 31 |
# File 'lib/flat_api/models/media_attachment.rb', line 29 def worksheet @worksheet end |
Class Method Details
._deserialize(type, value) ⇒ Object
Deserializes the data based on type
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
# File 'lib/flat_api/models/media_attachment.rb', line 381 def self._deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = FlatApi.const_get(type) klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
135 136 137 |
# File 'lib/flat_api/models/media_attachment.rb', line 135 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/flat_api/models/media_attachment.rb', line 107 def self.attribute_map { :'type' => :'type', :'score' => :'score', :'revision' => :'revision', :'worksheet' => :'worksheet', :'dedicated' => :'dedicated', :'track' => :'track', :'sharing_mode' => :'sharingMode', :'lock_score_template' => :'lockScoreTemplate', :'title' => :'title', :'description' => :'description', :'html' => :'html', :'html_width' => :'htmlWidth', :'html_height' => :'htmlHeight', :'url' => :'url', :'thumbnail_url' => :'thumbnailUrl', :'thumbnail_width' => :'thumbnailWidth', :'thumbnail_height' => :'thumbnailHeight', :'author_name' => :'authorName', :'author_url' => :'authorUrl', :'icon_url' => :'iconUrl', :'mime_type' => :'mimeType', :'google_drive_file_id' => :'googleDriveFileId' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/flat_api/models/media_attachment.rb', line 357 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
168 169 170 171 |
# File 'lib/flat_api/models/media_attachment.rb', line 168 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/flat_api/models/media_attachment.rb', line 140 def self.openapi_types { :'type' => :'String', :'score' => :'String', :'revision' => :'String', :'worksheet' => :'String', :'dedicated' => :'Boolean', :'track' => :'String', :'sharing_mode' => :'MediaScoreSharingMode', :'lock_score_template' => :'Boolean', :'title' => :'String', :'description' => :'String', :'html' => :'String', :'html_width' => :'String', :'html_height' => :'String', :'url' => :'String', :'thumbnail_url' => :'String', :'thumbnail_width' => :'Integer', :'thumbnail_height' => :'Integer', :'author_name' => :'String', :'author_url' => :'String', :'icon_url' => :'String', :'mime_type' => :'String', :'google_drive_file_id' => :'String' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/flat_api/models/media_attachment.rb', line 315 def ==(o) return true if self.equal?(o) self.class == o.class && type == o.type && score == o.score && revision == o.revision && worksheet == o.worksheet && dedicated == o.dedicated && track == o.track && sharing_mode == o.sharing_mode && lock_score_template == o.lock_score_template && title == o.title && description == o.description && html == o.html && html_width == o.html_width && html_height == o.html_height && url == o.url && thumbnail_url == o.thumbnail_url && thumbnail_width == o.thumbnail_width && thumbnail_height == o.thumbnail_height && == o. && == o. && icon_url == o.icon_url && mime_type == o.mime_type && google_drive_file_id == o.google_drive_file_id end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
452 453 454 455 456 457 458 459 460 461 462 463 464 |
# File 'lib/flat_api/models/media_attachment.rb', line 452 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#eql?(o) ⇒ Boolean
344 345 346 |
# File 'lib/flat_api/models/media_attachment.rb', line 344 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
350 351 352 |
# File 'lib/flat_api/models/media_attachment.rb', line 350 def hash [type, score, revision, worksheet, dedicated, track, sharing_mode, lock_score_template, title, description, html, html_width, html_height, url, thumbnail_url, thumbnail_width, thumbnail_height, , , icon_url, mime_type, google_drive_file_id].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
283 284 285 286 287 288 289 290 291 |
# File 'lib/flat_api/models/media_attachment.rb', line 283 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if @type.nil? invalid_properties.push('invalid value for "type", type cannot be nil.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
428 429 430 |
# File 'lib/flat_api/models/media_attachment.rb', line 428 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
434 435 436 437 438 439 440 441 442 443 444 445 446 |
# File 'lib/flat_api/models/media_attachment.rb', line 434 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
422 423 424 |
# File 'lib/flat_api/models/media_attachment.rb', line 422 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
295 296 297 298 299 300 301 |
# File 'lib/flat_api/models/media_attachment.rb', line 295 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @type.nil? type_validator = EnumAttributeValidator.new('String', ["rich", "photo", "video", "link", "flat", "googleDrive", "worksheet", "performance"]) return false unless type_validator.valid?(@type) true end |