| 1 | package WebService::SyoboiCalendar; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use 5.008_001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | our $VERSION = '0.02'; | |||||||||
| 7 | 2 | $VERSION = eval $VERSION; | |||||||||
| 8 | |||||||||||
| 9 | 2 | ▶ | use Smart::Args; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use WebService::SyoboiCalendar::API; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | ▶ | use WebService::SyoboiCalendar::API::Result; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 2 | has user => (is => 'rw'); | |||||||||
| 14 | 2 | has pass => (is => 'rw'); | |||||||||
| 15 | |||||||||||
| 16 | has api => ( | ||||||||||
| 17 | is => 'ro', | ||||||||||
| 18 | 5 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 5 | my $self = shift; | |||||||||
| 20 | 5 | WebService::SyoboiCalendar::API->new( | |||||||||
| 21 | user => $self->user, | ||||||||||
| 22 | pass => $self->pass, | ||||||||||
| 23 | ); | ||||||||||
| 24 | }, | ||||||||||
| 25 | 2 | ); | |||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | sub current { | ||||||||
|
Subroutine
current: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 28 | 0 | args my $self; | |||||||||
| 29 | 0 | my $results = $self->timetable; | |||||||||
| 30 | 0 | ▶ | return unless $results; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | $results->[0]; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 1 | ▶ | sub title { | ||||||||
|
Subroutine
title: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 35 | 1 | args_pos my $self, my $tid; | |||||||||
| 36 | 1 | WebService::SyoboiCalendar::API::Result->new( | |||||||||
| 37 | api => $self->api, | ||||||||||
| 38 | result => { TID => $tid }, | ||||||||||
| 39 | )->title; | ||||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 1 | ▶ | sub program { | ||||||||
|
Subroutine
program: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 43 | 1 | args_pos my $self, my $pid; | |||||||||
| 44 | 1 | WebService::SyoboiCalendar::API::Result->new( | |||||||||
| 45 | api => $self->api, | ||||||||||
| 46 | result => { PID => $pid }, | ||||||||||
| 47 | )->program; | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 1 | ▶ | sub timetable { | ||||||||
|
Subroutine
timetable: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 51 | 1 | args_pos my $self, my $args => { optional => 1, default => {} } ; | |||||||||
| 52 | |||||||||||
| 53 | [ $self->_map_to_results(@{ | ||||||||||
| 54 | 1 | $self->api->rss2({ %$args, })->{items} | |||||||||
| 55 | 1 | }) ]; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 1 | ▶ | sub search_tiny { | ||||||||
|
Subroutine
search_tiny: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 59 | 1 | args_pos my $self, my $title; | |||||||||
| 60 | |||||||||||
| 61 | my $titles = $self->api->json({ | ||||||||||
| 62 | req => 'TitleSearch', | ||||||||||
| 63 | search => $title, | ||||||||||
| 64 | limit => 15, | ||||||||||
| 65 | 1 | })->{Titles}; | |||||||||
| 66 | |||||||||||
| 67 | 1 | [ $self->_map_to_results(map { $titles->{$_} } sort { $b <=> $a } keys(%$titles)) ]; | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 0 | ▶ | sub search_title { | ||||||||
|
Subroutine
search_title: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 71 | 0 | my ($self, $args) = @_; | |||||||||
| 72 | |||||||||||
| 73 | 0 | [ $self->_map_to_results( @{ $self->api->search({ | |||||||||
| 74 | mode => 'title', | ||||||||||
| 75 | %$args | ||||||||||
| 76 | })}) ]; | ||||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | 0 | ▶ | sub search_program { | ||||||||
|
Subroutine
search_program: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 80 | 0 | my ($self, $args) = @_; | |||||||||
| 81 | |||||||||||
| 82 | 0 | [ $self->_map_to_results( @{ $self->api->search({ | |||||||||
| 83 | mode => 'program', | ||||||||||
| 84 | %$args | ||||||||||
| 85 | })}) ]; | ||||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | 2 | ▶ | sub _map_to_results { | ||||||||
|
Subroutine
_map_to_results: called CC=1 SCAR=0.0
| |||||||||||
| 89 | 2 | my ($self, @results) = @_; | |||||||||
| 90 | |||||||||||
| 91 | map { | ||||||||||
| 92 | 2 | WebService::SyoboiCalendar::API::Result->new( | |||||||||
| 93 | api => $self->api, | ||||||||||
| 94 | result => $_, | ||||||||||
| 95 | ) | ||||||||||
| 96 | } @results; | ||||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | 2 | 1; | |||||||||
| 100 | |||||||||||
| 101 | __END__ | ||||||||||