Class: Bandwidth::Media

Inherits:
BaseModel show all
Defined in:
lib/bandwidth/messaging_lib/messaging/models/media.rb

Overview

Media Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(content = nil, content_length = nil, media_name = nil) ⇒ Media

Returns a new instance of Media.



47
48
49
50
51
52
53
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 47

def initialize(content = nil,
               content_length = nil,
               media_name = nil)
  @content = content unless content == SKIP
  @content_length = content_length unless content_length == SKIP
  @media_name = media_name unless media_name == SKIP
end

Instance Attribute Details

#contentString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 14

def content
  @content
end

#content_lengthInteger

TODO: Write general description for this method

Returns:

  • (Integer)


18
19
20
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 18

def content_length
  @content_length
end

#media_nameString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 22

def media_name
  @media_name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 56

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  content = hash.key?('content') ? hash['content'] : SKIP
  content_length = hash.key?('contentLength') ? hash['contentLength'] : SKIP
  media_name = hash.key?('mediaName') ? hash['mediaName'] : SKIP

  # Create object from extracted values.
  Media.new(content,
            content_length,
            media_name)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['content'] = 'content'
  @_hash['content_length'] = 'contentLength'
  @_hash['media_name'] = 'mediaName'
  @_hash
end

Instance Method Details

#nullablesObject

An array for nullable fields



43
44
45
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 43

def nullables
  []
end

#optionalsObject

An array for optional fields



34
35
36
37
38
39
40
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 34

def optionals
  %w[
    content
    content_length
    media_name
  ]
end