merge_ruby_client 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/lib/merge_ruby_client/accounting/accounts/client.rb +16 -8
  3. data/lib/merge_ruby_client/accounting/audit_trail/client.rb +6 -4
  4. data/lib/merge_ruby_client/accounting/client.rb +7 -0
  5. data/lib/merge_ruby_client/accounting/contacts/client.rb +14 -6
  6. data/lib/merge_ruby_client/accounting/expenses/client.rb +12 -4
  7. data/lib/merge_ruby_client/accounting/invoices/client.rb +12 -4
  8. data/lib/merge_ruby_client/accounting/items/client.rb +332 -0
  9. data/lib/merge_ruby_client/accounting/journal_entries/client.rb +12 -4
  10. data/lib/merge_ruby_client/accounting/payments/client.rb +12 -4
  11. data/lib/merge_ruby_client/accounting/projects/client.rb +224 -0
  12. data/lib/merge_ruby_client/accounting/projects/types/projects_list_request_expand.rb +13 -0
  13. data/lib/merge_ruby_client/accounting/projects/types/projects_retrieve_request_expand.rb +13 -0
  14. data/lib/merge_ruby_client/accounting/purchase_orders/client.rb +12 -4
  15. data/lib/merge_ruby_client/accounting/tracking_categories/client.rb +16 -8
  16. data/lib/merge_ruby_client/accounting/types/account_details_and_actions.rb +10 -2
  17. data/lib/merge_ruby_client/accounting/types/audit_log_event.rb +2 -0
  18. data/lib/merge_ruby_client/accounting/types/credit_note_line_item.rb +29 -1
  19. data/lib/merge_ruby_client/accounting/types/credit_note_line_item_contact.rb +56 -0
  20. data/lib/merge_ruby_client/accounting/types/credit_note_line_item_project.rb +55 -0
  21. data/lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb +29 -1
  22. data/lib/merge_ruby_client/accounting/types/credit_note_line_item_request_contact.rb +56 -0
  23. data/lib/merge_ruby_client/accounting/types/credit_note_line_item_request_project.rb +55 -0
  24. data/lib/merge_ruby_client/accounting/types/event_type_enum.rb +2 -0
  25. data/lib/merge_ruby_client/accounting/types/expense_line.rb +15 -1
  26. data/lib/merge_ruby_client/accounting/types/expense_line_project.rb +55 -0
  27. data/lib/merge_ruby_client/accounting/types/expense_line_request.rb +15 -1
  28. data/lib/merge_ruby_client/accounting/types/expense_line_request_project.rb +55 -0
  29. data/lib/merge_ruby_client/accounting/types/external_target_field_api_response.rb +12 -1
  30. data/lib/merge_ruby_client/accounting/types/field_mapping_api_instance_response.rb +12 -1
  31. data/lib/merge_ruby_client/accounting/types/general_ledger_transaction_line.rb +15 -1
  32. data/lib/merge_ruby_client/accounting/types/general_ledger_transaction_line_project.rb +55 -0
  33. data/lib/merge_ruby_client/accounting/types/invoice_line_item.rb +29 -1
  34. data/lib/merge_ruby_client/accounting/types/invoice_line_item_contact.rb +56 -0
  35. data/lib/merge_ruby_client/accounting/types/invoice_line_item_project.rb +55 -0
  36. data/lib/merge_ruby_client/accounting/types/invoice_line_item_request.rb +29 -1
  37. data/lib/merge_ruby_client/accounting/types/invoice_line_item_request_contact.rb +56 -0
  38. data/lib/merge_ruby_client/accounting/types/invoice_line_item_request_project.rb +55 -0
  39. data/lib/merge_ruby_client/accounting/types/item_request_request.rb +202 -0
  40. data/lib/merge_ruby_client/accounting/types/item_request_request_company.rb +56 -0
  41. data/lib/merge_ruby_client/accounting/types/item_request_request_purchase_account.rb +56 -0
  42. data/lib/merge_ruby_client/accounting/types/item_request_request_purchase_tax_rate.rb +56 -0
  43. data/lib/merge_ruby_client/accounting/types/item_request_request_sales_account.rb +56 -0
  44. data/lib/merge_ruby_client/accounting/types/item_request_request_sales_tax_rate.rb +56 -0
  45. data/lib/merge_ruby_client/accounting/types/item_response.rb +101 -0
  46. data/lib/merge_ruby_client/accounting/types/journal_line.rb +15 -1
  47. data/lib/merge_ruby_client/accounting/types/journal_line_project.rb +55 -0
  48. data/lib/merge_ruby_client/accounting/types/journal_line_request.rb +15 -1
  49. data/lib/merge_ruby_client/accounting/types/journal_line_request_project.rb +55 -0
  50. data/lib/merge_ruby_client/accounting/types/paginated_project_list.rb +80 -0
  51. data/lib/merge_ruby_client/accounting/types/patched_item_request_request.rb +172 -0
  52. data/lib/merge_ruby_client/accounting/types/project.rb +162 -0
  53. data/lib/merge_ruby_client/accounting/types/project_company.rb +56 -0
  54. data/lib/merge_ruby_client/accounting/types/project_contact.rb +56 -0
  55. data/lib/merge_ruby_client/accounting/types/remote_field_api_response.rb +12 -1
  56. data/lib/merge_ruby_client/accounting/types/type_2_bb_enum.rb +16 -0
  57. data/lib/merge_ruby_client/accounting/types/vendor_credit_line.rb +29 -1
  58. data/lib/merge_ruby_client/accounting/types/vendor_credit_line_contact.rb +55 -0
  59. data/lib/merge_ruby_client/accounting/types/vendor_credit_line_project.rb +55 -0
  60. data/lib/merge_ruby_client/accounting/types/vendor_credit_line_request.rb +29 -1
  61. data/lib/merge_ruby_client/accounting/types/vendor_credit_line_request_contact.rb +55 -0
  62. data/lib/merge_ruby_client/accounting/types/vendor_credit_line_request_project.rb +55 -0
  63. data/lib/merge_ruby_client/ats/audit_trail/client.rb +6 -4
  64. data/lib/merge_ruby_client/ats/types/account_details_and_actions.rb +10 -2
  65. data/lib/merge_ruby_client/ats/types/audit_log_event.rb +2 -0
  66. data/lib/merge_ruby_client/ats/types/event_type_enum.rb +1 -0
  67. data/lib/merge_ruby_client/crm/accounts/client.rb +6 -2
  68. data/lib/merge_ruby_client/crm/audit_trail/client.rb +6 -4
  69. data/lib/merge_ruby_client/crm/contacts/client.rb +6 -2
  70. data/lib/merge_ruby_client/crm/custom_objects/client.rb +10 -2
  71. data/lib/merge_ruby_client/crm/engagement_types/client.rb +6 -2
  72. data/lib/merge_ruby_client/crm/engagements/client.rb +6 -2
  73. data/lib/merge_ruby_client/crm/leads/client.rb +6 -2
  74. data/lib/merge_ruby_client/crm/notes/client.rb +6 -2
  75. data/lib/merge_ruby_client/crm/opportunities/client.rb +6 -2
  76. data/lib/merge_ruby_client/crm/stages/client.rb +6 -2
  77. data/lib/merge_ruby_client/crm/sync_status/client.rb +20 -6
  78. data/lib/merge_ruby_client/crm/tasks/client.rb +6 -2
  79. data/lib/merge_ruby_client/crm/types/audit_log_event.rb +2 -0
  80. data/lib/merge_ruby_client/crm/types/custom_object_request.rb +26 -3
  81. data/lib/merge_ruby_client/crm/types/event_type_enum.rb +2 -0
  82. data/lib/merge_ruby_client/crm/users/client.rb +6 -2
  83. data/lib/merge_ruby_client/filestorage/audit_trail/client.rb +6 -4
  84. data/lib/merge_ruby_client/filestorage/files/client.rb +48 -12
  85. data/lib/merge_ruby_client/filestorage/files/types/files_download_request_meta_list_request_order_by.rb +14 -0
  86. data/lib/merge_ruby_client/filestorage/files/types/files_list_request_order_by.rb +14 -0
  87. data/lib/merge_ruby_client/filestorage/sync_status/client.rb +20 -6
  88. data/lib/merge_ruby_client/filestorage/types/account_details_and_actions.rb +10 -2
  89. data/lib/merge_ruby_client/filestorage/types/audit_log_event.rb +2 -0
  90. data/lib/merge_ruby_client/filestorage/types/download_request_meta.rb +2 -9
  91. data/lib/merge_ruby_client/filestorage/types/event_type_enum.rb +2 -0
  92. data/lib/merge_ruby_client/filestorage/types/file.rb +13 -1
  93. data/lib/merge_ruby_client/filestorage/types/file_request.rb +13 -1
  94. data/lib/merge_ruby_client/hris/audit_trail/client.rb +6 -4
  95. data/lib/merge_ruby_client/hris/types/account_details_and_actions.rb +10 -2
  96. data/lib/merge_ruby_client/hris/types/audit_log_event.rb +2 -0
  97. data/lib/merge_ruby_client/hris/types/event_type_enum.rb +2 -0
  98. data/lib/merge_ruby_client/ticketing/audit_trail/client.rb +6 -4
  99. data/lib/merge_ruby_client/ticketing/tickets/client.rb +26 -10
  100. data/lib/merge_ruby_client/ticketing/types/account_details_and_actions.rb +10 -2
  101. data/lib/merge_ruby_client/ticketing/types/audit_log_event.rb +2 -0
  102. data/lib/merge_ruby_client/ticketing/types/collection.rb +18 -16
  103. data/lib/merge_ruby_client/ticketing/types/{access_level_enum.rb → collection_access_level_enum.rb} +3 -1
  104. data/lib/merge_ruby_client/ticketing/types/event_type_enum.rb +2 -0
  105. data/lib/merge_ruby_client/ticketing/types/patched_ticket_request.rb +20 -1
  106. data/lib/merge_ruby_client/ticketing/types/ticket.rb +20 -1
  107. data/lib/merge_ruby_client/ticketing/types/ticket_access_level_enum.rb +16 -0
  108. data/lib/merge_ruby_client/ticketing/types/ticket_request.rb +20 -1
  109. data/lib/merge_ruby_client.rb +7 -7
  110. data/lib/requests.rb +2 -2
  111. data/lib/types_export.rb +243 -208
  112. metadata +39 -3
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "project"
5
+
6
+ module Merge
7
+ module Accounting
8
+ class JournalLineProject
9
+ # Deserialize a JSON object to an instance of JournalLineProject
10
+ #
11
+ # @param json_object [String]
12
+ # @return [Merge::Accounting::JournalLineProject]
13
+ def self.from_json(json_object:)
14
+ struct = JSON.parse(json_object, object_class: OpenStruct)
15
+ begin
16
+ struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.")
17
+ return struct unless struct.nil?
18
+
19
+ return nil
20
+ rescue StandardError
21
+ # noop
22
+ end
23
+ begin
24
+ Merge::Accounting::Project.validate_raw(obj: struct)
25
+ return Merge::Accounting::Project.from_json(json_object: struct) unless struct.nil?
26
+
27
+ return nil
28
+ rescue StandardError
29
+ # noop
30
+ end
31
+ struct
32
+ end
33
+
34
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
35
+ # hash and check each fields type against the current object's property
36
+ # definitions.
37
+ #
38
+ # @param obj [Object]
39
+ # @return [Void]
40
+ def self.validate_raw(obj:)
41
+ begin
42
+ return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.")
43
+ rescue StandardError
44
+ # noop
45
+ end
46
+ begin
47
+ return Merge::Accounting::Project.validate_raw(obj: obj)
48
+ rescue StandardError
49
+ # noop
50
+ end
51
+ raise("Passed value matched no type within the union, validation failed.")
52
+ end
53
+ end
54
+ end
55
+ end
@@ -4,6 +4,7 @@ require_relative "journal_line_request_account"
4
4
  require_relative "journal_line_request_tracking_category"
