Class: Rerout::Models::BatchCreateLinksResult

Inherits:
Object
  • Object
show all
Defined in:
lib/rerout/models.rb

Overview

Aggregate result of ‘links.create_batch` (`POST /v1/links/batch`).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(created:, total:, results:) ⇒ BatchCreateLinksResult

Returns a new instance of BatchCreateLinksResult.



648
649
650
651
652
653
# File 'lib/rerout/models.rb', line 648

def initialize(created:, total:, results:)
  @created = created
  @total = total
  @results = results.freeze
  freeze
end

Instance Attribute Details

#createdObject (readonly)

Returns the value of attribute created.



646
647
648
# File 'lib/rerout/models.rb', line 646

def created
  @created
end

#resultsObject (readonly)

Returns the value of attribute results.



646
647
648
# File 'lib/rerout/models.rb', line 646

def results
  @results
end

#totalObject (readonly)

Returns the value of attribute total.



646
647
648
# File 'lib/rerout/models.rb', line 646

def total
  @total
end

Class Method Details

.from_hash(hash) ⇒ Object



655
656
657
658
659
660
661
# File 'lib/rerout/models.rb', line 655

def self.from_hash(hash)
  new(
    created: hash.fetch('created', 0),
    total: hash.fetch('total', 0),
    results: (hash['results'] || []).map { |r| BatchLinkResult.from_hash(r) }
  )
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



667
668
669
# File 'lib/rerout/models.rb', line 667

def ==(other)
  other.is_a?(BatchCreateLinksResult) && other.to_h == to_h
end

#hashObject



672
673
674
# File 'lib/rerout/models.rb', line 672

def hash
  to_h.hash
end

#to_hObject



663
664
665
# File 'lib/rerout/models.rb', line 663

def to_h
  { created: created, total: total, results: results.map(&:to_h) }
end