File Coverage

blib/lib/WebService/TogetherWeRemember.pm
Criterion Covered Total %
statement 17 29 58.6
branch 0 4 0.0
condition n/a
subroutine 6 7 85.7
pod 0 1 0.0
total 23 41 56.1


line stmt bran cond sub pod time code
1             package WebService::TogetherWeRemember;
2              
3 1     1   124725 use 5.006;
  1         11  
4 1     1   8 use strict;
  1         2  
  1         49  
5 1     1   7 use warnings;
  1         4  
  1         138  
6              
7             our $VERSION = '0.03';
8              
9 1     1   982 use Moo;
  1         11626  
  1         6  
10 1     1   3137 use LWP::UserAgent;
  1         78897  
  1         40  
11 1     1   418 use HTTP::CookieJar::LWP;
  1         35072  
  1         426  
12              
13             has ua => (
14             is => 'ro',
15             default => sub {
16             my $jar = HTTP::CookieJar::LWP->new;
17             my $ua = LWP::UserAgent->new(cookie_jar => $jar);
18             return $ua;
19             }
20             );
21              
22             has host => (
23             is => 'ro',
24             default => sub {
25             return 'https://togetherweremember.com';
26             }
27             );
28              
29             has version => (
30             is => 'ro',
31             default => sub {
32             return 'v0';
33             }
34             );
35              
36             sub login {
37 0     0 0   my $self = shift;
38 0           my $api_version = $self->version;
39 0           my $api_host = $self->host;
40 0           my $api_class = "WebService::TogetherWeRemember::${api_version}::API";
41 0           eval "require $api_class";
42 0 0         if ($@) {
43 0           die "Could not load API class $api_class: $@";
44             }
45 0           my $api = $api_class->new(
46             ua => $self->ua,
47             host => $api_host,
48             );
49 0           my $res = $api->login(@_);
50              
51 0 0         if ($res->{ok}) {
52 0           return $api;
53             }
54              
55 0           die "Login failed: $res->{error}";
56             }
57              
58             =head1 NAME
59              
60             WebService::TogetherWeRemember - Together We Remember!
61              
62             =head1 VERSION
63              
64             Version 0.03
65              
66             =cut
67              
68             =head1 SYNOPSIS
69              
70             use WebService::TogetherWeRemember;
71              
72             my $twr = WebService::TogetherWeRemember->new();
73              
74             my $api = $twr->login($email, $password);
75              
76             my $timeline = $api->timeline_create({
77             name => "My First Timeline",
78             description => $markdown_text,
79             image => '/path/to/image.png',
80             related_links => [
81             { label => "lnation", url => "https//lnation.org" }
82             ],
83             passphrase => "123",
84             is_public => 1,
85             is_published => 0,
86             is_open => 0,
87             });
88              
89             my $memory = $api->memory_create($timline->{timeline}->{id}, {
90             title => "My First Memory",
91             content => $markdown_text,
92             date => time,
93             related_links => [
94             { label => "lnation", url => "https//lnation.org" }
95             ],
96             });
97              
98             $api->memory_asset($timeline->{timeline}->{id}, $memory->{memory}->{id}, '/path/to/asset.mp4', 5 * 1024 * 1024);
99              
100             $api->logout();
101              
102             See L for documentation.
103              
104             L
105              
106             =head1 AUTHOR
107              
108             LNATION, C<< >>
109              
110             =head1 BUGS
111              
112             Please report any bugs or feature requests to C, or through
113             the web interface at L. I will be notified, and then you'll
114             automatically be notified of progress on your bug as I make changes.
115              
116             =head1 SUPPORT
117              
118             You can find documentation for this module with the perldoc command.
119              
120             perldoc WebService::TogetherWeRemember
121              
122             You can also look for information at:
123              
124             =over 4
125              
126             =item * RT: CPAN's request tracker (report bugs here)
127              
128             L
129              
130             =item * Search CPAN
131              
132             L
133              
134             =back
135              
136             =head1 ACKNOWLEDGEMENTS
137              
138             =head1 LICENSE AND COPYRIGHT
139              
140             This software is Copyright (c) 2025 by LNATION.
141              
142             This is free software, licensed under:
143              
144             The Artistic License 2.0 (GPL Compatible)
145              
146             =cut
147              
148             1; # End of WebService::TogetherWeRemember