5
5
  require_relative "journal_line_request_tracking_categories_item"
6
6
  require_relative "transaction_currency_enum"
7
+ require_relative "journal_line_request_project"
7
8
  require_relative "remote_field_request"
8
9
  require "ostruct"
9
10
  require "json"
@@ -339,6 +340,8 @@ module Merge
339
340
  attr_reader :company
340
341
  # @return [String]
341
342
  attr_reader :employee
343
+ # @return [Merge::Accounting::JournalLineRequestProject]
344
+ attr_reader :project
342
345
  # @return [String]
343
346
  attr_reader :contact
344
347
  # @return [String] The tax rate that applies to this line item.
@@ -675,6 +678,7 @@ module Merge
675
678
  # * `ZWL` - Zimbabwean Dollar (2009)
676
679
  # @param company [String] The company the journal entry belongs to.
677
680
  # @param employee [String]
681
+ # @param project [Merge::Accounting::JournalLineRequestProject]
678
682
  # @param contact [String]
679
683
  # @param tax_rate [String] The tax rate that applies to this line item.
680
684
  # @param description [String] The line's description.
@@ -685,7 +689,7 @@ module Merge
685
689
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
686
690
  # @return [Merge::Accounting::JournalLineRequest]
687
691
  def initialize(remote_id: OMIT, account: OMIT, net_amount: OMIT, tracking_category: OMIT,
688
- tracking_categories: OMIT, currency: OMIT, company: OMIT, employee: OMIT, contact: OMIT, tax_rate: OMIT, description: OMIT, exchange_rate: OMIT, integration_params: OMIT, linked_account_params: OMIT, remote_fields: OMIT, additional_properties: nil)
692
+ tracking_categories: OMIT, currency: OMIT, company: OMIT, employee: OMIT, project: OMIT, contact: OMIT, tax_rate: OMIT, description: OMIT, exchange_rate: OMIT, integration_params: OMIT, linked_account_params: OMIT, remote_fields: OMIT, additional_properties: nil)
689
693
  @remote_id = remote_id if remote_id != OMIT
