xero-ruby 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +68 -0
  3. data/docs/accounting/AccountingApi.md +1497 -785
  4. data/docs/accounting/Allocation.md +11 -1
  5. data/docs/accounting/BankTransfer.md +1 -1
  6. data/docs/accounting/BatchPayment.md +1 -1
  7. data/docs/accounting/Contact.md +2 -2
  8. data/docs/accounting/CreditNote.md +2 -2
  9. data/docs/accounting/Invoice.md +2 -2
  10. data/docs/accounting/Organisation.md +2 -0
  11. data/docs/accounting/Payment.md +4 -4
  12. data/docs/accounting/Quote.md +5 -1
  13. data/docs/assets/AssetApi.md +40 -16
  14. data/docs/assets/AssetType.md +1 -1
  15. data/docs/projects/Amount.md +19 -0
  16. data/docs/projects/ChargeType.md +16 -0
  17. data/docs/projects/CurrencyCode.md +16 -0
  18. data/docs/projects/Error.md +19 -0
  19. data/docs/projects/Pagination.md +23 -0
  20. data/docs/projects/Project.md +59 -0
  21. data/docs/projects/ProjectApi.md +979 -0
  22. data/docs/projects/ProjectCreateOrUpdate.md +23 -0
  23. data/docs/projects/ProjectPatch.md +17 -0
  24. data/docs/projects/ProjectStatus.md +16 -0
  25. data/docs/projects/ProjectUser.md +21 -0
  26. data/docs/projects/ProjectUsers.md +19 -0
  27. data/docs/projects/Projects.md +19 -0
  28. data/docs/projects/Task.md +45 -0
  29. data/docs/projects/TaskCreateOrUpdate.md +23 -0
  30. data/docs/projects/Tasks.md +19 -0
  31. data/docs/projects/TimeEntries.md +19 -0
  32. data/docs/projects/TimeEntry.md +33 -0
  33. data/docs/projects/TimeEntryCreateOrUpdate.md +25 -0
  34. data/lib/xero-ruby.rb +21 -2
  35. data/lib/xero-ruby/api/accounting_api.rb +77 -85
  36. data/lib/xero-ruby/api/asset_api.rb +3 -3
  37. data/lib/xero-ruby/api/project_api.rb +1035 -0
  38. data/lib/xero-ruby/api_client.rb +33 -7
  39. data/lib/xero-ruby/api_error.rb +2 -2
  40. data/lib/xero-ruby/configuration.rb +4 -2
  41. data/lib/xero-ruby/models/accounting/account.rb +56 -20
  42. data/lib/xero-ruby/models/accounting/account_type.rb +2 -2
  43. data/lib/xero-ruby/models/accounting/accounts.rb +4 -3
  44. data/lib/xero-ruby/models/accounting/accounts_payable.rb +5 -3
  45. data/lib/xero-ruby/models/accounting/accounts_receivable.rb +5 -3
  46. data/lib/xero-ruby/models/accounting/address.rb +15 -12
  47. data/lib/xero-ruby/models/accounting/allocation.rb +61 -8
  48. data/lib/xero-ruby/models/accounting/allocations.rb +4 -3
  49. data/lib/xero-ruby/models/accounting/attachment.rb +8 -8
  50. data/lib/xero-ruby/models/accounting/attachments.rb +4 -3
  51. data/lib/xero-ruby/models/accounting/balances.rb +5 -3
  52. data/lib/xero-ruby/models/accounting/bank_transaction.rb +35 -20
  53. data/lib/xero-ruby/models/accounting/bank_transactions.rb +4 -3
  54. data/lib/xero-ruby/models/accounting/bank_transfer.rb +15 -13
  55. data/lib/xero-ruby/models/accounting/bank_transfers.rb +4 -3
  56. data/lib/xero-ruby/models/accounting/batch_payment.rb +24 -18
  57. data/lib/xero-ruby/models/accounting/batch_payment_details.rb +7 -7
  58. data/lib/xero-ruby/models/accounting/batch_payments.rb +4 -3
  59. data/lib/xero-ruby/models/accounting/bill.rb +4 -3
  60. data/lib/xero-ruby/models/accounting/branding_theme.rb +9 -8
  61. data/lib/xero-ruby/models/accounting/branding_themes.rb +4 -3
  62. data/lib/xero-ruby/models/accounting/cis_org_setting.rb +5 -5
  63. data/lib/xero-ruby/models/accounting/cis_setting.rb +4 -4
  64. data/lib/xero-ruby/models/accounting/cis_settings.rb +4 -3
  65. data/lib/xero-ruby/models/accounting/contact.rb +46 -36
  66. data/lib/xero-ruby/models/accounting/contact_group.rb +8 -6
  67. data/lib/xero-ruby/models/accounting/contact_groups.rb +4 -3
  68. data/lib/xero-ruby/models/accounting/contact_person.rb +6 -6
  69. data/lib/xero-ruby/models/accounting/contacts.rb +4 -3
  70. data/lib/xero-ruby/models/accounting/country_code.rb +2 -2
  71. data/lib/xero-ruby/models/accounting/credit_note.rb +38 -25
  72. data/lib/xero-ruby/models/accounting/credit_notes.rb +4 -3
  73. data/lib/xero-ruby/models/accounting/currencies.rb +4 -3
  74. data/lib/xero-ruby/models/accounting/currency.rb +5 -4
  75. data/lib/xero-ruby/models/accounting/currency_code.rb +2 -2
  76. data/lib/xero-ruby/models/accounting/element.rb +10 -4
  77. data/lib/xero-ruby/models/accounting/employee.rb +13 -8
  78. data/lib/xero-ruby/models/accounting/employees.rb +4 -3
  79. data/lib/xero-ruby/models/accounting/error.rb +6 -6
  80. data/lib/xero-ruby/models/accounting/expense_claim.rb +19 -12
  81. data/lib/xero-ruby/models/accounting/expense_claims.rb +4 -3
  82. data/lib/xero-ruby/models/accounting/external_link.rb +10 -4
  83. data/lib/xero-ruby/models/accounting/history_record.rb +6 -6
  84. data/lib/xero-ruby/models/accounting/history_records.rb +4 -3
  85. data/lib/xero-ruby/models/accounting/invoice.rb +56 -37
  86. data/lib/xero-ruby/models/accounting/invoice_reminder.rb +3 -3
  87. data/lib/xero-ruby/models/accounting/invoice_reminders.rb +4 -3
  88. data/lib/xero-ruby/models/accounting/invoices.rb +4 -3
  89. data/lib/xero-ruby/models/accounting/item.rb +18 -16
  90. data/lib/xero-ruby/models/accounting/items.rb +4 -3
  91. data/lib/xero-ruby/models/accounting/journal.rb +35 -10
  92. data/lib/xero-ruby/models/accounting/journal_line.rb +14 -13
  93. data/lib/xero-ruby/models/accounting/journals.rb +4 -3
  94. data/lib/xero-ruby/models/accounting/line_amount_types.rb +2 -2
  95. data/lib/xero-ruby/models/accounting/line_item.rb +15 -15
  96. data/lib/xero-ruby/models/accounting/line_item_tracking.rb +6 -6
  97. data/lib/xero-ruby/models/accounting/linked_transaction.rb +21 -13
  98. data/lib/xero-ruby/models/accounting/linked_transactions.rb +4 -3
  99. data/lib/xero-ruby/models/accounting/manual_journal.rb +21 -15
  100. data/lib/xero-ruby/models/accounting/manual_journal_line.rb +9 -9
  101. data/lib/xero-ruby/models/accounting/manual_journals.rb +4 -3
  102. data/lib/xero-ruby/models/accounting/online_invoice.rb +3 -3
  103. data/lib/xero-ruby/models/accounting/online_invoices.rb +4 -3
  104. data/lib/xero-ruby/models/accounting/organisation.rb +103 -43
  105. data/lib/xero-ruby/models/accounting/organisations.rb +4 -3
  106. data/lib/xero-ruby/models/accounting/overpayment.rb +27 -18
  107. data/lib/xero-ruby/models/accounting/overpayments.rb +4 -3
  108. data/lib/xero-ruby/models/accounting/payment.rb +41 -22
  109. data/lib/xero-ruby/models/accounting/payment_delete.rb +3 -3
  110. data/lib/xero-ruby/models/accounting/payment_service.rb +8 -8
  111. data/lib/xero-ruby/models/accounting/payment_services.rb +4 -3
  112. data/lib/xero-ruby/models/accounting/payment_term.rb +5 -3
  113. data/lib/xero-ruby/models/accounting/payment_term_type.rb +2 -2
  114. data/lib/xero-ruby/models/accounting/payments.rb +4 -3
  115. data/lib/xero-ruby/models/accounting/phone.rb +12 -6
  116. data/lib/xero-ruby/models/accounting/prepayment.rb +28 -18
  117. data/lib/xero-ruby/models/accounting/prepayments.rb +4 -3
  118. data/lib/xero-ruby/models/accounting/purchase.rb +6 -6
  119. data/lib/xero-ruby/models/accounting/purchase_order.rb +36 -28
  120. data/lib/xero-ruby/models/accounting/purchase_orders.rb +4 -3
  121. data/lib/xero-ruby/models/accounting/quote.rb +50 -24
  122. data/lib/xero-ruby/models/accounting/quote_line_amount_types.rb +2 -2
  123. data/lib/xero-ruby/models/accounting/quote_status_codes.rb +2 -2
  124. data/lib/xero-ruby/models/accounting/quotes.rb +4 -3
  125. data/lib/xero-ruby/models/accounting/receipt.rb +25 -16
  126. data/lib/xero-ruby/models/accounting/receipts.rb +4 -3
  127. data/lib/xero-ruby/models/accounting/repeating_invoice.rb +23 -14
  128. data/lib/xero-ruby/models/accounting/repeating_invoices.rb +4 -3
  129. data/lib/xero-ruby/models/accounting/report.rb +10 -8
  130. data/lib/xero-ruby/models/accounting/report_attribute.rb +5 -3
  131. data/lib/xero-ruby/models/accounting/report_cell.rb +5 -3
  132. data/lib/xero-ruby/models/accounting/report_fields.rb +6 -3
  133. data/lib/xero-ruby/models/accounting/report_row.rb +6 -3
  134. data/lib/xero-ruby/models/accounting/report_rows.rb +7 -3
  135. data/lib/xero-ruby/models/accounting/report_with_row.rb +11 -9
  136. data/lib/xero-ruby/models/accounting/report_with_rows.rb +4 -3
  137. data/lib/xero-ruby/models/accounting/reports.rb +4 -3
  138. data/lib/xero-ruby/models/accounting/request_empty.rb +3 -3
  139. data/lib/xero-ruby/models/accounting/row_type.rb +2 -2
  140. data/lib/xero-ruby/models/accounting/sales_tracking_category.rb +4 -4
  141. data/lib/xero-ruby/models/accounting/schedule.rb +19 -11
  142. data/lib/xero-ruby/models/accounting/tax_component.rb +6 -6
  143. data/lib/xero-ruby/models/accounting/tax_rate.rb +94 -16
  144. data/lib/xero-ruby/models/accounting/tax_rates.rb +4 -3
  145. data/lib/xero-ruby/models/accounting/tax_type.rb +2 -2
  146. data/lib/xero-ruby/models/accounting/ten_nintey_nine_contact.rb +24 -24
  147. data/lib/xero-ruby/models/accounting/time_zone.rb +2 -2
  148. data/lib/xero-ruby/models/accounting/tracking_categories.rb +4 -3
  149. data/lib/xero-ruby/models/accounting/tracking_category.rb +11 -8
  150. data/lib/xero-ruby/models/accounting/tracking_option.rb +9 -6
  151. data/lib/xero-ruby/models/accounting/tracking_options.rb +4 -3
  152. data/lib/xero-ruby/models/accounting/user.rb +16 -9
  153. data/lib/xero-ruby/models/accounting/users.rb +4 -3
  154. data/lib/xero-ruby/models/accounting/validation_error.rb +3 -3
  155. data/lib/xero-ruby/models/assets/asset.rb +17 -14
  156. data/lib/xero-ruby/models/assets/asset_status.rb +2 -2
  157. data/lib/xero-ruby/models/assets/asset_status_query_param.rb +2 -2
  158. data/lib/xero-ruby/models/assets/asset_type.rb +9 -13
  159. data/lib/xero-ruby/models/assets/assets.rb +5 -3
  160. data/lib/xero-ruby/models/assets/book_depreciation_detail.rb +9 -9
  161. data/lib/xero-ruby/models/assets/book_depreciation_setting.rb +21 -10
  162. data/lib/xero-ruby/models/assets/error.rb +7 -7
  163. data/lib/xero-ruby/models/assets/field_validation_errors_element.rb +8 -8
  164. data/lib/xero-ruby/models/assets/pagination.rb +7 -3
  165. data/lib/xero-ruby/models/assets/resource_validation_errors_element.rb +7 -7
  166. data/lib/xero-ruby/models/assets/setting.rb +10 -10
  167. data/lib/xero-ruby/models/projects/amount.rb +214 -0
  168. data/lib/xero-ruby/models/projects/charge_type.rb +38 -0
  169. data/lib/xero-ruby/models/projects/currency_code.rb +199 -0
  170. data/lib/xero-ruby/models/projects/error.rb +214 -0
  171. data/lib/xero-ruby/models/projects/pagination.rb +234 -0
  172. data/lib/xero-ruby/models/projects/project.rb +419 -0
  173. data/lib/xero-ruby/models/projects/project_create_or_update.rb +239 -0
  174. data/lib/xero-ruby/models/projects/project_patch.rb +209 -0
  175. data/lib/xero-ruby/models/projects/project_status.rb +37 -0
  176. data/lib/xero-ruby/models/projects/project_user.rb +224 -0
  177. data/lib/xero-ruby/models/projects/project_users.rb +216 -0
  178. data/lib/xero-ruby/models/projects/projects.rb +216 -0
  179. data/lib/xero-ruby/models/projects/task.rb +381 -0
  180. data/lib/xero-ruby/models/projects/task_create_or_update.rb +249 -0
  181. data/lib/xero-ruby/models/projects/tasks.rb +216 -0
  182. data/lib/xero-ruby/models/projects/time_entries.rb +216 -0
  183. data/lib/xero-ruby/models/projects/time_entry.rb +320 -0
  184. data/lib/xero-ruby/models/projects/time_entry_create_or_update.rb +264 -0
  185. data/lib/xero-ruby/version.rb +3 -3
  186. data/spec/accounting/api/accounting_api_spec.rb +3 -3
  187. data/spec/api_client_spec.rb +23 -23
  188. data/spec/assets/api/asset_api_spec.rb +3 -3
  189. data/spec/configuration_spec.rb +7 -23
  190. data/spec/projects/api/project_api_spec.rb +229 -0
  191. data/spec/projects/models/amount_spec.rb +47 -0
  192. data/spec/projects/models/charge_type_spec.rb +35 -0
  193. data/spec/projects/models/currency_code_spec.rb +35 -0
  194. data/spec/projects/models/error_spec.rb +47 -0
  195. data/spec/projects/models/pagination_spec.rb +59 -0
  196. data/spec/projects/models/project_create_or_update_spec.rb +59 -0
  197. data/spec/projects/models/project_patch_spec.rb +41 -0
  198. data/spec/projects/models/project_spec.rb +167 -0
  199. data/spec/projects/models/project_status_spec.rb +35 -0
  200. data/spec/projects/models/project_user_spec.rb +53 -0
  201. data/spec/projects/models/project_users_spec.rb +47 -0
  202. data/spec/projects/models/projects_spec.rb +47 -0
  203. data/spec/projects/models/task_create_or_update_spec.rb +59 -0
  204. data/spec/projects/models/task_spec.rb +129 -0
  205. data/spec/projects/models/tasks_spec.rb +47 -0
  206. data/spec/projects/models/time_entries_spec.rb +47 -0
  207. data/spec/projects/models/time_entry_create_or_update_spec.rb +65 -0
  208. data/spec/projects/models/time_entry_spec.rb +93 -0
  209. data/xero-ruby.gem +0 -0
  210. data/xero-ruby.gemspec +3 -3
  211. metadata +83 -7
  212. data/xero-ruby-1.0.gem +0 -0
