Class: DdbRuby::FifthEdition::Decorations
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::Decorations
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3142 def self.from_dynamic!(d) d = Types::Hash[d] new( avatar_url: d.fetch("avatarUrl"), frame_avatar_url: d.fetch("frameAvatarUrl"), backdrop_avatar_url: d.fetch("backdropAvatarUrl"), small_backdrop_avatar_url: d.fetch("smallBackdropAvatarUrl"), large_backdrop_avatar_url: d.fetch("largeBackdropAvatarUrl"), thumbnail_backdrop_avatar_url: d.fetch("thumbnailBackdropAvatarUrl"), default_backdrop: DefaultBackdrop.from_dynamic!(d.fetch("defaultBackdrop")), avatar_id: d.fetch("avatarId"), portrait_decoration_key: d.fetch("portraitDecorationKey"), frame_avatar_decoration_key: d.fetch("frameAvatarDecorationKey"), frame_avatar_id: d.fetch("frameAvatarId"), backdrop_avatar_decoration_key: d.fetch("backdropAvatarDecorationKey"), backdrop_avatar_id: d.fetch("backdropAvatarId"), small_backdrop_avatar_decoration_key: d.fetch("smallBackdropAvatarDecorationKey"), small_backdrop_avatar_id: d.fetch("smallBackdropAvatarId"), large_backdrop_avatar_decoration_key: d.fetch("largeBackdropAvatarDecorationKey"), large_backdrop_avatar_id: d.fetch("largeBackdropAvatarId"), thumbnail_backdrop_avatar_decoration_key: d.fetch("thumbnailBackdropAvatarDecorationKey"), thumbnail_backdrop_avatar_id: d.fetch("thumbnailBackdropAvatarId"), theme_color: d.fetch("themeColor") ? ThemeColor.from_dynamic!(d.fetch("themeColor")) : nil, ) end |
.from_json!(json) ⇒ Object
3168 3169 3170 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3168 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3172 def to_dynamic { "avatarUrl" => avatar_url, "frameAvatarUrl" => frame_avatar_url, "backdropAvatarUrl" => backdrop_avatar_url, "smallBackdropAvatarUrl" => small_backdrop_avatar_url, "largeBackdropAvatarUrl" => large_backdrop_avatar_url, "thumbnailBackdropAvatarUrl" => thumbnail_backdrop_avatar_url, "defaultBackdrop" => default_backdrop.to_dynamic, "avatarId" => avatar_id, "portraitDecorationKey" => portrait_decoration_key, "frameAvatarDecorationKey" => frame_avatar_decoration_key, "frameAvatarId" => frame_avatar_id, "backdropAvatarDecorationKey" => backdrop_avatar_decoration_key, "backdropAvatarId" => backdrop_avatar_id, "smallBackdropAvatarDecorationKey" => small_backdrop_avatar_decoration_key, "smallBackdropAvatarId" => small_backdrop_avatar_id, "largeBackdropAvatarDecorationKey" => large_backdrop_avatar_decoration_key, "largeBackdropAvatarId" => large_backdrop_avatar_id, "thumbnailBackdropAvatarDecorationKey" => thumbnail_backdrop_avatar_decoration_key, "thumbnailBackdropAvatarId" => thumbnail_backdrop_avatar_id, "themeColor" => theme_color&.to_dynamic, } end |
#to_json(options = nil) ⇒ Object
3197 3198 3199 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3197 def to_json( = nil) JSON.generate(to_dynamic, ) end |