Class: DomainResponse

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/schemas.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



3278
3279
3280
3281
3282
3283
3284
# File 'lib/schemas.rb', line 3278

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    equivalent_domains:        d.fetch("equivalentDomains"),
    global_equivalent_domains: d.fetch("globalEquivalentDomains").map { |x| GlobalDomains.from_dynamic!(x) },
  )
end

.from_json!(json) ⇒ Object



3286
3287
3288
# File 'lib/schemas.rb', line 3286

def self.from_json!(json)
  from_dynamic!(JSON.parse(json))
end

Instance Method Details

#to_dynamicObject



3290
3291
3292
3293
3294
3295
# File 'lib/schemas.rb', line 3290

def to_dynamic
  {
    "equivalentDomains"       => equivalent_domains,
    "globalEquivalentDomains" => global_equivalent_domains.map { |x| x.to_dynamic },
  }
end

#to_json(options = nil) ⇒ Object



3297
3298
3299
# File 'lib/schemas.rb', line 3297

def to_json(options = nil)
  JSON.generate(to_dynamic, options)
end