Class: Bandwidth::Media
- Defined in:
- lib/bandwidth/messaging_lib/messaging/models/media.rb
Overview
Media Model.
Instance Attribute Summary collapse
-
#cache_control ⇒ String
User’s account ID.
-
#content ⇒ String
TODO: Write general description for this method.
-
#content_length ⇒ String
TODO: Write general description for this method.
-
#content_type ⇒ String
TODO: Write general description for this method.
-
#input_stream ⇒ Object
TODO: Write general description for this method.
-
#media_id ⇒ String
User’s account ID.
-
#media_name ⇒ String
User’s account ID.
-
#tags ⇒ List of Tag
TODO: Write general description for this method.
-
#url ⇒ String
TODO: Write general description for this method.
-
#user_id ⇒ String
User’s account ID.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#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
constructor
A new instance of Media.
Methods inherited from BaseModel
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, = 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 = @user_id = user_id @media_name = media_name @media_id = media_id @cache_control = cache_control end |
Instance Attribute Details
#cache_control ⇒ String
User’s account ID
47 48 49 |
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 47 def cache_control @cache_control end |
#content ⇒ String
TODO: Write general description for this method
15 16 17 |
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 15 def content @content end |
#content_length ⇒ String
TODO: Write general description for this method
23 24 25 |
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 23 def content_length @content_length end |
#content_type ⇒ String
TODO: Write general description for this method
27 28 29 |
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 27 def content_type @content_type end |
#input_stream ⇒ Object
TODO: Write general description for this method
11 12 13 |
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 11 def input_stream @input_stream end |
#media_id ⇒ String
User’s account ID
43 44 45 |
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 43 def media_id @media_id end |
#media_name ⇒ String
User’s account ID
39 40 41 |
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 39 def media_name @media_name end |
#tags ⇒ List of Tag
TODO: Write general description for this method
31 32 33 |
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 31 def @tags end |
#url ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 19 def url @url end |
#user_id ⇒ String
User’s account ID
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 = nil unless hash['tags'].nil? = [] hash['tags'].each do |structure| << (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, , user_id, media_name, media_id, cache_control) end |
.names ⇒ Object
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 |