package WebService::SOP::Auth::V1_1::Request::PUT_JSON;
use strict;
use warnings;
use Carp ();
use JSON::XS qw(encode_json);
use HTTP::Request::Common qw(PUT);
use WebService::SOP::Auth::V1_1::Util qw
nt = encode_json($params);
my $sig = create_signature($content, $app_secret);
my $req = PUT $uri, Content => $content;
$req->headers->header('content-type' => 'application/json');
$re
Service::SOP::Auth::V1_1::Request::PUT_JSON
=head1 DESCRIPTION
To create a valid L<HTTP::Request> object for C<PUT> request with content type C<application/json>.
=head1 FUNCTIONS
=head2 $class->c
package WebService::SOP::Auth::V1_1::Request::POST_JSON;
use strict;
use warnings;
use Carp ();
use JSON::XS qw(encode_json);
use HTTP::Request::Common qw(POST);
use WebService::SOP::Auth::V1_1::Util
t = encode_json($params);
my $sig = create_signature($content, $app_secret);
my $req = POST $uri, Content => $content;
$req->headers->header('content-type' => 'application/json');
$re
ebService::SOP::Auth::V1_1::Request::POST_JSON
=head1 DESCRIPTION
To create a valid L<HTTP::Request> object for given C<POST> request parameters to send JSON data.
=head1 METHODS
=head2 $class->cr
;
use WebService::SOP::Auth::V1_1::Request::POST_JSON;
use WebService::SOP::Auth::V1_1::Request::PUT;
use WebService::SOP::Auth::V1_1::Request::PUT_JSON;
use WebService::SOP::Auth::V1_1::Util qw(is_si
UserAgent->new->request($req);
When making a POST request with JSON data to API:
my $req = $auth->create_request(
POST_JSON => 'http://<API_HOST>/path/to/endpoint' => {
hoge
w-form-urlencoded>.
=item C<POST_JSON>
For HTTP POST request to SOP endpoint with signature as request header
C<X-Sop-Sig> of request content type C<application/json>.
=item C<PUT>
For HTTP PUT re
warnings;
use Carp ();
use Digest::SHA qw(hmac_sha256_hex);
use Exporter qw(import);
use JSON::XS qw(decode_json);
our @EXPORT_OK = qw( create_signature is_signature_valid );
our $SIG_VALID_FOR_SEC
$time ||= time;
my $req_time = ref($params) ? $params->{time}
: decode_json($params)->{time};
return if not $req_time;
return if $req_time < ($time - $SIG_VALID_FOR