Class: UspsApi::SubscriptionsUnpaidPackagesPaginationMetadata

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

Overview

Standard error message response. example: |- [ “self”: “/post-office-locations?offset=40&limit=20”, “first”: “/post-office-locations?offset=0&limit=20”, “previous”: “/post-office-locations?offset=20&limit=20”, “next”: “/post-office-locations?offset=60&limit=20”, “last”: “/post-office-locations?offset=120&limit=20” ]

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(limit:, offset:, total_count: SKIP, page: SKIP, total_pages: SKIP, links: SKIP) ⇒ SubscriptionsUnpaidPackagesPaginationMetadata

Returns a new instance of SubscriptionsUnpaidPackagesPaginationMetadata.



69
70
71
72
73
74
75
76
77
# File 'lib/usps_api/models/subscriptions_unpaid_packages_pagination_metadata.rb', line 69

def initialize(limit:, offset:, total_count: SKIP, page: SKIP,
               total_pages: SKIP, links: SKIP)
  @total_count = total_count unless total_count == SKIP
  @page = page unless page == SKIP
  @total_pages = total_pages unless total_pages == SKIP
  @limit = limit
  @offset = offset
  @links = links unless links == SKIP
end

Instance Attribute Details

#limitInteger

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

Returns:

  • (Integer)


32
33
34
# File 'lib/usps_api/models/subscriptions_unpaid_packages_pagination_metadata.rb', line 32

def limit
  @limit
end

Hypermedia links to related resources.

Returns:



40
41
42
# File 'lib/usps_api/models/subscriptions_unpaid_packages_pagination_metadata.rb', line 40

def links
  @links
end

#offsetInteger

The current offset, based on the user provided offset

Returns:

  • (Integer)


36
37
38
# File 'lib/usps_api/models/subscriptions_unpaid_packages_pagination_metadata.rb', line 36

def offset
  @offset
end

#pageInteger

The current page number.

Returns:

  • (Integer)


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

def page
  @page
end

#total_countInteger

Total number of resources return in the API request.

Returns:

  • (Integer)


19
20
21
# File 'lib/usps_api/models/subscriptions_unpaid_packages_pagination_metadata.rb', line 19

def total_count
  @total_count
end

#total_pagesInteger

Total number of pages, based on the user provided limit and [totalCount]

Returns:

  • (Integer)


27
28
29
# File 'lib/usps_api/models/subscriptions_unpaid_packages_pagination_metadata.rb', line 27

def total_pages
  @total_pages
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/usps_api/models/subscriptions_unpaid_packages_pagination_metadata.rb', line 80

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  limit = hash.key?('limit') ? hash['limit'] : nil
  offset = hash.key?('offset') ? hash['offset'] : nil
  total_count = hash.key?('totalCount') ? hash['totalCount'] : SKIP
  page = hash.key?('page') ? hash['page'] : SKIP
  total_pages = hash.key?('totalPages') ? hash['totalPages'] : SKIP
  # Parameter is an array, so we need to iterate through it
  links = nil
  unless hash['links'].nil?
    links = []
    hash['links'].each do |structure|
      links << (AdjustmentsHypermediaLink.from_hash(structure) if structure)
    end
  end

  links = SKIP unless hash.key?('links')

  # Create object from extracted values.
  SubscriptionsUnpaidPackagesPaginationMetadata.new(limit: limit,
                                                    offset: offset,
                                                    total_count: total_count,
                                                    page: page,
                                                    total_pages: total_pages,
                                                    links: links)
end

.namesObject

A mapping from model property names to API property names.



43
44
45
46
47
48
49
50
51
52
# File 'lib/usps_api/models/subscriptions_unpaid_packages_pagination_metadata.rb', line 43

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['total_count'] = 'totalCount'
  @_hash['page'] = 'page'
  @_hash['total_pages'] = 'totalPages'
  @_hash['limit'] = 'limit'
  @_hash['offset'] = 'offset'
  @_hash['links'] = 'links'
  @_hash
end

.nullablesObject

An array for nullable fields



65
66
67
# File 'lib/usps_api/models/subscriptions_unpaid_packages_pagination_metadata.rb', line 65

def self.nullables
  []
end

.optionalsObject

An array for optional fields



55
56
57
58
59
60
61
62
# File 'lib/usps_api/models/subscriptions_unpaid_packages_pagination_metadata.rb', line 55

def self.optionals
  %w[
    total_count
    page
    total_pages
    links
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



117
118
119
120
121
122
# File 'lib/usps_api/models/subscriptions_unpaid_packages_pagination_metadata.rb', line 117

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} total_count: #{@total_count.inspect}, page: #{@page.inspect}, total_pages:"\
  " #{@total_pages.inspect}, limit: #{@limit.inspect}, offset: #{@offset.inspect}, links:"\
  " #{@links.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



110
111
112
113
114
# File 'lib/usps_api/models/subscriptions_unpaid_packages_pagination_metadata.rb', line 110

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} total_count: #{@total_count}, page: #{@page}, total_pages: #{@total_pages},"\
  " limit: #{@limit}, offset: #{@offset}, links: #{@links}>"
end