Class: NewDemoApiClient::IncomeStatementEntry

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date:, category:, field:, value: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::IncomeStatementEntry

Parameters:

  • date (String)

    The date of the entry.

  • category (String)

    The category of the entry.

  • field (String)

    The original field name of the entry.

  • value (Float) (defaults to: OMIT)

    The value of the entry.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



30
31
32
33
34
35
36
37
38
39
# File 'lib/test_sdk/types/income_statement_entry.rb', line 30

def initialize(date:, category:, field:, value: OMIT, additional_properties: nil)
  @date = date
  @category = category
  @field = field
  @value = value if value != OMIT
  @additional_properties = additional_properties
  @_field_set = { "date": date, "category": category, "field": field, "value": value }.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



17
18
19
# File 'lib/test_sdk/types/income_statement_entry.rb', line 17

def additional_properties
  @additional_properties
end

#categoryString (readonly)

Returns The category of the entry.

Returns:

  • (String)

    The category of the entry.



11
12
13
# File 'lib/test_sdk/types/income_statement_entry.rb', line 11

def category
  @category
end

#dateString (readonly)

Returns The date of the entry.

Returns:

  • (String)

    The date of the entry.



9
10
11
# File 'lib/test_sdk/types/income_statement_entry.rb', line 9

def date
  @date
end

#fieldString (readonly)

Returns The original field name of the entry.

Returns:

  • (String)

    The original field name of the entry.



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

def field
  @field
end

#valueFloat (readonly)

Returns The value of the entry.

Returns:

  • (Float)

    The value of the entry.



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

def value
  @value
end

Class Method Details

.from_json(json_object:) ⇒ NewDemoApiClient::IncomeStatementEntry

Deserialize a JSON object to an instance of IncomeStatementEntry

Parameters:

  • json_object (String)

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/test_sdk/types/income_statement_entry.rb', line 45

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  date = parsed_json["date"]
  category = parsed_json["category"]
  field = parsed_json["field"]
  value = parsed_json["value"]
  new(
    date: date,
    category: category,
    field: field,
    value: value,
    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)


74
75
76
77
78
79
# File 'lib/test_sdk/types/income_statement_entry.rb', line 74

def self.validate_raw(obj:)
  obj.date.is_a?(String) != false || raise("Passed value for field obj.date is not the expected type, validation failed.")
  obj.category.is_a?(String) != false || raise("Passed value for field obj.category is not the expected type, validation failed.")
  obj.field.is_a?(String) != false || raise("Passed value for field obj.field is not the expected type, validation failed.")
  obj.value&.is_a?(Float) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of IncomeStatementEntry to a JSON object

Returns:

  • (String)


64
65
66
# File 'lib/test_sdk/types/income_statement_entry.rb', line 64

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