| 1 | package Jaipo::Service; | ||
| 2 | use warnings; | ||
| 3 | use strict; | ||
| 4 | use base qw/Class::Accessor::Fast/; | ||
| 5 | __PACKAGE__->mk_accessors (qw/core options trigger_name sp_id/); | ||
| 6 | |||
| 7 | |||
| 8 | =head1 FUNCTIONS | ||
| 9 | |||
| 10 | =head2 new | ||
| 11 | |||
| 12 | =cut | ||
| 13 | |||
| 14 | sub new { | ||
| 15 | my $class = shift; | ||
| 16 | my %options = @_; | ||
| 17 | |||
| 18 | my $self = {}; | ||
| 19 | bless $self , $class; | ||
| 20 | |||
| 21 | $self->trigger_name( $options{trigger_name} ); | ||
| 22 | $self->sp_id( $options{sp_id} ); | ||
| 23 | $self->options( \%options ); | ||
| 24 | |||
| 25 | return $self; | ||
| 26 | } | ||
| 27 | |||
| 28 | =head2 init | ||
| 29 | |||
| 30 | =cut | ||
| 31 | |||
| 32 | sub init { | ||
| 33 | my $self = shift; | ||
| 34 | |||
| 35 | } | ||
| 36 | |||
| 37 | |||
| 38 | =head2 new_request | ||
| 39 | |||
| 40 | called right before every request | ||
| 41 | |||
| 42 | =cut | ||
| 43 | |||
| 44 | sub new_request { | ||
| 45 | my $self = shift; | ||
| 46 | |||
| 47 | } | ||
| 48 | |||
| 49 | |||
| 50 | sub dispatch_sub_command { | ||
| 51 | my ($self, $sub_command, $rest ) = @_; | ||
| 52 | |||
| 53 | # service | ||
| 54 | my $builtin_command = { | ||
| 55 | m => 'read_user_timeline', | ||
| 56 | p => 'read_public_timeline', | ||
| 57 | g => 'read_global_timeline', | ||
| 58 | '?' => 'help', | ||
| 59 | }; | ||
| 60 | |||
| 61 | if( defined $builtin_command->{ $sub_command } ) { | ||
| 62 | my $func = $builtin_command->{ $sub_command }; | ||
| 63 | $self->$func( $rest ); | ||
| 64 | } | ||
| 65 | |||
| 66 | # todo: otherwise we dispatch to service specific command | ||
| 67 | } | ||
| 68 | |||
| 69 | |||
| 70 | |||
| 71 | |||
| 72 | =head2 prereq_plugins | ||
| 73 | |||
| 74 | Returns an array of plugin module names that this plugin depends on. | ||
| 75 | |||
| 76 | =cut | ||
| 77 | |||
| 78 | sub prereq_plugins { | ||
| 79 | return (); | ||
| 80 | } | ||
| 81 | |||
| 82 | |||
| 83 | =head1 SERVICE METHODS | ||
| 84 | |||
| 85 | =head2 send_msg | ||
| 86 | |||
| 87 | =cut | ||
| 88 | |||
| 89 | sub send_msg { | ||
| 90 | |||
| 91 | } | ||
| 92 | |||
| 93 | =head2 set_location | ||
| 94 | |||
| 95 | =cut | ||
| 96 | |||
| 97 | sub set_location { | ||
| 98 | |||
| 99 | } | ||
| 100 | |||
| 101 | =head2 read_user_timeline | ||
| 102 | |||
| 103 | updates from user him self | ||
| 104 | |||
| 105 | =cut | ||
| 106 | |||
| 107 | sub read_user_timeline { | ||
| 108 | |||
| 109 | } | ||
| 110 | |||
| 111 | =head2 read_public_timeline | ||
| 112 | |||
| 113 | updates from users friends or follows | ||
| 114 | |||
| 115 | =cut | ||
| 116 | |||
| 117 | sub read_public_timeline { | ||
| 118 | |||
| 119 | } | ||
| 120 | |||
| 121 | =head2 read_global_timeline | ||
| 122 | |||
| 123 | global timeline ( out of space !! ) | ||
| 124 | |||
| 125 | =cut | ||
| 126 | |||
| 127 | sub read_global_timeline { | ||
| 128 | |||
| 129 | } | ||
| 130 | |||
| 131 | |||
| 132 | =head1 FILTER_METHODS | ||
| 133 | |||
| 134 | =head2 create_filter | ||
| 135 | |||
| 136 | =cut | ||
| 137 | |||
| 138 | sub create_filter { | ||
| 139 | |||
| 140 | } | ||
| 141 | |||
| 142 | =head2 apply_filter | ||
| 143 | |||
| 144 | =cut | ||
| 145 | |||
| 146 | sub apply_filter { | ||
| 147 | |||
| 148 | } | ||
| 149 | |||
| 150 | =head2 remove_filter | ||
| 151 | |||
| 152 | =cut | ||
| 153 | |||
| 154 | sub remove_filter { | ||
| 155 | |||
| 156 | } | ||
| 157 | |||
| 158 | |||
| 159 | |||
| 160 | |||
| 161 | 1; | ||
| 162 |