File Coverage

blib/lib/WebService/TypePad/Object.pm
Criterion Covered Total %
statement 24 24 100.0
branch 3 4 75.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 33 35 94.2


line stmt bran cond sub pod time code
1             package WebService::TypePad::Object;
2 3     3   498 use strict;
  3         6  
  3         114  
3 3     3   15 use warnings;
  3         5  
  3         96  
4 3     3   2594 use fields qw(last_known_etag data);
  3         4544  
  3         15  
5             our %Object_Types = (
6             'Application' => 'WebService::TypePad::Object::Application',
7             'Asset' => 'WebService::TypePad::Object::Asset',
8             'AssetRef' => 'WebService::TypePad::Object::AssetRef',
9             'AssetSource' => 'WebService::TypePad::Object::AssetSource',
10             'Audio' => 'WebService::TypePad::Object::Audio',
11             'AudioLink' => 'WebService::TypePad::Object::AudioLink',
12             'Base' => 'WebService::TypePad::Object::Base',
13             'Blog' => 'WebService::TypePad::Object::Blog',
14             'Comment' => 'WebService::TypePad::Object::Comment',
15             'Endpoint' => 'WebService::TypePad::Object::Endpoint',
16             'Entity' => 'WebService::TypePad::Object::Entity',
17             'Event' => 'WebService::TypePad::Object::Event',
18             'Favorite' => 'WebService::TypePad::Object::Favorite',
19             'Group' => 'WebService::TypePad::Object::Group',
20             'ImageLink' => 'WebService::TypePad::Object::ImageLink',
21             'LegacyHyperlink' => 'WebService::TypePad::Object::LegacyHyperlink',
22             'Link' => 'WebService::TypePad::Object::Link',
23             'MobileProfile' => 'WebService::TypePad::Object::MobileProfile',
24             'ObjectProperty' => 'WebService::TypePad::Object::ObjectProperty',
25             'ObjectType' => 'WebService::TypePad::Object::ObjectType',
26             'Page' => 'WebService::TypePad::Object::Page',
27             'Photo' => 'WebService::TypePad::Object::Photo',
28             'Post' => 'WebService::TypePad::Object::Post',
29             'Relationship' => 'WebService::TypePad::Object::Relationship',
30             'RelationshipStatus' => 'WebService::TypePad::Object::RelationshipStatus',
31             'User' => 'WebService::TypePad::Object::User',
32             'UserProfile' => 'WebService::TypePad::Object::UserProfile',
33             'Video' => 'WebService::TypePad::Object::Video',
34             'VideoLink' => 'WebService::TypePad::Object::VideoLink',
35             );
36             our %Object_Type_Classes_By_Uri = (
37             'tag:api.typepad.com,2009:Application' => 'WebService::TypePad::Object::Application',
38             'tag:api.typepad.com,2009:Asset' => 'WebService::TypePad::Object::Asset',
39             'tag:api.typepad.com,2009:AssetRef' => 'WebService::TypePad::Object::AssetRef',
40             'tag:api.typepad.com,2009:AssetSource' => 'WebService::TypePad::Object::AssetSource',
41             'tag:api.typepad.com,2009:Audio' => 'WebService::TypePad::Object::Audio',
42             'tag:api.typepad.com,2009:AudioLink' => 'WebService::TypePad::Object::AudioLink',
43             'tag:api.typepad.com,2009:Base' => 'WebService::TypePad::Object::Base',
44             'tag:api.typepad.com,2009:Blog' => 'WebService::TypePad::Object::Blog',
45             'tag:api.typepad.com,2009:Comment' => 'WebService::TypePad::Object::Comment',
46             'tag:api.typepad.com,2009:Endpoint' => 'WebService::TypePad::Object::Endpoint',
47             'tag:api.typepad.com,2009:Entity' => 'WebService::TypePad::Object::Entity',
48             'tag:api.typepad.com,2009:Event' => 'WebService::TypePad::Object::Event',
49             'tag:api.typepad.com,2009:Favorite' => 'WebService::TypePad::Object::Favorite',
50             'tag:api.typepad.com,2009:Group' => 'WebService::TypePad::Object::Group',
51             'tag:api.typepad.com,2009:ImageLink' => 'WebService::TypePad::Object::ImageLink',
52             'tag:api.typepad.com,2009:LegacyHyperlink' => 'WebService::TypePad::Object::LegacyHyperlink',
53             'tag:api.typepad.com,2009:Link' => 'WebService::TypePad::Object::Link',
54             'tag:api.typepad.com,2009:MobileProfile' => 'WebService::TypePad::Object::MobileProfile',
55             'tag:api.typepad.com,2009:ObjectProperty' => 'WebService::TypePad::Object::ObjectProperty',
56             'tag:api.typepad.com,2009:ObjectType' => 'WebService::TypePad::Object::ObjectType',
57             'tag:api.typepad.com,2009:Page' => 'WebService::TypePad::Object::Page',
58             'tag:api.typepad.com,2009:Photo' => 'WebService::TypePad::Object::Photo',
59             'tag:api.typepad.com,2009:Post' => 'WebService::TypePad::Object::Post',
60             'tag:api.typepad.com,2009:Relationship' => 'WebService::TypePad::Object::Relationship',
61             'tag:api.typepad.com,2009:RelationshipStatus' => 'WebService::TypePad::Object::RelationshipStatus',
62             'tag:api.typepad.com,2009:User' => 'WebService::TypePad::Object::User',
63             'tag:api.typepad.com,2009:UserProfile' => 'WebService::TypePad::Object::UserProfile',
64             'tag:api.typepad.com,2009:Video' => 'WebService::TypePad::Object::Video',
65             'tag:api.typepad.com,2009:VideoLink' => 'WebService::TypePad::Object::VideoLink',
66             );
67             sub new {
68 3     3 0 543 my ($class, %params) = @_;
69 3         12 my $self = fields::new($class);
70 3         5545 $self->{data} = {};
71 3         9 map { $self->$_($params{$_}) } keys %params;
  1         6  
72 3         8 return $self;}
73             sub _from_json_dictionary {
74 2     2   5 my ($class, $dict) = @_;
75 2 100       10 if (my $object_types = $dict->{objectTypes}) {
76 1         3 foreach my $type_uri (@$object_types) {
77 1 50       6 if (my $class_name = $Object_Type_Classes_By_Uri{$type_uri}) {
78 1         4 $class = $class_name;
79             }
80             }
81             }
82 2         23 my $self = $class->new();
83 2         6 $self->{data} = $dict;
84 2         12 return $self;}
85             sub _as_json_dictionary {
86 1     1   5 return $_[0]->{data};
87             }
88             1;
89              
90             =head1 NAME
91              
92             WebService::TypePad::Object - Base class for our local representations of TypePad's object types
93              
94             =head1 SYNOPSIS
95              
96             # Create a new "user" object
97             use TypePad::API::Object::User;
98             my $user = TypePad::API::Object::User->new();
99              
100             =head1 AVAILABLE OBJECT TYPES
101              
102             =over 1
103              
104             =item * L
105              
106             =item * L
107              
108             =item * L
109              
110             =item * L
111              
112             =item * L
113              
114             =item * L
115              
116             =item * L
117              
118             =item * L
119              
120             =item * L
121              
122             =item * L
123              
124             =item * L
125              
126             =item * L
127              
128             =item * L
129              
130             =item * L
131              
132             =item * L
133              
134             =item * L
135              
136             =item * L
137              
138             =item * L
139              
140             =item * L
141              
142             =item * L
143              
144             =item * L
145              
146             =item * L
147              
148             =item * L
149              
150             =item * L
151              
152             =item * L
153              
154             =item * L
155              
156             =item * L
157              
158             =item * L
159              
160             =item * L
161              
162             =back