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(input_stream = nil, content = nil, url = nil, content_length = nil, content_type = nil, tags = nil, user_id = nil, media_name = nil, media_id = nil, cache_control = nil) ⇒ Media

Returns a new instance of Media.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 65

def initialize(input_stream = nil,
               content = nil,
               url = nil,
               content_length = nil,
               content_type = nil,
               tags = nil,
               user_id = nil,
               media_name = nil,
               media_id = nil,
               cache_control = nil)
  @input_stream = input_stream
  @content = content
  @url = url
  @content_length = content_length
  @content_type = content_type
  @tags = tags
  @user_id = user_id
  @media_name = media_name
  @media_id = media_id
  @cache_control = cache_control
end

Instance Attribute Details

#cache_controlString

TODO: Write general description for this method

Returns:

  • (String)


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

def cache_control
  @cache_control
end

#contentString

TODO: Write general description for this method

Returns:

  • (String)


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

def content
  @content
end

#content_lengthString

TODO: Write general description for this method

Returns:

  • (String)


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

def content_length
  @content_length
end

#content_typeString

TODO: Write general description for this method

Returns:

  • (String)


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

def content_type
  @content_type
end

#input_streamObject

TODO: Write general description for this method

Returns:

  • (Object)


11
12
13
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 11

def input_stream
  @input_stream
end

#media_idString

TODO: Write general description for this method

Returns:

  • (String)


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

def media_id
  @media_id
end

#media_nameString

TODO: Write general description for this method

Returns:

  • (String)


39
40
41
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 39

def media_name
  @media_name
end

#tagsList of Tag

TODO: Write general description for this method

Returns:

  • (List of Tag)


31
32
33
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 31

def tags
  @tags
end

#urlString

TODO: Write general description for this method

Returns:

  • (String)


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

def url
  @url
end

#user_idString

TODO: Write general description for this method

Returns:

  • (String)


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

def user_id
  @user_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 88

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  input_stream = hash['inputStream']
  content = hash['content']
  url = hash['url']
  content_length = hash['contentLength']
  content_type = hash['contentType']
  # Parameter is an array, so we need to iterate through it
  tags = nil
  unless hash['tags'].nil?
    tags = []
    hash['tags'].each do |structure|
      tags << (Tag.from_hash(structure) if structure)
    end
  end
  user_id = hash['userId']
  media_name = hash['mediaName']
  media_id = hash['mediaId']
  cache_control = hash['cacheControl']

  # Create object from extracted values.
  Media.new(input_stream,
            content,
            url,
            content_length,
            content_type,
            tags,
            user_id,
            media_name,
            media_id,
            cache_control)
end

.namesObject

A mapping from model property names to API property names.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 50

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['input_stream'] = 'inputStream'
  @_hash['content'] = 'content'
  @_hash['url'] = 'url'
  @_hash['content_length'] = 'contentLength'
  @_hash['content_type'] = 'contentType'
  @_hash['tags'] = 'tags'
  @_hash['user_id'] = 'userId'
  @_hash['media_name'] = 'mediaName'
  @_hash['media_id'] = 'mediaId'
  @_hash['cache_control'] = 'cacheControl'
  @_hash
end