Class: TestPack1::DataPerCategoryResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/test_pack_1/models/data_per_category_response.rb

Overview

An object containing data grouped by contract category and aggregate.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(data_signal = nil, calculation = nil, data = nil) ⇒ DataPerCategoryResponse

Returns a new instance of DataPerCategoryResponse.



32
33
34
35
36
37
38
# File 'lib/test_pack_1/models/data_per_category_response.rb', line 32

def initialize(data_signal = nil,
               calculation = nil,
               data = nil)
  @data_signal = data_signal
  @calculation = calculation
  @data = data
end

Instance Attribute Details

#calculationCalculationModeEnum

Which operation to use when aggregating data.

Returns:



15
16
17
# File 'lib/test_pack_1/models/data_per_category_response.rb', line 15

def calculation
  @calculation
end

#dataList of DataPerCategoryItem

A list of objects: one per combination of

  • aggregate

  • contract category

Returns:



21
22
23
# File 'lib/test_pack_1/models/data_per_category_response.rb', line 21

def data
  @data
end

#data_signalDataSignal

A data signal.

Returns:



11
12
13
# File 'lib/test_pack_1/models/data_per_category_response.rb', line 11

def data_signal
  @data_signal
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/test_pack_1/models/data_per_category_response.rb', line 41

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  data_signal = DataSignal.from_hash(hash['dataSignal']) if
    hash['dataSignal']
  calculation = hash['calculation']
  # Parameter is an array, so we need to iterate through it

  data = nil
  unless hash['data'].nil?
    data = []
    hash['data'].each do |structure|
      data << (DataPerCategoryItem.from_hash(structure) if structure)
    end
  end

  # Create object from extracted values.

  DataPerCategoryResponse.new(data_signal,
                              calculation,
                              data)
end

.namesObject

A mapping from model property names to API property names.



24
25
26
27
28
29
30
# File 'lib/test_pack_1/models/data_per_category_response.rb', line 24

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['data_signal'] = 'dataSignal'
  @_hash['calculation'] = 'calculation'
  @_hash['data'] = 'data'
  @_hash
end