Email-SendGrid-V3
view release on metacpan or search on metacpan
lib/Email/SendGrid/V3.pm view on Meta::CPAN
#pod
#pod C<content> - The body of the response, including a detailed error message, if any.
#pod
#pod =back
#pod
#pod =cut
sub send {
my ($self, %args) = @_;
my $api_key = $args{api_key} || $self->{api_key} or croak "API key is required to send";
my $endpoint = $args{endpoint} || $self->{endpoint} || DEFAULT_ENDPOINT;
my $payload = $self->_payload;
my $http = HTTP::Tiny->new(
keep_alive => 0,
default_headers => {
'Content-Type' => 'application/json',
'Authorization' => "Bearer $api_key",
},
);
my $response = $http->post(
$endpoint, { content => $payload },
);
return $response;
}
#pod =head3 validate(%args)
#pod
#pod Temporarily sets the 'sandbox_mode' flag to true, and submits the API request
#pod to SendGrid. Returns the same hashref format as send(). If the 'success' key
#pod is true, the API request is valid.
( run in 0.925 second using v1.01-cache-2.11-cpan-2b1a40005be )