Class: Merge::Accounting::AccountingPeriod
- Inherits:
-
Object
- Object
- Merge::Accounting::AccountingPeriod
- 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
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#created_at ⇒ DateTime
readonly
The datetime that this object was created by Merge.
-
#end_date ⇒ DateTime
readonly
End date of the period.
- #id ⇒ String readonly
-
#modified_at ⇒ DateTime
readonly
The datetime that this object was modified by Merge.
-
#name ⇒ String
readonly
Name of the accounting period.
-
#start_date ⇒ DateTime
readonly
Beginning date of the period.
- #status ⇒ Merge::Accounting::AccountingPeriodStatusEnum readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Merge::Accounting::AccountingPeriod
Deserialize a JSON object to an instance of AccountingPeriod.
-
.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.
Instance Method Summary collapse
- #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 constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of AccountingPeriod to a JSON object.
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
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_properties ⇒ OpenStruct (readonly)
Returns 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_at ⇒ DateTime (readonly)
Returns 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_date ⇒ DateTime (readonly)
Returns 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 |
#id ⇒ String (readonly)
19 20 21 |
# File 'lib/merge_ruby_client/accounting/types/accounting_period.rb', line 19 def id @id end |
#modified_at ⇒ DateTime (readonly)
Returns 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 |
#name ⇒ String (readonly)
Returns 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_date ⇒ DateTime (readonly)
Returns 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 |
#status ⇒ Merge::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
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.
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
101 102 103 |
# File 'lib/merge_ruby_client/accounting/types/accounting_period.rb', line 101 def to_json(*_args) @_field_set&.to_json end |