| 1 | package RPC::ExtDirect::Demo::Profile; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use RPC::ExtDirect Action => 'Profile'; | ||
| 7 | |||
| 8 | sub updateBasicInfo : ExtDirect(formHandler) { | ||
| 9 | my ($class, %fields) = @_; | ||
| 10 | |||
| 11 | if ( $fields{email} eq 'aaron@sencha.com' ) { | ||
| 12 | return { | ||
| 13 | success => \0, # Shortcut for JSON::false | ||
| 14 | errors => { email => 'already taken' }, | ||
| 15 | debug_formPacket => \%fields, | ||
| 16 | }; | ||
| 17 | } | ||
| 18 | else { | ||
| 19 | return { | ||
| 20 | success => \1, # Shortcut for JSON::true | ||
| 21 | debug_formPacket => \%fields | ||
| 22 | }; | ||
| 23 | }; | ||
| 24 | } | ||
| 25 | |||
| 26 | sub getBasicInfo : ExtDirect(2) { | ||
| 27 | my ($class, $userId, $foo) = @_; | ||
| 28 | |||
| 29 | return { | ||
| 30 | success => \1, | ||
| 31 | data => { | ||
| 32 | foo => $foo, | ||
| 33 | name => 'Aaron Conran', | ||
| 34 | company => 'Sencha Inc.', | ||
| 35 | email => 'aaron@sencha.com', | ||
| 36 | }, | ||
| 37 | }; | ||
| 38 | } | ||
| 39 | |||
| 40 | sub getPhoneInfo : ExtDirect(1) { | ||
| 41 | my ($class, $userId) = @_; | ||
| 42 | |||
| 43 | return { | ||
| 44 | success => \1, | ||
| 45 | data => { | ||
| 46 | cell => '443-555-1234', | ||
| 47 | office => '1-800-CALLEXT', | ||
| 48 | home => '', | ||
| 49 | }, | ||
| 50 | }; | ||
| 51 | } | ||
| 52 | |||
| 53 | sub getLocationInfo : ExtDirect(1) { | ||
| 54 | my ($class, $userId) = @_; | ||
| 55 | |||
| 56 | return { | ||
| 57 | success => \1, | ||
| 58 | data => { | ||
| 59 | street => '1234 Red Dog Rd.', | ||
| 60 | city => 'Seminole', | ||
| 61 | state => 'FL', | ||
| 62 | zip => 33776, | ||
| 63 | }, | ||
| 64 | }; | ||
| 65 | } | ||
| 66 | |||
| 67 | 1; | ||
| 68 | |||
| 69 | =pod | ||
| 70 | |||
| 71 | =head1 NAME | ||
| 72 | |||
| 73 | RPC::ExtDirect::Demo::Profile - Part of Ext.Direct interface demo | ||
| 74 | |||
| 75 | =head1 DESCRIPTION | ||
| 76 | |||
| 77 | This module implements Profile class used in ExtJS Ext.Direct demo | ||
| 78 | scripts; it is not intended to be used per se but rather as an example. | ||
| 79 | |||
| 80 | I decided to keep it in the installation tree so that it will always | ||
| 81 | be available to look up without going to CPAN. | ||
| 82 | |||
| 83 | =head1 SEE ALSO | ||
| 84 | |||
| 85 | You can use C<perldoc -m RPC::ExtDirect::Demo::Profile> to see the actual | ||
| 86 | code. | ||
| 87 | |||
| 88 | =head1 AUTHOR | ||
| 89 | |||
| 90 | Alexander Tokarev E<lt>tokarev@cpan.orgE<gt> | ||
| 91 | |||
| 92 | =head1 LICENSE AND COPYRIGHT | ||
| 93 | |||
| 94 | Copyright (c) 2011-2016 by Alexander Tokarev. | ||
| 95 | |||
| 96 | This module is free software; you can redistribute it and/or modify it under | ||
| 97 | the same terms as Perl itself. See L<perlartistic>. | ||
| 98 | |||
| 99 | =cut | ||
| 100 |