File Coverage

lib/Finance/Robinhood/Forex/Currency.pm
Criterion Covered Total %
statement 16 39 41.0
branch n/a
condition 3 6 50.0
subroutine 8 11 72.7
pod 2 2 100.0
total 29 58 50.0


line stmt bran cond sub pod time code
1             package Finance::Robinhood::Forex::Currency;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls
6              
7             =head1 NAME
8              
9             Finance::Robinhood::Forex::Currency - Represents a Single Forex Currency
10             Watchlist
11              
12             =head1 SYNOPSIS
13              
14             use Finance::Robinhood;
15             my $rh = Finance::Robinhood->new;
16              
17             # TODO
18              
19             =cut
20              
21             our $VERSION = '0.92_001';
22 1     1   7 use Mojo::Base-base, -signatures;
  1         3  
  1         6  
23 1     1   219 use Mojo::URL;
  1         2  
  1         8  
24 1     1   477 use Finance::Robinhood::Forex::Quote;
  1         3  
  1         7  
25              
26             sub _test__init {
27 1     1   11881 my $rh = t::Utility::rh_instance(1);
28 0         0 my $btc = $rh->forex_currency_by_id('d674efea-e623-4396-9026-39574b92b093'); # BTC
29 0         0 isa_ok( $btc, __PACKAGE__ );
30 0         0 t::Utility::stash( 'CURRENCY', $btc ); # Store it for later
31             }
32 1     1   125 use overload '""' => sub ( $s, @ ) { $s->{id} }, fallback => 1;
  1     0   2  
  1         9  
  0         0  
  0         0  
  0         0  
  0         0  
33              
34             sub _test_stringify {
35 1   50 1   1891 t::Utility::stash('CURRENCY') // skip_all();
36 0         0 like(
37             +t::Utility::stash('CURRENCY'),
38             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
39             );
40             }
41             #
42             has _rh => undef => weak => 1;
43              
44             =head1 METHODS
45            
46             =head2 C
47              
48             If defined, this returns a hex color code used for display.
49              
50             =head2 C
51              
52             Short code used to represent this currency for display. 'USD', for example.
53              
54             =head2 C
55              
56             Returns a UUID.
57              
58             =head2 C
59              
60             The increment used as a minimum for display, etc. For example, USD would return
61             C<0.01> to prevent sub-penny price display.
62              
63             =head2 C
64              
65             Returns a string suited for display. And example would be 'US Dollar'.
66              
67             =head2 C
68              
69             This is the asset type. Currently, C or C.
70              
71             =cut
72              
73             has [ 'brand_color', 'code', 'id', 'increment', 'name', 'type' ];
74              
75             =head2 C
76              
77             my $news = $currency->news;
78              
79             Returns an iterator containing Finance::Robinhood::News elements.
80              
81             =cut
82              
83 0     0 1 0 sub news ($s) { $s->_rh->news( $s->id ) }
  0         0  
  0         0  
  0         0  
84              
85             sub _test_news {
86 1   50 1   1952 t::Utility::stash('CURRENCY') // skip_all();
87 0         0 my $news = t::Utility::stash('CURRENCY')->news;
88 0         0 isa_ok( $news, 'Finance::Robinhood::Utility::Iterator' );
89 0         0 isa_ok( $news->current, 'Finance::Robinhood::News' );
90             }
91              
92             =head2 C
93              
94             my $pair = $currency->pair;
95              
96             Returns a Finance::Robinhood::Forex::Pair object.
97              
98             =cut
99              
100 0     0 1 0 sub pair ($s) {
  0         0  
  0         0  
101 0         0 my ($retval) = grep { $_->asset_currency->id eq $s->id } $s->_rh->forex_pairs->all;
  0         0  
102 0         0 $retval;
103             }
104              
105             sub _test_pairs {
106 1   50 1   1870 t::Utility::stash('CURRENCY') // skip_all();
107 0           my $pair = t::Utility::stash('CURRENCY')->pair;
108 0           isa_ok( $pair, 'Finance::Robinhood::Forex::Pair' );
109             }
110              
111             =head1 LEGAL
112              
113             This is a simple wrapper around the API used in the official apps. The author
114             provides no investment, legal, or tax advice and is not responsible for any
115             damages incurred while using this software. This software is not affiliated
116             with Robinhood Financial LLC in any way.
117              
118             For Robinhood's terms and disclosures, please see their website at
119             https://robinhood.com/legal/
120              
121             =head1 LICENSE
122              
123             Copyright (C) Sanko Robinson.
124              
125             This library is free software; you can redistribute it and/or modify it under
126             the terms found in the Artistic License 2. Other copyrights, terms, and
127             conditions may apply to data transmitted through this module. Please refer to
128             the L section.
129              
130             =head1 AUTHOR
131              
132             Sanko Robinson Esanko@cpan.orgE
133              
134             =cut
135              
136             1;