@@ -0,0 +1,216 @@
1
+ =begin
2
+ #Xero Projects API
3
+
4
+ #This is the Xero Projects API
5
+
6
+ The version of the OpenAPI document: 2.2.6
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
+ class TimeEntries
18
+
19
+ attr_accessor :pagination
20
+
21
+
22
+ attr_accessor :items
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'pagination' => :'pagination',
28
+ :'items' => :'items'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'pagination' => :'Pagination',
36
+ :'items' => :'Array<TimeEntry>'
37
+ }
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ if (!attributes.is_a?(Hash))
44
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Projects::TimeEntries` initialize method"
45
+ end
46
+
47
+ # check to see if the attribute exists and convert string to symbol for hash key
48
+ attributes = attributes.each_with_object({}) { |(k, v), h|
49
+ if (!self.class.attribute_map.key?(k.to_sym))
50
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Projects::TimeEntries`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
51
+ end
52
+ h[k.to_sym] = v
53
+ }
54
+
55
+ if attributes.key?(:'pagination')
56
+ self.pagination = attributes[:'pagination']
57
+ end
58
+
59
+ if attributes.key?(:'items')
60
+ if (value = attributes[:'items']).is_a?(Array)
61
+ self.items = value
62
+ end
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ invalid_properties = Array.new
70
+ invalid_properties
71
+ end
72
+
73
+ # Check to see if the all the properties in the model are valid
74
+ # @return true if the model is valid
75
+ def valid?
76
+ true
77
+ end
78
+
79
+ # Checks equality by comparing each attribute.
80
+ # @param [Object] Object to be compared
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ pagination == o.pagination &&
85
+ items == o.items
86
+ end
87
+
88
+ # @see the `==` method
89
+ # @param [Object] Object to be compared
90
+ def eql?(o)
91
+ self == o
92
+ end
93
+
94
+ # Calculates hash code according to all attributes.
95
+ # @return [Integer] Hash code
96
+ def hash
97
+ [pagination, items].hash
98
+ end
99
+
100
+ # Builds the object from hash
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ # @return [Object] Returns the model itself
103
+ def self.build_from_hash(attributes)
104
+ new.build_from_hash(attributes)
105
+ end
106
+
107
+ # Builds the object from hash
108
+ # @param [Hash] attributes Model attributes in the form of hash
109
+ # @return [Object] Returns the model itself
110
+ def build_from_hash(attributes)
111
+ return nil unless attributes.is_a?(Hash)
112
+ self.class.openapi_types.each_pair do |key, type|
113
+ if type =~ /\AArray<(.*)>/i
114
+ # check to ensure the input is an array given that the attribute
115
+ # is documented as an array but the input is not
116
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
117
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
118
+ end
119
+ elsif !attributes[self.class.attribute_map[key]].nil?
120
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
121
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
122
+ end
123
+
124
+ self
125
+ end
126
+
127
+ # Deserializes the data based on type
128
+ # @param string type Data type
129
+ # @param string value Value to be deserialized
130
+ # @return [Object] Deserialized data
131
+ def _deserialize(type, value)
132
+ case type.to_sym
133
+ when :DateTime
134
+ DateTime.parse(parse_date(value))
135
+ when :Date
136
+ Date.parse(parse_date(value))
137
+ when :String
138
+ value.to_s
139
+ when :Integer
140
+ value.to_i
141
+ when :Float
142
+ value.to_f
143
+ when :Boolean
144
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
145
+ true
146
+ else
147
+ false
148
+ end
149
+ when :Object
150
+ # generic object (usually a Hash), return directly
151
+ value
152
+ when /\AArray<(?<inner_type>.+)>\z/
153
+ inner_type = Regexp.last_match[:inner_type]
154
+ value.map { |v| _deserialize(inner_type, v) }
155
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
156
+ k_type = Regexp.last_match[:k_type]
157
+ v_type = Regexp.last_match[:v_type]
158
+ {}.tap do |hash|
159
+ value.each do |k, v|
160
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
161
+ end
162
+ end
163
+ else # model
164
+ XeroRuby::Projects.const_get(type).build_from_hash(value)
165
+ end
166
+ end
167
+
168
+ # Returns the string representation of the object
169
+ # @return [String] String presentation of the object
170
+ def to_s
171
+ to_hash.to_s
172
+ end
173
+
174
+ # to_body is an alias to to_hash (backward compatibility)
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_body
177
+ to_hash
178
+ end
179
+
180
+ # Returns the object in the form of hash
181
+ # @return [Hash] Returns the object in the form of hash
182
+ def to_hash
183
+ hash = {}
184
+ self.class.attribute_map.each_pair do |attr, param|
185
+ value = self.send(attr)
186
+ next if value.nil?
187
+ hash[param] = _to_hash(value)
188
+ end
189
+ hash
190
+ end
191
+
192
+ # Outputs non-array value in the form of hash
193
+ # For object, use to_hash. Otherwise, just return the value
194
+ # @param [Object] value Any valid value
195
+ # @return [Hash] Returns the value in the form of hash
196
+ def _to_hash(value)
197
+ if value.is_a?(Array)
198
+ value.compact.map { |v| _to_hash(v) }
199
+ elsif value.is_a?(Hash)
200
+ {}.tap do |hash|
201
+ value.each { |k, v| hash[k] = _to_hash(v) }
202
+ end
203
+ elsif value.respond_to? :to_hash
204
+ value.to_hash
205
+ else
206
+ value
207
+ end
208
+ end
209
+
210
+ # customized data_parser
211
+ def parse_date(datestring)
212
+ seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0
213
+ return Time.at(seconds_since_epoch).to_s
214
+ end
215
+ end
216
+ end
@@ -0,0 +1,320 @@
1
+ =begin
2
+ #Xero Projects API
3
+
4
+ #This is the Xero Projects API
5
+
6
+ The version of the OpenAPI document: 2.2.6
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
+ class TimeEntry
18
+ # Identifier of the time entry.
19
+ attr_accessor :time_entry_id
20
+
21
+ # The xero user identifier of the person who logged time.
22
+ attr_accessor :user_id
23
+
24
+ # Identifier of the project, that the task (which the time entry is logged against) belongs to.
25
+ attr_accessor :project_id
26
+
27
+ # Identifier of the task that time entry is logged against.
28
+ attr_accessor :task_id
29
+
30
+ # The date time that time entry is logged on. UTC Date Time in ISO-8601 format.
31
+ attr_accessor :date_utc
32
+
33
+ # The date time that time entry is created. UTC Date Time in ISO-8601 format. By default it is set to server time.
34
+ attr_accessor :date_entered_utc
35
+
36
+ # The duration of logged minutes.
37
+ attr_accessor :duration
38
+
39
+ # A description of the time entry.
40
+ attr_accessor :description
41
+
42
+ # Status of the time entry. By default a time entry is created with status of `ACTIVE`. A `LOCKED` state indicates that the time entry is currently changing state (for example being invoiced). Updates are not allowed when in this state. It will have a status of INVOICED once it is invoiced.
43
+ attr_accessor :status
44
+ ACTIVE = "ACTIVE".freeze
45
+ LOCKED = "LOCKED".freeze
46
+
47
+ class EnumAttributeValidator
48
+ attr_reader :datatype
49
+ attr_reader :allowable_values
50
+
51
+ def initialize(datatype, allowable_values)
52
+ @allowable_values = allowable_values.map do |value|
53
+ case datatype.to_s
54
+ when /Integer/i
55
+ value.to_i
56
+ when /Float/i
57
+ value.to_f
58
+ else
59
+ value
60
+ end
61
+ end
62
+ end
63
+
64
+ def valid?(value)
65
+ !value || allowable_values.include?(value)
66
+ end
67
+ end
68
+
69
+ # Attribute mapping from ruby-style variable name to JSON key.
70
+ def self.attribute_map
71
+ {
72
+ :'time_entry_id' => :'timeEntryId',
73
+ :'user_id' => :'userId',
74
+ :'project_id' => :'projectId',
75
+ :'task_id' => :'taskId',
76
+ :'date_utc' => :'dateUtc',
77
+ :'date_entered_utc' => :'dateEnteredUtc',
78
+ :'duration' => :'duration',
79
+ :'description' => :'description',
80
+ :'status' => :'status'
81
+ }
82
+ end
83
+
84
+ # Attribute type mapping.
85
+ def self.openapi_types
86
+ {
87
+ :'time_entry_id' => :'String',
88
+ :'user_id' => :'String',
89
+ :'project_id' => :'String',
90
+ :'task_id' => :'String',
91
+ :'date_utc' => :'DateTime',
92
+ :'date_entered_utc' => :'DateTime',
93
+ :'duration' => :'Integer',
94
+ :'description' => :'String',
95
+ :'status' => :'String'
96
+ }
97
+ end
98
+
99
+ # Initializes the object
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ def initialize(attributes = {})
102
+ if (!attributes.is_a?(Hash))
103
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Projects::TimeEntry` initialize method"
104
+ end
105
+
106
+ # check to see if the attribute exists and convert string to symbol for hash key
107
+ attributes = attributes.each_with_object({}) { |(k, v), h|
108
+ if (!self.class.attribute_map.key?(k.to_sym))
109
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Projects::TimeEntry`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
110
+ end
111
+ h[k.to_sym] = v
112
+ }
113
+
114
+ if attributes.key?(:'time_entry_id')
115
+ self.time_entry_id = attributes[:'time_entry_id']
116
+ end
117
+
118
+ if attributes.key?(:'user_id')
119
+ self.user_id = attributes[:'user_id']
120
+ end
121
+
122
+ if attributes.key?(:'project_id')
123
+ self.project_id = attributes[:'project_id']
124
+ end
125
+
126
+ if attributes.key?(:'task_id')
127
+ self.task_id = attributes[:'task_id']
128
+ end
129
+
130
+ if attributes.key?(:'date_utc')
131
+ self.date_utc = attributes[:'date_utc']
132
+ end
133
+
134
+ if attributes.key?(:'date_entered_utc')
135
+ self.date_entered_utc = attributes[:'date_entered_utc']
136
+ end
137
+
138
+ if attributes.key?(:'duration')
139
+ self.duration = attributes[:'duration']
140
+ end
141
+
142
+ if attributes.key?(:'description')
143
+ self.description = attributes[:'description']
144
+ end
145
+
146
+ if attributes.key?(:'status')
147
+ self.status = attributes[:'status']
148
+ end
149
+ end
150
+
151
+ # Show invalid properties with the reasons. Usually used together with valid?
152
+ # @return Array for valid properties with the reasons
153
+ def list_invalid_properties
154
+ invalid_properties = Array.new
155
+ invalid_properties
156
+ end
157
+
158
+ # Check to see if the all the properties in the model are valid
159
+ # @return true if the model is valid
160
+ def valid?
161
+ status_validator = EnumAttributeValidator.new('String', ["ACTIVE", "LOCKED"])
162
+ return false unless status_validator.valid?(@status)
163
+ true
164
+ end
165
+
166
+ # Custom attribute writer method checking allowed values (enum).
167
+ # @param [Object] status Object to be assigned
168
+ def status=(status)
169
+ validator = EnumAttributeValidator.new('String', ["ACTIVE", "LOCKED"])
170
+ unless validator.valid?(status)
171
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
172
+ end
173
+ @status = status
174
+ end
175
+
176
+ # Checks equality by comparing each attribute.
177
+ # @param [Object] Object to be compared
178
+ def ==(o)
179
+ return true if self.equal?(o)
180
+ self.class == o.class &&
181
+ time_entry_id == o.time_entry_id &&
182
+ user_id == o.user_id &&
183
+ project_id == o.project_id &&
184
+ task_id == o.task_id &&
185
+ date_utc == o.date_utc &&
186
+ date_entered_utc == o.date_entered_utc &&
187
+ duration == o.duration &&
188
+ description == o.description &&
189
+ status == o.status
190
+ end
191
+
192
+ # @see the `==` method
193
+ # @param [Object] Object to be compared
194
+ def eql?(o)
195
+ self == o
196
+ end
197
+
198
+ # Calculates hash code according to all attributes.
199
+ # @return [Integer] Hash code
200
+ def hash
201
+ [time_entry_id, user_id, project_id, task_id, date_utc, date_entered_utc, duration, description, status].hash
202
+ end
203
+
204
+ # Builds the object from hash
205
+ # @param [Hash] attributes Model attributes in the form of hash
206
+ # @return [Object] Returns the model itself
207
+ def self.build_from_hash(attributes)
208
+ new.build_from_hash(attributes)
209
+ end
210
+
211
+ # Builds the object from hash
212
+ # @param [Hash] attributes Model attributes in the form of hash
213
+ # @return [Object] Returns the model itself
214
+ def build_from_hash(attributes)
215
+ return nil unless attributes.is_a?(Hash)
216
+ self.class.openapi_types.each_pair do |key, type|
217
+ if type =~ /\AArray<(.*)>/i
218
+ # check to ensure the input is an array given that the attribute
219
+ # is documented as an array but the input is not
220
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
221
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
222
+ end
223
+ elsif !attributes[self.class.attribute_map[key]].nil?
224
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
225
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
226
+ end
227
+
228
+ self
229
+ end
230
+
231
+ # Deserializes the data based on type
232
+ # @param string type Data type
233
+ # @param string value Value to be deserialized
234
+ # @return [Object] Deserialized data
235
+ def _deserialize(type, value)
236
+ case type.to_sym
237
+ when :DateTime
238
+ DateTime.parse(parse_date(value))
239
+ when :Date
240
+ Date.parse(parse_date(value))
241
+ when :String
242
+ value.to_s
243
+ when :Integer
244
+ value.to_i
245
+ when :Float
246
+ value.to_f
247
+ when :Boolean
248
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
249
+ true
250
+ else
251
+ false
252
+ end
253
+ when :Object
254
+ # generic object (usually a Hash), return directly
255
+ value
256
+ when /\AArray<(?<inner_type>.+)>\z/
257
+ inner_type = Regexp.last_match[:inner_type]
258
+ value.map { |v| _deserialize(inner_type, v) }
259
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
260
+ k_type = Regexp.last_match[:k_type]
261
+ v_type = Regexp.last_match[:v_type]
262
+ {}.tap do |hash|
263
+ value.each do |k, v|
264
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
265
+ end
266
+ end
267
+ else # model
268
+ XeroRuby::Projects.const_get(type).build_from_hash(value)
269
+ end
270
+ end
271
+
272
+ # Returns the string representation of the object
273
+ # @return [String] String presentation of the object
274
+ def to_s
275
+ to_hash.to_s
276
+ end
277
+
278
+ # to_body is an alias to to_hash (backward compatibility)
279
+ # @return [Hash] Returns the object in the form of hash
280
+ def to_body
281
+ to_hash
282
+ end
283
+
284
+ # Returns the object in the form of hash
285
+ # @return [Hash] Returns the object in the form of hash
286
+ def to_hash
287
+ hash = {}
288
+ self.class.attribute_map.each_pair do |attr, param|
289
+ value = self.send(attr)
290
+ next if value.nil?
291
+ hash[param] = _to_hash(value)
292
+ end
293
+ hash
294
+ end
295
+
296
+ # Outputs non-array value in the form of hash
297
+ # For object, use to_hash. Otherwise, just return the value
298
+ # @param [Object] value Any valid value
299
+ # @return [Hash] Returns the value in the form of hash
300
+ def _to_hash(value)
301
+ if value.is_a?(Array)
302
+ value.compact.map { |v| _to_hash(v) }
303
+ elsif value.is_a?(Hash)
304
+ {}.tap do |hash|
305
+ value.each { |k, v| hash[k] = _to_hash(v) }
306
+ end
307
+ elsif value.respond_to? :to_hash
308
+ value.to_hash
309
+ else
310
+ value
311
+ end
312
+ end
313
+
314
+ # customized data_parser
315
+ def parse_date(datestring)
316
+ seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0
317
+ return Time.at(seconds_since_epoch).to_s
318
+ end
319
+ end
320
+ end