Class: Ittybit::Media
- Inherits:
-
Object
- Object
- Ittybit::Media
- Defined in:
- lib/ittybit/types/media.rb,
lib/ittybit/media/types/media_get_response.rb,
lib/ittybit/media/types/media_create_response.rb,
lib/ittybit/media/types/media_delete_response.rb,
lib/ittybit/media/types/media_update_response.rb,
lib/ittybit/media/types/media_get_response_kind.rb,
lib/ittybit/media/types/media_create_response_kind.rb,
lib/ittybit/media/types/media_update_response_kind.rb,
lib/ittybit/media/types/media_get_response_files_item.rb,
lib/ittybit/media/types/media_create_response_files_item.rb,
lib/ittybit/media/types/media_update_response_files_item.rb,
lib/ittybit/media/types/media_get_response_files_item_kind.rb,
lib/ittybit/media/types/media_get_response_files_item_object.rb,
lib/ittybit/media/types/media_get_response_files_item_status.rb,
lib/ittybit/media/types/media_create_response_files_item_kind.rb,
lib/ittybit/media/types/media_update_response_files_item_kind.rb,
lib/ittybit/media/types/media_create_response_files_item_object.rb,
lib/ittybit/media/types/media_create_response_files_item_status.rb,
lib/ittybit/media/types/media_update_response_files_item_object.rb,
lib/ittybit/media/types/media_update_response_files_item_status.rb,
lib/ittybit/media/types/media_get_response_files_item_orientation.rb,
lib/ittybit/media/types/media_create_response_files_item_orientation.rb,
lib/ittybit/media/types/media_update_response_files_item_orientation.rb
Defined Under Namespace
Classes: MediaCreateResponse, MediaCreateResponseFilesItem, MediaCreateResponseFilesItemKind, MediaCreateResponseFilesItemObject, MediaCreateResponseFilesItemOrientation, MediaCreateResponseFilesItemStatus, MediaCreateResponseKind, MediaDeleteResponse, MediaGetResponse, MediaGetResponseFilesItem, MediaGetResponseFilesItemKind, MediaGetResponseFilesItemObject, MediaGetResponseFilesItemOrientation, MediaGetResponseFilesItemStatus, MediaGetResponseKind, MediaUpdateResponse, MediaUpdateResponseFilesItem, MediaUpdateResponseFilesItemKind, MediaUpdateResponseFilesItemObject, MediaUpdateResponseFilesItemOrientation, MediaUpdateResponseFilesItemStatus, MediaUpdateResponseKind
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #alt ⇒ String readonly
- #background ⇒ String readonly
- #created ⇒ DateTime readonly
- #duration ⇒ Float readonly
- #files ⇒ Array<Ittybit::MediaFilesItem> readonly
- #height ⇒ Integer readonly
- #id ⇒ String readonly
- #kind ⇒ Ittybit::MediaKind readonly
- #metadata ⇒ Hash{String => Object} readonly
- #object ⇒ String readonly
- #title ⇒ String readonly
- #updated ⇒ DateTime readonly
- #urls ⇒ Hash{String => Object} readonly
- #width ⇒ Integer readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Ittybit::Media
Deserialize a JSON object to an instance of Media.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(id:, object:, files:, urls:, created:, updated:, kind: OMIT, title: OMIT, alt: OMIT, width: OMIT, height: OMIT, duration: OMIT, background: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Ittybit::Media constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Media to a JSON object.
Constructor Details
#initialize(id:, object:, files:, urls:, created:, updated:, kind: OMIT, title: OMIT, alt: OMIT, width: OMIT, height: OMIT, duration: OMIT, background: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Ittybit::Media
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/ittybit/types/media.rb', line 63 def initialize(id:, object:, files:, urls:, created:, updated:, kind: OMIT, title: OMIT, alt: OMIT, width: OMIT, height: OMIT, duration: OMIT, background: OMIT, metadata: OMIT, additional_properties: nil) @id = id @object = object @kind = kind if kind != OMIT @title = title if title != OMIT @alt = alt if alt != OMIT @width = width if width != OMIT @height = height if height != OMIT @duration = duration if duration != OMIT @files = files @urls = urls @background = background if background != OMIT @metadata = if != OMIT @created = created @updated = updated @additional_properties = additional_properties @_field_set = { "id": id, "object": object, "kind": kind, "title": title, "alt": alt, "width": width, "height": height, "duration": duration, "files": files, "urls": urls, "background": background, "metadata": , "created": created, "updated": updated }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
40 41 42 |
# File 'lib/ittybit/types/media.rb', line 40 def additional_properties @additional_properties end |
#alt ⇒ String (readonly)
20 21 22 |
# File 'lib/ittybit/types/media.rb', line 20 def alt @alt end |
#background ⇒ String (readonly)
32 33 34 |
# File 'lib/ittybit/types/media.rb', line 32 def background @background end |
#created ⇒ DateTime (readonly)
36 37 38 |
# File 'lib/ittybit/types/media.rb', line 36 def created @created end |
#duration ⇒ Float (readonly)
26 27 28 |
# File 'lib/ittybit/types/media.rb', line 26 def duration @duration end |
#files ⇒ Array<Ittybit::MediaFilesItem> (readonly)
28 29 30 |
# File 'lib/ittybit/types/media.rb', line 28 def files @files end |
#height ⇒ Integer (readonly)
24 25 26 |
# File 'lib/ittybit/types/media.rb', line 24 def height @height end |
#id ⇒ String (readonly)
12 13 14 |
# File 'lib/ittybit/types/media.rb', line 12 def id @id end |
#kind ⇒ Ittybit::MediaKind (readonly)
16 17 18 |
# File 'lib/ittybit/types/media.rb', line 16 def kind @kind end |
#metadata ⇒ Hash{String => Object} (readonly)
34 35 36 |
# File 'lib/ittybit/types/media.rb', line 34 def @metadata end |
#object ⇒ String (readonly)
14 15 16 |
# File 'lib/ittybit/types/media.rb', line 14 def object @object end |
#title ⇒ String (readonly)
18 19 20 |
# File 'lib/ittybit/types/media.rb', line 18 def title @title end |
#updated ⇒ DateTime (readonly)
38 39 40 |
# File 'lib/ittybit/types/media.rb', line 38 def updated @updated end |
#urls ⇒ Hash{String => Object} (readonly)
30 31 32 |
# File 'lib/ittybit/types/media.rb', line 30 def urls @urls end |
#width ⇒ Integer (readonly)
22 23 24 |
# File 'lib/ittybit/types/media.rb', line 22 def width @width end |
Class Method Details
.from_json(json_object:) ⇒ Ittybit::Media
Deserialize a JSON object to an instance of Media
104 105 106 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 133 134 135 136 137 138 139 140 141 |
# File 'lib/ittybit/types/media.rb', line 104 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] object = parsed_json["object"] kind = parsed_json["kind"] title = parsed_json["title"] alt = parsed_json["alt"] width = parsed_json["width"] height = parsed_json["height"] duration = parsed_json["duration"] files = parsed_json["files"]&.map do |item| item = item.to_json Ittybit::MediaFilesItem.from_json(json_object: item) end urls = parsed_json["urls"] background = parsed_json["background"] = parsed_json["metadata"] created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?) updated = (DateTime.parse(parsed_json["updated"]) unless parsed_json["updated"].nil?) new( id: id, object: object, kind: kind, title: title, alt: alt, width: width, height: height, duration: duration, files: files, urls: urls, background: background, metadata: , created: created, updated: updated, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/ittybit/types/media.rb', line 156 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.object.is_a?(String) != false || raise("Passed value for field obj.object is not the expected type, validation failed.") obj.kind&.is_a?(Ittybit::MediaKind) != false || raise("Passed value for field obj.kind is not the expected type, validation failed.") obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") obj.alt&.is_a?(String) != false || raise("Passed value for field obj.alt is not the expected type, validation failed.") obj.width&.is_a?(Integer) != false || raise("Passed value for field obj.width is not the expected type, validation failed.") obj.height&.is_a?(Integer) != false || raise("Passed value for field obj.height is not the expected type, validation failed.") obj.duration&.is_a?(Float) != false || raise("Passed value for field obj.duration is not the expected type, validation failed.") obj.files.is_a?(Array) != false || raise("Passed value for field obj.files is not the expected type, validation failed.") obj.urls.is_a?(Hash) != false || raise("Passed value for field obj.urls is not the expected type, validation failed.") obj.background&.is_a?(String) != false || raise("Passed value for field obj.background is not the expected type, validation failed.") obj.&.is_a?(Hash) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.") obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.") obj.updated.is_a?(DateTime) != false || raise("Passed value for field obj.updated is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of Media to a JSON object
146 147 148 |
# File 'lib/ittybit/types/media.rb', line 146 def to_json(*_args) @_field_set&.to_json end |