@Test public void testUnmarshalling_createInvoiceResponse() { String xml = getResourceAsString("create-invoice-response.xml"); ResponseType response = XeroClient.unmarshallResponse(xml, ResponseType.class); Assert.assertNotNull(response); }
protected static <T> T unmarshallResponse(String responseBody, Class<T> clazz) { try { JAXBContext context = JAXBContext.newInstance(clazz); Unmarshaller unmarshaller = context.createUnmarshaller(); Source source = new StreamSource(new ByteArrayInputStream(responseBody.getBytes())); return unmarshaller.unmarshal(source, clazz).getValue(); } catch (JAXBException e) { throw new IllegalStateException("Error unmarshalling response: " + responseBody, e); } }
XeroClient { protected static <T> T unmarshallResponse(String responseBody, Class<T> clazz) { try { JAXBContext context = JAXBContext.newInstance(clazz); Unmarshaller unmarshaller = context.createUnmarshaller(); Source source = new StreamSource(new ByteArrayInputStream(responseBody.getBytes())); return unmarshaller.unmarshal(source, clazz).getValue(); } catch (JAXBException e) { throw new IllegalStateException("Error unmarshalling response: " + responseBody, e); } } }
XeroClient { protected static <T> T unmarshallResponse(String responseBody, Class<T> clazz) { try { JAXBContext context = JAXBContext.newInstance(clazz); Unmarshaller unmarshaller = context.createUnmarshaller(); Source source = new StreamSource(new ByteArrayInputStream(responseBody.getBytes())); return unmarshaller.unmarshal(source, clazz).getValue(); } catch (JAXBException e) { throw new IllegalStateException("Error unmarshalling response: " + responseBody, e); } } XeroClient(Reader pemReader, String consumerKey, String consumerSecret); }
XeroClient { protected static <T> T unmarshallResponse(String responseBody, Class<T> clazz) { try { JAXBContext context = JAXBContext.newInstance(clazz); Unmarshaller unmarshaller = context.createUnmarshaller(); Source source = new StreamSource(new ByteArrayInputStream(responseBody.getBytes())); return unmarshaller.unmarshal(source, clazz).getValue(); } catch (JAXBException e) { throw new IllegalStateException("Error unmarshalling response: " + responseBody, e); } } XeroClient(Reader pemReader, String consumerKey, String consumerSecret); Account getAccount(String id); List<Account> getAccounts(); List<Account> getAccounts(Date modifiedAfter, String where, String order); BankTransaction getBankTransaction(String id); List<BankTransaction> getBankTransactions(); List<BankTransaction> getBankTransactions(Date modifiedAfter, String where, String order); List<BankTransaction> createBankTransactions(List<BankTransaction> bankTransactions); List<BankTransaction> createBankTransaction(BankTransaction bankTransaction); List<BankTransfer> getBankTransfers(); List<BrandingTheme> getBrandingThemes(); List<BankTransaction> getBrandingThemes(String name, Integer sortOrder, Date createdDateUTC); Contact getContact(String id); List<Contact> getContacts(); List<Contact> getContacts(Date modifiedAfter, String where, String order, Integer page, Boolean includedArchive); CreditNote getCreditNote(String id); List<CreditNote> getCreditNotes(); List<CreditNote> getCreditNotes(Date modifiedAfter, String where, String order); List<Currency> getCurrencies(); Employee getEmployee(String id); List<Employee> getEmployees(); List<Employee> getEmployees(Date modifiedAfter, String where, String order); List<ExpenseClaim> getExpenseClaim(String id); List<ExpenseClaim> getExpenseClaims(); List<ExpenseClaim> getExpenseClaims(Date modifiedAfter, String where, String order); Invoice getInvoice(String id); List<Invoice> getInvoices(); List<Invoice> getInvoices(Date modifiedAfter, String where, String order, Integer page); List<Invoice> createInvoice(Invoice invoice); List<Invoice> updateInvoice(Invoice invoice); List<Receipt> createReceipts(List<Receipt> receipts); List<Receipt> createReceipt(Receipt receipt); List<Invoice> createInvoices(List<Invoice> invoices); List<Invoice> updateInvoices(List<Invoice> invoices); Item getItem(String id); List<Item> getItems(); List<Item> getItems(Date modifiedAfter, String where, String order); Journal getJournal(String id); List<Journal> getJournals(); List<Journal> getJournals(Date modifiedAfter, Integer offset, String where, String order); ManualJournal getManualJournal(String id); List<ManualJournal> getManualJournals(); List<ManualJournal> getManualJournals(Date modifiedAfter, String where, String order); List<ManualJournal> createManualJournals(List<ManualJournal> manualJournals); Organisation getOrganisation(); Payment getPayments(String id); List<Payment> getPayments(); List<Payment> getPayments(Date modifiedAfter, String where, String order); Receipt getReceipt(String id); List<Receipt> getReceipts(); List<Receipt> getReceipts(Date modifiedAfter, String where, String order); List<RepeatingInvoice> getRepeatingInvoices(); List<TaxRate> getTaxRates(); List<TaxRate> getTaxRates(String where, String order); TrackingCategory getTrackingCategory(String id); List<TrackingCategory> getTrackingCategories(); List<TrackingCategory> getTrackingCategories(String where, String order); User getUser(String id); List<User> getUsers(); List<User> getUsers(Date modifiedAfter, String where, String order); }
XeroClient { protected static <T> T unmarshallResponse(String responseBody, Class<T> clazz) { try { JAXBContext context = JAXBContext.newInstance(clazz); Unmarshaller unmarshaller = context.createUnmarshaller(); Source source = new StreamSource(new ByteArrayInputStream(responseBody.getBytes())); return unmarshaller.unmarshal(source, clazz).getValue(); } catch (JAXBException e) { throw new IllegalStateException("Error unmarshalling response: " + responseBody, e); } } XeroClient(Reader pemReader, String consumerKey, String consumerSecret); Account getAccount(String id); List<Account> getAccounts(); List<Account> getAccounts(Date modifiedAfter, String where, String order); BankTransaction getBankTransaction(String id); List<BankTransaction> getBankTransactions(); List<BankTransaction> getBankTransactions(Date modifiedAfter, String where, String order); List<BankTransaction> createBankTransactions(List<BankTransaction> bankTransactions); List<BankTransaction> createBankTransaction(BankTransaction bankTransaction); List<BankTransfer> getBankTransfers(); List<BrandingTheme> getBrandingThemes(); List<BankTransaction> getBrandingThemes(String name, Integer sortOrder, Date createdDateUTC); Contact getContact(String id); List<Contact> getContacts(); List<Contact> getContacts(Date modifiedAfter, String where, String order, Integer page, Boolean includedArchive); CreditNote getCreditNote(String id); List<CreditNote> getCreditNotes(); List<CreditNote> getCreditNotes(Date modifiedAfter, String where, String order); List<Currency> getCurrencies(); Employee getEmployee(String id); List<Employee> getEmployees(); List<Employee> getEmployees(Date modifiedAfter, String where, String order); List<ExpenseClaim> getExpenseClaim(String id); List<ExpenseClaim> getExpenseClaims(); List<ExpenseClaim> getExpenseClaims(Date modifiedAfter, String where, String order); Invoice getInvoice(String id); List<Invoice> getInvoices(); List<Invoice> getInvoices(Date modifiedAfter, String where, String order, Integer page); List<Invoice> createInvoice(Invoice invoice); List<Invoice> updateInvoice(Invoice invoice); List<Receipt> createReceipts(List<Receipt> receipts); List<Receipt> createReceipt(Receipt receipt); List<Invoice> createInvoices(List<Invoice> invoices); List<Invoice> updateInvoices(List<Invoice> invoices); Item getItem(String id); List<Item> getItems(); List<Item> getItems(Date modifiedAfter, String where, String order); Journal getJournal(String id); List<Journal> getJournals(); List<Journal> getJournals(Date modifiedAfter, Integer offset, String where, String order); ManualJournal getManualJournal(String id); List<ManualJournal> getManualJournals(); List<ManualJournal> getManualJournals(Date modifiedAfter, String where, String order); List<ManualJournal> createManualJournals(List<ManualJournal> manualJournals); Organisation getOrganisation(); Payment getPayments(String id); List<Payment> getPayments(); List<Payment> getPayments(Date modifiedAfter, String where, String order); Receipt getReceipt(String id); List<Receipt> getReceipts(); List<Receipt> getReceipts(Date modifiedAfter, String where, String order); List<RepeatingInvoice> getRepeatingInvoices(); List<TaxRate> getTaxRates(); List<TaxRate> getTaxRates(String where, String order); TrackingCategory getTrackingCategory(String id); List<TrackingCategory> getTrackingCategories(); List<TrackingCategory> getTrackingCategories(String where, String order); User getUser(String id); List<User> getUsers(); List<User> getUsers(Date modifiedAfter, String where, String order);  }