diff --git a/source/XeroApi.VBConsole/PrivateApplicationRunner.vb b/source/XeroApi.VBConsole/PrivateApplicationRunner.vb new file mode 100644 index 0000000..f46a503 --- /dev/null +++ b/source/XeroApi.VBConsole/PrivateApplicationRunner.vb @@ -0,0 +1,25 @@ +Imports DevDefined.OAuth.Storage.Basic +Imports DevDefined.OAuth.Logging +Imports DevDefined.OAuth.Consumer +Imports XeroApi.OAuth +Imports DevDefined.OAuth.Framework +Imports System.Security.Cryptography.X509Certificates + +Public Class PrivateApplicationRunner + + Const UserAgent As String = "Xero.API.ScreenCast v1.0 (Private App Testing)" + Const ConsumerKey As String = "A34K6MSHPFUKVVMLLFLBB7VAJ5MBH6" + + Public Shared Function CreateRepository() As Repository + + Dim privateCertificate As X509Certificate2 = New X509Certificate2("D:\Stevie-Cert.pfx", "xero") + Dim consumerSession As IOAuthSession = New XeroApiPrivateSession(UserAgent, ConsumerKey, privateCertificate) + + consumerSession.MessageLogger = New DebugMessageLogger() + + ' Wrap the authenticated consumerSession in the repository... + Return New Repository(consumerSession) + + End Function + +End Class diff --git a/source/XeroApi.VBConsole/Program.vb b/source/XeroApi.VBConsole/Program.vb index a89648c..adec27c 100644 --- a/source/XeroApi.VBConsole/Program.vb +++ b/source/XeroApi.VBConsole/Program.vb @@ -1,10 +1,12 @@ -Module Program +Imports XeroApi.Model + +Module Program Sub Main() Console.WriteLine("Do you want to run as a public or private application?") Console.WriteLine(" Press 1 for a public application") - 'Console.WriteLine(" Press 2 for a private application") + Console.WriteLine(" Press 2 for a private application") 'Console.WriteLine(" Press 3 for a partner application") Dim keyInfo As ConsoleKeyInfo = Console.ReadKey(True) @@ -16,22 +18,17 @@ Console.WriteLine("Running as a public application...") ExerciseOrganisation(PublicApplicationRunner.CreateRepository()) - End If - + ElseIf (keyInfo.KeyChar.Equals("2"c)) Then - 'if (keyInfo.KeyChar = '2') + Console.WriteLine("Running as a private application...") + ExerciseOrganisation(PrivateApplicationRunner.CreateRepository()) - ' Console.WriteLine("Running as a private application...") - ' ExerciseOrganisation(PrivateApplicationRunner.CreateRepository()) + 'ElseIf (keyInfo.KeyChar = '3') Then - 'End If + ' Console.WriteLine("Running as a partner application...") + ' ExerciseOrganisation(PartnerApplicationRunner.CreateRepository()) - ' if (keyInfo.KeyChar = '3') - - ' Console.WriteLine("Running as a partner application...") - ' ExerciseOrganisation(PartnerApplicationRunner.CreateRepository()) - - 'End If + End If Console.WriteLine("") Console.WriteLine(" Press Enter to Exit") @@ -44,6 +41,20 @@ Dim organisation As XeroApi.Model.Organisation = repository.Organisation Console.WriteLine("You are currently connected to {0}", organisation.Name) + ' Q39411 + Dim arInvoices = From invoices In repository.Invoices Where invoices.Type = "ACCREC" + + For Each arInvoice As Invoice In arInvoices + Console.WriteLine("Invoice {0} is at status {1}", arInvoice.InvoiceNumber, arInvoice.Status) + Next + + + Dim notArInvoices = From invoices In repository.Invoices Where invoices.Type <> "ACCREC" + + For Each notAnArInvoice As Invoice In notArInvoices + Console.WriteLine("Invoice {0} is at status {1}", notAnArInvoice.InvoiceNumber, notAnArInvoice.Status) + Next + End Sub End Module diff --git a/source/XeroApi.VBConsole/XeroApi.VBConsole.vbproj b/source/XeroApi.VBConsole/XeroApi.VBConsole.vbproj index 7b994f2..8876394 100644 --- a/source/XeroApi.VBConsole/XeroApi.VBConsole.vbproj +++ b/source/XeroApi.VBConsole/XeroApi.VBConsole.vbproj @@ -69,6 +69,7 @@ +