690
694
  @account = account if account != OMIT
691
695
  @net_amount = net_amount if net_amount != OMIT
@@ -694,6 +698,7 @@ module Merge
694
698
  @currency = currency if currency != OMIT
695
699
  @company = company if company != OMIT
696
700
  @employee = employee if employee != OMIT
701
+ @project = project if project != OMIT
697
702
  @contact = contact if contact != OMIT
698
703
  @tax_rate = tax_rate if tax_rate != OMIT
699
704
  @description = description if description != OMIT
@@ -711,6 +716,7 @@ module Merge
711
716
  "currency": currency,
712
717
  "company": company,
713
718
  "employee": employee,
719
+ "project": project,
714
720
  "contact": contact,
715
721
  "tax_rate": tax_rate,
716
722
  "description": description,
@@ -751,6 +757,12 @@ module Merge
751
757
  currency = parsed_json["currency"]
752
758
  company = parsed_json["company"]
753
759
  employee = parsed_json["employee"]
760
+ if parsed_json["project"].nil?
761
+ project = nil
762
+ else
763
+ project = parsed_json["project"].to_json
764
+ project = Merge::Accounting::JournalLineRequestProject.from_json(json_object: project)
765
+ end
754
766
  contact = parsed_json["contact"]
755
767
  tax_rate = parsed_json["tax_rate"]
