| 1 | # $Id: Backpack.pm 29 2008-07-13 10:35:47Z dave $ | ||||||||||||
| 2 | |||||||||||||
| 3 | =head1 NAME | ||||||||||||
| 4 | |||||||||||||
| 5 | Net::ThirtySevenSignals::Highrise - Perl extension for talking 37Signals' Highrise API | ||||||||||||
| 6 | |||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||
| 8 | |||||||||||||
| 9 | use Net::ThirtySevenSignals::Highrise; | ||||||||||||
| 10 | |||||||||||||
| 11 | my $hr = Net::ThirtySevenSignals::Highrise( | ||||||||||||
| 12 | user => $your_highrise_url_prefix, | ||||||||||||
| 13 | token => $your_highrise_api_token, | ||||||||||||
| 14 | ssl => $use_ssl); | ||||||||||||
| 15 | |||||||||||||
| 16 | # Fill out a Perl data structure with information about | ||||||||||||
| 17 | my $people = $hr->list_all_people; | ||||||||||||
| 18 | |||||||||||||
| 19 | # return a hashref of people | ||||||||||||
| 20 | my $people = $hr->people_list_by_criteria(email => 'danny@example.com'); | ||||||||||||
| 21 | |||||||||||||
| 22 | |||||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||||
| 24 | |||||||||||||
| 25 | Net::ThirtySevenSignals::Highrise provides a thin Perl wrapper around the Highrise API | ||||||||||||
| 26 | (L<http://developer.37signals.com/highrise/>). Currently it only implements a very few | ||||||||||||
| 27 | API points. | ||||||||||||
| 28 | |||||||||||||
| 29 | The API is unstable at this time. | ||||||||||||
| 30 | |||||||||||||
| 31 | |||||||||||||
| 32 | =head2 Getting Started | ||||||||||||
| 33 | |||||||||||||
| 34 | In order to use the Highrise API, you'll need to have a Highrise | ||||||||||||
| 35 | API token. And in order to get one of those, you'll need a Highrise | ||||||||||||
| 36 | account. But then again, the API will be pretty useless to you if | ||||||||||||
| 37 | you don't have a Highrise account to manipulate with it. | ||||||||||||
| 38 | |||||||||||||
| 39 | You can get a Highrise account from L<http://highrisehq.com>. | ||||||||||||
| 40 | |||||||||||||
| 41 | =head2 Highrise API | ||||||||||||
| 42 | |||||||||||||
| 43 | The Highrise API is based on XML over HTTP. You send an XML message | ||||||||||||
| 44 | over HTTP to the Highrise server and the server sends a response to | ||||||||||||
| 45 | you which is also in XML. The format of the various XML requests and | ||||||||||||
| 46 | responses are defined at L<http://developer.37signals.com/highrise/> | ||||||||||||
| 47 | |||||||||||||
| 48 | This module removes the need to deal with any XML. You create an | ||||||||||||
| 49 | object to talk to the Highrise server and call methods on that object | ||||||||||||
| 50 | to manipulate your data. The values returned from Highrise | ||||||||||||
| 51 | are converted to Perl data structures before being handed back to | ||||||||||||
| 52 | you (although it is also possible to get back the raw XML). | ||||||||||||
| 53 | |||||||||||||
| 54 | =head1 XML | ||||||||||||
| 55 | |||||||||||||
| 56 | To get the XML back from the API, you can pass the parameter C<forcearray | ||||||||||||
| 57 | =E<gt> 0> to the C<new> function. | ||||||||||||
| 58 | |||||||||||||
| 59 | =cut | ||||||||||||
| 60 | |||||||||||||
| 61 | package Net::ThirtySevenSignals::Highrise; | ||||||||||||
| 62 | { | ||||||||||||
| 63 | 2 | $Net::ThirtySevenSignals::Highrise::VERSION = '0.03'; | |||||||||||
| 64 | } | ||||||||||||
| 65 | |||||||||||||
| 66 | 2 | ▶ | use 5.006; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 67 | 2 | ▶ | use utf8; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 68 | 2 | ▶ | use strict qw(vars subs); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 69 | 2 | ▶ | no warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 70 | 2 | ▶ | use warnings qw(FATAL closed threads internal debugging pack malloc | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 71 | portable prototype inplace io pipe unpack regexp | ||||||||||||
| 72 | deprecated glob digit printf layer | ||||||||||||
| 73 | 2 | reserved taint closure semicolon); | |||||||||||
| 74 | 2 | ▶ | no warnings qw(exec newline unopened); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 75 | |||||||||||||
| 76 | 2 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 77 | 2 | ▶ | use LWP::UserAgent; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 78 | 2 | ▶ | use URI; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 79 | 2 | ▶ | use HTTP::Request; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 80 | 2 | ▶ | use XML::Simple; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 81 | # use Log::Log4perl qw( get_logger ); | ||||||||||||
| 82 | |||||||||||||
| 83 | # my $logger = get_logger(); | ||||||||||||
| 84 | |||||||||||||
| 85 | |||||||||||||
| 86 | 2 | my %data = ( | |||||||||||
| 87 | 'people_list_all' => | ||||||||||||
| 88 | { | ||||||||||||
| 89 | url => '/people.xml', | ||||||||||||
| 90 | return_key => 'person', | ||||||||||||
| 91 | }, | ||||||||||||
| 92 | |||||||||||||
| 93 | 'person_get' => | ||||||||||||
| 94 | { | ||||||||||||
| 95 | url => '/people/[P:id].xml', | ||||||||||||
| 96 | }, | ||||||||||||
| 97 | |||||||||||||
| 98 | |||||||||||||
| 99 | tag_add =>{ | ||||||||||||
| 100 | url => '/[P:subjectType]/[P:subjectID]/tags.xml', | ||||||||||||
| 101 | method => "POST", | ||||||||||||
| 102 | req => '<name>[P:tagName]</name>' | ||||||||||||
| 103 | }, | ||||||||||||
| 104 | |||||||||||||
| 105 | 'person_create' => | ||||||||||||
| 106 | { | ||||||||||||
| 107 | url => '/people.xml?reload=true', | ||||||||||||
| 108 | req => ' | ||||||||||||
| 109 | <person> | ||||||||||||
| 110 | <first-name>[P:firstName]</first-name> | ||||||||||||
| 111 | <last-name>[P:lastName]</last-name> | ||||||||||||
| 112 | <company-name>[P:companyName]</company-name> | ||||||||||||
| 113 | <contact-data> | ||||||||||||
| 114 | |||||||||||||
| 115 | [% IF P:emailAddress %] | ||||||||||||
| 116 | <email-addresses> | ||||||||||||
| 117 | <email-address> | ||||||||||||
| 118 | <address>[P:emailAddress]</address> | ||||||||||||
| 119 | <location>Work</location> | ||||||||||||
| 120 | </email-address> | ||||||||||||
| 121 | </email-addresses> | ||||||||||||
| 122 | [% END %] | ||||||||||||
| 123 | |||||||||||||
| 124 | |||||||||||||
| 125 | [% IF P:workPhone %] | ||||||||||||
| 126 | <phone-numbers> | ||||||||||||
| 127 | <phone-number> | ||||||||||||
| 128 | <number>[P:workPhone]</number> | ||||||||||||
| 129 | <location>Work</location> | ||||||||||||
| 130 | </phone-number> | ||||||||||||
| 131 | </phone-numbers> | ||||||||||||
| 132 | [% END %] | ||||||||||||
| 133 | |||||||||||||
| 134 | </contact-data> | ||||||||||||
| 135 | </person>' | ||||||||||||
| 136 | }, | ||||||||||||
| 137 | |||||||||||||
| 138 | 'person_destroy' => | ||||||||||||
| 139 | { | ||||||||||||
| 140 | method => "DELETE", | ||||||||||||
| 141 | url => '/people/[P:id].xml', | ||||||||||||
| 142 | }, | ||||||||||||
| 143 | |||||||||||||
| 144 | 'people_list_by_criteria' => | ||||||||||||
| 145 | { | ||||||||||||
| 146 | url => '/people/search.xml', | ||||||||||||
| 147 | return_key => 'person', | ||||||||||||
| 148 | }, | ||||||||||||
| 149 | |||||||||||||
| 150 | 'tags_list_all' => | ||||||||||||
| 151 | { | ||||||||||||
| 152 | url => '/tags.xml', | ||||||||||||
| 153 | return_key=>'tag', | ||||||||||||
| 154 | }, | ||||||||||||
| 155 | |||||||||||||
| 156 | |||||||||||||
| 157 | 'tags_list_for_subject' => | ||||||||||||
| 158 | { | ||||||||||||
| 159 | url => '/[P:subjectType]/[P:subjectID]/tags.xml', | ||||||||||||
| 160 | required_params => [qw(subjectType subjectID )], | ||||||||||||
| 161 | return_key => 'tag', | ||||||||||||
| 162 | }, | ||||||||||||
| 163 | |||||||||||||
| 164 | 'create_page' => | ||||||||||||
| 165 | { | ||||||||||||
| 166 | url => '/ws/pages/new', | ||||||||||||
| 167 | req => '<request> | ||||||||||||
| 168 | <token>[S:token]</token> | ||||||||||||
| 169 | <page> | ||||||||||||
| 170 | <title>[P:title]</title> | ||||||||||||
| 171 | <description>[P:description]</description> | ||||||||||||
| 172 | </page> | ||||||||||||
| 173 | </request>' | ||||||||||||
| 174 | }, | ||||||||||||
| 175 | 'show_page' => | ||||||||||||
| 176 | { | ||||||||||||
| 177 | url => '/ws/page/[P:id]', | ||||||||||||
| 178 | req => '<request> | ||||||||||||
| 179 | <token>[S:token]</token> | ||||||||||||
| 180 | </request>' | ||||||||||||
| 181 | }, | ||||||||||||
| 182 | 'destroy_page' => | ||||||||||||
| 183 | { | ||||||||||||
| 184 | url => '/ws/page/[P:id]/destroy', | ||||||||||||
| 185 | req => '<request> | ||||||||||||
| 186 | <token>[S:token]</token> | ||||||||||||
| 187 | </request>' | ||||||||||||
| 188 | }, | ||||||||||||
| 189 | 'update_title' => | ||||||||||||
| 190 | { | ||||||||||||
| 191 | url => '/ws/page/[P:id]/update_title', | ||||||||||||
| 192 | req => '<request> | ||||||||||||
| 193 | <token>[S:token]</token> | ||||||||||||
| 194 | <page><title>[P:title]</title></page> | ||||||||||||
| 195 | </request>' | ||||||||||||
| 196 | }, | ||||||||||||
| 197 | update_body => | ||||||||||||
| 198 | { | ||||||||||||
| 199 | url => '/ws/page/[P:id]/update_body', | ||||||||||||
| 200 | req => '<request> | ||||||||||||
| 201 | <token>[S:token]</token> | ||||||||||||
| 202 | <page><description>[P:description]</description></page> | ||||||||||||
| 203 | </request>' | ||||||||||||
| 204 | }, | ||||||||||||
| 205 | 'duplicate_page' => | ||||||||||||
| 206 | { | ||||||||||||
| 207 | url => '/ws/page/[P:id]/duplicate', | ||||||||||||
| 208 | req => '<request> | ||||||||||||
| 209 | <token>[S:token]</token> | ||||||||||||
| 210 | </request>' | ||||||||||||
| 211 | }, | ||||||||||||
| 212 | 'link_page' => | ||||||||||||
| 213 | { | ||||||||||||
| 214 | url => '/ws/page/[P:to_page]/link', | ||||||||||||
| 215 | req => '<request> | ||||||||||||
| 216 | <token>[S:token]</token> | ||||||||||||
| 217 | <linked_page_id>[P:link_page]</linked_page_id> | ||||||||||||
| 218 | </request>' | ||||||||||||
| 219 | }, | ||||||||||||
| 220 | 'unlink_page' => | ||||||||||||
| 221 | { | ||||||||||||
| 222 | url => '/ws/page/[P:from_page]/link', | ||||||||||||
| 223 | req => '<request> | ||||||||||||
| 224 | <token>[S:token]</token> | ||||||||||||
| 225 | <linked_page_id>[P:link_page]</linked_page_id> | ||||||||||||
| 226 | </request>' | ||||||||||||
| 227 | }, | ||||||||||||
| 228 | 'share_people' => | ||||||||||||
| 229 | { | ||||||||||||
| 230 | url => '/ws/page/[P:id]/share', | ||||||||||||
| 231 | req => '<request> | ||||||||||||
| 232 | <token>[S:token]</token> | ||||||||||||
| 233 | <email_addresses> | ||||||||||||
| 234 | [P:people] | ||||||||||||
| 235 | </email_addresses> | ||||||||||||
| 236 | </request>' | ||||||||||||
| 237 | }, | ||||||||||||
| 238 | 'make_page_public' => | ||||||||||||
| 239 | { | ||||||||||||
| 240 | url => '/ws/page/[P:id]/share', | ||||||||||||
| 241 | req => '<request> | ||||||||||||
| 242 | <token>[S:token]</token> | ||||||||||||
| 243 | <page> | ||||||||||||
| 244 | <public>[P:public]</public> | ||||||||||||
| 245 | </page> | ||||||||||||
| 246 | </request>' | ||||||||||||
| 247 | }, | ||||||||||||
| 248 | 'unshare_friend_page' => | ||||||||||||
| 249 | { | ||||||||||||
| 250 | url => '/ws/page/[P:id]/unshare_friend_page', | ||||||||||||
| 251 | req => '<request> | ||||||||||||
| 252 | <token>[S:token]</token> | ||||||||||||
| 253 | </request>' | ||||||||||||
| 254 | }, | ||||||||||||
| 255 | 'email_page' => | ||||||||||||
| 256 | { | ||||||||||||
| 257 | url => '/ws/page/[P:id]/email', | ||||||||||||
| 258 | req => '<request> | ||||||||||||
| 259 | <token>[S:token]</token> | ||||||||||||
| 260 | </request>' | ||||||||||||
| 261 | }, | ||||||||||||
| 262 | 'list_all_items' => | ||||||||||||
| 263 | { | ||||||||||||
| 264 | url => '/ws/page/[P:page_id]/items/list', | ||||||||||||
| 265 | req => '<request> | ||||||||||||
| 266 | <token>[S:token]</token> | ||||||||||||
| 267 | </request>' | ||||||||||||
| 268 | }, | ||||||||||||
| 269 | 'create_item' => | ||||||||||||
| 270 | { | ||||||||||||
| 271 | url => '/ws/page/[P:page_id]/items/add', | ||||||||||||
| 272 | req => '<request> | ||||||||||||
| 273 | <token>[S:token]</token> | ||||||||||||
| 274 | <item> | ||||||||||||
| 275 | <content>[P:item]</content> | ||||||||||||
| 276 | </item> | ||||||||||||
| 277 | </request>' | ||||||||||||
| 278 | }, | ||||||||||||
| 279 | 'update_item' => | ||||||||||||
| 280 | { | ||||||||||||
| 281 | url => '/ws/page/[P:page_id]/items/update/[P:id]', | ||||||||||||
| 282 | req => '<request> | ||||||||||||
| 283 | <token>[S:token]</token> | ||||||||||||
| 284 | <item> | ||||||||||||
| 285 | <content>[P:item]</content> | ||||||||||||
| 286 | </item> | ||||||||||||
| 287 | </request>' | ||||||||||||
| 288 | }, | ||||||||||||
| 289 | 'toggle_item' => | ||||||||||||
| 290 | { | ||||||||||||
| 291 | url => '/ws/page/[P:page_id]/items/toggle/[P:id]', | ||||||||||||
| 292 | req => '<request> | ||||||||||||
| 293 | <token>[S:token]</token> | ||||||||||||
| 294 | </request>' | ||||||||||||
| 295 | }, | ||||||||||||
| 296 | 'destroy_item' => | ||||||||||||
| 297 | { | ||||||||||||
| 298 | url => '/ws/page/[P:page_id]/items/destroy/[P:id]', | ||||||||||||
| 299 | req => '<request> | ||||||||||||
| 300 | <token>[S:token]</token> | ||||||||||||
| 301 | </request>' | ||||||||||||
| 302 | }, | ||||||||||||
| 303 | 'move_item' => | ||||||||||||
| 304 | { | ||||||||||||
| 305 | url => '/ws/page/[P:page_id]/items/move/[P:id]', | ||||||||||||
| 306 | req => '<request> | ||||||||||||
| 307 | <token>[S:token]</token> | ||||||||||||
| 308 | <direction>[P:direction]</direction> | ||||||||||||
| 309 | </request>' | ||||||||||||
| 310 | }, | ||||||||||||
| 311 | 'list_all_notes' => | ||||||||||||
| 312 | { | ||||||||||||
| 313 | url => '/ws/page/[P:page_id]/notes/list', | ||||||||||||
| 314 | req => '<request> | ||||||||||||
| 315 | <token>[S:token]</token> | ||||||||||||
| 316 | </request>' | ||||||||||||
| 317 | }, | ||||||||||||
| 318 | 'create_note' => | ||||||||||||
| 319 | { | ||||||||||||
| 320 | url => '/ws/page/[P:page_id]/notes/create', | ||||||||||||
| 321 | req => '<request> | ||||||||||||
| 322 | <token>[S:token]</token> | ||||||||||||
| 323 | <note> | ||||||||||||
| 324 | <title>[P:title]</title> | ||||||||||||
| 325 | <body>[P:body]</body> | ||||||||||||
| 326 | </note> | ||||||||||||
| 327 | </request>' | ||||||||||||
| 328 | }, | ||||||||||||
| 329 | 'update_note' => | ||||||||||||
| 330 | { | ||||||||||||
| 331 | url => '/ws/page/[P:page_id]/notes/update/[P:id]', | ||||||||||||
| 332 | req => '<request> | ||||||||||||
| 333 | <token>[S:token]</token> | ||||||||||||
| 334 | <note> | ||||||||||||
| 335 | <title>[P:title]</title> | ||||||||||||
| 336 | <body>[P:body]</body> | ||||||||||||
| 337 | </note> | ||||||||||||
| 338 | </request>' | ||||||||||||
| 339 | }, | ||||||||||||
| 340 | 'destroy_note' => | ||||||||||||
| 341 | { | ||||||||||||
| 342 | url => '/ws/page/[P:page_id]/notes/destroy/[P:id]', | ||||||||||||
| 343 | req => '<request> | ||||||||||||
| 344 | <token>[S:token]</token> | ||||||||||||
| 345 | </request>' | ||||||||||||
| 346 | }, | ||||||||||||
| 347 | 'get_tag_pages' => | ||||||||||||
| 348 | { | ||||||||||||
| 349 | url => '/ws/tags/[P:page_id]', | ||||||||||||
| 350 | req => '<request> | ||||||||||||
| 351 | <token>[S:token]</token> | ||||||||||||
| 352 | </request>' | ||||||||||||
| 353 | }, | ||||||||||||
| 354 | 'set_page_tags' => | ||||||||||||
| 355 | { | ||||||||||||
| 356 | url => '/ws/page/[P:page_id]/tags/tag', | ||||||||||||
| 357 | req => '<request> | ||||||||||||
| 358 | <token>[S:token]</token> | ||||||||||||
| 359 | <tags>[P:tags]</tags> | ||||||||||||
| 360 | </request>' | ||||||||||||
| 361 | }, | ||||||||||||
| 362 | 'upcoming_reminders' => | ||||||||||||
| 363 | { | ||||||||||||
| 364 | url => '/ws/reminders', | ||||||||||||
| 365 | req => '<request> | ||||||||||||
| 366 | <token>[S:token]</token> | ||||||||||||
| 367 | </request>' | ||||||||||||
| 368 | }, | ||||||||||||
| 369 | 'create_reminder' => | ||||||||||||
| 370 | { | ||||||||||||
| 371 | url => '/ws/reminders/create', | ||||||||||||
| 372 | req => '<request> | ||||||||||||
| 373 | <token>[S:token]</token> | ||||||||||||
| 374 | <reminder> | ||||||||||||
| 375 | <content>[P:content]</content> | ||||||||||||
| 376 | <remind_at>[P:remind_at]</remind_at> | ||||||||||||
| 377 | </reminder> | ||||||||||||
| 378 | </request>' | ||||||||||||
| 379 | }, | ||||||||||||
| 380 | 'update_reminder' => | ||||||||||||
| 381 | { | ||||||||||||
| 382 | url => '/ws/reminders/update/[P:id]', | ||||||||||||
| 383 | req => '<request> | ||||||||||||
| 384 | <token>[S:token]</token> | ||||||||||||
| 385 | <reminder> | ||||||||||||
| 386 | <content>[P:content]</content> | ||||||||||||
| 387 | <remind_at>[P:remind_at]</remind_at> | ||||||||||||
| 388 | </reminder> | ||||||||||||
| 389 | </request>' | ||||||||||||
| 390 | }, | ||||||||||||
| 391 | 'destroy_reminder' => | ||||||||||||
| 392 | { | ||||||||||||
| 393 | url => '/ws/reminders/destroy/[P:id]', | ||||||||||||
| 394 | req => '<request> | ||||||||||||
| 395 | <token>[S:token]</token> | ||||||||||||
| 396 | </request>' | ||||||||||||
| 397 | }, | ||||||||||||
| 398 | 'list_all_emails' => | ||||||||||||
| 399 | { | ||||||||||||
| 400 | url => '/ws/page/[P:page_id]/emails/list', | ||||||||||||
| 401 | req => '<request> | ||||||||||||
| 402 | <token>[S:token]</token> | ||||||||||||
| 403 | </request>' | ||||||||||||
| 404 | }, | ||||||||||||
| 405 | 'show_email' => | ||||||||||||
| 406 | { | ||||||||||||
| 407 | url => '/ws/page/[P:page_id]/emails/show/[P:id]', | ||||||||||||
| 408 | req => '<request> | ||||||||||||
| 409 | <token>[S:token]</token> | ||||||||||||
| 410 | </request>' | ||||||||||||
| 411 | }, | ||||||||||||
| 412 | 'destroy_email' => | ||||||||||||
| 413 | { | ||||||||||||
| 414 | url => '/ws/page/[P:page_id]/emails/destroy/[P:id]', | ||||||||||||
| 415 | req => '<request> | ||||||||||||
| 416 | <token>[S:token]</token> | ||||||||||||
| 417 | </request>' | ||||||||||||
| 418 | }, | ||||||||||||
| 419 | 'export' => | ||||||||||||
| 420 | { | ||||||||||||
| 421 | url => '/ws/account/export', | ||||||||||||
| 422 | req => '<request> | ||||||||||||
| 423 | <token>[S:token]</token> | ||||||||||||
| 424 | </request>' | ||||||||||||
| 425 | }, | ||||||||||||
| 426 | 'list_all_lists' => | ||||||||||||
| 427 | { | ||||||||||||
| 428 | url => '/ws/page/[P:page_id]/lists/list', | ||||||||||||
| 429 | req => '<request> | ||||||||||||
| 430 | <token>[S:token]</token> | ||||||||||||
| 431 | </request>' | ||||||||||||
| 432 | }, | ||||||||||||
| 433 | 'list_this_list' => | ||||||||||||
| 434 | { | ||||||||||||
| 435 | url => '/ws/page/[P:page_id]/items/list?list_id=[P:list_id]', | ||||||||||||
| 436 | req => '<request> | ||||||||||||
| 437 | <token>[S:token]</token> | ||||||||||||
| 438 | </request>' | ||||||||||||
| 439 | }, | ||||||||||||
| 440 | 'create_list' => | ||||||||||||
| 441 | { | ||||||||||||
| 442 | url => '/ws/page/[P:page_id]/lists/add', | ||||||||||||
| 443 | req => '<request> | ||||||||||||
| 444 | <token>[S:token]</token> | ||||||||||||
| 445 | <name>[P:title]</name> | ||||||||||||
| 446 | </request>' | ||||||||||||
| 447 | }, | ||||||||||||
| 448 | 'update_list' => | ||||||||||||
| 449 | { | ||||||||||||
| 450 | url => '/ws/page/[P:page_id]/lists/update/[P:list_id]', | ||||||||||||
| 451 | req => '<request> | ||||||||||||
| 452 | <token>[S:token]</token> | ||||||||||||
| 453 | <list> | ||||||||||||
| 454 | <name>[P:title]</name> | ||||||||||||
| 455 | </list> | ||||||||||||
| 456 | </request>' | ||||||||||||
| 457 | }, | ||||||||||||
| 458 | 'destroy_list' => | ||||||||||||
| 459 | { | ||||||||||||
| 460 | url => '/ws/page/[P:page_id]/lists/destroy/[P:list_id]', | ||||||||||||
| 461 | req => '<request> | ||||||||||||
| 462 | <token>[S:token]</token> | ||||||||||||
| 463 | </request>' | ||||||||||||
| 464 | }, | ||||||||||||
| 465 | 'create_list_item' => | ||||||||||||
| 466 | { | ||||||||||||
| 467 | url => '/ws/page/[P:page_id]/items/add?list_id=[P:list_id]', | ||||||||||||
| 468 | req => '<request> | ||||||||||||
| 469 | <token>[S:token]</token> | ||||||||||||
| 470 | <item> | ||||||||||||
| 471 | <content>[P:item]</content> | ||||||||||||
| 472 | </item> | ||||||||||||
| 473 | </request>' | ||||||||||||
| 474 | }, | ||||||||||||
| 475 | ); | ||||||||||||
| 476 | |||||||||||||
| 477 | =head1 METHODS | ||||||||||||
| 478 | |||||||||||||
| 479 | =head2 $hr = Net::ThirtySevenSignals::Highrise->new(token => $token, user => $user, [forcearray => 0], ssl => 0); | ||||||||||||
| 480 | |||||||||||||
| 481 | Creates a new Net::ThirtySevenSignals::Highrise object. All communication with the | ||||||||||||
| 482 | Highrise server is made through this object. | ||||||||||||
| 483 | |||||||||||||
| 484 | Takes two mandatory arguments, your Highrise API token and your | ||||||||||||
| 485 | Highrise username. Returns the new Net:Highrise object. | ||||||||||||
| 486 | |||||||||||||
| 487 | There is also an optional parameter, forcearray. This controls the | ||||||||||||
| 488 | value of the C<ForceArray> parameter that is used by C<XML::Simple>. The | ||||||||||||
| 489 | default value is 1. | ||||||||||||
| 490 | |||||||||||||
| 491 | If the C<ssl> parameter is provided, then communication will take | ||||||||||||
| 492 | place over SSL. This is required for Plus and Premium accounts. | ||||||||||||
| 493 | |||||||||||||
| 494 | =cut | ||||||||||||
| 495 | |||||||||||||
| 496 | 1 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=6 SCAR=32.3
Pod
documented
| |||||||||||||
| 497 | 1 | my $class = shift; | |||||||||||
| 498 | 1 | my %params = @_; | |||||||||||
| 499 | |||||||||||||
| 500 | 1 | my $self; | |||||||||||
| 501 | 1 | $self->{debug} = $params{debug}; | |||||||||||
| 502 | $self->{token} = $params{token} | ||||||||||||
| 503 | 1 | ▶ | || croak "No Highrise API token passed Net::ThirtySevenSignals::Highrise::new\n"; | ||||||||||
|
Condition50%1/2
$params{'token'} || croak("No Highrise API token passed Net::ThirtySevenSignals::Highrise::new\n")
MC/DC0%0/1
$params{'token'} || croak("No Highrise API token passed Net::ThirtySevenSignals::Highrise::new\n")
$params{'token'}
Truth table50%1/2
A
A= $params{'token'}
| |||||||||||||
| 504 | $self->{user} = $params{user} | ||||||||||||
| 505 | 0 | ▶ | || croak "No Highrise API user passed Net::ThirtySevenSignals::Highrise::new\n"; | ||||||||||
|
Condition0%0/2
$params{'user'} || croak("No Highrise API user passed Net::ThirtySevenSignals::Highrise::new\n")
MC/DC0%0/1
$params{'user'} || croak("No Highrise API user passed Net::ThirtySevenSignals::Highrise::new\n")
$params{'user'}
Truth table0%0/2
A
A= $params{'user'}
| |||||||||||||
| 506 | |||||||||||||
| 507 | 0 | ▶ | $self->{protocol} = $params{ssl} ? 'https' : 'http'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 508 | |||||||||||||
| 509 | 0 | ▶ | $self->{forcearray} = $params{forcearray} || 1; | ||||||||||
|
Condition0%0/2
$params{'forcearray'} || 1
MC/DC0%0/1
$params{'forcearray'} || 1
$params{'forcearray'}
Truth table0%0/2
A
A= $params{'forcearray'}
| |||||||||||||
| 510 | |||||||||||||
| 511 | 0 | my $ua = $self->{ua} = LWP::UserAgent->new; | |||||||||||
| 512 | |||||||||||||
| 513 | 0 | $ua->env_proxy; | |||||||||||
| 514 | 0 | $ua->default_header('X-POST-DATA-FORMAT' => 'xml'); | |||||||||||
| 515 | |||||||||||||
| 516 | 0 | $ua->credentials($self->{user} . ".highrisehq.com:443","Application", $self->{token}, 'X'); | |||||||||||
| 517 | 0 | $ua->credentials($self->{user} . ".highrisehq.com:80","Application", $self->{token}, 'X'); | |||||||||||
| 518 | 0 | ▶ | if( $self->{debug}){ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 519 | 0 | ▶ | $ua->add_handler("request_send",sub{warn(shift->dump);return }); | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 520 | 0 | ▶ | $ua->add_handler("response_done",sub{warn(shift->dump);return }); | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 521 | } | ||||||||||||
| 522 | |||||||||||||
| 523 | 0 | $self->{base_url} = "$self->{protocol}://$self->{user}.highrisehq.com"; | |||||||||||
| 524 | |||||||||||||
| 525 | 0 | return bless $self, $class; | |||||||||||
| 526 | } | ||||||||||||
| 527 | |||||||||||||
| 528 | =head2 $pages = $hr->people_list_all([xml => 1]); | ||||||||||||
| 529 | |||||||||||||
| 530 | Get a list of all of your Highrise people. Returns a Perl data structure | ||||||||||||
| 531 | unless the C<xml> parameter is true, in which case it returns the raw | ||||||||||||
| 532 | XML as returned by the Highrise server. | ||||||||||||
| 533 | |||||||||||||
| 534 | =cut | ||||||||||||
| 535 | |||||||||||||
| 536 | 0 | ▶ | sub people_list_all { | ||||||||||
|
Subroutine
people_list_all: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 537 | 0 | my $self = shift; | |||||||||||
| 538 | 0 | my %params = @_; | |||||||||||
| 539 | |||||||||||||
| 540 | 0 | my $req_data = $data{people_list_all}; | |||||||||||
| 541 | 0 | my $url = $self->{base_url} . $req_data->{url}; | |||||||||||
| 542 | |||||||||||||
| 543 | 0 | my $req = HTTP::Request->new('GET', $url); | |||||||||||
| 544 | |||||||||||||
| 545 | 0 | my $structure = $self->_call(%params, req => $req); | |||||||||||
| 546 | 0 | ▶ | return $structure if $params{xml}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 547 | 0 | return $structure->{$req_data->{return_key}}; | |||||||||||
| 548 | } | ||||||||||||
| 549 | |||||||||||||
| 550 | |||||||||||||
| 551 | |||||||||||||
| 552 | =head2 $people = $hr->people_list_by_criteria([xml => 1], city => 'Oakland',country=>'US'...); | ||||||||||||
| 553 | |||||||||||||
| 554 | Returns a collection of people that match the criteria passed | ||||||||||||
| 555 | in. Available criteria are: | ||||||||||||
| 556 | |||||||||||||
| 557 | city | ||||||||||||
| 558 | state | ||||||||||||
| 559 | country | ||||||||||||
| 560 | zip | ||||||||||||
| 561 | phone | ||||||||||||
| 562 | |||||||||||||
| 563 | |||||||||||||
| 564 | Returns an arrayref or undef | ||||||||||||
| 565 | unless the C<xml> parameter is true, in which case it returns the raw | ||||||||||||
| 566 | XML as returned by the Highrise server. | ||||||||||||
| 567 | |||||||||||||
| 568 | =cut | ||||||||||||
| 569 | |||||||||||||
| 570 | 0 | ▶ | sub people_list_by_criteria{ | ||||||||||
|
Subroutine
people_list_by_criteria: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||
| 571 | 0 | my $self = shift; | |||||||||||
| 572 | 0 | my %params = @_; | |||||||||||
| 573 | |||||||||||||
| 574 | 0 | my $req_data = $data{people_list_by_criteria}; | |||||||||||
| 575 | 0 | my $url = $self->{base_url} . $req_data->{url}; | |||||||||||
| 576 | |||||||||||||
| 577 | 0 | my $expandedURL = new URI($self->_expand($url, %params)); | |||||||||||
| 578 | 0 | my %criteria = (); | |||||||||||
| 579 | 0 | for my $key (qw(city state country zip phone email)){ | |||||||||||
| 580 | 0 | ▶ | $criteria{"criteria[$key]"} = $params{$key} if exists $params{$key}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 581 | } | ||||||||||||
| 582 | 0 | $expandedURL->query_form(%criteria); | |||||||||||
| 583 | 0 | my $req = HTTP::Request->new('GET', $expandedURL); | |||||||||||
| 584 | |||||||||||||
| 585 | 0 | my $structure = $self->_call(%params, req => $req); | |||||||||||
| 586 | 0 | ▶ | return $structure if $params{xml}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 587 | 0 | return $structure->{$req_data->{return_key}}; | |||||||||||
| 588 | } | ||||||||||||
| 589 | |||||||||||||
| 590 | |||||||||||||
| 591 | =head2 $tags = $hr->tags_list_all([xml => 1]); | ||||||||||||
| 592 | |||||||||||||
| 593 | Get a list of all of your Highrise tags. Returns a Perl data structure | ||||||||||||
| 594 | unless the C<xml> parameter is true, in which case it returns the raw | ||||||||||||
| 595 | XML as returned by the Highrise server. | ||||||||||||
| 596 | |||||||||||||
| 597 | =cut | ||||||||||||
| 598 | |||||||||||||
| 599 | 0 | ▶ | sub tags_list_all { | ||||||||||
|
Subroutine
tags_list_all: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 600 | 0 | my $self = shift; | |||||||||||
| 601 | 0 | my %params = @_; | |||||||||||
| 602 | |||||||||||||
| 603 | 0 | my $req_data = $data{tags_list_all}; | |||||||||||
| 604 | 0 | my $url = $self->{base_url} . $req_data->{url}; | |||||||||||
| 605 | |||||||||||||
| 606 | 0 | my $req = HTTP::Request->new('GET', $url); | |||||||||||
| 607 | |||||||||||||
| 608 | 0 | my $structure = $self->_call(%params, req => $req); | |||||||||||
| 609 | 0 | ▶ | return $structure if $params{xml}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 610 | 0 | return $structure->{$req_data->{return_key}}; | |||||||||||
| 611 | |||||||||||||
| 612 | } | ||||||||||||
| 613 | |||||||||||||
| 614 | =head2 $tags = $hr->tags_list_for_subject([xml => 1]); | ||||||||||||
| 615 | |||||||||||||
| 616 | Get a list of all of your Highrise tags. Returns a Perl data structure | ||||||||||||
| 617 | unless the C<xml> parameter is true, in which case it returns the raw | ||||||||||||
| 618 | XML as returned by the Highrise server. | ||||||||||||
| 619 | |||||||||||||
| 620 | =cut | ||||||||||||
| 621 | |||||||||||||
| 622 | 0 | ▶ | sub tags_list_for_subject { | ||||||||||
|
Subroutine
tags_list_for_subject: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||
| 623 | 0 | my $self = shift; | |||||||||||
| 624 | 0 | my %params = @_; | |||||||||||
| 625 | |||||||||||||
| 626 | 0 | my $req_data = $data{tags_list_for_subject}; | |||||||||||
| 627 | 0 | ▶ | if( $req_data->{required_params} ){ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 628 | 0 | for my $name (@{$req_data->{required_params}}){ | |||||||||||
| 629 | 0 | ▶ | die "missing required param $name" unless defined $params{$name}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 630 | } | ||||||||||||
| 631 | |||||||||||||
| 632 | } | ||||||||||||
| 633 | 0 | my $url = $self->{base_url} . $req_data->{url}; | |||||||||||
| 634 | 0 | my $expandedURL = $self->_expand($url, %params); | |||||||||||
| 635 | |||||||||||||
| 636 | 0 | my $req = HTTP::Request->new('GET', $expandedURL); | |||||||||||
| 637 | |||||||||||||
| 638 | 0 | my $structure = $self->_call(%params, req => $req); | |||||||||||
| 639 | 0 | ▶ | return $structure if $params{xml}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 640 | 0 | return $structure->{$req_data->{return_key}}; | |||||||||||
| 641 | } | ||||||||||||
| 642 | |||||||||||||
| 643 | |||||||||||||
| 644 | |||||||||||||
| 645 | =head2 $pages = $hr->person_get(id=> 123455, | ||||||||||||
| 646 | [xml => 1]); | ||||||||||||
| 647 | |||||||||||||
| 648 | Get a list of all of your Highrise people. Returns a Perl data structure | ||||||||||||
| 649 | unless the C<xml> parameter is true, in which case it returns the raw | ||||||||||||
| 650 | XML as returned by the Highrise server. | ||||||||||||
| 651 | |||||||||||||
| 652 | returns a $person hashref or die()s if the person does not exist; | ||||||||||||
| 653 | |||||||||||||
| 654 | =cut | ||||||||||||
| 655 | |||||||||||||
| 656 | 0 | ▶ | sub person_get { | ||||||||||
|
Subroutine
person_get: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 657 | 0 | my $self = shift; | |||||||||||
| 658 | 0 | my %params = @_; | |||||||||||
| 659 | |||||||||||||
| 660 | 0 | my $req_data = $data{person_get}; | |||||||||||
| 661 | 0 | my $url = $self->{base_url} . $req_data->{url}; | |||||||||||
| 662 | 0 | my $expandedURL = $self->_expand($url, %params); | |||||||||||
| 663 | 0 | my $req = HTTP::Request->new('GET', $expandedURL); | |||||||||||
| 664 | |||||||||||||
| 665 | 0 | return $self->_call(%params, req => $req); | |||||||||||
| 666 | } | ||||||||||||
| 667 | |||||||||||||
| 668 | |||||||||||||
| 669 | |||||||||||||
| 670 | =head2 $pages = $hr->person_create( | ||||||||||||
| 671 | [xml => 1]); | ||||||||||||
| 672 | |||||||||||||
| 673 | Create a person | ||||||||||||
| 674 | unless the C<xml> parameter is true, in which case it returns the raw | ||||||||||||
| 675 | XML as returned by the Highrise server. | ||||||||||||
| 676 | Pass in parameters with keys: | ||||||||||||
| 677 | firstName | ||||||||||||
| 678 | lastName | ||||||||||||
| 679 | companyName | ||||||||||||
| 680 | emailAddress | ||||||||||||
| 681 | emailAddress | ||||||||||||
| 682 | |||||||||||||
| 683 | =cut | ||||||||||||
| 684 | |||||||||||||
| 685 | 0 | ▶ | sub person_create { | ||||||||||
|
Subroutine
person_create: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 686 | 0 | my $self = shift; | |||||||||||
| 687 | 0 | my %params = @_; | |||||||||||
| 688 | |||||||||||||
| 689 | 0 | my $req_data = $data{person_create}; | |||||||||||
| 690 | 0 | my $url = $self->{base_url} . $req_data->{url}; | |||||||||||
| 691 | 0 | my $expandedURL = $self->_expand($url, %params); | |||||||||||
| 692 | 0 | ▶ | warn "url = $url, expanded = $expandedURL" if $self->{debug}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 693 | 0 | my $req = HTTP::Request->new('POST', $expandedURL); | |||||||||||
| 694 | 0 | my %encodedParams = (); | |||||||||||
| 695 | 0 | ▶ | while (my ($key, $value) = each %params){ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 696 | 0 | $value =~ s/&/&/g; | |||||||||||
| 697 | 0 | $value =~ s/</</g; | |||||||||||
| 698 | 0 | $value =~ s/>/>/g; | |||||||||||
| 699 | 0 | $encodedParams{$key} = $value; | |||||||||||
| 700 | } | ||||||||||||
| 701 | 0 | $req->content($self->_expand($req_data->{req}, %encodedParams)); | |||||||||||
| 702 | |||||||||||||
| 703 | 0 | return $self->_call(%params, req => $req); | |||||||||||
| 704 | } | ||||||||||||
| 705 | |||||||||||||
| 706 | |||||||||||||
| 707 | =head2 $pages = $hr->tag_add( $subject, $subjectType, $tagName ); | ||||||||||||
| 708 | |||||||||||||
| 709 | add a tag to an item. | ||||||||||||
| 710 | $subject should be a perl structure returned from one of person_get, company_get etc. | ||||||||||||
| 711 | $subjectType should be one of | ||||||||||||
| 712 | people | ||||||||||||
| 713 | |||||||||||||
| 714 | =cut | ||||||||||||
| 715 | |||||||||||||
| 716 | 0 | ▶ | sub tag_add { | ||||||||||
|
Subroutine
tag_add: not called CC=2 SCAR=15.1
Pod
documented
| |||||||||||||
| 717 | 0 | my $self = shift; | |||||||||||
| 718 | 0 | my ($subject, $subjectType, $tagName ) = @_; | |||||||||||
| 719 | |||||||||||||
| 720 | 0 | my $req_data = $data{tag_add}; | |||||||||||
| 721 | 2 | ▶ | use Data::Dumper; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 722 | 0 | warn "tag add. Subject = ".Dumper($subject); | |||||||||||
| 723 | my %params = ( subjectType => $subjectType, | ||||||||||||
| 724 | tagName => $tagName, | ||||||||||||
| 725 | subjectID => $subject->{id}[0]{content}, | ||||||||||||
| 726 | 0 | ); | |||||||||||
| 727 | 0 | my $url = $self->{base_url} . $req_data->{url}; | |||||||||||
| 728 | |||||||||||||
| 729 | 0 | my $expandedURL = $self->_expand($url, %params); | |||||||||||
| 730 | 0 | my $req = HTTP::Request->new('POST', $expandedURL); | |||||||||||
| 731 | 0 | my %encodedParams = (); | |||||||||||
| 732 | 0 | ▶ | while (my ($key, $value) = each %params){ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 733 | 0 | $value =~ s/&/&/g; | |||||||||||
| 734 | 0 | $value =~ s/</</g; | |||||||||||
| 735 | 0 | $value =~ s/>/>/g; | |||||||||||
| 736 | 0 | $encodedParams{$key} = $value; | |||||||||||
| 737 | } | ||||||||||||
| 738 | 0 | $req->content($self->_expand($req_data->{req}, %encodedParams)); | |||||||||||
| 739 | |||||||||||||
| 740 | 0 | return $self->_call(%params, req => $req); | |||||||||||
| 741 | } | ||||||||||||
| 742 | |||||||||||||
| 743 | |||||||||||||
| 744 | =head2 $pages = $hr->person_destroy(); | ||||||||||||
| 745 | |||||||||||||
| 746 | Destroy a person. either returns undef or die()s. | ||||||||||||
| 747 | |||||||||||||
| 748 | Pass in parameters with keys: | ||||||||||||
| 749 | id => the personid to be destroyed | ||||||||||||
| 750 | =cut | ||||||||||||
| 751 | |||||||||||||
| 752 | 0 | ▶ | sub person_destroy { | ||||||||||
|
Subroutine
person_destroy: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 753 | 0 | my $self = shift; | |||||||||||
| 754 | 0 | my %params = @_; | |||||||||||
| 755 | |||||||||||||
| 756 | 0 | my $req_data = $data{person_destroy}; | |||||||||||
| 757 | 0 | my $url = $self->{base_url} . $req_data->{url}; | |||||||||||
| 758 | 0 | my $expandedURL = $self->_expand($url, %params); | |||||||||||
| 759 | 0 | my $req = HTTP::Request->new($req_data->{method}, $expandedURL); | |||||||||||
| 760 | |||||||||||||
| 761 | 0 | ▶ | if( $req_data->{req}){ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 762 | 0 | my %encodedParams = (); | |||||||||||
| 763 | 0 | ▶ | while (my ($key, $value) = each %params){ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 764 | 0 | $value =~ s/&/&/g; | |||||||||||
| 765 | 0 | $value =~ s/</</g; | |||||||||||
| 766 | 0 | $value =~ s/>/>/g; | |||||||||||
| 767 | 0 | $encodedParams{$key} = $value; | |||||||||||
| 768 | } | ||||||||||||
| 769 | 0 | $req->content($self->_expand($req_data->{req}, %encodedParams)); | |||||||||||
| 770 | } | ||||||||||||
| 771 | |||||||||||||
| 772 | 0 | $self->_call(%params, req => $req, xml=>1); | |||||||||||
| 773 | 0 | return ; | |||||||||||
| 774 | } | ||||||||||||
| 775 | |||||||||||||
| 776 | =head2 $page = $hr->create_page(title => $title, | ||||||||||||
| 777 | [description => $desc, xml => 1]); | ||||||||||||
| 778 | |||||||||||||
| 779 | Create a new Highrise page with the given title and (optional) | ||||||||||||
| 780 | description. Returns a Perl data structure unless the C<xml> parameter is | ||||||||||||
| 781 | true, in which case it returns the raw XML as returned by the Highrise server. | ||||||||||||
| 782 | |||||||||||||
| 783 | =cut | ||||||||||||
| 784 | |||||||||||||
| 785 | 0 | ▶ | sub _call { | ||||||||||
|
Subroutine
_call: not called CC=4 SCAR=30.0
| |||||||||||||
| 786 | 0 | my $self = shift; | |||||||||||
| 787 | 0 | my %params = @_; | |||||||||||
| 788 | |||||||||||||
| 789 | 0 | my $resp = $self->{ua}->request($params{req}); | |||||||||||
| 790 | 0 | ▶ | unless( $resp->is_success){ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 791 | 0 | die "Request Failed: ".$resp->status_line."\t".$resp->content; | |||||||||||
| 792 | } | ||||||||||||
| 793 | 0 | my $xml = $resp->content; | |||||||||||
| 794 | 0 | ▶ | if( $self->{debug}){ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 795 | 0 | print "received xml: $xml\n"; | |||||||||||
| 796 | } | ||||||||||||
| 797 | |||||||||||||
| 798 | 0 | ▶ | if ($params{xml}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 799 | 0 | return $xml; | |||||||||||
| 800 | } else { | ||||||||||||
| 801 | 0 | my $data = XMLin($xml, ForceArray => $self->{forcearray}); | |||||||||||
| 802 | 0 | return $data; | |||||||||||
| 803 | } | ||||||||||||
| 804 | } | ||||||||||||
| 805 | |||||||||||||
| 806 | 0 | ▶ | sub _expand { | ||||||||||
|
Subroutine
_expand: not called CC=2 SCAR=17.9
| |||||||||||||
| 807 | 0 | my $self = shift; | |||||||||||
| 808 | 0 | my $string = shift; | |||||||||||
| 809 | 0 | my %params = @_; | |||||||||||
| 810 | 0 | my $startTag = qr"\Q[%\E"; | |||||||||||
| 811 | 0 | my $endTag = "%]"; | |||||||||||
| 812 | 0 | $string =~ s{ $startTag \s* IF \s* P:(\w+) \s* $endTag | |||||||||||
| 813 | (.+?) | ||||||||||||
| 814 | $startTag \s* END \s* $endTag | ||||||||||||
| 815 | } { | ||||||||||||
| 816 | 0 | my ($condParam, $ifClause ) = ($1,$2); | |||||||||||
| 817 | 0 | ▶ | if( $params{$1} ){ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 818 | 0 | $2; | |||||||||||
| 819 | } | ||||||||||||
| 820 | else{ | ||||||||||||
| 821 | 0 | ''; | |||||||||||
| 822 | } | ||||||||||||
| 823 | }sexg; | ||||||||||||
| 824 | |||||||||||||
| 825 | 0 | $string =~ s/\[S:(\w+)]/$self->{$1}/g; | |||||||||||
| 826 | 0 | $string =~ s/\[P:(\w+)]/$params{$1}/g; | |||||||||||
| 827 | # warn "expanded is $string\n"; | ||||||||||||
| 828 | 0 | return $string; | |||||||||||
| 829 | } | ||||||||||||
| 830 | |||||||||||||
| 831 | |||||||||||||
| 832 | |||||||||||||
| 833 | |||||||||||||
| 834 | =head2 $url = $hr->person_url($personHash); | ||||||||||||
| 835 | |||||||||||||
| 836 | Create an URL pointing at a person page. | ||||||||||||
| 837 | |||||||||||||
| 838 | =cut | ||||||||||||
| 839 | |||||||||||||
| 840 | 0 | ▶ | sub person_url{ | ||||||||||
|
Subroutine
person_url: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 841 | 0 | my $self = shift; | |||||||||||
| 842 | 0 | my ($person) = @_; | |||||||||||
| 843 | 0 | return sprintf ("http://%s.highrisehq.com/people/%d", $self->{user}, $person->{id}->[0]->{content}); | |||||||||||
| 844 | } | ||||||||||||
| 845 | |||||||||||||
| 846 | |||||||||||||
| 847 | |||||||||||||
| 848 | |||||||||||||
| 849 | =head1 TO DO | ||||||||||||
| 850 | |||||||||||||
| 851 | =over 4 | ||||||||||||
| 852 | |||||||||||||
| 853 | =item * | ||||||||||||
| 854 | |||||||||||||
| 855 | Improve documentation (I know, it's shameful) | ||||||||||||
| 856 | |||||||||||||
| 857 | =item * | ||||||||||||
| 858 | |||||||||||||
| 859 | More tests | ||||||||||||
| 860 | |||||||||||||
| 861 | =back | ||||||||||||
| 862 | |||||||||||||
| 863 | =head1 AUTHOR | ||||||||||||
| 864 | |||||||||||||
| 865 | Danny Sadinoff E<lt>danny@sadinoff.comE<gt> | ||||||||||||
| 866 | |||||||||||||
| 867 | derived directly from Dave Cross's Net::Backpack | ||||||||||||
| 868 | |||||||||||||
| 869 | Please feel free to email me to tell me how you are using the module. | ||||||||||||
| 870 | |||||||||||||
| 871 | =head1 BUGS | ||||||||||||
| 872 | |||||||||||||
| 873 | the API is incomplete, to say the least. | ||||||||||||
| 874 | |||||||||||||
| 875 | Please report bugs by email to danny@sadinoff.com | ||||||||||||
| 876 | |||||||||||||
| 877 | =head1 LICENSE AND COPYRIGHT | ||||||||||||
| 878 | |||||||||||||
| 879 | Copyright (c) 2005,2010, Dave Cross, Danny Sadinoff. All Rights Reserved. | ||||||||||||
| 880 | |||||||||||||
| 881 | This script is free software; you can redistribute it and/or | ||||||||||||
| 882 | modify it under the same terms as Perl itself. | ||||||||||||
| 883 | |||||||||||||
| 884 | =head1 SEE ALSO | ||||||||||||
| 885 | |||||||||||||
| 886 | L<perl>, L<http://developer.37signals.com/highrise/> | ||||||||||||
| 887 | |||||||||||||
| 888 | =cut | ||||||||||||
| 889 | |||||||||||||
| 890 | |||||||||||||
| 891 | |||||||||||||
| 892 | 2 | 1; | |||||||||||
| 893 | __END__ | ||||||||||||