Class: Cryptopay::Pagination

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Pagination

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



32
33
34
# File 'lib/cryptopay/models/pagination.rb', line 32

def initialize(attributes = {})
  @attributes = ENCODER.sanitize(attributes)
end

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::Pagination

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:



25
26
27
28
# File 'lib/cryptopay/models/pagination.rb', line 25

def self.build_from_hash(data)
  attributes = ENCODER.build_from_hash(data)
  new(attributes)
end

Instance Method Details

#has_moreObject



40
41
42
# File 'lib/cryptopay/models/pagination.rb', line 40

def has_more
  @attributes[:has_more]
end

#inspectObject



68
69
70
# File 'lib/cryptopay/models/pagination.rb', line 68

def inspect
  "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
end

#invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



46
47
48
49
50
51
52
53
54
# File 'lib/cryptopay/models/pagination.rb', line 46

def invalid_properties
  properties = []

  properties.push('invalid value for "total", total cannot be nil.') if total.nil?

  properties.push('invalid value for "has_more", has_more cannot be nil.') if has_more.nil?

  properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



64
65
66
# File 'lib/cryptopay/models/pagination.rb', line 64

def to_hash
  ENCODER.to_hash(@attributes)
end

#totalObject



36
37
38
# File 'lib/cryptopay/models/pagination.rb', line 36

def total
  @attributes[:total]
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



58
59
60
# File 'lib/cryptopay/models/pagination.rb', line 58

def valid?
  invalid_properties.empty?
end