blib/lib/WebService/Saasu.pm untested

filter: Statementstmt 0.0% 0 / 95 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 102 CC 1 SCAR 6.9
CC
1
Cov
0%
commands
2.0
BUILD
2.0
BEGIN
2.0
CRAP 2.0
1 package WebService::Saasu;
2  
3 use Modern::Perl;
4 use Mouse;
5  
6 # ABSTRACT: WebService::Saasu - an interface to saasu.com's RESTful accounting API using Web::API
7  
8 our $VERSION = '0.5'; # VERSION
9  
10 use XML::Simple;
11 with 'Web::API';
12  
13  
14 has 'commands' => (
15 is => 'rw',
16 default => sub {
17 {
18 # invoices
19 list_invoices => {
20 path => 'InvoiceList',
21 mandatory => ['transactionType'],
22 },
23 get_invoice => {
24 path => 'Invoice',
25 mandatory => ['uid'],
26 },
27 create_invoice => {
28 path => 'Tasks',
29 method => 'POST',
30 wrapper => [ 'tasks', 'insertInvoice', 'invoice' ],
31 mandatory =>
32 [ 'transactionType', 'date', 'layout', 'invoiceItems' ],
33 },
34 update_invoice => {
35 path => 'Tasks',
36 method => 'POST',
37 wrapper => [ 'tasks', 'updateInvoice', 'invoice' ],
38 mandatory => [
39 'uid', 'lastUpdatedUid',
40 'transactionType', 'date',
41 'layout', 'invoiceItems'
42 ],
43 },
44 delete_invoice => {
45 path => 'Invoice',
46 method => 'DELETE',
47 mandatory => ['uid'],
48 },
49  
50 # payments
51 list_payments => {
52 path => 'InvoicePaymentList',
53 mandatory => ['transactionType'],
54 },
55 get_payment => {
56 path => 'InvoicePayment',
57 mandatory => ['uid'],
58 },
59 create_payment => {
60 path => 'Tasks',
61 method => 'POST',
62 wrapper =>
63 [ 'tasks', 'insertInvoicePayment', 'invoicePayment' ],
64 mandatory =>
65 [ 'transactionType', 'date', 'invoicePaymentItems' ],
66 },
67 update_payment => {
68 path => 'Tasks',
69 method => 'POST',
70 wrapper =>
71 [ 'tasks', 'updateInvoicePayment', 'invoicePayment' ],
72 mandatory => [
73 'uid', 'lastUpdatedUid',
74 'transactionType', 'date',
75 'invoicePaymentItems'
76 ],
77 },
78 delete_payment => {
79 path => 'InvoicePayment',
80 method => 'DELETE',
81 mandatory => ['uid'],
82 },
83  
84 # contacts
85 list_contacts => { path => 'ContactList' },
86 get_contact => {
87 path => 'Contact',
88 mandatory => ['uid'],
89 },
90 create_contact => {
91 path => 'Tasks',
92 method => 'POST',
93 wrapper => [ 'tasks', 'insertContact', 'contact' ],
94 },
95 update_contact => {
96 path => 'Tasks',
97 method => 'POST',
98 wrapper => [ 'tasks', 'updateContact', 'contact' ],
99 mandatory => [ 'uid', 'lastUpdatedUid' ],
100 },
101 delete_contact => {
102 path => 'Contact',
103 method => 'DELETE',
104 mandatory => ['uid'],
105 },
106  
107 # chart of accounts
108 list_accounts => { path => 'TransactionCategoryList' },
109 get_account => {
110 path => 'TransactionCategory',
111 mandatory => ['uid'],
112 },
113 create_account => {
114 path => 'Tasks',
115 method => 'POST',
116 wrapper => [
117 'tasks', 'insertTransactionCategory',
118 'transactionCategory'
119 ],
120 mandatory => [ 'type', 'name' ],
121 },
122 update_account => {
123 path => 'Tasks',
124 method => 'POST',
125 wrapper => [
126 'tasks', 'updateTransactionCategory',
127 'transactionCategory'
128 ],
129 mandatory => [ 'uid', 'lastUpdatedUid', 'type', 'name' ],
130 },
131 delete_account => {
132 path => 'TransactionCategory',
133 method => 'DELETE',
134 mandatory => ['uid'],
135 },
136  
137 # bank accounts
138 list_bank_accounts => { path => 'BankAccountList' },
139 get_bank_account => {
140 path => 'BankAccount',
141 mandatory => ['uid'],
142 },
143 create_bank_account => {
144 path => 'Tasks',
145 method => 'POST',
146 wrapper => [ 'tasks', 'insertBankAccount', 'bankAccount' ],
147 mandatory => [ 'type', 'displayName' ],
148 },
149 update_bank_account => {
150 path => 'Tasks',
151 method => 'POST',
152 wrapper => [ 'tasks', 'updateBankAccount', 'bankAccount' ],
153 mandatory => [ 'uid', 'lastUpdatedUid', 'type', 'displayName' ],
154 },
155 delete_bank_account => {
156 path => 'BankAccount',
157 method => 'DELETE',
158 mandatory => ['uid'],
159 },
160  
161 # inventory items
162 list_items => { path => 'FullInventoryItemList' },
163 get_item => {
164 path => 'InventoryItem',
165 mandatory => ['uid'],
166 },
167 create_item => {
168 path => 'Tasks',
169 method => 'POST',
170 wrapper => [ 'tasks', 'insertInventoryItem', 'inventoryItem' ],
171 mandatory => [ 'code', 'description' ],
172 },
173 update_item => {
174 path => 'Tasks',
175 method => 'POST',
176 wrapper => [ 'tasks', 'updateInventoryItem', 'inventoryItem' ],
177 mandatory => [ 'uid', 'lastUpdatedUid', 'code', 'description' ],
178 },
179 delete_item => {
180 path => 'InventoryItem',
181 method => 'DELETE',
182 mandatory => ['uid'],
183 },
184  
185 # inventory adjustments
186 list_adjustments => { path => 'InventoryAdjustmentList' },
187 get_adjustment => {
188 path => 'InventoryAdjustment',
189 mandatory => ['uid'],
190 },
191 create_adjustment => {
192 path => 'Tasks',
193 method => 'POST',
194 wrapper => [
195 'tasks', 'insertInventoryAdjustment',
196 'inventoryAdjustment'
197 ],
198 mandatory => ['items'],
199 },
200 update_adjustment => {
201 path => 'Tasks',
202 method => 'POST',
203 wrapper => [
204 'tasks', 'updateInventoryAdjustment',
205 'InventoryAdjustment'
206 ],
207 mandatory => [ 'uid', 'lastUpdatedUid', 'items' ],
208 },
209 delete_adjustment => {
210 path => 'InventoryAdjustment',
211 method => 'DELETE',
212 mandatory => ['uid'],
213 },
214  
215 # combo items
216 list_comboitems => { path => 'FullComboItemList' },
217 get_comboitem => {
218 path => 'ComboItem',
219 mandatory => ['uid'],
220 },
221 create_comboitem => {
222 path => 'Tasks',
223 method => 'POST',
224 wrapper => [ 'tasks', 'insertComboItem', 'comboItem' ],
225 mandatory => [ 'code', 'description', 'items' ],
226 },
227 update_comboitem => {
228 path => 'Tasks',
229 method => 'POST',
230 wrapper => [ 'tasks', 'updateComboItem', 'comboItem' ],
231 mandatory =>
232 [ 'uid', 'lastUpdatedUid', 'code', 'description', 'items' ],
233 },
234 delete_comboitem => {
235 path => 'ComboItem',
236 method => 'DELETE',
237 mandatory => ['uid'],
238 },
239  
240 # inventory transfers
241 list_transfers => { path => 'InventoryTransferList' },
242 get_transfer => {
243 path => 'InventoryTransfer',
244 mandatory => ['uid'],
245 },
246 create_transfer => {
247 path => 'Tasks',
248 method => 'POST',
249 wrapper =>
250 [ 'tasks', 'insertInventoryTransfer', 'inventoryTransfer' ],
251 mandatory => ['items'],
252 },
253 update_transfer => {
254 path => 'Tasks',
255 method => 'POST',
256 wrapper =>
257 [ 'tasks', 'updateInventoryTransfer', 'inventoryTransfer' ],
258 mandatory => [ 'uid', 'lastUpdatedUid', 'items' ],
259 },
260 delete_transfer => {
261 path => 'InventoryTransfer',
262 method => 'DELETE',
263 mandatory => ['uid'],
264 },
265  
266 # journal
267 list_journals => { path => 'JournalList' },
268 get_journal => {
269 path => 'Journal',
270 mandatory => ['uid'],
271 },
272 create_journal => {
273 path => 'Tasks',
274 method => 'POST',
275 wrapper => [ 'tasks', 'insertJournal', 'journal' ],
276 mandatory => ['journalItems'],
277 },
278 update_journal => {
279 path => 'Tasks',
280 method => 'POST',
281 wrapper => [ 'tasks', 'updateJournal', 'journal' ],
282 mandatory => [ 'uid', 'lastUpdatedUid', 'journalItems' ],
283 },
284 delete_journal => {
285 path => 'Journal',
286 method => 'DELETE',
287 mandatory => ['uid'],
288 },
289  
290 # activities
291 list_activities => { path => 'ActivityList' },
292 get_activity => { path => 'Activity' },
293 create_activity => {
294 method => 'POST',
295 path => 'Tasks',
296 wrapper => [ 'tasks', 'insertActivity', 'activity' ],
297 mandatory => [ 'type', 'title' ],
298 },
299 update_activity => {
300 method => 'POST',
301 path => 'Tasks',
302 wrapper => [ 'tasks', 'updateActivity', 'activity' ],
303 mandatory => [ 'uid', 'lastUpdatedUid', 'type', 'title' ],
304 },
305 delete_activity => {
306 path => 'Activity',
307 method => 'DELETE',
308 mandatory => ['uid'],
309 },
310  
311 # reports
312 contact_statement_report => {
313 path => 'contactstatementreport',
314 mandatory => [ 'contactuid', 'datefrom', 'dateto' ],
315 },
316  
317 # tax codes
318 list_tax_codes => { path => 'TaxCodeList' },
319  
320 # tags
321 list_tags => { path => 'TagList' },
322  
323 # deleted entities
324 list_deleted => { path => 'DeletedEntityList' },
325  
326 };
327 },
328 );
329  
330 sub commands {
331 my ($self) = @_;
332 return $self->commands;
333 }
334  
335  
336 sub BUILD {
337 my ($self) = @_;
338  
339 $self->user_agent(__PACKAGE__ . ' ' . $WebService::Saasu::VERSION);
340 $self->content_type('application/xml');
341 $self->base_url('https://secure.saasu.com/webservices/rest/r1');
342 $self->auth_type('get_params');
343 $self->mapping({
344 user => 'FileUid',
345 api_key => 'wsaccesskey',
346 id => 'uid',
347 });
348 $self->xml(
349 XML::Simple->new(
350 ContentKey => '-content',
351 NoAttr => 1,
352 KeepRoot => 1,
353 KeyAttr => ['layout'],
354 ),
355 );
356 $self->retry_http_codes([500]);
357  
358 return $self;
359 }
360  
361  
362 1; # End of WebService::Saasu
363  
364 __END__