line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Robinhood::Notification; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=for stopwords watchlist watchlists untradable urls btw |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Finance::Robinhood::Notification - Represents a Single Notification Card |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Text::Wrap qw[wrap]; |
14
|
|
|
|
|
|
|
use Finance::Robinhood; |
15
|
|
|
|
|
|
|
my $rh = Finance::Robinhood->new; |
16
|
|
|
|
|
|
|
CORE::say wrap( '', ' ', $_->title . "\n" . $_->message ) for $rh->notifications->take(10); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 METHODS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.92_003'; |
23
|
1
|
|
|
1
|
|
4934
|
use Mojo::Base-base, -signatures; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
24
|
1
|
|
|
1
|
|
363
|
use Mojo::URL; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
10
|
|
25
|
1
|
|
|
1
|
|
31
|
use Time::Moment; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
201
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _test__init { |
28
|
1
|
|
|
1
|
|
8293
|
my $rh = t::Utility::rh_instance(1); |
29
|
0
|
|
|
|
|
0
|
my $notifications = $rh->notifications; |
30
|
0
|
|
|
|
|
0
|
my $notification; |
31
|
0
|
|
0
|
|
|
0
|
do { |
32
|
0
|
|
|
|
|
0
|
$notification = $notifications->next; |
33
|
|
|
|
|
|
|
} while $notification && |
34
|
|
|
|
|
|
|
$notification->type ne 'referral_hook_asset_stock'; |
35
|
0
|
|
0
|
|
|
0
|
$notification // skip_all('Failed to fine executied equity order'); |
36
|
0
|
|
|
|
|
0
|
isa_ok($notification, __PACKAGE__); |
37
|
0
|
|
|
|
|
0
|
t::Utility::stash('CARD', $notification); # Store it for later |
38
|
|
|
|
|
|
|
} |
39
|
1
|
|
|
1
|
|
11
|
use overload '""' => sub ($s, @) { $s->{url} }, fallback => 1; |
|
1
|
|
|
0
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _test_stringify { |
42
|
1
|
|
50
|
1
|
|
1888
|
t::Utility::stash('CARD') // skip_all(); |
43
|
0
|
|
|
|
|
0
|
like(+t::Utility::stash('CARD'), |
44
|
|
|
|
|
|
|
qr'^https://midlands.robinhood.com/notifications/stack/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/$'i |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
has _rh => undef => weak => 1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 C |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Text provided to direct attention to the action. C, C, |
53
|
|
|
|
|
|
|
etc. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 C |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
If true, this notification is locked into place. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 C |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
For display, this sets a uniform type size. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 C |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Returns which icon should be used. These are built into the apps, btw. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 C |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
The actual text shown in the notification card. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 C |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 C |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Returns a hash with asset information for the official clients. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 C |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns the type of notification. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 C |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns the article's title. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 C |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
What sort of notification is is. C, C, etc. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
has ['call_to_action', 'fixed', |
93
|
|
|
|
|
|
|
'font_size', 'icon', |
94
|
|
|
|
|
|
|
'message', 'show_if_unsupported', |
95
|
|
|
|
|
|
|
'side_image', 'title', |
96
|
|
|
|
|
|
|
'type' |
97
|
|
|
|
|
|
|
]; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 C |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Returns the (usually app internal) action that should take place when the |
102
|
|
|
|
|
|
|
notification is activated. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
0
|
1
|
0
|
sub action($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
107
|
0
|
|
|
|
|
0
|
Mojo::URL->new($s->{action}); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub _test_action { |
111
|
1
|
|
50
|
1
|
|
2049
|
t::Utility::stash('CARD') // skip_all(); |
112
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('CARD')->action, 'Mojo::URL'); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 C |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
$notification->time->to_string; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Returns the time the notification was published as a Time::Moment object. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Note that some notifications do not have a timestamp. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
0
|
1
|
0
|
sub time($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
126
|
0
|
0
|
|
|
|
0
|
$s->{time} ? Time::Moment->from_string($s->{time}) : (); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub _test_time { |
130
|
1
|
|
50
|
1
|
|
1878
|
t::Utility::stash('CARD') // skip_all(); |
131
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('CARD')->time, 'Time::Moment'); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 C |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
$notification->dismiss(); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Marks the notification as read and hides it from the stack. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
0
|
1
|
0
|
sub dismiss ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
143
|
0
|
|
|
|
|
0
|
$s->_rh->_post($s->{url} . 'dismiss/')->is_success; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub _test_dismiss { # I'd rather not mark a notification as read... |
147
|
1
|
|
|
1
|
|
1886
|
skip_all(); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 C |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Returns a UUID. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
0
|
1
|
0
|
sub id($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
157
|
|
|
|
|
|
|
$s->{url} |
158
|
0
|
|
|
|
|
0
|
=~ m'^.+/([0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})/$'i; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub _test_id { |
162
|
1
|
|
50
|
1
|
|
1849
|
t::Utility::stash('CARD') // skip_all(); |
163
|
0
|
|
|
|
|
|
like(t::Utility::stash('CARD')->id, |
164
|
|
|
|
|
|
|
qr'^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'i |
165
|
|
|
|
|
|
|
); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 LEGAL |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
This is a simple wrapper around the API used in the official apps. The author |
171
|
|
|
|
|
|
|
provides no investment, legal, or tax advice and is not responsible for any |
172
|
|
|
|
|
|
|
damages incurred while using this software. This software is not affiliated |
173
|
|
|
|
|
|
|
with Robinhood Financial LLC in any way. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
For Robinhood's terms and disclosures, please see their website at |
176
|
|
|
|
|
|
|
https://robinhood.com/legal/ |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 LICENSE |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Copyright (C) Sanko Robinson. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
183
|
|
|
|
|
|
|
the terms found in the Artistic License 2. Other copyrights, terms, and |
184
|
|
|
|
|
|
|
conditions may apply to data transmitted through this module. Please refer to |
185
|
|
|
|
|
|
|
the L section. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 AUTHOR |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
1; |