Class: Raas::GetOrdersResponseModel

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/raas/models/get_orders_response_model.rb

Overview

Represents the response from the get orders call

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(page = nil, orders = nil) ⇒ GetOrdersResponseModel

Returns a new instance of GetOrdersResponseModel.



23
24
25
26
27
# File 'lib/raas/models/get_orders_response_model.rb', line 23

def initialize(page = nil,
               orders = nil)
  @page = page
  @orders = orders
end

Instance Attribute Details

#ordersList of OrderSummaryModel

An array of orders

Returns:



13
14
15
# File 'lib/raas/models/get_orders_response_model.rb', line 13

def orders
  @orders
end

#pagePageModel

Pagination information

Returns:



9
10
11
# File 'lib/raas/models/get_orders_response_model.rb', line 9

def page
  @page
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/raas/models/get_orders_response_model.rb', line 30

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  page = PageModel.from_hash(hash['page']) if hash['page']
  # Parameter is an array, so we need to iterate through it
  orders = nil
  unless hash['orders'].nil?
    orders = []
    hash['orders'].each do |structure|
      orders << (OrderSummaryModel.from_hash(structure) if structure)
    end
  end

  # Create object from extracted values.
  GetOrdersResponseModel.new(page,
                             orders)
end

.namesObject

A mapping from model property names to API property names.



16
17
18
19
20
21
# File 'lib/raas/models/get_orders_response_model.rb', line 16

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['page'] = 'page'
  @_hash['orders'] = 'orders'
  @_hash
end