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.
- checksums.yaml +4 -4
- data/Gemfile.lock +68 -0
- data/docs/accounting/AccountingApi.md +1497 -785
- data/docs/accounting/Allocation.md +11 -1
- data/docs/accounting/BankTransfer.md +1 -1
- data/docs/accounting/BatchPayment.md +1 -1
- data/docs/accounting/Contact.md +2 -2
- data/docs/accounting/CreditNote.md +2 -2
- data/docs/accounting/Invoice.md +2 -2
- data/docs/accounting/Organisation.md +2 -0
- data/docs/accounting/Payment.md +4 -4
- data/docs/accounting/Quote.md +5 -1
- data/docs/assets/AssetApi.md +40 -16
- data/docs/assets/AssetType.md +1 -1
- data/docs/projects/Amount.md +19 -0
- data/docs/projects/ChargeType.md +16 -0
- data/docs/projects/CurrencyCode.md +16 -0
- data/docs/projects/Error.md +19 -0
- data/docs/projects/Pagination.md +23 -0
- data/docs/projects/Project.md +59 -0
- data/docs/projects/ProjectApi.md +979 -0
- data/docs/projects/ProjectCreateOrUpdate.md +23 -0
- data/docs/projects/ProjectPatch.md +17 -0
- data/docs/projects/ProjectStatus.md +16 -0
- data/docs/projects/ProjectUser.md +21 -0
- data/docs/projects/ProjectUsers.md +19 -0
- data/docs/projects/Projects.md +19 -0
- data/docs/projects/Task.md +45 -0
- data/docs/projects/TaskCreateOrUpdate.md +23 -0
- data/docs/projects/Tasks.md +19 -0
- data/docs/projects/TimeEntries.md +19 -0
- data/docs/projects/TimeEntry.md +33 -0
- data/docs/projects/TimeEntryCreateOrUpdate.md +25 -0
- data/lib/xero-ruby.rb +21 -2
- data/lib/xero-ruby/api/accounting_api.rb +77 -85
- data/lib/xero-ruby/api/asset_api.rb +3 -3
- data/lib/xero-ruby/api/project_api.rb +1035 -0
- data/lib/xero-ruby/api_client.rb +33 -7
- data/lib/xero-ruby/api_error.rb +2 -2
- data/lib/xero-ruby/configuration.rb +4 -2
- data/lib/xero-ruby/models/accounting/account.rb +56 -20
- data/lib/xero-ruby/models/accounting/account_type.rb +2 -2
- data/lib/xero-ruby/models/accounting/accounts.rb +4 -3
- data/lib/xero-ruby/models/accounting/accounts_payable.rb +5 -3
- data/lib/xero-ruby/models/accounting/accounts_receivable.rb +5 -3
- data/lib/xero-ruby/models/accounting/address.rb +15 -12
- data/lib/xero-ruby/models/accounting/allocation.rb +61 -8
- data/lib/xero-ruby/models/accounting/allocations.rb +4 -3
- data/lib/xero-ruby/models/accounting/attachment.rb +8 -8
- data/lib/xero-ruby/models/accounting/attachments.rb +4 -3
- data/lib/xero-ruby/models/accounting/balances.rb +5 -3
- data/lib/xero-ruby/models/accounting/bank_transaction.rb +35 -20
- data/lib/xero-ruby/models/accounting/bank_transactions.rb +4 -3
- data/lib/xero-ruby/models/accounting/bank_transfer.rb +15 -13
- data/lib/xero-ruby/models/accounting/bank_transfers.rb +4 -3
- data/lib/xero-ruby/models/accounting/batch_payment.rb +24 -18
- data/lib/xero-ruby/models/accounting/batch_payment_details.rb +7 -7
- data/lib/xero-ruby/models/accounting/batch_payments.rb +4 -3
- data/lib/xero-ruby/models/accounting/bill.rb +4 -3
- data/lib/xero-ruby/models/accounting/branding_theme.rb +9 -8
- data/lib/xero-ruby/models/accounting/branding_themes.rb +4 -3
- data/lib/xero-ruby/models/accounting/cis_org_setting.rb +5 -5
- data/lib/xero-ruby/models/accounting/cis_setting.rb +4 -4
- data/lib/xero-ruby/models/accounting/cis_settings.rb +4 -3
- data/lib/xero-ruby/models/accounting/contact.rb +46 -36
- data/lib/xero-ruby/models/accounting/contact_group.rb +8 -6
- data/lib/xero-ruby/models/accounting/contact_groups.rb +4 -3
- data/lib/xero-ruby/models/accounting/contact_person.rb +6 -6
- data/lib/xero-ruby/models/accounting/contacts.rb +4 -3
- data/lib/xero-ruby/models/accounting/country_code.rb +2 -2
- data/lib/xero-ruby/models/accounting/credit_note.rb +38 -25
- data/lib/xero-ruby/models/accounting/credit_notes.rb +4 -3
- data/lib/xero-ruby/models/accounting/currencies.rb +4 -3
- data/lib/xero-ruby/models/accounting/currency.rb +5 -4
- data/lib/xero-ruby/models/accounting/currency_code.rb +2 -2
- data/lib/xero-ruby/models/accounting/element.rb +10 -4
- data/lib/xero-ruby/models/accounting/employee.rb +13 -8
- data/lib/xero-ruby/models/accounting/employees.rb +4 -3
- data/lib/xero-ruby/models/accounting/error.rb +6 -6
- data/lib/xero-ruby/models/accounting/expense_claim.rb +19 -12
- data/lib/xero-ruby/models/accounting/expense_claims.rb +4 -3
- data/lib/xero-ruby/models/accounting/external_link.rb +10 -4
- data/lib/xero-ruby/models/accounting/history_record.rb +6 -6
- data/lib/xero-ruby/models/accounting/history_records.rb +4 -3
- data/lib/xero-ruby/models/accounting/invoice.rb +56 -37
- data/lib/xero-ruby/models/accounting/invoice_reminder.rb +3 -3
- data/lib/xero-ruby/models/accounting/invoice_reminders.rb +4 -3
- data/lib/xero-ruby/models/accounting/invoices.rb +4 -3
- data/lib/xero-ruby/models/accounting/item.rb +18 -16
- data/lib/xero-ruby/models/accounting/items.rb +4 -3
- data/lib/xero-ruby/models/accounting/journal.rb +35 -10
- data/lib/xero-ruby/models/accounting/journal_line.rb +14 -13
- data/lib/xero-ruby/models/accounting/journals.rb +4 -3
- data/lib/xero-ruby/models/accounting/line_amount_types.rb +2 -2
- data/lib/xero-ruby/models/accounting/line_item.rb +15 -15
- data/lib/xero-ruby/models/accounting/line_item_tracking.rb +6 -6
- data/lib/xero-ruby/models/accounting/linked_transaction.rb +21 -13
- data/lib/xero-ruby/models/accounting/linked_transactions.rb +4 -3
- data/lib/xero-ruby/models/accounting/manual_journal.rb +21 -15
- data/lib/xero-ruby/models/accounting/manual_journal_line.rb +9 -9
- data/lib/xero-ruby/models/accounting/manual_journals.rb +4 -3
- data/lib/xero-ruby/models/accounting/online_invoice.rb +3 -3
- data/lib/xero-ruby/models/accounting/online_invoices.rb +4 -3
- data/lib/xero-ruby/models/accounting/organisation.rb +103 -43
- data/lib/xero-ruby/models/accounting/organisations.rb +4 -3
- data/lib/xero-ruby/models/accounting/overpayment.rb +27 -18
- data/lib/xero-ruby/models/accounting/overpayments.rb +4 -3
- data/lib/xero-ruby/models/accounting/payment.rb +41 -22
- data/lib/xero-ruby/models/accounting/payment_delete.rb +3 -3
- data/lib/xero-ruby/models/accounting/payment_service.rb +8 -8
- data/lib/xero-ruby/models/accounting/payment_services.rb +4 -3
- data/lib/xero-ruby/models/accounting/payment_term.rb +5 -3
- data/lib/xero-ruby/models/accounting/payment_term_type.rb +2 -2
- data/lib/xero-ruby/models/accounting/payments.rb +4 -3
- data/lib/xero-ruby/models/accounting/phone.rb +12 -6
- data/lib/xero-ruby/models/accounting/prepayment.rb +28 -18
- data/lib/xero-ruby/models/accounting/prepayments.rb +4 -3
- data/lib/xero-ruby/models/accounting/purchase.rb +6 -6
- data/lib/xero-ruby/models/accounting/purchase_order.rb +36 -28
- data/lib/xero-ruby/models/accounting/purchase_orders.rb +4 -3
- data/lib/xero-ruby/models/accounting/quote.rb +50 -24
- data/lib/xero-ruby/models/accounting/quote_line_amount_types.rb +2 -2
- data/lib/xero-ruby/models/accounting/quote_status_codes.rb +2 -2
- data/lib/xero-ruby/models/accounting/quotes.rb +4 -3
- data/lib/xero-ruby/models/accounting/receipt.rb +25 -16
- data/lib/xero-ruby/models/accounting/receipts.rb +4 -3
- data/lib/xero-ruby/models/accounting/repeating_invoice.rb +23 -14
- data/lib/xero-ruby/models/accounting/repeating_invoices.rb +4 -3
- data/lib/xero-ruby/models/accounting/report.rb +10 -8
- data/lib/xero-ruby/models/accounting/report_attribute.rb +5 -3
- data/lib/xero-ruby/models/accounting/report_cell.rb +5 -3
- data/lib/xero-ruby/models/accounting/report_fields.rb +6 -3
- data/lib/xero-ruby/models/accounting/report_row.rb +6 -3
- data/lib/xero-ruby/models/accounting/report_rows.rb +7 -3
- data/lib/xero-ruby/models/accounting/report_with_row.rb +11 -9
- data/lib/xero-ruby/models/accounting/report_with_rows.rb +4 -3
- data/lib/xero-ruby/models/accounting/reports.rb +4 -3
- data/lib/xero-ruby/models/accounting/request_empty.rb +3 -3
- data/lib/xero-ruby/models/accounting/row_type.rb +2 -2
- data/lib/xero-ruby/models/accounting/sales_tracking_category.rb +4 -4
- data/lib/xero-ruby/models/accounting/schedule.rb +19 -11
- data/lib/xero-ruby/models/accounting/tax_component.rb +6 -6
- data/lib/xero-ruby/models/accounting/tax_rate.rb +94 -16
- data/lib/xero-ruby/models/accounting/tax_rates.rb +4 -3
- data/lib/xero-ruby/models/accounting/tax_type.rb +2 -2
- data/lib/xero-ruby/models/accounting/ten_nintey_nine_contact.rb +24 -24
- data/lib/xero-ruby/models/accounting/time_zone.rb +2 -2
- data/lib/xero-ruby/models/accounting/tracking_categories.rb +4 -3
- data/lib/xero-ruby/models/accounting/tracking_category.rb +11 -8
- data/lib/xero-ruby/models/accounting/tracking_option.rb +9 -6
- data/lib/xero-ruby/models/accounting/tracking_options.rb +4 -3
- data/lib/xero-ruby/models/accounting/user.rb +16 -9
- data/lib/xero-ruby/models/accounting/users.rb +4 -3
- data/lib/xero-ruby/models/accounting/validation_error.rb +3 -3
- data/lib/xero-ruby/models/assets/asset.rb +17 -14
- data/lib/xero-ruby/models/assets/asset_status.rb +2 -2
- data/lib/xero-ruby/models/assets/asset_status_query_param.rb +2 -2
- data/lib/xero-ruby/models/assets/asset_type.rb +9 -13
- data/lib/xero-ruby/models/assets/assets.rb +5 -3
- data/lib/xero-ruby/models/assets/book_depreciation_detail.rb +9 -9
- data/lib/xero-ruby/models/assets/book_depreciation_setting.rb +21 -10
- data/lib/xero-ruby/models/assets/error.rb +7 -7
- data/lib/xero-ruby/models/assets/field_validation_errors_element.rb +8 -8
- data/lib/xero-ruby/models/assets/pagination.rb +7 -3
- data/lib/xero-ruby/models/assets/resource_validation_errors_element.rb +7 -7
- data/lib/xero-ruby/models/assets/setting.rb +10 -10
- data/lib/xero-ruby/models/projects/amount.rb +214 -0
- data/lib/xero-ruby/models/projects/charge_type.rb +38 -0
- data/lib/xero-ruby/models/projects/currency_code.rb +199 -0
- data/lib/xero-ruby/models/projects/error.rb +214 -0
- data/lib/xero-ruby/models/projects/pagination.rb +234 -0
- data/lib/xero-ruby/models/projects/project.rb +419 -0
- data/lib/xero-ruby/models/projects/project_create_or_update.rb +239 -0
- data/lib/xero-ruby/models/projects/project_patch.rb +209 -0
- data/lib/xero-ruby/models/projects/project_status.rb +37 -0
- data/lib/xero-ruby/models/projects/project_user.rb +224 -0
- data/lib/xero-ruby/models/projects/project_users.rb +216 -0
- data/lib/xero-ruby/models/projects/projects.rb +216 -0
- data/lib/xero-ruby/models/projects/task.rb +381 -0
- data/lib/xero-ruby/models/projects/task_create_or_update.rb +249 -0
- data/lib/xero-ruby/models/projects/tasks.rb +216 -0
- data/lib/xero-ruby/models/projects/time_entries.rb +216 -0
- data/lib/xero-ruby/models/projects/time_entry.rb +320 -0
- data/lib/xero-ruby/models/projects/time_entry_create_or_update.rb +264 -0
- data/lib/xero-ruby/version.rb +3 -3
- data/spec/accounting/api/accounting_api_spec.rb +3 -3
- data/spec/api_client_spec.rb +23 -23
- data/spec/assets/api/asset_api_spec.rb +3 -3
- data/spec/configuration_spec.rb +7 -23
- data/spec/projects/api/project_api_spec.rb +229 -0
- data/spec/projects/models/amount_spec.rb +47 -0
- data/spec/projects/models/charge_type_spec.rb +35 -0
- data/spec/projects/models/currency_code_spec.rb +35 -0
- data/spec/projects/models/error_spec.rb +47 -0
- data/spec/projects/models/pagination_spec.rb +59 -0
- data/spec/projects/models/project_create_or_update_spec.rb +59 -0
- data/spec/projects/models/project_patch_spec.rb +41 -0
- data/spec/projects/models/project_spec.rb +167 -0
- data/spec/projects/models/project_status_spec.rb +35 -0
- data/spec/projects/models/project_user_spec.rb +53 -0
- data/spec/projects/models/project_users_spec.rb +47 -0
- data/spec/projects/models/projects_spec.rb +47 -0
- data/spec/projects/models/task_create_or_update_spec.rb +59 -0
- data/spec/projects/models/task_spec.rb +129 -0
- data/spec/projects/models/tasks_spec.rb +47 -0
- data/spec/projects/models/time_entries_spec.rb +47 -0
- data/spec/projects/models/time_entry_create_or_update_spec.rb +65 -0
- data/spec/projects/models/time_entry_spec.rb +93 -0
- data/xero-ruby.gem +0 -0
- data/xero-ruby.gemspec +3 -3
- metadata +83 -7
- data/xero-ruby-1.0.gem +0 -0
@@ -0,0 +1,264 @@
|
|
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 TimeEntryCreateOrUpdate
|
18
|
+
# The xero user identifier of the person logging the time.
|
19
|
+
attr_accessor :user_id
|
20
|
+
|
21
|
+
# Identifier of the task that time entry is logged against.
|
22
|
+
attr_accessor :task_id
|
23
|
+
|
24
|
+
# Date time entry is logged on. UTC Date Time in ISO-8601 format.
|
25
|
+
attr_accessor :date_utc
|
26
|
+
|
27
|
+
# Number of minutes to be logged. Duration is between 1 and 59940 inclusively.
|
28
|
+
attr_accessor :duration
|
29
|
+
|
30
|
+
# An optional description of the time entry, will be set to null if not provided during update.
|
31
|
+
attr_accessor :description
|
32
|
+
|
33
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
34
|
+
def self.attribute_map
|
35
|
+
{
|
36
|
+
:'user_id' => :'userId',
|
37
|
+
:'task_id' => :'taskId',
|
38
|
+
:'date_utc' => :'dateUtc',
|
39
|
+
:'duration' => :'duration',
|
40
|
+
:'description' => :'description'
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
# Attribute type mapping.
|
45
|
+
def self.openapi_types
|
46
|
+
{
|
47
|
+
:'user_id' => :'String',
|
48
|
+
:'task_id' => :'String',
|
49
|
+
:'date_utc' => :'DateTime',
|
50
|
+
:'duration' => :'Integer',
|
51
|
+
:'description' => :'String'
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# Initializes the object
|
56
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
57
|
+
def initialize(attributes = {})
|
58
|
+
if (!attributes.is_a?(Hash))
|
59
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Projects::TimeEntryCreateOrUpdate` initialize method"
|
60
|
+
end
|
61
|
+
|
62
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
63
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
64
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
65
|
+
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
|
66
|
+
end
|
67
|
+
h[k.to_sym] = v
|
68
|
+
}
|
69
|
+
|
70
|
+
if attributes.key?(:'user_id')
|
71
|
+
self.user_id = attributes[:'user_id']
|
72
|
+
end
|
73
|
+
|
74
|
+
if attributes.key?(:'task_id')
|
75
|
+
self.task_id = attributes[:'task_id']
|
76
|
+
end
|
77
|
+
|
78
|
+
if attributes.key?(:'date_utc')
|
79
|
+
self.date_utc = attributes[:'date_utc']
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.key?(:'duration')
|
83
|
+
self.duration = attributes[:'duration']
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.key?(:'description')
|
87
|
+
self.description = attributes[:'description']
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
92
|
+
# @return Array for valid properties with the reasons
|
93
|
+
def list_invalid_properties
|
94
|
+
invalid_properties = Array.new
|
95
|
+
if @user_id.nil?
|
96
|
+
invalid_properties.push('invalid value for "user_id", user_id cannot be nil.')
|
97
|
+
end
|
98
|
+
|
99
|
+
if @task_id.nil?
|
100
|
+
invalid_properties.push('invalid value for "task_id", task_id cannot be nil.')
|
101
|
+
end
|
102
|
+
|
103
|
+
if @date_utc.nil?
|
104
|
+
invalid_properties.push('invalid value for "date_utc", date_utc cannot be nil.')
|
105
|
+
end
|
106
|
+
|
107
|
+
if @duration.nil?
|
108
|
+
invalid_properties.push('invalid value for "duration", duration cannot be nil.')
|
109
|
+
end
|
110
|
+
|
111
|
+
invalid_properties
|
112
|
+
end
|
113
|
+
|
114
|
+
# Check to see if the all the properties in the model are valid
|
115
|
+
# @return true if the model is valid
|
116
|
+
def valid?
|
117
|
+
return false if @user_id.nil?
|
118
|
+
return false if @task_id.nil?
|
119
|
+
return false if @date_utc.nil?
|
120
|
+
return false if @duration.nil?
|
121
|
+
true
|
122
|
+
end
|
123
|
+
|
124
|
+
# Checks equality by comparing each attribute.
|
125
|
+
# @param [Object] Object to be compared
|
126
|
+
def ==(o)
|
127
|
+
return true if self.equal?(o)
|
128
|
+
self.class == o.class &&
|
129
|
+
user_id == o.user_id &&
|
130
|
+
task_id == o.task_id &&
|
131
|
+
date_utc == o.date_utc &&
|
132
|
+
duration == o.duration &&
|
133
|
+
description == o.description
|
134
|
+
end
|
135
|
+
|
136
|
+
# @see the `==` method
|
137
|
+
# @param [Object] Object to be compared
|
138
|
+
def eql?(o)
|
139
|
+
self == o
|
140
|
+
end
|
141
|
+
|
142
|
+
# Calculates hash code according to all attributes.
|
143
|
+
# @return [Integer] Hash code
|
144
|
+
def hash
|
145
|
+
[user_id, task_id, date_utc, duration, description].hash
|
146
|
+
end
|
147
|
+
|
148
|
+
# Builds the object from hash
|
149
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
150
|
+
# @return [Object] Returns the model itself
|
151
|
+
def self.build_from_hash(attributes)
|
152
|
+
new.build_from_hash(attributes)
|
153
|
+
end
|
154
|
+
|
155
|
+
# Builds the object from hash
|
156
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
157
|
+
# @return [Object] Returns the model itself
|
158
|
+
def build_from_hash(attributes)
|
159
|
+
return nil unless attributes.is_a?(Hash)
|
160
|
+
self.class.openapi_types.each_pair do |key, type|
|
161
|
+
if type =~ /\AArray<(.*)>/i
|
162
|
+
# check to ensure the input is an array given that the attribute
|
163
|
+
# is documented as an array but the input is not
|
164
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
165
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
166
|
+
end
|
167
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
168
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
169
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
170
|
+
end
|
171
|
+
|
172
|
+
self
|
173
|
+
end
|
174
|
+
|
175
|
+
# Deserializes the data based on type
|
176
|
+
# @param string type Data type
|
177
|
+
# @param string value Value to be deserialized
|
178
|
+
# @return [Object] Deserialized data
|
179
|
+
def _deserialize(type, value)
|
180
|
+
case type.to_sym
|
181
|
+
when :DateTime
|
182
|
+
DateTime.parse(parse_date(value))
|
183
|
+
when :Date
|
184
|
+
Date.parse(parse_date(value))
|
185
|
+
when :String
|
186
|
+
value.to_s
|
187
|
+
when :Integer
|
188
|
+
value.to_i
|
189
|
+
when :Float
|
190
|
+
value.to_f
|
191
|
+
when :Boolean
|
192
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
193
|
+
true
|
194
|
+
else
|
195
|
+
false
|
196
|
+
end
|
197
|
+
when :Object
|
198
|
+
# generic object (usually a Hash), return directly
|
199
|
+
value
|
200
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
201
|
+
inner_type = Regexp.last_match[:inner_type]
|
202
|
+
value.map { |v| _deserialize(inner_type, v) }
|
203
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
204
|
+
k_type = Regexp.last_match[:k_type]
|
205
|
+
v_type = Regexp.last_match[:v_type]
|
206
|
+
{}.tap do |hash|
|
207
|
+
value.each do |k, v|
|
208
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
else # model
|
212
|
+
XeroRuby::Projects.const_get(type).build_from_hash(value)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
# Returns the string representation of the object
|
217
|
+
# @return [String] String presentation of the object
|
218
|
+
def to_s
|
219
|
+
to_hash.to_s
|
220
|
+
end
|
221
|
+
|
222
|
+
# to_body is an alias to to_hash (backward compatibility)
|
223
|
+
# @return [Hash] Returns the object in the form of hash
|
224
|
+
def to_body
|
225
|
+
to_hash
|
226
|
+
end
|
227
|
+
|
228
|
+
# Returns the object in the form of hash
|
229
|
+
# @return [Hash] Returns the object in the form of hash
|
230
|
+
def to_hash
|
231
|
+
hash = {}
|
232
|
+
self.class.attribute_map.each_pair do |attr, param|
|
233
|
+
value = self.send(attr)
|
234
|
+
next if value.nil?
|
235
|
+
hash[param] = _to_hash(value)
|
236
|
+
end
|
237
|
+
hash
|
238
|
+
end
|
239
|
+
|
240
|
+
# Outputs non-array value in the form of hash
|
241
|
+
# For object, use to_hash. Otherwise, just return the value
|
242
|
+
# @param [Object] value Any valid value
|
243
|
+
# @return [Hash] Returns the value in the form of hash
|
244
|
+
def _to_hash(value)
|
245
|
+
if value.is_a?(Array)
|
246
|
+
value.compact.map { |v| _to_hash(v) }
|
247
|
+
elsif value.is_a?(Hash)
|
248
|
+
{}.tap do |hash|
|
249
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
250
|
+
end
|
251
|
+
elsif value.respond_to? :to_hash
|
252
|
+
value.to_hash
|
253
|
+
else
|
254
|
+
value
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
# customized data_parser
|
259
|
+
def parse_date(datestring)
|
260
|
+
seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0
|
261
|
+
return Time.at(seconds_since_epoch).to_s
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
data/lib/xero-ruby/version.rb
CHANGED
@@ -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.
|
6
|
+
The version of the OpenAPI document: 2.2.2
|
7
7
|
Contact: api@xero.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.3.
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
module XeroRuby
|
14
|
-
VERSION = '1.
|
14
|
+
VERSION = '1.2.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::
|
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::
|
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::
|
31
|
+
expect(@api_instance).to be_instance_of(XeroRuby::AccountingApi)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
data/spec/api_client_spec.rb
CHANGED
@@ -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::
|
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
|
21
|
-
expect(XeroRuby::
|
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
|
26
|
-
expect(XeroRuby::
|
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
|
31
|
-
expect(XeroRuby::
|
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
|
38
|
-
expect(XeroRuby::
|
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
|
43
|
-
expect(XeroRuby::
|
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
|
48
|
-
expect(XeroRuby::
|
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::
|
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::
|
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::
|
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>')
|
@@ -83,7 +83,7 @@ describe XeroRuby::Accounting::ApiClient do
|
|
83
83
|
describe "#object_to_hash" do
|
84
84
|
it 'ignores nils and includes empty arrays' do
|
85
85
|
# uncomment below to test object_to_hash for model
|
86
|
-
# api_client = XeroRuby::
|
86
|
+
# api_client = XeroRuby::ApiClient.new
|
87
87
|
# _model = XeroRuby::Accounting::ModelName.new
|
88
88
|
# update the model attribute below
|
89
89
|
# _model.id = 1
|
@@ -95,7 +95,7 @@ describe XeroRuby::Accounting::ApiClient do
|
|
95
95
|
|
96
96
|
describe '#build_collection_param' do
|
97
97
|
let(:param) { ['aa', 'bb', 'cc'] }
|
98
|
-
let(:api_client) { XeroRuby::
|
98
|
+
let(:api_client) { XeroRuby::ApiClient.new }
|
99
99
|
|
100
100
|
it 'works for csv' do
|
101
101
|
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
|
@@ -123,7 +123,7 @@ describe XeroRuby::Accounting::ApiClient do
|
|
123
123
|
end
|
124
124
|
|
125
125
|
describe '#json_mime?' do
|
126
|
-
let(:api_client) { XeroRuby::
|
126
|
+
let(:api_client) { XeroRuby::ApiClient.new }
|
127
127
|
|
128
128
|
it 'works' do
|
129
129
|
expect(api_client.json_mime?(nil)).to eq false
|
@@ -140,7 +140,7 @@ describe XeroRuby::Accounting::ApiClient do
|
|
140
140
|
end
|
141
141
|
|
142
142
|
describe '#select_header_accept' do
|
143
|
-
let(:api_client) { XeroRuby::
|
143
|
+
let(:api_client) { XeroRuby::ApiClient.new }
|
144
144
|
|
145
145
|
it 'works' do
|
146
146
|
expect(api_client.select_header_accept(nil)).to be_nil
|
@@ -156,7 +156,7 @@ describe XeroRuby::Accounting::ApiClient do
|
|
156
156
|
end
|
157
157
|
|
158
158
|
describe '#select_header_content_type' do
|
159
|
-
let(:api_client) { XeroRuby::
|
159
|
+
let(:api_client) { XeroRuby::ApiClient.new }
|
160
160
|
|
161
161
|
it 'works' do
|
162
162
|
expect(api_client.select_header_content_type(nil)).to eq('application/json')
|
@@ -171,7 +171,7 @@ describe XeroRuby::Accounting::ApiClient do
|
|
171
171
|
end
|
172
172
|
|
173
173
|
describe '#sanitize_filename' do
|
174
|
-
let(:api_client) { XeroRuby::
|
174
|
+
let(:api_client) { XeroRuby::ApiClient.new }
|
175
175
|
|
176
176
|
it 'works' do
|
177
177
|
expect(api_client.sanitize_filename('sun')).to eq('sun')
|
@@ -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::
|
16
|
+
# Unit tests for XeroRuby::AssetApi
|
17
17
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
18
18
|
# Please update as you see appropriate
|
19
19
|
describe 'AssetApi' do
|
20
20
|
before do
|
21
21
|
# run before each test
|
22
|
-
@api_instance = XeroRuby::
|
22
|
+
@api_instance = XeroRuby::AssetApi.new
|
23
23
|
end
|
24
24
|
|
25
25
|
after do
|
@@ -28,7 +28,7 @@ describe 'AssetApi' do
|
|
28
28
|
|
29
29
|
describe 'test an instance of AssetApi' do
|
30
30
|
it 'should create an instance of AssetApi' do
|
31
|
-
expect(@api_instance).to be_instance_of(XeroRuby::
|
31
|
+
expect(@api_instance).to be_instance_of(XeroRuby::AssetApi)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|