Skip to content

Commit

Permalink
Added support for the remaining endpoints to sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Walsh committed Mar 2, 2017
1 parent d093f8d commit d5952b3
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 16 deletions.
1 change: 1 addition & 0 deletions oauth_test/assets/css/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ body {
.nav-sidebar>li>a {
padding-right: 20px;
padding-left: 20px;
font-size: 0.9em;
}

.nav-sidebar>.active>a,
Expand Down
Binary file removed oauth_test/invoice.pdf
Binary file not shown.
42 changes: 42 additions & 0 deletions oauth_test/sample_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ app.get('/access', function(req, res) {
}
});

app.get('/organisations', function(req, res) {
authorizedOperation(req, res, '/organisations', function(xeroApp) {
xeroApp.core.organisations.getOrganisations()
.then(function(organisations) {
res.render('organisations', { organisations: organisations });
})
})
});

app.get('/employees', function(req, res) {
authorizedOperation(req, res, '/employees', function(xeroApp) {
var employees = [];
Expand Down Expand Up @@ -173,6 +182,21 @@ app.get('/banktransactions', function(req, res) {
})
});

app.get('/journals', function(req, res) {
authorizedOperation(req, res, '/journals', function(xeroApp) {
var journals = [];
xeroApp.core.journals.getJournals({ pager: { callback: pagerCallback } })
.then(function() {
res.render('journals', { journals: journals });
})

function pagerCallback(err, response, cb) {
journals.push.apply(journals, response.data);
cb()
}
})
});

app.get('/banktransfers', function(req, res) {
authorizedOperation(req, res, '/banktransfers', function(xeroApp) {
var bankTransfers = [];
Expand All @@ -188,6 +212,24 @@ app.get('/banktransfers', function(req, res) {
})
});

app.get('/payments', function(req, res) {
authorizedOperation(req, res, '/payments', function(xeroApp) {
xeroApp.core.payments.getPayments()
.then(function(payments) {
res.render('payments', { payments: payments });
})
})
});

app.get('/trackingcategories', function(req, res) {
authorizedOperation(req, res, '/trackingcategories', function(xeroApp) {
xeroApp.core.trackingCategories.getTrackingCategories()
.then(function(trackingcategories) {
res.render('trackingcategories', { trackingcategories: trackingcategories });
})
})
});

app.get('/accounts', function(req, res) {
authorizedOperation(req, res, '/accounts', function(xeroApp) {
xeroApp.core.accounts.getAccounts()
Expand Down
2 changes: 0 additions & 2 deletions oauth_test/views/banktransfers.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<table class="table table-bordered table-striped table-collapsed">
<thead>
<tr>
<td>ID</td>
<td>Transfer Date</td>
<td>From Acct Name</td>
<td>To Acct Name</td>
Expand All @@ -11,7 +10,6 @@
</thead>
{{#each bankTransfers}}
<tr>
<td>{{ this.BankTransferID }}</td>
<td>{{ this.Date }}</td>
<td>{{ this.FromBankAccount.Name }} (<a href="https://go.xero.com/Bank/ViewTransaction.aspx?bankTransactionID={{this.FromBankTransactionID}}&&accountID={{this.FromBankAccount.AccountID}}" target="_blank">ref</a>)</td>
<td>{{ this.ToBankAccount.Name }} (<a href="https://go.xero.com/Bank/ViewTransaction.aspx?bankTransactionID={{this.ToBankTransactionID}}&&accountID={{this.ToBankAccount.AccountID}}" target="_blank">ref</a>)</td>
Expand Down
12 changes: 4 additions & 8 deletions oauth_test/views/index.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
<li>Public</li>
<li>Partner</li>
</ul>
<h2>
<a id="Features_13"></a>Features</h2>
<h2>Features</h2>
<p>The following endpoints are supported:</p>
<ul>
<li>Accounts</li>
Expand All @@ -28,12 +27,10 @@
<li>Search (using ‘where’ clause)</li>
<li>Efficient pagination with callbacks</li>
</ul>
<h1>
<a id="Installation_35"></a>Installation</h1>
<h1></a>Installation</h1>
<pre><code>$ npm install xero-node --save
</code></pre>
<h3>
<a id="External_Config_40"></a>External Config</h3>
<h3></a>External Config</h3>
<p>This SDK requires the config to be externalised to ensure private keys are not committed into your codebase by mistake.</p>
<p>The config file should be set up as follows:</p>
<pre><code class="language-javascript">{
Expand All @@ -44,8 +41,7 @@
<span class="hljs-string">"RunscopeBucketId"</span> : <span class="hljs-string">"xxxyyyzzzz"</span>
}
</code></pre>
<h3>
<a id="Config_Parameters_56"></a>Config Parameters</h3>
<h3></a>Config Parameters</h3>
<table class="table table-striped table-bordered">
<thead>
<tr>
Expand Down
4 changes: 1 addition & 3 deletions oauth_test/views/items.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<table class="table table-bordered table-striped table-collapsed">
<thead>
<tr>
<td>ID</td>
<td>Code</td>
<td>Description</td>
<td>Cost Price</td>
Expand All @@ -11,8 +10,7 @@
</thead>
{{#each items}}
<tr>
<td>{{ this.ItemID }}</td>
<td>{{ this.Code }}</td>
<td><a href="https://go.xero.com/Accounts/Inventory/{{this.ItemID}}" target="_blank">{{this.Code }}</a></td>
<td>{{ this.Description }}</td>
<td>{{ this.PurchaseDetails.UnitPrice }}</td>
<td>{{ this.SalesDetails.UnitPrice }}</td>
Expand Down
19 changes: 19 additions & 0 deletions oauth_test/views/journals.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h3>Journals</h3>
<table class="table table-bordered table-striped table-collapsed">
<thead>
<tr>
<td>Number</td>
<td>Journal Date</td>
<td>Reference</td>
<td># Lines</td>
</tr>
</thead>
{{#each journals}}
<tr>
<td>{{ this.JournalNumber }}</td>
<td>{{ this.JournalDate }}</td>
<td>{{ this.Reference }}</td>
<td>{{ this.JournalLines.length }}</td>
</tr>
{{/each}}
</table>
19 changes: 19 additions & 0 deletions oauth_test/views/organisations.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h3>Organisations</h3>
<table class="table table-bordered table-striped table-collapsed">
<thead>
<tr>
<td>Name</td>
<td>Version</td>
<td>IsDemoCompany</td>
<td>OrganisationStatus</td>
</tr>
</thead>
{{#each organisations}}
<tr>
<td><a href="https://my.xero.com/Action/OrganisationLogin/{{ this.ShortCode }}" target="_blank">{{this.Name}}</a></td>
<td>{{ this.Version }}</td>
<td>{{ this.IsDemoCompany }}</td>
<td>{{ this.OrganisationStatus }}</td>
</tr>
{{/each}}
</table>
11 changes: 8 additions & 3 deletions oauth_test/views/partials/nav.handlebars
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
<div class="col-sm-3 col-md-2 sidebar">
<h5>Accounting API</h5>
<ul class="nav nav-sidebar">
<li class="active"><a href="/">Overview <span class="sr-only">(current)</span></a></li>
<li><a href="/organisations">List Organisations</a></li>
<li><a href="/accounts">List Accounts</a></li>
<li><a href="/banktransactions">List Bank Transactions</a></li>
<li><a href="/banktransfers">List Bank Transfers</a></li>
<li><a href="/contacts">List Contacts</a></li>
<li><a href="/invoices">List Invoices</a></li>
<li><a href="/items">List Items</a></li>
<li><a href="/journals">List Journals</a></li>
<li><a href="/payments">List Payments</a></li>
<li><a href="/trackingcategories">List Tracking Categories</a></li>
</ul>
<h5>Payroll API - AU</h5>
<ul class="nav nav-sidebar">
<li><a href="/employees">List employees</a></li>
<li><a href="/timesheets">List timesheets</a></li>
<li><a href="/createtimesheet">Create Timesheet</a></li>
<li><a href="/createinvoice">Create Invoice</a></li>
<li><a href="/sendinvoice">Send Invoice</a></li>
</ul>
</div>
29 changes: 29 additions & 0 deletions oauth_test/views/payments.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<h3>Payments</h3>
<table class="table table-bordered table-striped table-collapsed">
<thead>
<tr>
<td>Date</td>
<td>Contact Name</td>
<td>Status</td>
<td>Amount</td>
</tr>
</thead>
{{#each payments}}
<tr>
{{#ifCond this.Invoice.Type '==' 'ACCREC'}}
<td><a href="https://go.xero.com/AccountsReceivable/View.aspx?InvoiceID={{ this.Invoice.InvoiceID }}" target="_blank">
{{this.Date}}
</a>
</td>
{{else}}
<td><a href="https://go.xero.com/AccountsPayable/View.aspx?InvoiceID={{ this.Invoice.InvoiceID }}" target="_blank">
{{this.Date}}
</a>
</td>
{{/ifCond}}
<td>{{this.Invoice.Contact.Name}} </td>
<td>{{this.Status}} </td>
<td>{{this.Amount}} </td>
</tr>
{{/each}}
</table>
15 changes: 15 additions & 0 deletions oauth_test/views/trackingcategories.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h3>Tracking Categories</h3>
<table class="table table-bordered table-striped table-collapsed">
<thead>
<tr>
<td>Name</td>
<td>Status</td>
</tr>
</thead>
{{#each trackingcategories}}
<tr>
<td><a href="https://go.xero.com//Setup/Tracking.aspx" target="_blank">{{ this.Name }}</a></td>
<td>{{ this.Status }}</td>
</tr>
{{/each}}
</table>

0 comments on commit d5952b3

Please sign in to comment.