| 1 | package Net::UP::Notify; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use vars qw($VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use LWP::UserAgent; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | 1 | $VERSION = '1.01'; | |||||||||
| 9 | |||||||||||
| 10 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 11 | 0 | my $package = shift; | |||||||||
| 12 | 0 | return bless({}, $package); | |||||||||
| 13 | }; | ||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub subscriberid { | ||||||||
|
Subroutine
subscriberid: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 16 | 0 | my $self = shift; | |||||||||
| 17 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 0 | $self->{'subscriberid'} = shift; | |||||||||
| 19 | 0 | ($self->{'connecthost'}) = ( $self->{'subscriberid'} =~ /\_(.+)/ ); | |||||||||
| 20 | }; | ||||||||||
| 21 | 0 | return $self->{'subscriberid'}; | |||||||||
| 22 | }; | ||||||||||
| 23 | |||||||||||
| 24 | 0 | ▶ | sub location { | ||||||||
|
Subroutine
location: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 25 | 0 | my $self = shift; | |||||||||
| 26 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 0 | $self->{'location'} = shift; | |||||||||
| 28 | }; | ||||||||||
| 29 | 0 | return $self->{'location'}; | |||||||||
| 30 | }; | ||||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | sub description { | ||||||||
|
Subroutine
description: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 33 | 0 | my $self = shift; | |||||||||
| 34 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | $self->{'description'} = shift; | |||||||||
| 36 | }; | ||||||||||
| 37 | 0 | return $self->{'description'}; | |||||||||
| 38 | }; | ||||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | sub urgency { | ||||||||
|
Subroutine
urgency: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 41 | 0 | my $self = shift; | |||||||||
| 42 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | $self->{'urgency'} = shift; | |||||||||
| 44 | }; | ||||||||||
| 45 | 0 | return $self->{'urgency'}; | |||||||||
| 46 | }; | ||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub send { | ||||||||
|
Subroutine
send: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 51 | 0 | my $self = shift; | |||||||||
| 52 | 0 | ▶ | if (! $self->{'urgency'}) { $self->{'urgency'} = "HIGH" }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | 0 | my $ua = LWP::UserAgent->new; | |||||||||
| 54 | 0 | $ua->agent("up-notify.pl/1.0"); | |||||||||
| 55 | 0 | my $req = HTTP::Request->new(POST => 'http://'.$self->{'connecthost'}.':4445/ntfn/add'); | |||||||||
| 56 | 0 | $req->header("x-up-upnotifyp-version" => "upnotifyp/3.0"); | |||||||||
| 57 | 0 | $req->header("x-up-subno" => "$self->{'subscriberid'}"); | |||||||||
| 58 | 0 | $req->header("x-up-ntfn-ttl" => "0"); | |||||||||
| 59 | 0 | $req->header("x-up-ntfn-channel" => "push"); | |||||||||
| 60 | 0 | $req->header("Content-Location" => "$self->{'location'}"); | |||||||||
| 61 | 0 | my $xmldoc= "<?xml version=\"1.0\"?> \n<!DOCTYPE ALERT \nPUBLIC \"-//PHONE.COM//DTD ALERT 1.0//EN\" \n\"http://www.phone.com/dtd/alert1.xml\"> \n<ALERT LABEL = \"$self->{'description'}\" \nCOUNT = \"1\" \nHREF = \"\" \nURGENCY = \"$self->{'urgency'}\" />\n"; | |||||||||
| 62 | 0 | $req->content_type('application/vnd.uplanet.alert'); | |||||||||
| 63 | 0 | $req->content($xmldoc); | |||||||||
| 64 | 0 | my $res = $ua->request($req); | |||||||||
| 65 | 0 | my $toreturn; | |||||||||
| 66 | 0 | return $res->content; | |||||||||
| 67 | }; | ||||||||||
| 68 | |||||||||||
| 69 | 1 | 1; | |||||||||
| 70 | __END__ | ||||||||||