756
768
  description = parsed_json["description"]
@@ -770,6 +782,7 @@ module Merge
770
782
  currency: currency,
771
783
  company: company,
772
784
  employee: employee,
785
+ project: project,
773
786
  contact: contact,
774
787
  tax_rate: tax_rate,
775
788
  description: description,
@@ -803,6 +816,7 @@ module Merge
803
816
  obj.currency&.is_a?(Merge::Accounting::TransactionCurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.")
804
817
  obj.company&.is_a?(String) != false || raise("Passed value for field obj.company is not the expected type, validation failed.")
805
818
  obj.employee&.is_a?(String) != false || raise("Passed value for field obj.employee is not the expected type, validation failed.")
819
+ obj.project.nil? || Merge::Accounting::JournalLineRequestProject.validate_raw(obj: obj.project)
806
820
  obj.contact&.is_a?(String) != false || raise("Passed value for field obj.contact is not the expected type, validation failed.")
807
821
  obj.tax_rate&.is_a?(String) != false || raise("Passed value for field obj.tax_rate is not the expected type, validation failed.")
808
822
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "project"
5
+
6
+ module Merge
7
+ module Accounting
8
+ class JournalLineRequestProject
9
+ # Deserialize a JSON object to an instance of JournalLineRequestProject
10
+ #
11
+ # @param json_object [String]
12
+ # @return [Merge::Accounting::JournalLineRequestProject]
13
+ def self.from_json(json_object:)
14
+ struct = JSON.parse(json_object, object_class: OpenStruct)
15
+ begin
16
+ struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.")
17
+ return struct unless struct.nil?
18
+
19
+ return nil
20
+ rescue StandardError
21
+ # noop
22
+ end
23
+ begin
24
+ Merge::Accounting::Project.validate_raw(obj: struct)
25
+ return Merge::Accounting::Project.from_json(json_object: struct) unless struct.nil?
26
+
27
+ return nil
28
+ rescue StandardError
29
+ # noop
30
+ end
31
+ struct
32
+ end
33
+
34
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
35
+ # hash and check each fields type against the current object's property
36
+ # definitions.
37
+ #
38
+ # @param obj [Object]
39
+ # @return [Void]
40
+ def self.validate_raw(obj:)
41
+ begin
42
+ return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.")
43
+ rescue StandardError
44
+ # noop
45
+ end
46
+ begin
47
+ return Merge::Accounting::Project.validate_raw(obj: obj)
48
+ rescue StandardError
49
+ # noop
50
+ end
51
+ raise("Passed value matched no type within the union, validation failed.")
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "project"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module Merge
8
+ module Accounting
9
+ class PaginatedProjectList
10
+ # @return [String]
11
+ attr_reader :next_
12
+ # @return [String]
13
+ attr_reader :previous
14
+ # @return [Array<Merge::Accounting::Project>]
15
+ attr_reader :results
16
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
17
+ attr_reader :additional_properties
18
+ # @return [Object]
19
+ attr_reader :_field_set
20
+ protected :_field_set
21
+
22
+ OMIT = Object.new
23
+
24
+ # @param next_ [String]
25
+ # @param previous [String]
26
+ # @param results [Array<Merge::Accounting::Project>]
27
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
28
+ # @return [Merge::Accounting::PaginatedProjectList]
29
+ def initialize(next_: OMIT, previous: OMIT, results: OMIT, additional_properties: nil)
30
+ @next_ = next_ if next_ != OMIT
31
+ @previous = previous if previous != OMIT
32
+ @results = results if results != OMIT
33
+ @additional_properties = additional_properties
34
+ @_field_set = { "next": next_, "previous": previous, "results": results }.reject do |_k, v|
35
+ v == OMIT
36
+ end
37
+ end
38
+
39
+ # Deserialize a JSON object to an instance of PaginatedProjectList
40
+ #
41
+ # @param json_object [String]
42
+ # @return [Merge::Accounting::PaginatedProjectList]
43
+ def self.from_json(json_object:)
44
+ struct = JSON.parse(json_object, object_class: OpenStruct)
45
+ parsed_json = JSON.parse(json_object)
46
+ next_ = parsed_json["next"]
47
+ previous = parsed_json["previous"]
48
+ results = parsed_json["results"]&.map do |item|
49
+ item = item.to_json
50
+ Merge::Accounting::Project.from_json(json_object: item)
51
+ end
52
+ new(
53
+ next_: next_,
54
+ previous: previous,
55
+ results: results,
56
+ additional_properties: struct
57
+ )
58
+ end
59
+
60
+ # Serialize an instance of PaginatedProjectList to a JSON object
61
+ #
62
+ # @return [String]
63
+ def to_json(*_args)
64
+ @_field_set&.to_json
65
+ end
66
+
67
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
68
+ # hash and check each fields type against the current object's property
69
+ # definitions.
70
+ #
71
+ # @param obj [Object]
72
+ # @return [Void]
73
+ def self.validate_raw(obj:)
74
+ obj.next_&.is_a?(String) != false || raise("Passed value for field obj.next_ is not the expected type, validation failed.")
75
+ obj.previous&.is_a?(String) != false || raise("Passed value for field obj.previous is not the expected type, validation failed.")
76
+ obj.results&.is_a?(Array) != false || raise("Passed value for field obj.results is not the expected type, validation failed.")
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,172 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "status_7_d_1_enum"
4
+ require_relative "type_2_bb_enum"
5
+ require "ostruct"
6
+ require "json"
7
+
8
+ module Merge
9
+ module Accounting
10
+ # # The Item Object
11
+ # ### Description
12
+ # The `Item` object refers to the goods involved in a transaction.
13
+ # ### Usage Example
14
+ # Fetch from the `LIST Items` endpoint and view a company's items.
15
+ class PatchedItemRequestRequest
16
+ # @return [String] The item's name.
17
+ attr_reader :name
18
+ # @return [Merge::Accounting::Status7D1Enum] The item's status.
19
+ # * `ACTIVE` - ACTIVE
20
+ # * `ARCHIVED` - ARCHIVED
21
+ attr_reader :status
22
+ # @return [Merge::Accounting::Type2BbEnum] The item's type.
23
+ # * `INVENTORY` - INVENTORY
24
+ # * `NON_INVENTORY` - NON_INVENTORY
25
+ # * `SERVICE` - SERVICE
26
+ # * `UNKNOWN` - UNKNOWN
27
+ attr_reader :type
28
+ # @return [Float] The item's unit price.
29
+ attr_reader :unit_price
30
+ # @return [Float] The price at which the item is purchased from a vendor.
31
+ attr_reader :purchase_price
32
+ # @return [String] References the default account used to record a purchase of the item.
33
+ attr_reader :purchase_account
34
+ # @return [String] References the default account used to record a sale.
35
+ attr_reader :sales_account
36
+ # @return [String] The company the item belongs to.
37
+ attr_reader :company
38
+ # @return [String] The default purchase tax rate for this item.
39
+ attr_reader :purchase_tax_rate
40
+ # @return [String] The default sales tax rate for this item.
41
+ attr_reader :sales_tax_rate
42
+ # @return [Hash{String => Object}]
43
+ attr_reader :integration_params
44
+ # @return [Hash{String => Object}]
45
+ attr_reader :linked_account_params
46
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
47
+ attr_reader :additional_properties
48
+ # @return [Object]
49
+ attr_reader :_field_set
50
+ protected :_field_set
51
+
52
+ OMIT = Object.new
53
+
54
+ # @param name [String] The item's name.
55
+ # @param status [Merge::Accounting::Status7D1Enum] The item's status.
56
+ # * `ACTIVE` - ACTIVE
57
+ # * `ARCHIVED` - ARCHIVED
58
+ # @param type [Merge::Accounting::Type2BbEnum] The item's type.
59
+ # * `INVENTORY` - INVENTORY
60
+ # * `NON_INVENTORY` - NON_INVENTORY
61
+ # * `SERVICE` - SERVICE
62
+ # * `UNKNOWN` - UNKNOWN
63
+ # @param unit_price [Float] The item's unit price.
64
+ # @param purchase_price [Float] The price at which the item is purchased from a vendor.
65
+ # @param purchase_account [String] References the default account used to record a purchase of the item.
66
+ # @param sales_account [String] References the default account used to record a sale.
67
+ # @param company [String] The company the item belongs to.
68
+ # @param purchase_tax_rate [String] The default purchase tax rate for this item.
69
+ # @param sales_tax_rate [String] The default sales tax rate for this item.
70
+ # @param integration_params [Hash{String => Object}]
71
+ # @param linked_account_params [Hash{String => Object}]
72
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
73
+ # @return [Merge::Accounting::PatchedItemRequestRequest]
74
+ def initialize(name: OMIT, status: OMIT, type: OMIT, unit_price: OMIT, purchase_price: OMIT,
75
+ purchase_account: OMIT, sales_account: OMIT, company: OMIT, purchase_tax_rate: OMIT, sales_tax_rate: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil)
76
+ @name = name if name != OMIT
77
+ @status = status if status != OMIT
78
+ @type = type if type != OMIT
79
+ @unit_price = unit_price if unit_price != OMIT
80
+ @purchase_price = purchase_price if purchase_price != OMIT
81
+ @purchase_account = purchase_account if purchase_account != OMIT
82
+ @sales_account = sales_account if sales_account != OMIT
83
+ @company = company if company != OMIT
84
+ @purchase_tax_rate = purchase_tax_rate if purchase_tax_rate != OMIT
85
+ @sales_tax_rate = sales_tax_rate if sales_tax_rate != OMIT
86
+ @integration_params = integration_params if integration_params != OMIT
87
+ @linked_account_params = linked_account_params if linked_account_params != OMIT
88
+ @additional_properties = additional_properties
89
+ @_field_set = {
90
+ "name": name,
91
+ "status": status,
92
+ "type": type,
93
+ "unit_price": unit_price,
94
+ "purchase_price": purchase_price,
95
+ "purchase_account": purchase_account,
96
+ "sales_account": sales_account,
97
+ "company": company,
98
+ "purchase_tax_rate": purchase_tax_rate,
99
+ "sales_tax_rate": sales_tax_rate,
100
+ "integration_params": integration_params,
101
+ "linked_account_params": linked_account_params
102
+ }.reject do |_k, v|
103
+ v == OMIT
104
+ end
105
+ end
106
+
107
+ # Deserialize a JSON object to an instance of PatchedItemRequestRequest
108
+ #
109
+ # @param json_object [String]
110
+ # @return [Merge::Accounting::PatchedItemRequestRequest]
111
+ def self.from_json(json_object:)
112
+ struct = JSON.parse(json_object, object_class: OpenStruct)
113
+ parsed_json = JSON.parse(json_object)
114
+ name = parsed_json["name"]
115
+ status = parsed_json["status"]
116
+ type = parsed_json["type"]
117
+ unit_price = parsed_json["unit_price"]
118
+ purchase_price = parsed_json["purchase_price"]
119
+ purchase_account = parsed_json["purchase_account"]
120
+ sales_account = parsed_json["sales_account"]
121
+ company = parsed_json["company"]
122
+ purchase_tax_rate = parsed_json["purchase_tax_rate"]
123
+ sales_tax_rate = parsed_json["sales_tax_rate"]
124
+ integration_params = parsed_json["integration_params"]
125
+ linked_account_params = parsed_json["linked_account_params"]
126
+ new(
127
+ name: name,
128
+ status: status,
129
+ type: type,
130
+ unit_price: unit_price,
131
+ purchase_price: purchase_price,
132
+ purchase_account: purchase_account,
133
+ sales_account: sales_account,
134
+ company: company,
135
+ purchase_tax_rate: purchase_tax_rate,
136
+ sales_tax_rate: sales_tax_rate,
137
+ integration_params: integration_params,
138
+ linked_account_params: linked_account_params,
139
+ additional_properties: struct
140
+ )
141
+ end
142
+
143
+ # Serialize an instance of PatchedItemRequestRequest to a JSON object
144
+ #
145
+ # @return [String]
146
+ def to_json(*_args)
147
+ @_field_set&.to_json
148
+ end
149
+
150
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
151
+ # hash and check each fields type against the current object's property
152
+ # definitions.
153
+ #
154
+ # @param obj [Object]
155
+ # @return [Void]
156
+ def self.validate_raw(obj:)
157
+ obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
158
+ obj.status&.is_a?(Merge::Accounting::Status7D1Enum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
159
+ obj.type&.is_a?(Merge::Accounting::Type2BbEnum) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
160
+ obj.unit_price&.is_a?(Float) != false || raise("Passed value for field obj.unit_price is not the expected type, validation failed.")
161
+ obj.purchase_price&.is_a?(Float) != false || raise("Passed value for field obj.purchase_price is not the expected type, validation failed.")
162
+ obj.purchase_account&.is_a?(String) != false || raise("Passed value for field obj.purchase_account is not the expected type, validation failed.")
163
+ obj.sales_account&.is_a?(String) != false || raise("Passed value for field obj.sales_account is not the expected type, validation failed.")
164
+ obj.company&.is_a?(String) != false || raise("Passed value for field obj.company is not the expected type, validation failed.")
165
+ obj.purchase_tax_rate&.is_a?(String) != false || raise("Passed value for field obj.purchase_tax_rate is not the expected type, validation failed.")
166
+ obj.sales_tax_rate&.is_a?(String) != false || raise("Passed value for field obj.sales_tax_rate is not the expected type, validation failed.")
167
+ obj.integration_params&.is_a?(Hash) != false || raise("Passed value for field obj.integration_params is not the expected type, validation failed.")
168
+ obj.linked_account_params&.is_a?(Hash) != false || raise("Passed value for field obj.linked_account_params is not the expected type, validation failed.")
169
+ end
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,162 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ require_relative "project_company"
5
+ require_relative "project_contact"
6
+ require_relative "remote_data"
7
+ require "ostruct"
8
+ require "json"
9
+
10
+ module Merge
11
+ module Accounting
12
+ # # The Project Object
13
+ # ### Description
14
+ # The `Project` object is used to track and manage time, costs, resources, and
15
+ # revenue for specific initiatives or work efforts.
16
+ # It provides classification on transactions for allocating expenses, revenue, and
17
+ # activities to a specific project for financial reporting.
18
+ # ### Usage Example
19
+ # Fetch from the `GET Project` endpoint and view project information.
20
+ class Project
21
+ # @return [String]
22
+ attr_reader :id
23
+ # @return [String] The third-party API ID of the matching object.
24
+ attr_reader :remote_id
25
+ # @return [DateTime] The datetime that this object was created by Merge.
26
+ attr_reader :created_at
27
+ # @return [DateTime] The datetime that this object was modified by Merge.
28
+ attr_reader :modified_at
29
+ # @return [String] The project’s name
30
+ attr_reader :name
31
+ # @return [Boolean] `True` if the project is active, `False` if the project is not active.
32
+ attr_reader :is_active
33
+ # @return [Merge::Accounting::ProjectCompany] The subsidiary that the project belongs to.
34
+ attr_reader :company
35
+ # @return [Merge::Accounting::ProjectContact] The supplier, or customer involved in the project.
36
+ attr_reader :contact
37
+ # @return [Hash{String => Object}]
38
+ attr_reader :field_mappings
39
+ # @return [Array<Merge::Accounting::RemoteData>]
40
+ attr_reader :remote_data
41
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
42
+ attr_reader :additional_properties
43
+ # @return [Object]
44
+ attr_reader :_field_set
45
+ protected :_field_set
46
+
47
+ OMIT = Object.new
48
+
49
+ # @param id [String]
50
+ # @param remote_id [String] The third-party API ID of the matching object.
51
+ # @param created_at [DateTime] The datetime that this object was created by Merge.
52
+ # @param modified_at [DateTime] The datetime that this object was modified by Merge.
53
+ # @param name [String] The project’s name
54
+ # @param is_active [Boolean] `True` if the project is active, `False` if the project is not active.
55
+ # @param company [Merge::Accounting::ProjectCompany] The subsidiary that the project belongs to.
56
+ # @param contact [Merge::Accounting::ProjectContact] The supplier, or customer involved in the project.
57
+ # @param field_mappings [Hash{String => Object}]
58
+ # @param remote_data [Array<Merge::Accounting::RemoteData>]
59
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
60
+ # @return [Merge::Accounting::Project]
61
+ def initialize(name:, id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, is_active: OMIT,
62
+ company: OMIT, contact: OMIT, field_mappings: OMIT, remote_data: OMIT, additional_properties: nil)
63
+ @id = id if id != OMIT
64
+ @remote_id = remote_id if remote_id != OMIT
65
+ @created_at = created_at if created_at != OMIT
66
+ @modified_at = modified_at if modified_at != OMIT
67
+ @name = name
68
+ @is_active = is_active if is_active != OMIT
69
+ @company = company if company != OMIT
70
+ @contact = contact if contact != OMIT
71
+ @field_mappings = field_mappings if field_mappings != OMIT
72
+ @remote_data = remote_data if remote_data != OMIT
73
+ @additional_properties = additional_properties
74
+ @_field_set = {
75
+ "id": id,
76
+ "remote_id": remote_id,
77
+ "created_at": created_at,
78
+ "modified_at": modified_at,
79
+ "name": name,
80
+ "is_active": is_active,
81
+ "company": company,
82
+ "contact": contact,
83
+ "field_mappings": field_mappings,
84
+ "remote_data": remote_data
85
+ }.reject do |_k, v|
86
+ v == OMIT
87
+ end
88
+ end
89
+
90
+ # Deserialize a JSON object to an instance of Project
91
+ #
92
+ # @param json_object [String]
93
+ # @return [Merge::Accounting::Project]
94
+ def self.from_json(json_object:)
95
+ struct = JSON.parse(json_object, object_class: OpenStruct)
96
+ parsed_json = JSON.parse(json_object)
97
+ id = parsed_json["id"]
98
+ remote_id = parsed_json["remote_id"]
99
+ created_at = (DateTime.parse(parsed_json["created_at"]) unless parsed_json["created_at"].nil?)
100
+ modified_at = (DateTime.parse(parsed_json["modified_at"]) unless parsed_json["modified_at"].nil?)
101
+ name = parsed_json["name"]
102
+ is_active = parsed_json["is_active"]
103
+ if parsed_json["company"].nil?
104
+ company = nil
105
+ else
106
+ company = parsed_json["company"].to_json
107
+ company = Merge::Accounting::ProjectCompany.from_json(json_object: company)
108
+ end
109
+ if parsed_json["contact"].nil?
110
+ contact = nil
111
+ else
112
+ contact = parsed_json["contact"].to_json
113
+ contact = Merge::Accounting::ProjectContact.from_json(json_object: contact)
114
+ end
115
+ field_mappings = parsed_json["field_mappings"]
116
+ remote_data = parsed_json["remote_data"]&.map do |item|
117
+ item = item.to_json
118
+ Merge::Accounting::RemoteData.from_json(json_object: item)
119
+ end
120
+ new(
121
+ id: id,
122
+ remote_id: remote_id,
123
+ created_at: created_at,
124
+ modified_at: modified_at,
125
+ name: name,
126
+ is_active: is_active,
127
+ company: company,
128
+ contact: contact,
129
+ field_mappings: field_mappings,
130
+ remote_data: remote_data,
131
+ additional_properties: struct
132
+ )
133
+ end
134
+
135
+ # Serialize an instance of Project to a JSON object
136
+ #
137
+ # @return [String]
138
+ def to_json(*_args)
139
+ @_field_set&.to_json
140
+ end
141
+
142
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
143
+ # hash and check each fields type against the current object's property
144
+ # definitions.
145
+ #
146
+ # @param obj [Object]
147
+ # @return [Void]
148
+ def self.validate_raw(obj:)
149
+ obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
150
+ obj.remote_id&.is_a?(String) != false || raise("Passed value for field obj.remote_id is not the expected type, validation failed.")
151
+ obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.")
152
+ obj.modified_at&.is_a?(DateTime) != false || raise("Passed value for field obj.modified_at is not the expected type, validation failed.")
153
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
154
+ obj.is_active&.is_a?(Boolean) != false || raise("Passed value for field obj.is_active is not the expected type, validation failed.")
155
+ obj.company.nil? || Merge::Accounting::ProjectCompany.validate_raw(obj: obj.company)
156
+ obj.contact.nil? || Merge::Accounting::ProjectContact.validate_raw(obj: obj.contact)
157
+ obj.field_mappings&.is_a?(Hash) != false || raise("Passed value for field obj.field_mappings is not the expected type, validation failed.")
158
+ obj.remote_data&.is_a?(Array) != false || raise("Passed value for field obj.remote_data is not the expected type, validation failed.")
159
+ end
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "company_info"
5
+
6
+ module Merge
7
+ module Accounting
8
+ # The subsidiary that the project belongs to.
9
+ class ProjectCompany
10
+ # Deserialize a JSON object to an instance of ProjectCompany
11
+ #
12
+ # @param json_object [String]
13
+ # @return [Merge::Accounting::ProjectCompany]
14
+ def self.from_json(json_object:)
15
+ struct = JSON.parse(json_object, object_class: OpenStruct)
16
+ begin
17
+ struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.")
18
+ return struct unless struct.nil?
19
+
20
+ return nil
21
+ rescue StandardError
22
+ # noop
23
+ end
24
+ begin
25
+ Merge::Accounting::CompanyInfo.validate_raw(obj: struct)
26
+ return Merge::Accounting::CompanyInfo.from_json(json_object: struct) unless struct.nil?
27
+
28
+ return nil
29
+ rescue StandardError
30
+ # noop
31
+ end
32
+ struct
33
+ end
34
+
35
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
36
+ # hash and check each fields type against the current object's property
37
+ # definitions.
38
+ #
39
+ # @param obj [Object]
40
+ # @return [Void]
41
+ def self.validate_raw(obj:)
42
+ begin
43
+ return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.")
44
+ rescue StandardError
45
+ # noop
46
+ end
47
+ begin
48
+ return Merge::Accounting::CompanyInfo.validate_raw(obj: obj)
49
+ rescue StandardError
50
+ # noop
51
+ end
52
+ raise("Passed value matched no type within the union, validation failed.")
53
+ end
54
+ end
55
+ end
56
+ end