Class: Ittybit::Media

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

Class Method Summary collapse

Instance Method Summary collapse

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

Parameters:

  • id (String)
  • object (String)
  • kind (Ittybit::MediaKind) (defaults to: OMIT)
  • title (String) (defaults to: OMIT)
  • alt (String) (defaults to: OMIT)
  • width (Integer) (defaults to: OMIT)
  • height (Integer) (defaults to: OMIT)
  • duration (Float) (defaults to: OMIT)
  • files (Array<Ittybit::MediaFilesItem>)
  • urls (Hash{String => Object})
  • background (String) (defaults to: OMIT)
  • metadata (Hash{String => Object}) (defaults to: OMIT)
  • created (DateTime)
  • updated (DateTime)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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

#altString (readonly)

Returns:

  • (String)


20
21
22
# File 'lib/ittybit/types/media.rb', line 20

def alt
  @alt
end

#backgroundString (readonly)

Returns:

  • (String)


32
33
34
# File 'lib/ittybit/types/media.rb', line 32

def background
  @background
end

#createdDateTime (readonly)

Returns:

  • (DateTime)


36
37
38
# File 'lib/ittybit/types/media.rb', line 36

def created
  @created
end

#durationFloat (readonly)

Returns:

  • (Float)


26
27
28
# File 'lib/ittybit/types/media.rb', line 26

def duration
  @duration
end

#filesArray<Ittybit::MediaFilesItem> (readonly)

Returns:



28
29
30
# File 'lib/ittybit/types/media.rb', line 28

def files
  @files
end

#heightInteger (readonly)

Returns:

  • (Integer)


24
25
26
# File 'lib/ittybit/types/media.rb', line 24

def height
  @height
end

#idString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/ittybit/types/media.rb', line 12

def id
  @id
end

#kindIttybit::MediaKind (readonly)

Returns:



16
17
18
# File 'lib/ittybit/types/media.rb', line 16

def kind
  @kind
end

#metadataHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


34
35
36
# File 'lib/ittybit/types/media.rb', line 34

def 
  @metadata
end

#objectString (readonly)

Returns:

  • (String)


14
15
16
# File 'lib/ittybit/types/media.rb', line 14

def object
  @object
end

#titleString (readonly)

Returns:

  • (String)


18
19
20
# File 'lib/ittybit/types/media.rb', line 18

def title
  @title
end

#updatedDateTime (readonly)

Returns:

  • (DateTime)


38
39
40
# File 'lib/ittybit/types/media.rb', line 38

def updated
  @updated
end

#urlsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


30
31
32
# File 'lib/ittybit/types/media.rb', line 30

def urls
  @urls
end

#widthInteger (readonly)

Returns:

  • (Integer)


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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


146
147
148
# File 'lib/ittybit/types/media.rb', line 146

def to_json(*_args)
  @_field_set&.to_json
end