Skip to content

Commit

Permalink
Merge pull request #120 from XeroAPI/patch_to_hash
Browse files Browse the repository at this point in the history
patch to_hash and add #attributes
  • Loading branch information
SerKnight authored Jan 27, 2021
2 parents 3980d20 + 5cb3b84 commit be42b63
Show file tree
Hide file tree
Showing 390 changed files with 2,344 additions and 397 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# xero-ruby
Xero Ruby SDK for OAuth 2.0 generated from [Xero API OpenAPI Spec](https://github.com/XeroAPI/Xero-OpenAPI).

[![RubyGem](https://img.shields.io/badge/xero--ruby%20gem-v2.6.0-brightgreen)](https://rubygems.org/gems/xero-ruby)
[![RubyGem](https://img.shields.io/badge/xero--ruby%20gem-v2.6.1-brightgreen)](https://rubygems.org/gems/xero-ruby)

# Documentation
Xero Ruby SDK supports Xero's OAuth2.0 authentication and the following Xero API sets.
Expand Down Expand Up @@ -184,8 +184,8 @@ invoices = { invoices: [{ type: XeroRuby::Accounting::Invoice::ACCREC, contact:
invoice = xero_client.accounting_api.create_invoices(tenant_id, invoices).invoices.first

# display out all the serialized data as a hash
puts invoice.to_hash
=> {type: 'ACCREC', ...}
puts invoices.attributes
=> {type: 'ACCREC', line_items: [...]}

# Create History
payment = xero_client.accounting_api.get_payments(tenant_id).payments.first
Expand Down Expand Up @@ -356,4 +356,4 @@ bundle install
```

## Testing
* `rspec spec/`
* `rspec spec/`
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -494,6 +494,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/accounts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -183,6 +183,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/accounts_payable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -191,6 +191,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/accounts_receivable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -191,6 +191,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -227,6 +227,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -183,6 +183,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -442,6 +442,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/address_for_organisation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -443,6 +443,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/allocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -268,6 +268,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/allocations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -183,6 +183,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -231,6 +231,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/attachments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -183,6 +183,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/balance_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -202,6 +202,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/balances.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -192,6 +192,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/bank_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -469,6 +469,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/bank_transactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -183,6 +183,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
7 changes: 6 additions & 1 deletion lib/xero-ruby/models/accounting/bank_transfer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def to_body

# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash(downcase: true)
def to_hash(downcase: false)
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
Expand All @@ -300,6 +300,11 @@ def to_hash(downcase: true)
hash
end

# Returns the object in the form of hash with snake_case
def attributes
to_hash(downcase: true)
end

# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
Expand Down
Loading

0 comments on commit be42b63

Please sign in to comment.