ittybit 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/environment.rb +7 -0
- data/lib/gemconfig.rb +14 -0
- data/lib/ittybit/automations/client.rb +412 -0
- data/lib/ittybit/automations/types/automations_update_request_trigger.rb +75 -0
- data/lib/ittybit/automations/types/automations_update_request_trigger_conditions_item.rb +69 -0
- data/lib/ittybit/files/client.rb +437 -0
- data/lib/ittybit/files/types/files_delete_response.rb +89 -0
- data/lib/ittybit/files/types/files_delete_response_data.rb +60 -0
- data/lib/ittybit/media/client.rb +367 -0
- data/lib/ittybit/signatures/client.rb +132 -0
- data/lib/ittybit/signatures/types/signatures_create_request_method.rb +13 -0
- data/lib/ittybit/tasks/client.rb +379 -0
- data/lib/ittybit/tasks/types/tasks_create_request_kind.rb +22 -0
- data/lib/ittybit/tasks/types/tasks_list_request_kind.rb +26 -0
- data/lib/ittybit/tasks/types/tasks_list_request_status.rb +16 -0
- data/lib/ittybit/types/api_response_base.rb +5 -0
- data/lib/ittybit/types/automation.rb +141 -0
- data/lib/ittybit/types/automation_list_response.rb +90 -0
- data/lib/ittybit/types/automation_response.rb +87 -0
- data/lib/ittybit/types/automation_status.rb +10 -0
- data/lib/ittybit/types/automation_trigger.rb +72 -0
- data/lib/ittybit/types/automation_trigger_conditions_item.rb +65 -0
- data/lib/ittybit/types/confirmation_response.rb +87 -0
- data/lib/ittybit/types/confirmation_response_data.rb +55 -0
- data/lib/ittybit/types/error.rb +57 -0
- data/lib/ittybit/types/error_response.rb +74 -0
- data/lib/ittybit/types/file.rb +319 -0
- data/lib/ittybit/types/file_kind.rb +10 -0
- data/lib/ittybit/types/file_list_response.rb +90 -0
- data/lib/ittybit/types/file_object.rb +10 -0
- data/lib/ittybit/types/file_response.rb +87 -0
- data/lib/ittybit/types/file_status.rb +11 -0
- data/lib/ittybit/types/links.rb +67 -0
- data/lib/ittybit/types/links_list.rb +103 -0
- data/lib/ittybit/types/media.rb +195 -0
- data/lib/ittybit/types/media_kind.rb +10 -0
- data/lib/ittybit/types/media_list_response.rb +90 -0
- data/lib/ittybit/types/media_response.rb +87 -0
- data/lib/ittybit/types/media_source.rb +261 -0
- data/lib/ittybit/types/media_source_kind.rb +10 -0
- data/lib/ittybit/types/media_source_object.rb +10 -0
- data/lib/ittybit/types/media_source_status.rb +11 -0
- data/lib/ittybit/types/media_urls.rb +70 -0
- data/lib/ittybit/types/meta.rb +5 -0
- data/lib/ittybit/types/meta_list.rb +103 -0
- data/lib/ittybit/types/signature.rb +110 -0
- data/lib/ittybit/types/signature_response.rb +87 -0
- data/lib/ittybit/types/task.rb +204 -0
- data/lib/ittybit/types/task_kind.rb +5 -0
- data/lib/ittybit/types/task_list_response.rb +90 -0
- data/lib/ittybit/types/task_response.rb +87 -0
- data/lib/ittybit/types/task_results.rb +74 -0
- data/lib/ittybit/types/task_status.rb +15 -0
- data/lib/ittybit/types/task_summary.rb +138 -0
- data/lib/ittybit/types/task_summary_kind.rb +25 -0
- data/lib/ittybit/types/task_summary_status.rb +15 -0
- data/lib/ittybit/types/workflow_task_step.rb +112 -0
- data/lib/ittybit/types/workflow_task_step_kind.rb +25 -0
- data/lib/ittybit.rb +86 -0
- data/lib/requests.rb +177 -0
- data/lib/types_export.rb +53 -0
- metadata +185 -0
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ostruct"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Ittybit
|
7
|
+
class LinksList
|
8
|
+
# @return [String] The absolute URL of the current request, potentially including query parameters.
|
9
|
+
attr_reader :self_
|
10
|
+
# @return [String] URL for the next page of results.
|
11
|
+
attr_reader :next_
|
12
|
+
# @return [String] URL for the previous page of results.
|
13
|
+
attr_reader :prev
|
14
|
+
# @return [String] URL for the parent resource.
|
15
|
+
attr_reader :parent
|
16
|
+
# @return [String] URL for the first page of results.
|
17
|
+
attr_reader :first
|
18
|
+
# @return [String] URL for the last page of results.
|
19
|
+
attr_reader :last
|
20
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
21
|
+
attr_reader :additional_properties
|
22
|
+
# @return [Object]
|
23
|
+
attr_reader :_field_set
|
24
|
+
protected :_field_set
|
25
|
+
|
26
|
+
OMIT = Object.new
|
27
|
+
|
28
|
+
# @param self_ [String] The absolute URL of the current request, potentially including query parameters.
|
29
|
+
# @param next_ [String] URL for the next page of results.
|
30
|
+
# @param prev [String] URL for the previous page of results.
|
31
|
+
# @param parent [String] URL for the parent resource.
|
32
|
+
# @param first [String] URL for the first page of results.
|
33
|
+
# @param last [String] URL for the last page of results.
|
34
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
35
|
+
# @return [Ittybit::LinksList]
|
36
|
+
def initialize(self_: OMIT, next_: OMIT, prev: OMIT, parent: OMIT, first: OMIT, last: OMIT,
|
37
|
+
additional_properties: nil)
|
38
|
+
@self_ = self_ if self_ != OMIT
|
39
|
+
@next_ = next_ if next_ != OMIT
|
40
|
+
@prev = prev if prev != OMIT
|
41
|
+
@parent = parent if parent != OMIT
|
42
|
+
@first = first if first != OMIT
|
43
|
+
@last = last if last != OMIT
|
44
|
+
@additional_properties = additional_properties
|
45
|
+
@_field_set = {
|
46
|
+
"self": self_,
|
47
|
+
"next": next_,
|
48
|
+
"prev": prev,
|
49
|
+
"parent": parent,
|
50
|
+
"first": first,
|
51
|
+
"last": last
|
52
|
+
}.reject do |_k, v|
|
53
|
+
v == OMIT
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Deserialize a JSON object to an instance of LinksList
|
58
|
+
#
|
59
|
+
# @param json_object [String]
|
60
|
+
# @return [Ittybit::LinksList]
|
61
|
+
def self.from_json(json_object:)
|
62
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
63
|
+
parsed_json = JSON.parse(json_object)
|
64
|
+
self_ = parsed_json["self"]
|
65
|
+
next_ = parsed_json["next"]
|
66
|
+
prev = parsed_json["prev"]
|
67
|
+
parent = parsed_json["parent"]
|
68
|
+
first = parsed_json["first"]
|
69
|
+
last = parsed_json["last"]
|
70
|
+
new(
|
71
|
+
self_: self_,
|
72
|
+
next_: next_,
|
73
|
+
prev: prev,
|
74
|
+
parent: parent,
|
75
|
+
first: first,
|
76
|
+
last: last,
|
77
|
+
additional_properties: struct
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Serialize an instance of LinksList to a JSON object
|
82
|
+
#
|
83
|
+
# @return [String]
|
84
|
+
def to_json(*_args)
|
85
|
+
@_field_set&.to_json
|
86
|
+
end
|
87
|
+
|
88
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
89
|
+
# hash and check each fields type against the current object's property
|
90
|
+
# definitions.
|
91
|
+
#
|
92
|
+
# @param obj [Object]
|
93
|
+
# @return [Void]
|
94
|
+
def self.validate_raw(obj:)
|
95
|
+
obj.self_&.is_a?(String) != false || raise("Passed value for field obj.self_ is not the expected type, validation failed.")
|
96
|
+
obj.next_&.is_a?(String) != false || raise("Passed value for field obj.next_ is not the expected type, validation failed.")
|
97
|
+
obj.prev&.is_a?(String) != false || raise("Passed value for field obj.prev is not the expected type, validation failed.")
|
98
|
+
obj.parent&.is_a?(String) != false || raise("Passed value for field obj.parent is not the expected type, validation failed.")
|
99
|
+
obj.first&.is_a?(String) != false || raise("Passed value for field obj.first is not the expected type, validation failed.")
|
100
|
+
obj.last&.is_a?(String) != false || raise("Passed value for field obj.last is not the expected type, validation failed.")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,195 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "media_kind"
|
4
|
+
require_relative "media_source"
|
5
|
+
require_relative "media_urls"
|
6
|
+
require "date"
|
7
|
+
require "ostruct"
|
8
|
+
require "json"
|
9
|
+
|
10
|
+
module Ittybit
|
11
|
+
class Media
|
12
|
+
# @return [String] Unique identifier for the media item.
|
13
|
+
attr_reader :id
|
14
|
+
# @return [String] Object type, always 'media'.
|
15
|
+
attr_reader :object
|
16
|
+
# @return [Ittybit::MediaKind] The primary kind of the media, derived from the original file.
|
17
|
+
attr_reader :kind
|
18
|
+
# @return [String] Title of the media item.
|
19
|
+
attr_reader :title
|
20
|
+
# @return [String] Alternative text for the media item.
|
21
|
+
attr_reader :alt
|
22
|
+
# @return [Integer] Width of the primary source in pixels.
|
23
|
+
attr_reader :width
|
24
|
+
# @return [Integer] Height of the primary source in pixels.
|
25
|
+
attr_reader :height
|
26
|
+
# @return [Float] Duration of the primary source in seconds.
|
27
|
+
attr_reader :duration
|
28
|
+
# @return [Array<Ittybit::MediaSource>] Array of source files associated with this media item.
|
29
|
+
attr_reader :files
|
30
|
+
# @return [Ittybit::MediaUrls] URLs for the media item.
|
31
|
+
attr_reader :urls
|
32
|
+
# @return [String] URL of the poster image (video kinds only).
|
33
|
+
attr_reader :poster
|
34
|
+
# @return [String] Base64 encoded placeholder image (video/image only).
|
35
|
+
attr_reader :placeholder
|
36
|
+
# @return [String] Dominant background color hex code (video/image only).
|
37
|
+
attr_reader :background
|
38
|
+
# @return [Hash{String => Object}] User-defined key-value metadata for the media item.
|
39
|
+
attr_reader :metadata
|
40
|
+
# @return [DateTime] Timestamp when the media record was created.
|
41
|
+
attr_reader :created
|
42
|
+
# @return [DateTime] Timestamp when the media item was last updated.
|
43
|
+
attr_reader :updated
|
44
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
45
|
+
attr_reader :additional_properties
|
46
|
+
# @return [Object]
|
47
|
+
attr_reader :_field_set
|
48
|
+
protected :_field_set
|
49
|
+
|
50
|
+
OMIT = Object.new
|
51
|
+
|
52
|
+
# @param id [String] Unique identifier for the media item.
|
53
|
+
# @param object [String] Object type, always 'media'.
|
54
|
+
# @param kind [Ittybit::MediaKind] The primary kind of the media, derived from the original file.
|
55
|
+
# @param title [String] Title of the media item.
|
56
|
+
# @param alt [String] Alternative text for the media item.
|
57
|
+
# @param width [Integer] Width of the primary source in pixels.
|
58
|
+
# @param height [Integer] Height of the primary source in pixels.
|
59
|
+
# @param duration [Float] Duration of the primary source in seconds.
|
60
|
+
# @param files [Array<Ittybit::MediaSource>] Array of source files associated with this media item.
|
61
|
+
# @param urls [Ittybit::MediaUrls] URLs for the media item.
|
62
|
+
# @param poster [String] URL of the poster image (video kinds only).
|
63
|
+
# @param placeholder [String] Base64 encoded placeholder image (video/image only).
|
64
|
+
# @param background [String] Dominant background color hex code (video/image only).
|
65
|
+
# @param metadata [Hash{String => Object}] User-defined key-value metadata for the media item.
|
66
|
+
# @param created [DateTime] Timestamp when the media record was created.
|
67
|
+
# @param updated [DateTime] Timestamp when the media item was last updated.
|
68
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
69
|
+
# @return [Ittybit::Media]
|
70
|
+
def initialize(id:, object:, kind:, files:, urls:, created:, updated:, title: OMIT, alt: OMIT, width: OMIT,
|
71
|
+
height: OMIT, duration: OMIT, poster: OMIT, placeholder: OMIT, background: OMIT, metadata: OMIT, additional_properties: nil)
|
72
|
+
@id = id
|
73
|
+
@object = object
|
74
|
+
@kind = kind
|
75
|
+
@title = title if title != OMIT
|
76
|
+
@alt = alt if alt != OMIT
|
77
|
+
@width = width if width != OMIT
|
78
|
+
@height = height if height != OMIT
|
79
|
+
@duration = duration if duration != OMIT
|
80
|
+
@files = files
|
81
|
+
@urls = urls
|
82
|
+
@poster = poster if poster != OMIT
|
83
|
+
@placeholder = placeholder if placeholder != OMIT
|
84
|
+
@background = background if background != OMIT
|
85
|
+
@metadata = metadata if metadata != OMIT
|
86
|
+
@created = created
|
87
|
+
@updated = updated
|
88
|
+
@additional_properties = additional_properties
|
89
|
+
@_field_set = {
|
90
|
+
"id": id,
|
91
|
+
"object": object,
|
92
|
+
"kind": kind,
|
93
|
+
"title": title,
|
94
|
+
"alt": alt,
|
95
|
+
"width": width,
|
96
|
+
"height": height,
|
97
|
+
"duration": duration,
|
98
|
+
"files": files,
|
99
|
+
"urls": urls,
|
100
|
+
"poster": poster,
|
101
|
+
"placeholder": placeholder,
|
102
|
+
"background": background,
|
103
|
+
"metadata": metadata,
|
104
|
+
"created": created,
|
105
|
+
"updated": updated
|
106
|
+
}.reject do |_k, v|
|
107
|
+
v == OMIT
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Deserialize a JSON object to an instance of Media
|
112
|
+
#
|
113
|
+
# @param json_object [String]
|
114
|
+
# @return [Ittybit::Media]
|
115
|
+
def self.from_json(json_object:)
|
116
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
117
|
+
parsed_json = JSON.parse(json_object)
|
118
|
+
id = parsed_json["id"]
|
119
|
+
object = parsed_json["object"]
|
120
|
+
kind = parsed_json["kind"]
|
121
|
+
title = parsed_json["title"]
|
122
|
+
alt = parsed_json["alt"]
|
123
|
+
width = parsed_json["width"]
|
124
|
+
height = parsed_json["height"]
|
125
|
+
duration = parsed_json["duration"]
|
126
|
+
files = parsed_json["files"]&.map do |item|
|
127
|
+
item = item.to_json
|
128
|
+
Ittybit::MediaSource.from_json(json_object: item)
|
129
|
+
end
|
130
|
+
if parsed_json["urls"].nil?
|
131
|
+
urls = nil
|
132
|
+
else
|
133
|
+
urls = parsed_json["urls"].to_json
|
134
|
+
urls = Ittybit::MediaUrls.from_json(json_object: urls)
|
135
|
+
end
|
136
|
+
poster = parsed_json["poster"]
|
137
|
+
placeholder = parsed_json["placeholder"]
|
138
|
+
background = parsed_json["background"]
|
139
|
+
metadata = parsed_json["metadata"]
|
140
|
+
created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
|
141
|
+
updated = (DateTime.parse(parsed_json["updated"]) unless parsed_json["updated"].nil?)
|
142
|
+
new(
|
143
|
+
id: id,
|
144
|
+
object: object,
|
145
|
+
kind: kind,
|
146
|
+
title: title,
|
147
|
+
alt: alt,
|
148
|
+
width: width,
|
149
|
+
height: height,
|
150
|
+
duration: duration,
|
151
|
+
files: files,
|
152
|
+
urls: urls,
|
153
|
+
poster: poster,
|
154
|
+
placeholder: placeholder,
|
155
|
+
background: background,
|
156
|
+
metadata: metadata,
|
157
|
+
created: created,
|
158
|
+
updated: updated,
|
159
|
+
additional_properties: struct
|
160
|
+
)
|
161
|
+
end
|
162
|
+
|
163
|
+
# Serialize an instance of Media to a JSON object
|
164
|
+
#
|
165
|
+
# @return [String]
|
166
|
+
def to_json(*_args)
|
167
|
+
@_field_set&.to_json
|
168
|
+
end
|
169
|
+
|
170
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
171
|
+
# hash and check each fields type against the current object's property
|
172
|
+
# definitions.
|
173
|
+
#
|
174
|
+
# @param obj [Object]
|
175
|
+
# @return [Void]
|
176
|
+
def self.validate_raw(obj:)
|
177
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
178
|
+
obj.object.is_a?(String) != false || raise("Passed value for field obj.object is not the expected type, validation failed.")
|
179
|
+
obj.kind.is_a?(Ittybit::MediaKind) != false || raise("Passed value for field obj.kind is not the expected type, validation failed.")
|
180
|
+
obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.")
|
181
|
+
obj.alt&.is_a?(String) != false || raise("Passed value for field obj.alt is not the expected type, validation failed.")
|
182
|
+
obj.width&.is_a?(Integer) != false || raise("Passed value for field obj.width is not the expected type, validation failed.")
|
183
|
+
obj.height&.is_a?(Integer) != false || raise("Passed value for field obj.height is not the expected type, validation failed.")
|
184
|
+
obj.duration&.is_a?(Float) != false || raise("Passed value for field obj.duration is not the expected type, validation failed.")
|
185
|
+
obj.files.is_a?(Array) != false || raise("Passed value for field obj.files is not the expected type, validation failed.")
|
186
|
+
Ittybit::MediaUrls.validate_raw(obj: obj.urls)
|
187
|
+
obj.poster&.is_a?(String) != false || raise("Passed value for field obj.poster is not the expected type, validation failed.")
|
188
|
+
obj.placeholder&.is_a?(String) != false || raise("Passed value for field obj.placeholder is not the expected type, validation failed.")
|
189
|
+
obj.background&.is_a?(String) != false || raise("Passed value for field obj.background is not the expected type, validation failed.")
|
190
|
+
obj.metadata&.is_a?(Hash) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.")
|
191
|
+
obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
|
192
|
+
obj.updated.is_a?(DateTime) != false || raise("Passed value for field obj.updated is not the expected type, validation failed.")
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "meta_list"
|
4
|
+
require_relative "media"
|
5
|
+
require_relative "links_list"
|
6
|
+
require "ostruct"
|
7
|
+
require "json"
|
8
|
+
|
9
|
+
module Ittybit
|
10
|
+
class MediaListResponse
|
11
|
+
# @return [Ittybit::MetaList]
|
12
|
+
attr_reader :meta
|
13
|
+
# @return [Array<Ittybit::Media>]
|
14
|
+
attr_reader :data
|
15
|
+
# @return [Ittybit::LinksList]
|
16
|
+
attr_reader :links
|
17
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
18
|
+
attr_reader :additional_properties
|
19
|
+
# @return [Object]
|
20
|
+
attr_reader :_field_set
|
21
|
+
protected :_field_set
|
22
|
+
|
23
|
+
OMIT = Object.new
|
24
|
+
|
25
|
+
# @param meta [Ittybit::MetaList]
|
26
|
+
# @param data [Array<Ittybit::Media>]
|
27
|
+
# @param links [Ittybit::LinksList]
|
28
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
29
|
+
# @return [Ittybit::MediaListResponse]
|
30
|
+
def initialize(meta: OMIT, data: OMIT, links: OMIT, additional_properties: nil)
|
31
|
+
@meta = meta if meta != OMIT
|
32
|
+
@data = data if data != OMIT
|
33
|
+
@links = links if links != OMIT
|
34
|
+
@additional_properties = additional_properties
|
35
|
+
@_field_set = { "meta": meta, "data": data, "links": links }.reject do |_k, v|
|
36
|
+
v == OMIT
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Deserialize a JSON object to an instance of MediaListResponse
|
41
|
+
#
|
42
|
+
# @param json_object [String]
|
43
|
+
# @return [Ittybit::MediaListResponse]
|
44
|
+
def self.from_json(json_object:)
|
45
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
46
|
+
parsed_json = JSON.parse(json_object)
|
47
|
+
if parsed_json["meta"].nil?
|
48
|
+
meta = nil
|
49
|
+
else
|
50
|
+
meta = parsed_json["meta"].to_json
|
51
|
+
meta = Ittybit::MetaList.from_json(json_object: meta)
|
52
|
+
end
|
53
|
+
data = parsed_json["data"]&.map do |item|
|
54
|
+
item = item.to_json
|
55
|
+
Ittybit::Media.from_json(json_object: item)
|
56
|
+
end
|
57
|
+
if parsed_json["links"].nil?
|
58
|
+
links = nil
|
59
|
+
else
|
60
|
+
links = parsed_json["links"].to_json
|
61
|
+
links = Ittybit::LinksList.from_json(json_object: links)
|
62
|
+
end
|
63
|
+
new(
|
64
|
+
meta: meta,
|
65
|
+
data: data,
|
66
|
+
links: links,
|
67
|
+
additional_properties: struct
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Serialize an instance of MediaListResponse to a JSON object
|
72
|
+
#
|
73
|
+
# @return [String]
|
74
|
+
def to_json(*_args)
|
75
|
+
@_field_set&.to_json
|
76
|
+
end
|
77
|
+
|
78
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
79
|
+
# hash and check each fields type against the current object's property
|
80
|
+
# definitions.
|
81
|
+
#
|
82
|
+
# @param obj [Object]
|
83
|
+
# @return [Void]
|
84
|
+
def self.validate_raw(obj:)
|
85
|
+
obj.meta.nil? || Ittybit::MetaList.validate_raw(obj: obj.meta)
|
86
|
+
obj.data&.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.")
|
87
|
+
obj.links.nil? || Ittybit::LinksList.validate_raw(obj: obj.links)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "meta"
|
4
|
+
require_relative "media"
|
5
|
+
require_relative "links"
|
6
|
+
require "ostruct"
|
7
|
+
require "json"
|
8
|
+
|
9
|
+
module Ittybit
|
10
|
+
class MediaResponse
|
11
|
+
# @return [Ittybit::META]
|
12
|
+
attr_reader :meta
|
13
|
+
# @return [Ittybit::Media]
|
14
|
+
attr_reader :data
|
15
|
+
# @return [Ittybit::Links]
|
16
|
+
attr_reader :links
|
17
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
18
|
+
attr_reader :additional_properties
|
19
|
+
# @return [Object]
|
20
|
+
attr_reader :_field_set
|
21
|
+
protected :_field_set
|
22
|
+
|
23
|
+
OMIT = Object.new
|
24
|
+
|
25
|
+
# @param meta [Ittybit::META]
|
26
|
+
# @param data [Ittybit::Media]
|
27
|
+
# @param links [Ittybit::Links]
|
28
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
29
|
+
# @return [Ittybit::MediaResponse]
|
30
|
+
def initialize(meta: OMIT, data: OMIT, links: OMIT, additional_properties: nil)
|
31
|
+
@meta = meta if meta != OMIT
|
32
|
+
@data = data if data != OMIT
|
33
|
+
@links = links if links != OMIT
|
34
|
+
@additional_properties = additional_properties
|
35
|
+
@_field_set = { "meta": meta, "data": data, "links": links }.reject do |_k, v|
|
36
|
+
v == OMIT
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Deserialize a JSON object to an instance of MediaResponse
|
41
|
+
#
|
42
|
+
# @param json_object [String]
|
43
|
+
# @return [Ittybit::MediaResponse]
|
44
|
+
def self.from_json(json_object:)
|
45
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
46
|
+
parsed_json = JSON.parse(json_object)
|
47
|
+
meta = parsed_json["meta"]
|
48
|
+
if parsed_json["data"].nil?
|
49
|
+
data = nil
|
50
|
+
else
|
51
|
+
data = parsed_json["data"].to_json
|
52
|
+
data = Ittybit::Media.from_json(json_object: data)
|
53
|
+
end
|
54
|
+
if parsed_json["links"].nil?
|
55
|
+
links = nil
|
56
|
+
else
|
57
|
+
links = parsed_json["links"].to_json
|
58
|
+
links = Ittybit::Links.from_json(json_object: links)
|
59
|
+
end
|
60
|
+
new(
|
61
|
+
meta: meta,
|
62
|
+
data: data,
|
63
|
+
links: links,
|
64
|
+
additional_properties: struct
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Serialize an instance of MediaResponse to a JSON object
|
69
|
+
#
|
70
|
+
# @return [String]
|
71
|
+
def to_json(*_args)
|
72
|
+
@_field_set&.to_json
|
73
|
+
end
|
74
|
+
|
75
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
76
|
+
# hash and check each fields type against the current object's property
|
77
|
+
# definitions.
|
78
|
+
#
|
79
|
+
# @param obj [Object]
|
80
|
+
# @return [Void]
|
81
|
+
def self.validate_raw(obj:)
|
82
|
+
obj.meta&.is_a?(Object) != false || raise("Passed value for field obj.meta is not the expected type, validation failed.")
|
83
|
+
obj.data.nil? || Ittybit::Media.validate_raw(obj: obj.data)
|
84
|
+
obj.links.nil? || Ittybit::Links.validate_raw(obj: obj.links)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|