Class: FlatApi::MediaAttachment

Inherits:
ApiModelBase show all
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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ MediaAttachment

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/flat_api/models/media_attachment.rb', line 190

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
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_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: " + acceptable_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?(:'part_uuid')
    self.part_uuid = attributes[:'part_uuid']
  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.author_name = attributes[:'author_name']
  end

  if attributes.key?(:'author_url')
    self.author_url = 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

  if attributes.key?(:'teacher_only')
    self.teacher_only = attributes[:'teacher_only']
  else
    self.teacher_only = false
  end
end

Instance Attribute Details

#author_nameObject

The resolved author name of the attachment



73
74
75
# File 'lib/flat_api/models/media_attachment.rb', line 73

def author_name
  @author_name
end

#author_urlObject

The resolved author url of the attachment



76
77
78
# File 'lib/flat_api/models/media_attachment.rb', line 76

def author_url
  @author_url
end

#dedicatedObject

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

#descriptionObject

The resolved description of the attachment



49
50
51
# File 'lib/flat_api/models/media_attachment.rb', line 49

def description
  @description
end

#google_drive_file_idObject

The ID of the Google Drive File



85
86
87
# File 'lib/flat_api/models/media_attachment.rb', line 85

def google_drive_file_id
  @google_drive_file_id
end

#htmlObject

If the attachment type is rich or video, the HTML code of the media to display



52
53
54
# File 'lib/flat_api/models/media_attachment.rb', line 52

def html
  @html
end

#html_heightObject

If the html is available, the height of the widget



58
59
60
# File 'lib/flat_api/models/media_attachment.rb', line 58

def html_height
  @html_height
end

#html_widthObject

If the html is available, the width of the widget



55
56
57
# File 'lib/flat_api/models/media_attachment.rb', line 55

def html_width
  @html_width
end

#icon_urlObject

The URL of the icon



79
80
81
# File 'lib/flat_api/models/media_attachment.rb', line 79

def icon_url
  @icon_url
end

#lock_score_templateObject

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.



43
44
45
# File 'lib/flat_api/models/media_attachment.rb', line 43

def lock_score_template
  @lock_score_template
end

#mime_typeObject

The mine type of the file



82
83
84
# File 'lib/flat_api/models/media_attachment.rb', line 82

def mime_type
  @mime_type
end

#part_uuidObject

The UUID of the instrument part selected for this attachment (for performance submissions)



38
39
40
# File 'lib/flat_api/models/media_attachment.rb', line 38

def part_uuid
  @part_uuid
end

#revisionObject

An unique revision identifier of a score



26
27
28
# File 'lib/flat_api/models/media_attachment.rb', line 26

def revision
  @revision
end

#scoreObject

An unique Flat score identifier



23
24
25
# File 'lib/flat_api/models/media_attachment.rb', line 23

def score
  @score
end

#sharing_modeObject

Returns the value of attribute sharing_mode.



40
41
42
# File 'lib/flat_api/models/media_attachment.rb', line 40

def sharing_mode
  @sharing_mode
end

#teacher_onlyObject

If true, this attachment is only visible to teachers. When students view the assignment, attachments with this flag will be filtered out.



88
89
90
# File 'lib/flat_api/models/media_attachment.rb', line 88

def teacher_only
  @teacher_only
end

#thumbnail_heightObject

If the thumbnailUrl is available, the width of the thumbnail



70
71
72
# File 'lib/flat_api/models/media_attachment.rb', line 70

def thumbnail_height
  @thumbnail_height
end

#thumbnail_urlObject

If the attachment type is rich, video, photo or link, a displayable thumbnail for this attachment



64
65
66
# File 'lib/flat_api/models/media_attachment.rb', line 64

def thumbnail_url
  @thumbnail_url
end

#thumbnail_widthObject

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_width
  @thumbnail_width
end

#titleObject

The resolved title of the attachment



46
47
48
# File 'lib/flat_api/models/media_attachment.rb', line 46

def title
  @title
end

#trackObject

A unique track identifier



35
36
37
# File 'lib/flat_api/models/media_attachment.rb', line 35

def track
  @track
end

#typeObject

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

#urlObject

The url of the attachment



61
62
63
# File 'lib/flat_api/models/media_attachment.rb', line 61

def url
  @url
end

#worksheetObject

An unique worksheet identifier



29
30
31
# File 'lib/flat_api/models/media_attachment.rb', line 29

def worksheet
  @worksheet
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



143
144
145
# File 'lib/flat_api/models/media_attachment.rb', line 143

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



148
149
150
# File 'lib/flat_api/models/media_attachment.rb', line 148

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/flat_api/models/media_attachment.rb', line 113

def self.attribute_map
  {
    :'type' => :'type',
    :'score' => :'score',
    :'revision' => :'revision',
    :'worksheet' => :'worksheet',
    :'dedicated' => :'dedicated',
    :'track' => :'track',
    :'part_uuid' => :'partUuid',
    :'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',
    :'teacher_only' => :'teacherOnly'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/flat_api/models/media_attachment.rb', line 385

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_nullableObject

List of attributes with nullable: true



183
184
185
186
# File 'lib/flat_api/models/media_attachment.rb', line 183

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/flat_api/models/media_attachment.rb', line 153

def self.openapi_types
  {
    :'type' => :'String',
    :'score' => :'String',
    :'revision' => :'String',
    :'worksheet' => :'String',
    :'dedicated' => :'Boolean',
    :'track' => :'String',
    :'part_uuid' => :'String',
    :'sharing_mode' => :'MediaScoreSharingMode',
    :'lock_score_template' => :'Boolean',
    :'title' => :'String',
    :'description' => :'String',
    :'html' => :'String',
    :'html_width' => :'Float',
    :'html_height' => :'Float',
    :'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',
    :'teacher_only' => :'Boolean'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/flat_api/models/media_attachment.rb', line 341

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 &&
      part_uuid == o.part_uuid &&
      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 &&
      author_name == o.author_name &&
      author_url == o.author_url &&
      icon_url == o.icon_url &&
      mime_type == o.mime_type &&
      google_drive_file_id == o.google_drive_file_id &&
      teacher_only == o.teacher_only
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


372
373
374
# File 'lib/flat_api/models/media_attachment.rb', line 372

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



378
379
380
# File 'lib/flat_api/models/media_attachment.rb', line 378

def hash
  [type, score, revision, worksheet, dedicated, track, part_uuid, sharing_mode, lock_score_template, title, description, html, html_width, html_height, url, thumbnail_url, thumbnail_width, thumbnail_height, author_name, author_url, icon_url, mime_type, google_drive_file_id, teacher_only].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



309
310
311
312
313
314
315
316
317
# File 'lib/flat_api/models/media_attachment.rb', line 309

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_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



407
408
409
410
411
412
413
414
415
416
417
418
419
# File 'lib/flat_api/models/media_attachment.rb', line 407

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

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



321
322
323
324
325
326
327
# File 'lib/flat_api/models/media_attachment.rb', line 321

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"])
  return false unless type_validator.valid?(@type)
  true
end