| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package IO::Iron::ConnectorBase; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | ## no critic (Documentation::RequirePodAtEnd) | 
| 4 |  |  |  |  |  |  | ## no critic (Documentation::RequirePodSections) | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 3 |  |  | 3 |  | 1659 | use 5.010_000; | 
|  | 3 |  |  |  |  | 12 |  | 
| 7 | 3 |  |  | 3 |  | 22 | use strict; | 
|  | 3 |  |  |  |  | 10 |  | 
|  | 3 |  |  |  |  | 81 |  | 
| 8 | 3 |  |  | 3 |  | 15 | use warnings; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 85 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | # Global creator | 
| 11 |  |  |  | 3 |  |  | BEGIN { | 
| 12 |  |  |  |  |  |  | # Export nothing. | 
| 13 |  |  |  |  |  |  | } | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | # Global destructor | 
| 16 |  |  |  | 3 |  |  | END { | 
| 17 |  |  |  |  |  |  | } | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | # ABSTRACT: Base class for the REST API Connector, HTTP interface class. | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | our $VERSION = '0.14'; # VERSION: generated by DZP::OurPkgVersion | 
| 22 |  |  |  |  |  |  |  | 
| 23 | 3 |  |  | 3 |  | 22 | use Log::Any qw{$log}; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 34 |  | 
| 24 | 3 |  |  | 3 |  | 679 | use Hash::Util 0.06 qw{lock_keys unlock_keys}; | 
|  | 3 |  |  |  |  | 53 |  | 
|  | 3 |  |  |  |  | 18 |  | 
| 25 | 3 |  |  | 3 |  | 197 | use Carp; | 
|  | 3 |  |  |  |  | 8 |  | 
|  | 3 |  |  |  |  | 184 |  | 
| 26 | 3 |  |  | 3 |  | 20 | use Carp::Assert; | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 16 |  | 
| 27 | 3 |  |  | 3 |  | 472 | use Carp::Assert::More; | 
|  | 3 |  |  |  |  | 14 |  | 
|  | 3 |  |  |  |  | 558 |  | 
| 28 | 3 |  |  | 3 |  | 21 | use English '-no_match_vars'; | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 26 |  | 
| 29 | 3 |  |  | 3 |  | 1177 | use Scalar::Util qw{blessed}; | 
|  | 3 |  |  | 0 |  | 22 |  | 
|  | 3 |  |  |  |  | 612 |  | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | # DEFAULTS | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | sub new { | 
| 34 | 0 |  |  | 3 | 1 | 0 | my ($class) = @_; | 
| 35 | 3 |  |  |  |  | 13 | $log->tracef( 'Entering new(%s)', $class ); | 
| 36 | 3 |  |  |  |  | 15 | my $self      = {}; | 
| 37 | 3 |  |  |  |  | 157 | my @self_keys = (     ### no critic (CodeLayout::ProhibitQuotedWordLists) | 
| 38 |  |  |  |  |  |  | # No keys. | 
| 39 |  |  |  |  |  |  | ); | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 3 |  |  |  |  | 11 | bless $self, $class; | 
| 42 | 3 |  |  |  |  | 8 | lock_keys( %{$self}, @self_keys ); | 
|  | 3 |  |  |  |  | 6 |  | 
| 43 |  |  |  |  |  |  |  | 
| 44 | 3 |  |  |  |  | 28 | $log->tracef( 'Exiting new: %s', $self ); | 
| 45 | 3 |  |  |  |  | 52 | return $self; | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | # Connector needs: | 
| 49 |  |  |  |  |  |  | # all API info | 
| 50 |  |  |  |  |  |  | # params for API.href     => if it's a mock! | 
| 51 |  |  |  |  |  |  | # message body | 
| 52 |  |  |  |  |  |  | # headers: content type, authorization | 
| 53 |  |  |  |  |  |  | # connection params: timeout?, retry? | 
| 54 |  |  |  |  |  |  | # Connector arranges by inself: | 
| 55 |  |  |  |  |  |  | # HTTP REST connection: REST::Client / LWP | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | sub perform_iron_action { | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | #my ($self, $iron_action, $params) = @_; | 
| 60 |  |  |  |  |  |  | #if(!defined $params){ | 
| 61 |  |  |  |  |  |  | #	$params = {}; | 
| 62 |  |  |  |  |  |  | #} | 
| 63 |  |  |  |  |  |  | #$log->tracef('Entering ConnectorBase:perform_iron_action(%s, %s)', $iron_action, $params); | 
| 64 |  |  |  |  |  |  |  | 
| 65 | 3 |  |  | 0 | 1 | 626 | croak('This routine must be replaced in the inheriting sub class.'); | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | #my ($returned_msg, $http_status_code); | 
| 68 |  |  |  |  |  |  | #$log->tracef('Exiting ConnectorBase:perform_iron_action(): %s', $returned_msg ); | 
| 69 |  |  |  |  |  |  | #return $http_status_code, $returned_msg; | 
| 70 |  |  |  |  |  |  | } | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | 1; | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | __END__ | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | =pod | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | =encoding UTF-8 | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | =head1 NAME | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | IO::Iron::ConnectorBase - Base class for the REST API Connector, HTTP interface class. | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | =head1 VERSION | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | version 0.14 | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | This package is for internal use of IO::Iron packages. | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | =for stopwords Params params API Mikko Koivunalho TODO | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | =head1 SUBROUTINES/METHODS | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =head2 new | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | Creator function. | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | =head2 perform_iron_action | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | =over 8 | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | =item Params: action name, params hash. | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | =item Return: 1/0 (1 if success, 0 in all failures), | 
| 109 |  |  |  |  |  |  | HTTP return code, hash if success/failed request. | 
| 110 |  |  |  |  |  |  | If you need to create your own Connector class, start with copying | 
| 111 |  |  |  |  |  |  | this routine. | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | =back | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | =head1 AUTHOR | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | Mikko Koivunalho <mikko.koivunalho@iki.fi> | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | =head1 BUGS | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | Please report any bugs or feature requests to bug-io-iron@rt.cpan.org or through the web interface at: | 
| 122 |  |  |  |  |  |  | http://rt.cpan.org/Public/Dist/Display.html?Name=IO-Iron | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | This software is copyright (c) 2023 by Mikko Koivunalho. | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 129 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  | The full text of the license can be found in the | 
| 132 |  |  |  |  |  |  | F<LICENSE> file included with this distribution. | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | =cut |