Class: Merge::Accounting::AccountingPeriod

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/accounting/types/accounting_period.rb

Overview

# The AccountingPeriod Object

### Description
The `AccountingPeriod` object is used to define a period of time in which events
occurred.
### Usage Example
Common models like `Invoice` and `Transaction` will have `AccountingPeriod`
objects which will denote when they occurred.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: OMIT, created_at: OMIT, modified_at: OMIT, start_date: OMIT, end_date: OMIT, status: OMIT, name: OMIT, additional_properties: nil) ⇒ Merge::Accounting::AccountingPeriod

Parameters:

  • id (String) (defaults to: OMIT)
  • created_at (DateTime) (defaults to: OMIT)

    The datetime that this object was created by Merge.

  • modified_at (DateTime) (defaults to: OMIT)

    The datetime that this object was modified by Merge.

  • start_date (DateTime) (defaults to: OMIT)

    Beginning date of the period

  • end_date (DateTime) (defaults to: OMIT)

    End date of the period

  • status (Merge::Accounting::AccountingPeriodStatusEnum) (defaults to: OMIT)
  • name (String) (defaults to: OMIT)

    Name of the accounting period.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/merge_ruby_client/accounting/types/accounting_period.rb', line 49

def initialize(id: OMIT, created_at: OMIT, modified_at: OMIT, start_date: OMIT, end_date: OMIT, status: OMIT,
               name: OMIT, additional_properties: nil)
  @id = id if id != OMIT
  @created_at = created_at if created_at != OMIT
  @modified_at = modified_at if modified_at != OMIT
  @start_date = start_date if start_date != OMIT
  @end_date = end_date if end_date != OMIT
  @status = status if status != OMIT
  @name = name if name != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "id": id,
    "created_at": created_at,
    "modified_at": modified_at,
    "start_date": start_date,
    "end_date": end_date,
    "status": status,
    "name": name
  }.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



33
34
35
# File 'lib/merge_ruby_client/accounting/types/accounting_period.rb', line 33

def additional_properties
  @additional_properties
end

#created_atDateTime (readonly)

Returns The datetime that this object was created by Merge.

Returns:

  • (DateTime)

    The datetime that this object was created by Merge.



21
22
23
# File 'lib/merge_ruby_client/accounting/types/accounting_period.rb', line 21

def created_at
  @created_at
end

#end_dateDateTime (readonly)

Returns End date of the period.

Returns:

  • (DateTime)

    End date of the period



27
28
29
# File 'lib/merge_ruby_client/accounting/types/accounting_period.rb', line 27

def end_date
  @end_date
end

#idString (readonly)

Returns:

  • (String)


19
20
21
# File 'lib/merge_ruby_client/accounting/types/accounting_period.rb', line 19

def id
  @id
end

#modified_atDateTime (readonly)

Returns The datetime that this object was modified by Merge.

Returns:

  • (DateTime)

    The datetime that this object was modified by Merge.



23
24
25
# File 'lib/merge_ruby_client/accounting/types/accounting_period.rb', line 23

def modified_at
  @modified_at
end

#nameString (readonly)

Returns Name of the accounting period.

Returns:

  • (String)

    Name of the accounting period.



31
32
33
# File 'lib/merge_ruby_client/accounting/types/accounting_period.rb', line 31

def name
  @name
end

#start_dateDateTime (readonly)

Returns Beginning date of the period.

Returns:

  • (DateTime)

    Beginning date of the period



25
26
27
# File 'lib/merge_ruby_client/accounting/types/accounting_period.rb', line 25

def start_date
  @start_date
end

#statusMerge::Accounting::AccountingPeriodStatusEnum (readonly)



29
30
31
# File 'lib/merge_ruby_client/accounting/types/accounting_period.rb', line 29

def status
  @status
end

Class Method Details

.from_json(json_object:) ⇒ Merge::Accounting::AccountingPeriod

Deserialize a JSON object to an instance of AccountingPeriod

Parameters:

  • json_object (String)

Returns:



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/merge_ruby_client/accounting/types/accounting_period.rb', line 76

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  created_at = (DateTime.parse(parsed_json["created_at"]) unless parsed_json["created_at"].nil?)
  modified_at = (DateTime.parse(parsed_json["modified_at"]) unless parsed_json["modified_at"].nil?)
  start_date = (DateTime.parse(parsed_json["start_date"]) unless parsed_json["start_date"].nil?)
  end_date = (DateTime.parse(parsed_json["end_date"]) unless parsed_json["end_date"].nil?)
  status = parsed_json["status"]
  name = parsed_json["name"]
  new(
    id: id,
    created_at: created_at,
    modified_at: modified_at,
    start_date: start_date,
    end_date: end_date,
    status: status,
    name: name,
    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)


111
112
113
114
115
116
117
118
119
# File 'lib/merge_ruby_client/accounting/types/accounting_period.rb', line 111

def self.validate_raw(obj:)
  obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.")
  obj.modified_at&.is_a?(DateTime) != false || raise("Passed value for field obj.modified_at is not the expected type, validation failed.")
  obj.start_date&.is_a?(DateTime) != false || raise("Passed value for field obj.start_date is not the expected type, validation failed.")
  obj.end_date&.is_a?(DateTime) != false || raise("Passed value for field obj.end_date is not the expected type, validation failed.")
  obj.status&.is_a?(Merge::Accounting::AccountingPeriodStatusEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of AccountingPeriod to a JSON object

Returns:

  • (String)


101
102
103
# File 'lib/merge_ruby_client/accounting/types/accounting_period.rb', line 101

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