| 1 | package Finance::Dogechain::Base; | ||||||||||
| 2 | 1 | $Finance::Dogechain::Base::VERSION = '1.20210418.2306'; | |||||||||
| 3 | 1 | ▶ | use Mojo::Base -base, -signatures; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use Mojo::UserAgent; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Net::SSLeay; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 0 | ▶ | has 'ua' => sub { Mojo::UserAgent->new->max_redirects(3) }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 8 | 0 | ▶ | has 'base_url' => sub { 'https://dogechain.info/api/v1' }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 9 | |||||||||||
| 10 | ▶ | sub return_field_if_success($self, $url_path, $field) { | |||||||||
|
Subroutine
return_field_if_success: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 11 | 0 | my $res = $self->ua->get( $self->base_url . $url_path )->result; | |||||||||
| 12 | |||||||||||
| 13 | 0 | ▶ | if ($res->is_success) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 0 | my $json = $res->json; | |||||||||
| 15 | 0 | ▶ | return $json->{$field} if $json->{success}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 0 | return 0; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 0 | return; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 1 | 'to the moon'; | |||||||||
| 23 | __END__ | ||||||||||