xero-ruby 1.1.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +181 -72
  3. data/build_notes.md +43 -0
  4. data/docs/accounting/AccountingApi.md +1503 -779
  5. data/docs/accounting/Allocation.md +11 -1
  6. data/docs/accounting/Attachment.md +1 -1
  7. data/docs/accounting/BankTransfer.md +1 -1
  8. data/docs/accounting/BatchPayment.md +1 -1
  9. data/docs/accounting/Contact.md +2 -2
  10. data/docs/accounting/CreditNote.md +2 -2
  11. data/docs/accounting/Invoice.md +2 -2
  12. data/docs/accounting/ManualJournalLine.md +2 -0
  13. data/docs/accounting/Organisation.md +3 -1
  14. data/docs/accounting/Payment.md +4 -4
  15. data/docs/accounting/Quote.md +5 -1
  16. data/docs/accounting/Report.md +1 -1
  17. data/docs/accounting/{TenNinteyNineContact.md → TenNinetyNineContact.md} +2 -2
  18. data/docs/assets/AssetApi.md +40 -16
  19. data/docs/assets/AssetType.md +1 -1
  20. data/docs/projects/Amount.md +19 -0
  21. data/docs/projects/ChargeType.md +16 -0
  22. data/docs/projects/CurrencyCode.md +16 -0
  23. data/docs/projects/Error.md +19 -0
  24. data/docs/projects/Pagination.md +23 -0
  25. data/docs/projects/Project.md +59 -0
  26. data/docs/projects/ProjectApi.md +979 -0
  27. data/docs/projects/ProjectCreateOrUpdate.md +23 -0
  28. data/docs/projects/ProjectPatch.md +17 -0
  29. data/docs/projects/ProjectStatus.md +16 -0
  30. data/docs/projects/ProjectUser.md +21 -0
  31. data/docs/projects/ProjectUsers.md +19 -0
  32. data/docs/projects/Projects.md +19 -0
  33. data/docs/projects/Task.md +45 -0
  34. data/docs/projects/TaskCreateOrUpdate.md +23 -0
  35. data/docs/projects/Tasks.md +19 -0
  36. data/docs/projects/TimeEntries.md +19 -0
  37. data/docs/projects/TimeEntry.md +33 -0
  38. data/docs/projects/TimeEntryCreateOrUpdate.md +25 -0
  39. data/lib/xero-ruby.rb +22 -3
  40. data/lib/xero-ruby/api/accounting_api.rb +1368 -72
  41. data/lib/xero-ruby/api/asset_api.rb +39 -3
  42. data/lib/xero-ruby/api/project_api.rb +1113 -0
  43. data/lib/xero-ruby/api_client.rb +104 -38
  44. data/lib/xero-ruby/api_error.rb +2 -2
  45. data/lib/xero-ruby/configuration.rb +4 -5
  46. data/lib/xero-ruby/models/accounting/account.rb +61 -20
  47. data/lib/xero-ruby/models/accounting/account_type.rb +2 -2
  48. data/lib/xero-ruby/models/accounting/accounts.rb +8 -3
  49. data/lib/xero-ruby/models/accounting/accounts_payable.rb +11 -5
  50. data/lib/xero-ruby/models/accounting/accounts_receivable.rb +11 -5
  51. data/lib/xero-ruby/models/accounting/address.rb +19 -12
  52. data/lib/xero-ruby/models/accounting/allocation.rb +66 -9
  53. data/lib/xero-ruby/models/accounting/allocations.rb +8 -3
  54. data/lib/xero-ruby/models/accounting/attachment.rb +13 -9
  55. data/lib/xero-ruby/models/accounting/attachments.rb +8 -3
  56. data/lib/xero-ruby/models/accounting/balances.rb +9 -3
  57. data/lib/xero-ruby/models/accounting/bank_transaction.rb +43 -24
  58. data/lib/xero-ruby/models/accounting/bank_transactions.rb +8 -3
  59. data/lib/xero-ruby/models/accounting/bank_transfer.rb +20 -14
  60. data/lib/xero-ruby/models/accounting/bank_transfers.rb +8 -3
  61. data/lib/xero-ruby/models/accounting/batch_payment.rb +29 -19
  62. data/lib/xero-ruby/models/accounting/batch_payment_details.rb +11 -7
  63. data/lib/xero-ruby/models/accounting/batch_payments.rb +8 -3
  64. data/lib/xero-ruby/models/accounting/bill.rb +8 -3
  65. data/lib/xero-ruby/models/accounting/branding_theme.rb +13 -8
  66. data/lib/xero-ruby/models/accounting/branding_themes.rb +8 -3
  67. data/lib/xero-ruby/models/accounting/cis_org_setting.rb +9 -5
  68. data/lib/xero-ruby/models/accounting/cis_setting.rb +8 -4
  69. data/lib/xero-ruby/models/accounting/cis_settings.rb +8 -3
  70. data/lib/xero-ruby/models/accounting/contact.rb +51 -37
  71. data/lib/xero-ruby/models/accounting/contact_group.rb +12 -6
  72. data/lib/xero-ruby/models/accounting/contact_groups.rb +8 -3
  73. data/lib/xero-ruby/models/accounting/contact_person.rb +10 -6
  74. data/lib/xero-ruby/models/accounting/contacts.rb +8 -3
  75. data/lib/xero-ruby/models/accounting/country_code.rb +2 -2
  76. data/lib/xero-ruby/models/accounting/credit_note.rb +47 -30
  77. data/lib/xero-ruby/models/accounting/credit_notes.rb +8 -3
  78. data/lib/xero-ruby/models/accounting/currencies.rb +8 -3
  79. data/lib/xero-ruby/models/accounting/currency.rb +9 -4
  80. data/lib/xero-ruby/models/accounting/currency_code.rb +2 -2
  81. data/lib/xero-ruby/models/accounting/element.rb +14 -4
  82. data/lib/xero-ruby/models/accounting/employee.rb +17 -8
  83. data/lib/xero-ruby/models/accounting/employees.rb +8 -3
  84. data/lib/xero-ruby/models/accounting/error.rb +10 -6
  85. data/lib/xero-ruby/models/accounting/expense_claim.rb +26 -15
  86. data/lib/xero-ruby/models/accounting/expense_claims.rb +8 -3
  87. data/lib/xero-ruby/models/accounting/external_link.rb +14 -4
  88. data/lib/xero-ruby/models/accounting/history_record.rb +10 -6
  89. data/lib/xero-ruby/models/accounting/history_records.rb +8 -3
  90. data/lib/xero-ruby/models/accounting/invoice.rb +69 -46
  91. data/lib/xero-ruby/models/accounting/invoice_reminder.rb +7 -3
  92. data/lib/xero-ruby/models/accounting/invoice_reminders.rb +8 -3
  93. data/lib/xero-ruby/models/accounting/invoices.rb +8 -3
  94. data/lib/xero-ruby/models/accounting/item.rb +24 -18
  95. data/lib/xero-ruby/models/accounting/items.rb +8 -3
  96. data/lib/xero-ruby/models/accounting/journal.rb +39 -10
  97. data/lib/xero-ruby/models/accounting/journal_line.rb +21 -16
  98. data/lib/xero-ruby/models/accounting/journals.rb +8 -3
  99. data/lib/xero-ruby/models/accounting/line_amount_types.rb +2 -2
  100. data/lib/xero-ruby/models/accounting/line_item.rb +25 -21
  101. data/lib/xero-ruby/models/accounting/line_item_tracking.rb +10 -6
  102. data/lib/xero-ruby/models/accounting/linked_transaction.rb +25 -13
  103. data/lib/xero-ruby/models/accounting/linked_transactions.rb +8 -3
  104. data/lib/xero-ruby/models/accounting/manual_journal.rb +25 -15
  105. data/lib/xero-ruby/models/accounting/manual_journal_line.rb +26 -12
  106. data/lib/xero-ruby/models/accounting/manual_journals.rb +8 -3
  107. data/lib/xero-ruby/models/accounting/online_invoice.rb +7 -3
  108. data/lib/xero-ruby/models/accounting/online_invoices.rb +8 -3
  109. data/lib/xero-ruby/models/accounting/organisation.rb +122 -32
  110. data/lib/xero-ruby/models/accounting/organisations.rb +8 -3
  111. data/lib/xero-ruby/models/accounting/overpayment.rb +36 -23
  112. data/lib/xero-ruby/models/accounting/overpayments.rb +8 -3
  113. data/lib/xero-ruby/models/accounting/payment.rb +47 -24
  114. data/lib/xero-ruby/models/accounting/payment_delete.rb +7 -3
  115. data/lib/xero-ruby/models/accounting/payment_service.rb +12 -8
  116. data/lib/xero-ruby/models/accounting/payment_services.rb +8 -3
  117. data/lib/xero-ruby/models/accounting/payment_term.rb +9 -3
  118. data/lib/xero-ruby/models/accounting/payment_term_type.rb +2 -2
  119. data/lib/xero-ruby/models/accounting/payments.rb +8 -3
  120. data/lib/xero-ruby/models/accounting/phone.rb +16 -6
  121. data/lib/xero-ruby/models/accounting/prepayment.rb +37 -23
  122. data/lib/xero-ruby/models/accounting/prepayments.rb +8 -3
  123. data/lib/xero-ruby/models/accounting/purchase.rb +11 -7
  124. data/lib/xero-ruby/models/accounting/purchase_order.rb +45 -33
  125. data/lib/xero-ruby/models/accounting/purchase_orders.rb +8 -3
  126. data/lib/xero-ruby/models/accounting/quote.rb +58 -28
  127. data/lib/xero-ruby/models/accounting/quote_line_amount_types.rb +2 -2
  128. data/lib/xero-ruby/models/accounting/quote_status_codes.rb +3 -2
  129. data/lib/xero-ruby/models/accounting/quotes.rb +8 -3
  130. data/lib/xero-ruby/models/accounting/receipt.rb +32 -19
  131. data/lib/xero-ruby/models/accounting/receipts.rb +8 -3
  132. data/lib/xero-ruby/models/accounting/repeating_invoice.rb +30 -17
  133. data/lib/xero-ruby/models/accounting/repeating_invoices.rb +8 -3
  134. data/lib/xero-ruby/models/accounting/report.rb +15 -9
  135. data/lib/xero-ruby/models/accounting/report_attribute.rb +9 -3
  136. data/lib/xero-ruby/models/accounting/report_cell.rb +9 -3
  137. data/lib/xero-ruby/models/accounting/report_fields.rb +10 -3
  138. data/lib/xero-ruby/models/accounting/report_row.rb +10 -3
  139. data/lib/xero-ruby/models/accounting/report_rows.rb +11 -3
  140. data/lib/xero-ruby/models/accounting/report_with_row.rb +15 -9
  141. data/lib/xero-ruby/models/accounting/report_with_rows.rb +8 -3
  142. data/lib/xero-ruby/models/accounting/reports.rb +8 -3
  143. data/lib/xero-ruby/models/accounting/request_empty.rb +7 -3
  144. data/lib/xero-ruby/models/accounting/row_type.rb +2 -2
  145. data/lib/xero-ruby/models/accounting/sales_tracking_category.rb +8 -4
  146. data/lib/xero-ruby/models/accounting/schedule.rb +23 -11
  147. data/lib/xero-ruby/models/accounting/tax_component.rb +11 -7
  148. data/lib/xero-ruby/models/accounting/tax_rate.rb +100 -18
  149. data/lib/xero-ruby/models/accounting/tax_rates.rb +8 -3
  150. data/lib/xero-ruby/models/accounting/tax_type.rb +2 -2
  151. data/lib/xero-ruby/models/accounting/{ten_nintey_nine_contact.rb → ten_ninety_nine_contact.rb} +44 -40
  152. data/lib/xero-ruby/models/accounting/time_zone.rb +2 -2
  153. data/lib/xero-ruby/models/accounting/tracking_categories.rb +8 -3
  154. data/lib/xero-ruby/models/accounting/tracking_category.rb +15 -8
  155. data/lib/xero-ruby/models/accounting/tracking_option.rb +13 -6
  156. data/lib/xero-ruby/models/accounting/tracking_options.rb +8 -3
  157. data/lib/xero-ruby/models/accounting/user.rb +20 -9
  158. data/lib/xero-ruby/models/accounting/users.rb +8 -3
  159. data/lib/xero-ruby/models/accounting/validation_error.rb +7 -3
  160. data/lib/xero-ruby/models/assets/asset.rb +24 -17
  161. data/lib/xero-ruby/models/assets/asset_status.rb +2 -2
  162. data/lib/xero-ruby/models/assets/asset_status_query_param.rb +2 -2
  163. data/lib/xero-ruby/models/assets/asset_type.rb +13 -13
  164. data/lib/xero-ruby/models/assets/assets.rb +9 -3
  165. data/lib/xero-ruby/models/assets/book_depreciation_detail.rb +19 -15
  166. data/lib/xero-ruby/models/assets/book_depreciation_setting.rb +26 -11
  167. data/lib/xero-ruby/models/assets/error.rb +11 -7
  168. data/lib/xero-ruby/models/assets/field_validation_errors_element.rb +12 -8
  169. data/lib/xero-ruby/models/assets/pagination.rb +11 -3
  170. data/lib/xero-ruby/models/assets/resource_validation_errors_element.rb +11 -7
  171. data/lib/xero-ruby/models/assets/setting.rb +14 -10
  172. data/lib/xero-ruby/models/projects/amount.rb +218 -0
  173. data/lib/xero-ruby/models/projects/charge_type.rb +38 -0
  174. data/lib/xero-ruby/models/projects/currency_code.rb +199 -0
  175. data/lib/xero-ruby/models/projects/error.rb +218 -0
  176. data/lib/xero-ruby/models/projects/pagination.rb +238 -0
  177. data/lib/xero-ruby/models/projects/project.rb +423 -0
  178. data/lib/xero-ruby/models/projects/project_create_or_update.rb +243 -0
  179. data/lib/xero-ruby/models/projects/project_patch.rb +213 -0
  180. data/lib/xero-ruby/models/projects/project_status.rb +37 -0
  181. data/lib/xero-ruby/models/projects/project_user.rb +228 -0
  182. data/lib/xero-ruby/models/projects/project_users.rb +220 -0
  183. data/lib/xero-ruby/models/projects/projects.rb +220 -0
  184. data/lib/xero-ruby/models/projects/task.rb +385 -0
  185. data/lib/xero-ruby/models/projects/task_create_or_update.rb +253 -0
  186. data/lib/xero-ruby/models/projects/tasks.rb +220 -0
  187. data/lib/xero-ruby/models/projects/time_entries.rb +220 -0
  188. data/lib/xero-ruby/models/projects/time_entry.rb +324 -0
  189. data/lib/xero-ruby/models/projects/time_entry_create_or_update.rb +268 -0
  190. data/lib/xero-ruby/version.rb +3 -3
  191. data/spec/accounting/api/accounting_api_spec.rb +3 -3
  192. data/spec/accounting/models/ten_nintey_nine_contact_spec.rb +6 -6
  193. data/spec/api_client_spec.rb +125 -38
  194. data/spec/assets/api/asset_api_spec.rb +3 -3
  195. data/spec/configuration_spec.rb +7 -23
  196. data/spec/projects/api/project_api_spec.rb +229 -0
  197. data/spec/projects/models/amount_spec.rb +47 -0
  198. data/spec/projects/models/charge_type_spec.rb +35 -0
  199. data/spec/projects/models/currency_code_spec.rb +35 -0
  200. data/spec/projects/models/error_spec.rb +47 -0
  201. data/spec/projects/models/pagination_spec.rb +59 -0
  202. data/spec/projects/models/project_create_or_update_spec.rb +59 -0
  203. data/spec/projects/models/project_patch_spec.rb +41 -0
  204. data/spec/projects/models/project_spec.rb +167 -0
  205. data/spec/projects/models/project_status_spec.rb +35 -0
  206. data/spec/projects/models/project_user_spec.rb +53 -0
  207. data/spec/projects/models/project_users_spec.rb +47 -0
  208. data/spec/projects/models/projects_spec.rb +47 -0
  209. data/spec/projects/models/task_create_or_update_spec.rb +59 -0
  210. data/spec/projects/models/task_spec.rb +129 -0
  211. data/spec/projects/models/tasks_spec.rb +47 -0
  212. data/spec/projects/models/time_entries_spec.rb +47 -0
  213. data/spec/projects/models/time_entry_create_or_update_spec.rb +65 -0
  214. data/spec/projects/models/time_entry_spec.rb +93 -0
  215. data/xero-ruby.gemspec +3 -4
  216. metadata +85 -10
  217. data/xero-ruby-1.0.gem +0 -0
  218. data/xero-ruby.gem +0 -0
