Class: NewDemoApiClient::FinancialsResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/test_sdk/types/financials_response.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(freq: OMIT, income_statement: OMIT, category_growth_rates: OMIT, financial_metrics: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::FinancialsResponse

Parameters:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/test_sdk/types/financials_response.rb', line 36

def initialize(freq: OMIT, income_statement: OMIT, category_growth_rates: OMIT, financial_metrics: OMIT,
               additional_properties: nil)
  @freq = freq if freq != OMIT
  @income_statement = income_statement if income_statement != OMIT
  @category_growth_rates = category_growth_rates if category_growth_rates != OMIT
  @financial_metrics = financial_metrics if financial_metrics != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "freq": freq,
    "income_statement": income_statement,
    "category_growth_rates": category_growth_rates,
    "financial_metrics": financial_metrics
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



22
23
24
# File 'lib/test_sdk/types/financials_response.rb', line 22

def additional_properties
  @additional_properties
end

#category_growth_ratesArray<NewDemoApiClient::CategoryGrowthRates> (readonly)

Returns The growth rates for each category. The cxgr values will occur where x matches the frequency.

Returns:



18
19
20
# File 'lib/test_sdk/types/financials_response.rb', line 18

def category_growth_rates
  @category_growth_rates
end

#financial_metricsArray<NewDemoApiClient::FinancialMetrics> (readonly)

Returns Derived financial metrics for the company.

Returns:



20
21
22
# File 'lib/test_sdk/types/financials_response.rb', line 20

def financial_metrics
  @financial_metrics
end

#freqNewDemoApiClient::Frequency (readonly)

Returns The frequency of the financial data.

Returns:



13
14
15
# File 'lib/test_sdk/types/financials_response.rb', line 13

def freq
  @freq
end

#income_statementArray<NewDemoApiClient::IncomeStatementEntry> (readonly)

Returns The entries in the income statement.

Returns:



15
16
17
# File 'lib/test_sdk/types/financials_response.rb', line 15

def income_statement
  @income_statement
end

Class Method Details

.from_json(json_object:) ⇒ NewDemoApiClient::FinancialsResponse

Deserialize a JSON object to an instance of FinancialsResponse

Parameters:

  • json_object (String)

Returns:



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/test_sdk/types/financials_response.rb', line 57

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  freq = parsed_json["freq"]
  income_statement = parsed_json["income_statement"]&.map do |item|
    item = item.to_json
    NewDemoApiClient::IncomeStatementEntry.from_json(json_object: item)
  end
  category_growth_rates = parsed_json["category_growth_rates"]&.map do |item|
    item = item.to_json
    NewDemoApiClient::CategoryGrowthRates.from_json(json_object: item)
  end
  financial_metrics = parsed_json["financial_metrics"]&.map do |item|
    item = item.to_json
    NewDemoApiClient::FinancialMetrics.from_json(json_object: item)
  end
  new(
    freq: freq,
    income_statement: income_statement,
    category_growth_rates: category_growth_rates,
    financial_metrics: financial_metrics,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


95
96
97
98
99
100
# File 'lib/test_sdk/types/financials_response.rb', line 95

def self.validate_raw(obj:)
  obj.freq&.is_a?(NewDemoApiClient::Frequency) != false || raise("Passed value for field obj.freq is not the expected type, validation failed.")
  obj.income_statement&.is_a?(Array) != false || raise("Passed value for field obj.income_statement is not the expected type, validation failed.")
  obj.category_growth_rates&.is_a?(Array) != false || raise("Passed value for field obj.category_growth_rates is not the expected type, validation failed.")
  obj.financial_metrics&.is_a?(Array) != false || raise("Passed value for field obj.financial_metrics is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of FinancialsResponse to a JSON object

Returns:

  • (String)


85
86
87
# File 'lib/test_sdk/types/financials_response.rb', line 85

def to_json(*_args)
  @_field_set&.to_json
end