Skip to content

Commit

Permalink
Merge pull request #166 from XeroAPI/nested_snake_serialization
Browse files Browse the repository at this point in the history
Nested snake serialization & payroll MS date parse fix
  • Loading branch information
SerKnight authored May 11, 2021
2 parents 0aebca7 + e813d74 commit a0a7c98
Show file tree
Hide file tree
Showing 401 changed files with 4,365 additions and 2,742 deletions.
21 changes: 10 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
PATH
remote: .
specs:
xero-ruby (2.10.0)
xero-ruby (3.0.0)
faraday (~> 1.0, >= 1.0.1)
json (~> 2.1, >= 2.1.0)
json-jwt (~> 1.5, >= 1.5.2)

GEM
remote: https://rubygems.org/
specs:
activesupport (6.0.3.4)
activesupport (6.1.3.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
aes_key_wrap (1.1.0)
ast (2.4.1)
bindata (2.4.9)
Expand All @@ -31,7 +31,7 @@ GEM
faraday-excon (1.1.0)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.1.0)
i18n (1.8.7)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.4)
json (2.5.1)
Expand All @@ -40,7 +40,7 @@ GEM
aes_key_wrap
bindata
method_source (1.0.0)
minitest (5.14.3)
minitest (5.14.4)
multipart-post (2.1.1)
parallel (1.20.1)
parser (2.7.2.0)
Expand Down Expand Up @@ -77,9 +77,8 @@ GEM
unicode-display_width (>= 1.4.0, < 1.6)
ruby-progressbar (1.10.1)
ruby2_keywords (0.0.4)
thread_safe (0.3.6)
tzinfo (1.2.9)
thread_safe (~> 0.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (1.5.0)
zeitwerk (2.4.2)

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ We have two sample apps showing SDK usage:
* Login to your Xero developer [/myapps](https://developer.xero.com/myapps) dashboard & create an API application
* Copy the credentials from your API app and store/access them using a secure ENV variable strategy
* Resaearch and include the [neccesary scopes](https://developer.xero.com/documentation/oauth2/scopes) for your app's functionality as a space-seperated list, ex. "`SCOPES="openid profile email accounting.transactions accounting.settings"`"



## Installation
To install this gem to your project:
```
Expand Down Expand Up @@ -115,10 +112,10 @@ Both the `id_token` & `access_token` are JWT's, and can be decoded to see additi
After the initial user interaction you can simply setup a xero_client by passing the whole token_set to the client.
```ruby
xero_client.set_token_set(user.token_set)
# or set it and refresh in same go

xero_client.refresh_token_set(user.token_set)
```
This sets the access_token on the client returns either the existing, or newly refreshed `token_set`. You should save in your database for the next time you need to connect to Xero's AP and repeat the process. Assuming you keep your connection live at least once per 60 days, you can persist infinite API connection assuming the user does not revoke your API access.
This sets the access_token on the client, and returns a refreshed `token_set` that you should save in your datastore for the next time you need to connect to Xero's API.
## Token Helpers
```ruby
xero_client.token_set
Expand Down Expand Up @@ -228,10 +225,13 @@ accounts = xero_client.accounting_api.get_accounts(tenant_id).accounts
invoices = { invoices: [{ type: XeroRuby::Accounting::Invoice::ACCREC, contact: { contact_id: contacts[0].contact_id }, line_items: [{ description: "Big Agency", quantity: BigDecimal("2.0"), unit_amount: BigDecimal("50.99"), account_code: "600", tax_type: XeroRuby::Accounting::TaxType::NONE }], date: "2019-03-11", due_date: "2018-12-10", reference: "Website Design", status: XeroRuby::Accounting::Invoice::DRAFT }]}
invoice = xero_client.accounting_api.create_invoices(tenant_id, invoices).invoices.first

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

puts invoices.to_hash(downcase: false)
=> {'Type': 'ACCREC', 'LineItems': [...]}

# Create History
payment = xero_client.accounting_api.get_payments(tenant_id).payments.first
history_records = { history_records: [{ details: "This payment now has some History!" }]}
Expand Down
7 changes: 5 additions & 2 deletions docs/accounting/AccountingApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -6625,7 +6625,7 @@ opts = {

include_archived: true, # Boolean | e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response

summary_only: false # Boolean | Use summaryOnly=true in GET Contacts endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient.
summary_only: false # Boolean | Use summaryOnly=true in GET Contacts and Invoices endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient.
}

begin
Expand All @@ -6649,7 +6649,7 @@ Name | Type | Description | Notes
**i_ds** | [**Array&lt;String&gt;**](String.md)| Filter by a comma separated list of ContactIDs. Allows you to retrieve a specific set of contacts in a single call. | [optional]
**page** | **Integer**| e.g. page&#x3D;1 - Up to 100 contacts will be returned in a single API call. | [optional]
**include_archived** | **Boolean**| e.g. includeArchived&#x3D;true - Contacts with a status of ARCHIVED will be included in the response | [optional]
**summary_only** | **Boolean**| Use summaryOnly&#x3D;true in GET Contacts endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient. | [optional] [default to false]
**summary_only** | **Boolean**| Use summaryOnly&#x3D;true in GET Contacts and Invoices endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient. | [optional] [default to false]

### Return type

Expand Down Expand Up @@ -8061,6 +8061,8 @@ opts = {

created_by_my_app: false, # Boolean | When set to true you'll only retrieve Invoices created by your app

summary_only: false, # Boolean | Use summaryOnly=true in GET Contacts and Invoices endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient.

unitdp: 4 # Integer | e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts
}

Expand Down Expand Up @@ -8089,6 +8091,7 @@ Name | Type | Description | Notes
**page** | **Integer**| e.g. page&#x3D;1 – Up to 100 invoices will be returned in a single API call with line items shown for each invoice | [optional]
**include_archived** | **Boolean**| e.g. includeArchived&#x3D;true - Invoices with a status of ARCHIVED will be included in the response | [optional]
**created_by_my_app** | **Boolean**| When set to true you&#39;ll only retrieve Invoices created by your app | [optional]
**summary_only** | **Boolean**| Use summaryOnly&#x3D;true in GET Contacts and Invoices endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient. | [optional] [default to false]
**unitdp** | **Integer**| e.g. unitdp&#x3D;4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts | [optional]

### Return type
Expand Down
2 changes: 2 additions & 0 deletions docs/accounting/Prepayment.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Name | Type | Description | Notes
**currency_rate** | **BigDecimal** | The currency rate for a multicurrency prepayment. If no rate is specified, the XE.com day rate is used | [optional]
**remaining_credit** | **BigDecimal** | The remaining credit balance on the prepayment | [optional]
**allocations** | [**Array&lt;Allocation&gt;**](Allocation.md) | See Allocations | [optional]
**payments** | [**Array&lt;Payment&gt;**](Payment.md) | See Payments | [optional]
**applied_amount** | **Float** | The amount of applied to an invoice | [optional]
**has_attachments** | **Boolean** | boolean to indicate if a prepayment has an attachment | [optional] [default to false]
**attachments** | [**Array&lt;Attachment&gt;**](Attachment.md) | See Attachments | [optional]
Expand All @@ -45,6 +46,7 @@ instance = XeroRuby::Accounting::Prepayment.new(type: null,
currency_rate: null,
remaining_credit: null,
allocations: null,
payments: null,
applied_amount: 2.0,
has_attachments: false,
attachments: null)
Expand Down
34 changes: 31 additions & 3 deletions docs/accounting/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4372,6 +4372,13 @@
"$ref" : "#/components/schemas/Allocation"
}
},
"Payments" : {
"type" : "array",
"description" : "See Payments",
"items" : {
"$ref" : "#/components/schemas/Payment"
}
},
"AppliedAmount" : {
"type" : "number",
"description" : "The amount of applied to an invoice",
Expand Down Expand Up @@ -5818,7 +5825,7 @@
<nav id="scrollingNav">
<ul class="sidenav nav nav-list">
<li class="nav-header" data-group="Accounting"><strong>SDK: </strong><span id='sdk-name'></span></li>
<li class="nav-header" data-group="Accounting"><strong>VSN: </strong>2.9.0</li>
<li class="nav-header" data-group="Accounting"><strong>VSN: </strong>3.0.0</li>
<li class="nav-header" data-group="Accounting"><a href="#api-Accounting">Methods</a></li>
<li data-group="Accounting" data-name="createAccount" class="">
<a href="#api-Accounting-createAccount">createAccount</a>
Expand Down Expand Up @@ -20909,7 +20916,7 @@ <h2>Parameters</h2>
</span>

<div class="inner description marked">
Use summaryOnly=true in GET Contacts endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient.
Use summaryOnly=true in GET Contacts and Invoices endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient.
</div>
</div>
</div>
Expand Down Expand Up @@ -23611,10 +23618,11 @@ <h3>Usage and SDK Samples</h3>
page = 1
include_archived = true
created_by_my_app = false
summary_only = true
unitdp = 4

begin
response = xero_client.accounting_api.get_invoices(xero_tenant_id, if_modified_since, where, order, ids, invoice_numbers, contact_ids, statuses, page, include_archived, created_by_my_app, unitdp)
response = xero_client.accounting_api.get_invoices(xero_tenant_id, if_modified_since, where, order, ids, invoice_numbers, contact_ids, statuses, page, include_archived, created_by_my_app, summary_only, unitdp)
return response
rescue XeroRuby::ApiError => e
puts "Exception when calling get_invoices: #{e}"
Expand Down Expand Up @@ -23875,6 +23883,26 @@ <h2>Parameters</h2>
</div>
</div>
</td>
</tr>

<tr><td style="width:150px;">summaryOnly</td>
<td>


<div id="d2e199_getInvoices_summaryOnly">
<div class="json-schema-view">
<div class="primitive">
<span class="type">
Boolean
</span>

<div class="inner description marked">
Use summaryOnly=true in GET Contacts and Invoices endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient.
</div>
</div>
</div>
</div>
</td>
</tr>

<tr><td style="width:150px;">unitdp</td>
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@
<nav id="scrollingNav">
<ul class="sidenav nav nav-list">
<li class="nav-header" data-group="Asset"><strong>SDK: </strong><span id='sdk-name'></span></li>
<li class="nav-header" data-group="Asset"><strong>VSN: </strong>2.9.0</li>
<li class="nav-header" data-group="Asset"><strong>VSN: </strong>3.0.0</li>
<li class="nav-header" data-group="Asset"><a href="#api-Asset">Methods</a></li>
<li data-group="Asset" data-name="createAsset" class="">
<a href="#api-Asset-createAsset">createAsset</a>
Expand Down
2 changes: 1 addition & 1 deletion docs/files/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@
<nav id="scrollingNav">
<ul class="sidenav nav nav-list">
<li class="nav-header" data-group="Files"><strong>SDK: </strong><span id='sdk-name'></span></li>
<li class="nav-header" data-group="Files"><strong>VSN: </strong>2.9.0</li>
<li class="nav-header" data-group="Files"><strong>VSN: </strong>3.0.0</li>
<li class="nav-header" data-group="Files"><a href="#api-Files">Methods</a></li>
<li data-group="Files" data-name="createFileAssociation" class="">
<a href="#api-Files-createFileAssociation">createFileAssociation</a>
Expand Down
2 changes: 1 addition & 1 deletion docs/payroll_au/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3231,7 +3231,7 @@
<nav id="scrollingNav">
<ul class="sidenav nav nav-list">
<li class="nav-header" data-group="PayrollAu"><strong>SDK: </strong><span id='sdk-name'></span></li>
<li class="nav-header" data-group="PayrollAu"><strong>VSN: </strong>2.9.0</li>
<li class="nav-header" data-group="PayrollAu"><strong>VSN: </strong>3.0.0</li>
<li class="nav-header" data-group="PayrollAu"><a href="#api-PayrollAu">Methods</a></li>
<li data-group="PayrollAu" data-name="createEmployee" class="">
<a href="#api-PayrollAu-createEmployee">createEmployee</a>
Expand Down
2 changes: 1 addition & 1 deletion docs/payroll_nz/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3836,7 +3836,7 @@
<nav id="scrollingNav">
<ul class="sidenav nav nav-list">
<li class="nav-header" data-group="PayrollNz"><strong>SDK: </strong><span id='sdk-name'></span></li>
<li class="nav-header" data-group="PayrollNz"><strong>VSN: </strong>2.9.0</li>
<li class="nav-header" data-group="PayrollNz"><strong>VSN: </strong>3.0.0</li>
<li class="nav-header" data-group="PayrollNz"><a href="#api-PayrollNz">Methods</a></li>
<li data-group="PayrollNz" data-name="approveTimesheet" class="">
<a href="#api-PayrollNz-approveTimesheet">approveTimesheet</a>
Expand Down
2 changes: 1 addition & 1 deletion docs/payroll_uk/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3504,7 +3504,7 @@
<nav id="scrollingNav">
<ul class="sidenav nav nav-list">
<li class="nav-header" data-group="PayrollUk"><strong>SDK: </strong><span id='sdk-name'></span></li>
<li class="nav-header" data-group="PayrollUk"><strong>VSN: </strong>2.9.0</li>
<li class="nav-header" data-group="PayrollUk"><strong>VSN: </strong>3.0.0</li>
<li class="nav-header" data-group="PayrollUk"><a href="#api-PayrollUk">Methods</a></li>
<li data-group="PayrollUk" data-name="approveTimesheet" class="">
<a href="#api-PayrollUk-approveTimesheet">approveTimesheet</a>
Expand Down
2 changes: 1 addition & 1 deletion docs/projects/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@
<nav id="scrollingNav">
<ul class="sidenav nav nav-list">
<li class="nav-header" data-group="Project"><strong>SDK: </strong><span id='sdk-name'></span></li>
<li class="nav-header" data-group="Project"><strong>VSN: </strong>2.9.0</li>
<li class="nav-header" data-group="Project"><strong>VSN: </strong>3.0.0</li>
<li class="nav-header" data-group="Project"><a href="#api-Project">Methods</a></li>
<li data-group="Project" data-name="createProject" class="">
<a href="#api-Project-createProject">createProject</a>
Expand Down
Loading

0 comments on commit a0a7c98

Please sign in to comment.