@@ -0,0 +1,268 @@
1
+ =begin
2
+ #Xero Projects API
3
+
4
+ #This is the Xero Projects API
5
+
6
+ The version of the OpenAPI document: 2.2.12
7
+ Contact: api@xero.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'time'
14
+ require 'date'
15
+
16
+ module XeroRuby::Projects
17
+ require 'bigdecimal'
18
+
19
+ class TimeEntryCreateOrUpdate
20
+ # The xero user identifier of the person logging the time.
21
+ attr_accessor :user_id
22
+
23
+ # Identifier of the task that time entry is logged against.
24
+ attr_accessor :task_id
25
+
26
+ # Date time entry is logged on. UTC Date Time in ISO-8601 format.
27
+ attr_accessor :date_utc
28
+
29
+ # Number of minutes to be logged. Duration is between 1 and 59940 inclusively.
30
+ attr_accessor :duration
31
+
32
+ # An optional description of the time entry, will be set to null if not provided during update.
33
+ attr_accessor :description
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'user_id' => :'userId',
39
+ :'task_id' => :'taskId',
40
+ :'date_utc' => :'dateUtc',
41
+ :'duration' => :'duration',
42
+ :'description' => :'description'
43
+ }
44
+ end
45
+
46
+ # Attribute type mapping.
47
+ def self.openapi_types
48
+ {
49
+ :'user_id' => :'String',
50
+ :'task_id' => :'String',
51
+ :'date_utc' => :'DateTime',
52
+ :'duration' => :'Integer',
53
+ :'description' => :'String'
54
+ }
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Projects::TimeEntryCreateOrUpdate` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Projects::TimeEntryCreateOrUpdate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'user_id')
73
+ self.user_id = attributes[:'user_id']
74
+ end
75
+
76
+ if attributes.key?(:'task_id')
77
+ self.task_id = attributes[:'task_id']
78
+ end
79
+
80
+ if attributes.key?(:'date_utc')
81
+ self.date_utc = attributes[:'date_utc']
82
+ end
83
+
84
+ if attributes.key?(:'duration')
85
+ self.duration = attributes[:'duration']
86
+ end
87
+
88
+ if attributes.key?(:'description')
89
+ self.description = attributes[:'description']
90
+ end
91
+ end
92
+
93
+ # Show invalid properties with the reasons. Usually used together with valid?
94
+ # @return Array for valid properties with the reasons
95
+ def list_invalid_properties
96
+ invalid_properties = Array.new
97
+ if @user_id.nil?
98
+ invalid_properties.push('invalid value for "user_id", user_id cannot be nil.')
99
+ end
100
+
101
+ if @task_id.nil?
102
+ invalid_properties.push('invalid value for "task_id", task_id cannot be nil.')
103
+ end
104
+
105
+ if @date_utc.nil?
106
+ invalid_properties.push('invalid value for "date_utc", date_utc cannot be nil.')
107
+ end
108
+
109
+ if @duration.nil?
110
+ invalid_properties.push('invalid value for "duration", duration cannot be nil.')
111
+ end
112
+
113
+ invalid_properties
114
+ end
115
+
116
+ # Check to see if the all the properties in the model are valid
117
+ # @return true if the model is valid
118
+ def valid?
119
+ return false if @user_id.nil?
120
+ return false if @task_id.nil?
121
+ return false if @date_utc.nil?
122
+ return false if @duration.nil?
123
+ true
124
+ end
125
+
126
+ # Checks equality by comparing each attribute.
127
+ # @param [Object] Object to be compared
128
+ def ==(o)
129
+ return true if self.equal?(o)
130
+ self.class == o.class &&
131
+ user_id == o.user_id &&
132
+ task_id == o.task_id &&
133
+ date_utc == o.date_utc &&
134
+ duration == o.duration &&
135
+ description == o.description
136
+ end
137
+
138
+ # @see the `==` method
139
+ # @param [Object] Object to be compared
140
+ def eql?(o)
141
+ self == o
142
+ end
143
+
144
+ # Calculates hash code according to all attributes.
145
+ # @return [Integer] Hash code
146
+ def hash
147
+ [user_id, task_id, date_utc, duration, description].hash
148
+ end
149
+
150
+ # Builds the object from hash
151
+ # @param [Hash] attributes Model attributes in the form of hash
152
+ # @return [Object] Returns the model itself
153
+ def self.build_from_hash(attributes)
154
+ new.build_from_hash(attributes)
155
+ end
156
+
157
+ # Builds the object from hash
158
+ # @param [Hash] attributes Model attributes in the form of hash
159
+ # @return [Object] Returns the model itself
160
+ def build_from_hash(attributes)
161
+ return nil unless attributes.is_a?(Hash)
162
+ self.class.openapi_types.each_pair do |key, type|
163
+ if type =~ /\AArray<(.*)>/i
164
+ # check to ensure the input is an array given that the attribute
165
+ # is documented as an array but the input is not
166
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
167
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
168
+ end
169
+ elsif !attributes[self.class.attribute_map[key]].nil?
170
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
171
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
172
+ end
173
+
174
+ self
175
+ end
176
+
177
+ # Deserializes the data based on type
178
+ # @param string type Data type
179
+ # @param string value Value to be deserialized
180
+ # @return [Object] Deserialized data
181
+ def _deserialize(type, value)
182
+ case type.to_sym
183
+ when :DateTime
184
+ DateTime.parse(parse_date(value))
185
+ when :Date
186
+ Date.parse(parse_date(value))
187
+ when :String
188
+ value.to_s
189
+ when :Integer
190
+ value.to_i
191
+ when :Float
192
+ value.to_f
193
+ when :BigDecimal
194
+ BigDecimal(value.to_s)
195
+ when :Boolean
196
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
197
+ true
198
+ else
199
+ false
200
+ end
201
+ when :Object
202
+ # generic object (usually a Hash), return directly
203
+ value
204
+ when /\AArray<(?<inner_type>.+)>\z/
205
+ inner_type = Regexp.last_match[:inner_type]
206
+ value.map { |v| _deserialize(inner_type, v) }
207
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
208
+ k_type = Regexp.last_match[:k_type]
209
+ v_type = Regexp.last_match[:v_type]
210
+ {}.tap do |hash|
211
+ value.each do |k, v|
212
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
213
+ end
214
+ end
215
+ else # model
216
+ XeroRuby::Projects.const_get(type).build_from_hash(value)
217
+ end
218
+ end
219
+
220
+ # Returns the string representation of the object
221
+ # @return [String] String presentation of the object
222
+ def to_s
223
+ to_hash.to_s
224
+ end
225
+
226
+ # to_body is an alias to to_hash (backward compatibility)
227
+ # @return [Hash] Returns the object in the form of hash
228
+ def to_body
229
+ to_hash
230
+ end
231
+
232
+ # Returns the object in the form of hash
233
+ # @return [Hash] Returns the object in the form of hash
234
+ def to_hash
235
+ hash = {}
236
+ self.class.attribute_map.each_pair do |attr, param|
237
+ value = self.send(attr)
238
+ next if value.nil?
239
+ hash[param] = _to_hash(value)
240
+ end
241
+ hash
242
+ end
243
+
244
+ # Outputs non-array value in the form of hash
245
+ # For object, use to_hash. Otherwise, just return the value
246
+ # @param [Object] value Any valid value
247
+ # @return [Hash] Returns the value in the form of hash
248
+ def _to_hash(value)
249
+ if value.is_a?(Array)
250
+ value.compact.map { |v| _to_hash(v) }
251
+ elsif value.is_a?(Hash)
252
+ {}.tap do |hash|
253
+ value.each { |k, v| hash[k] = _to_hash(v) }
254
+ end
255
+ elsif value.respond_to? :to_hash
256
+ value.to_hash
257
+ else
258
+ value
259
+ end
260
+ end
261
+
262
+ # customized data_parser
263
+ def parse_date(datestring)
264
+ seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0
265
+ return Time.at(seconds_since_epoch).to_s
266
+ end
267
+ end
268
+ end
@@ -3,13 +3,13 @@
3
3
 
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
- The version of the OpenAPI document: 2.1.3
6
+ The version of the OpenAPI document: 2.2.12
7
7
  Contact: api@xero.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.0
9
+ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
13
13
  module XeroRuby
14
- VERSION = '1.1.0'
14
+ VERSION = '2.1.0'
15
15
  end
@@ -13,13 +13,13 @@ OpenAPI Generator version: 4.3.0
13
13
  require 'spec_helper'
14
14
  require 'json'
15
15
 
16
- # Unit tests for XeroRuby::Accounting::AccountingApi
16
+ # Unit tests for XeroRuby::AccountingApi
17
17
  # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
18
  # Please update as you see appropriate
19
19
  describe 'AccountingApi' do
20
20
  before do
21
21
  # run before each test
22
- @api_instance = XeroRuby::Accounting::AccountingApi.new
22
+ @api_instance = XeroRuby::AccountingApi.new
23
23
  end
24
24
 
25
25
  after do
@@ -28,7 +28,7 @@ describe 'AccountingApi' do
28
28
 
29
29
  describe 'test an instance of AccountingApi' do
30
30
  it 'should create an instance of AccountingApi' do
31
- expect(@api_instance).to be_instance_of(XeroRuby::Accounting::AccountingApi)
31
+ expect(@api_instance).to be_instance_of(XeroRuby::AccountingApi)
32
32
  end
33
33
  end
34
34
 
@@ -14,22 +14,22 @@ require 'spec_helper'
14
14
  require 'json'
15
15
  require 'date'
16
16
 
17
- # Unit tests for XeroRuby::Accounting::TenNinteyNineContact
17
+ # Unit tests for XeroRuby::Accounting::TenNinetyNineContact
18
18
  # Automatically generated by openapi-generator (https://openapi-generator.tech)
19
19
  # Please update as you see appropriate
20
- describe 'TenNinteyNineContact' do
20
+ describe 'TenNinetyNineContact' do
21
21
  before do
22
22
  # run before each test
23
- @instance = XeroRuby::Accounting::TenNinteyNineContact.new
23
+ @instance = XeroRuby::Accounting::TenNinetyNineContact.new
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
- describe 'test an instance of TenNinteyNineContact' do
31
- it 'should create an instance of TenNinteyNineContact' do
32
- expect(@instance).to be_instance_of(XeroRuby::Accounting::TenNinteyNineContact)
30
+ describe 'test an instance of TenNinetyNineContact' do
31
+ it 'should create an instance of TenNinetyNineContact' do
32
+ expect(@instance).to be_instance_of(XeroRuby::Accounting::TenNinetyNineContact)
33
33
  end
34
34
  end
35
35
  describe 'test attribute "box1"' do
@@ -10,42 +10,42 @@ OpenAPI Generator version: 4.3.0
10
10
 
11
11
  =end
12
12
 
13
- require 'spec_helper'
13
+ require './spec_helper'
14
14
 
15
- describe XeroRuby::Accounting::ApiClient do
15
+ describe XeroRuby::ApiClient do
16
16
  context 'initialization' do
17
17
  context 'URL stuff' do
18
18
  context 'host' do
19
19
  it 'removes http from host' do
20
- XeroRuby::Accounting.configure { |c| c.host = 'http://example.com' }
21
- expect(XeroRuby::Accounting::Configuration.default.host).to eq('example.com')
20
+ XeroRuby.configure { |c| c.host = 'http://example.com' }
21
+ expect(XeroRuby::Configuration.default.host).to eq('example.com')
22
22
  end
23
23
 
24
24
  it 'removes https from host' do
25
- XeroRuby::Accounting.configure { |c| c.host = 'https://wookiee.com' }
26
- expect(XeroRuby::Accounting::ApiClient.default.config.host).to eq('wookiee.com')
25
+ XeroRuby.configure { |c| c.host = 'https://wookiee.com' }
26
+ expect(XeroRuby::Configuration.default.host).to eq('wookiee.com')
27
27
  end
28
28
 
29
29
  it 'removes trailing path from host' do
30
- XeroRuby::Accounting.configure { |c| c.host = 'hobo.com/v4' }
31
- expect(XeroRuby::Accounting::Configuration.default.host).to eq('hobo.com')
30
+ XeroRuby.configure { |c| c.host = 'hobo.com/v4' }
31
+ expect(XeroRuby::Configuration.default.host).to eq('hobo.com')
32
32
  end
33
33
  end
34
34
 
35
35
  context 'base_path' do
36
36
  it "prepends a slash to base_path" do
37
- XeroRuby::Accounting.configure { |c| c.base_path = 'v4/dog' }
38
- expect(XeroRuby::Accounting::Configuration.default.base_path).to eq('/v4/dog')
37
+ XeroRuby.configure { |c| c.base_path = 'v4/dog' }
38
+ expect(XeroRuby::Configuration.default.base_path).to eq('/v4/dog')
39
39
  end
40
40
 
41
41
  it "doesn't prepend a slash if one is already there" do
42
- XeroRuby::Accounting.configure { |c| c.base_path = '/v4/dog' }
43
- expect(XeroRuby::Accounting::Configuration.default.base_path).to eq('/v4/dog')
42
+ XeroRuby.configure { |c| c.base_path = '/v4/dog' }
43
+ expect(XeroRuby::Configuration.default.base_path).to eq('/v4/dog')
44
44
  end
45
45
 
46
46
  it "ends up as a blank string if nil" do
47
- XeroRuby::Accounting.configure { |c| c.base_path = nil }
48
- expect(XeroRuby::Accounting::Configuration.default.base_path).to eq('')
47
+ XeroRuby.configure { |c| c.base_path = nil }
48
+ expect(XeroRuby::Configuration.default.base_path).to eq('')
49
49
  end
50
50
  end
51
51
  end
@@ -53,7 +53,7 @@ describe XeroRuby::Accounting::ApiClient do
53
53
 
54
54
  describe '#deserialize' do
55
55
  it "handles Array<Integer>" do
56
- api_client = XeroRuby::Accounting::ApiClient.new
56
+ api_client = XeroRuby::ApiClient.new
57
57
  headers = { 'Content-Type' => 'application/json' }
58
58
  response = double('response', headers: headers, body: '[12, 34]')
59
59
  data = api_client.deserialize(response, 'Array<Integer>')
@@ -62,7 +62,7 @@ describe XeroRuby::Accounting::ApiClient do
62
62
  end
63
63
 
64
64
  it 'handles Array<Array<Integer>>' do
65
- api_client = XeroRuby::Accounting::ApiClient.new
65
+ api_client = XeroRuby::ApiClient.new
66
66
  headers = { 'Content-Type' => 'application/json' }
67
67
  response = double('response', headers: headers, body: '[[12, 34], [56]]')
68
68
  data = api_client.deserialize(response, 'Array<Array<Integer>>')
@@ -71,7 +71,7 @@ describe XeroRuby::Accounting::ApiClient do
71
71
  end
72
72
 
73
73
  it 'handles Hash<String, String>' do
74
- api_client = XeroRuby::Accounting::ApiClient.new
74
+ api_client = XeroRuby::ApiClient.new
75
75
  headers = { 'Content-Type' => 'application/json' }
76
76
  response = double('response', headers: headers, body: '{"message": "Hello"}')
77
77
  data = api_client.deserialize(response, 'Hash<String, String>')
@@ -80,41 +80,128 @@ describe XeroRuby::Accounting::ApiClient do
80
80
  end
81
81
  end
82
82
 
83
- describe "#object_to_hash" do
84
- it 'ignores nils and includes empty arrays' do
85
- # uncomment below to test object_to_hash for model
86
- # api_client = XeroRuby::Accounting::ApiClient.new
87
- # _model = XeroRuby::Accounting::ModelName.new
88
- # update the model attribute below
89
- # _model.id = 1
90
- # update the expected value (hash) below
91
- # expected = {id: 1, name: '', tags: []}
92
- # expect(api_client.object_to_hash(_model)).to eq(expected)
83
+ describe "#object_to_hash modifies a hash from snake_case to PascalCase" do
84
+ contact_after = {:Contacts=>[{:Name=>"Bruce Banner", :EmailAddress=>"hulk@avengers.com", :Phones=>[{:PhoneType=>"MOBILE", :PhoneNumber=>"555-1212", :PhoneAreaCode=>"415"}], :PaymentTerms=>{:Bills=>{:Day=>15, :Type=>"OFCURRENTMONTH"}, :Sales=>{:Day=>10, :Type=>"DAYSAFTERBILLMONTH"}}}]}
85
+
86
+ it 'Serializes snake_case object correctly' do
87
+ contact_before = {:contacts=>[{:name=>"Bruce Banner", :email_address=>"hulk@avengers.com", :phones=>[{:phone_type=>"MOBILE", :phone_number=>"555-1212", :phone_area_code=>"415"}], :payment_terms=>{:bills=>{:day=>15, :type=>"OFCURRENTMONTH"}, :sales=>{:day=>10, :type=>"DAYSAFTERBILLMONTH"}}}]}
88
+ api_client = XeroRuby::ApiClient.new
89
+ expect(api_client.object_to_hash(contact_before)).to eq(contact_after)
90
+ end
91
+
92
+ it 'Serializes camelCase object correctly' do
93
+ json_before = {
94
+ type: "ACCREC",
95
+ invoiceNumber: "INV-01",
96
+ dueDate: "2020-01-01",
97
+ lineItems: [
98
+ { quantity: 1.0, unitAmount: 20 }
99
+ ]
100
+ }
101
+ json_after = {
102
+ Type: "ACCREC",
103
+ InvoiceNumber: "INV-01",
104
+ DueDate: "2020-01-01",
105
+ LineItems: [
106
+ { Quantity: 1.0, UnitAmount: 20 }
107
+ ]
108
+ }
109
+ api_client = XeroRuby::ApiClient.new
110
+ expect(api_client.object_to_hash(json_before)).to eq(json_after)
111
+ end
112
+
113
+ it 'Serializes json with multiple nested objects correctly' do
114
+ json_before = {
115
+ "line_Items":[
116
+ {
117
+ "quantity":1.0,
118
+ "unit_amount":20,
119
+ "sub_Items":[
120
+ {
121
+ "quantity":1.0,
122
+ "unit_amount":20
123
+ },
124
+ {
125
+ "quantity":1.0,
126
+ "Unit_amount":20,
127
+ "Deep_Items":[
128
+ {
129
+ "quantity":1.0,
130
+ "unit_amount":20
131
+ },
132
+ {
133
+ "quantity":1.0,
134
+ "unit_Amount":20
135
+ }
136
+ ]
137
+ }
138
+ ]
139
+ }
140
+ ]
141
+ }
142
+
143
+ json_after = {
144
+ "LineItems":[
145
+ {
146
+ "UnitAmount":20,
147
+ "Quantity":1.0,
148
+ "SubItems":[
149
+ {
150
+ "UnitAmount":20,
151
+ "Quantity":1.0
152
+ },
153
+ {
154
+ "UnitAmount":20,
155
+ "Quantity":1.0,
156
+ "DeepItems":[
157
+ {
158
+ "UnitAmount":20,
159
+ "Quantity":1.0
160
+ },
161
+ {
162
+ "UnitAmount":20,
163
+ "Quantity":1.0
164
+ }
165
+ ]
166
+ }
167
+ ]
168
+ }
169
+ ]
170
+ }
171
+ api_client = XeroRuby::ApiClient.new
172
+ expect(api_client.object_to_hash(json_before)).to eq(json_after)
173
+ end
174
+
175
+ it 'Serializes mixed cased keys correctly' do
176
+ contact_after = { :Contacts=>[{:Name=>"Bruce Banner", :EmailAddress=>"hulk@avengers.com", :Phones=>[{:PhoneType=>"MOBILE", :PhoneNumber=>"555-1212", :PhoneAreaCode=>"415"}], :PaymentTerms=>{:Bills=>{:Day=>15, :Type=>"OFCURRENTMONTH"}, :Sales=>{:Day=>10, :Type=>"DAYSAFTERBILLMONTH"}}}]}
177
+ contact_before = {:contacts=>[{:name=>"Bruce Banner", :emailAddress=>"hulk@avengers.com", :phones=>[{:phoneType=>"MOBILE", :phone_number=>"555-1212", :phone_areaCode=>"415"}], :Payment_terms=>{:bills=>{:day=>15, :type=>"OFCURRENTMONTH"}, :sales=>{:day=>10, :type=>"DAYSAFTERBILLMONTH"}}}]}
178
+ api_client = XeroRuby::ApiClient.new
179
+ expect(api_client.object_to_hash(contact_before)).to eq(contact_after)
93
180
  end
94
181
  end
95
182
 
96
183
  describe '#build_collection_param' do
97
- let(:param) { ['aa', 'bb', 'cc'] }
98
- let(:api_client) { XeroRuby::Accounting::ApiClient.new }
184
+ let(:param) { ['contact_ids', 'order', 'where'] }
185
+ let(:api_client) { XeroRuby::ApiClient.new }
99
186
 
100
187
  it 'works for csv' do
101
- expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
188
+ expect(api_client.build_collection_param(param, :csv)).to eq('contact_ids,order,where')
102
189
  end
103
190
 
104
191
  it 'works for ssv' do
105
- expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
192
+ expect(api_client.build_collection_param(param, :ssv)).to eq('contact_ids order where')
106
193
  end
107
194
 
108
195
  it 'works for tsv' do
109
- expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
196
+ expect(api_client.build_collection_param(param, :tsv)).to eq("contact_ids\torder\twhere")
110
197
  end
111
198
 
112
199
  it 'works for pipes' do
113
- expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
200
+ expect(api_client.build_collection_param(param, :pipes)).to eq('contact_ids|order|where')
114
201
  end
115
202
 
116
203
  it 'works for multi' do
117
- expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
204
+ expect(api_client.build_collection_param(param, :multi)).to eq(['contact_ids', 'order', 'where'])
118
205
  end
119
206
 
120
207
  it 'fails for invalid collection format' do
@@ -123,7 +210,7 @@ describe XeroRuby::Accounting::ApiClient do
123
210
  end
124
211
 
125
212
  describe '#json_mime?' do
126
- let(:api_client) { XeroRuby::Accounting::ApiClient.new }
213
+ let(:api_client) { XeroRuby::ApiClient.new }
127
214
 
128
215
  it 'works' do
129
216
  expect(api_client.json_mime?(nil)).to eq false
@@ -140,7 +227,7 @@ describe XeroRuby::Accounting::ApiClient do
140
227
  end
141
228
 
142
229
  describe '#select_header_accept' do
143
- let(:api_client) { XeroRuby::Accounting::ApiClient.new }
230
+ let(:api_client) { XeroRuby::ApiClient.new }
144
231
 
145
232
  it 'works' do
146
233
  expect(api_client.select_header_accept(nil)).to be_nil
@@ -156,7 +243,7 @@ describe XeroRuby::Accounting::ApiClient do
156
243
  end
157
244
 
158
245
  describe '#select_header_content_type' do
159
- let(:api_client) { XeroRuby::Accounting::ApiClient.new }
246
+ let(:api_client) { XeroRuby::ApiClient.new }
160
247
 
161
248
  it 'works' do
162
249
  expect(api_client.select_header_content_type(nil)).to eq('application/json')
@@ -171,7 +258,7 @@ describe XeroRuby::Accounting::ApiClient do
171
258
  end
172
259
 
173
260
  describe '#sanitize_filename' do
174
- let(:api_client) { XeroRuby::Accounting::ApiClient.new }
261
+ let(:api_client) { XeroRuby::ApiClient.new }
175
262
 
176
263
  it 'works' do
177
264
  expect(api_client.sanitize_filename('sun')).to eq('sun')