Class: UspsApi::ReconciliationAdjustmentsPaginationMetadata

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/reconciliation_adjustments_pagination_metadata.rb

Overview

Standard error message response.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(page_size:, total_record_count: SKIP, page_num: SKIP, total_pages: SKIP) ⇒ ReconciliationAdjustmentsPaginationMetadata

Returns a new instance of ReconciliationAdjustmentsPaginationMetadata.



54
55
56
57
58
59
60
# File 'lib/usps_api/models/reconciliation_adjustments_pagination_metadata.rb', line 54

def initialize(page_size:, total_record_count: SKIP, page_num: SKIP,
               total_pages: SKIP)
  @total_record_count = total_record_count unless total_record_count == SKIP
  @page_num = page_num unless page_num == SKIP
  @total_pages = total_pages unless total_pages == SKIP
  @page_size = page_size
end

Instance Attribute Details

#page_numInteger

The current page number.

Returns:

  • (Integer)


18
19
20
# File 'lib/usps_api/models/reconciliation_adjustments_pagination_metadata.rb', line 18

def page_num
  @page_num
end

#page_sizeInteger

The number of resources returned per call, based on the user provided pageSize

Returns:

  • (Integer)


28
29
30
# File 'lib/usps_api/models/reconciliation_adjustments_pagination_metadata.rb', line 28

def page_size
  @page_size
end

#total_pagesInteger

Total number of pages, based on the user provided pageSize and

totalRecordCount

Returns:

  • (Integer)


23
24
25
# File 'lib/usps_api/models/reconciliation_adjustments_pagination_metadata.rb', line 23

def total_pages
  @total_pages
end

#total_record_countInteger

Total number of resources return in the API request.

Returns:

  • (Integer)


14
15
16
# File 'lib/usps_api/models/reconciliation_adjustments_pagination_metadata.rb', line 14

def total_record_count
  @total_record_count
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/usps_api/models/reconciliation_adjustments_pagination_metadata.rb', line 63

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  page_size = hash.key?('pageSize') ? hash['pageSize'] : nil
  total_record_count =
    hash.key?('totalRecordCount') ? hash['totalRecordCount'] : SKIP
  page_num = hash.key?('pageNum') ? hash['pageNum'] : SKIP
  total_pages = hash.key?('totalPages') ? hash['totalPages'] : SKIP

  # Create object from extracted values.
  ReconciliationAdjustmentsPaginationMetadata.new(page_size: page_size,
                                                  total_record_count: total_record_count,
                                                  page_num: page_num,
                                                  total_pages: total_pages)
end

.namesObject

A mapping from model property names to API property names.



31
32
33
34
35
36
37
38
# File 'lib/usps_api/models/reconciliation_adjustments_pagination_metadata.rb', line 31

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['total_record_count'] = 'totalRecordCount'
  @_hash['page_num'] = 'pageNum'
  @_hash['total_pages'] = 'totalPages'
  @_hash['page_size'] = 'pageSize'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/usps_api/models/reconciliation_adjustments_pagination_metadata.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



41
42
43
44
45
46
47
# File 'lib/usps_api/models/reconciliation_adjustments_pagination_metadata.rb', line 41

def self.optionals
  %w[
    total_record_count
    page_num
    total_pages
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



88
89
90
91
92
93
# File 'lib/usps_api/models/reconciliation_adjustments_pagination_metadata.rb', line 88

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} total_record_count: #{@total_record_count.inspect}, page_num:"\
  " #{@page_num.inspect}, total_pages: #{@total_pages.inspect}, page_size:"\
  " #{@page_size.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



81
82
83
84
85
# File 'lib/usps_api/models/reconciliation_adjustments_pagination_metadata.rb', line 81

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} total_record_count: #{@total_record_count}, page_num: #{@page_num},"\
  " total_pages: #{@total_pages}, page_size: #{@page_size}>"
end