rface to SendGrid Newsletter API
our $VERSION = '0.02'; # VERSION
use HTTP::Request::Common;
use JSON;
use HTTP::Tiny;
use WebService::SendGrid::Newsletter::Lists;
use WebService::SendGrid::Newslett
nt(__PACKAGE__ . '/' .
($__PACKAGE__::VERSION || 0) . ' (Perl)');
$self->{json_options} = $args{json_options};
$self->{last_response} = undef;
$self->{last_response_code} = undef
tter/' . $path . '.json';
my $response = $self->{ua}->post_form($url, $params);
$self->{last_response_code} = $response->{status};
$self->{last_response} = decode_json $response->{conten
use strict;
use warnings;
package WebService::SendGrid::Newsletter::Lists::Email;
use JSON;
use parent 'WebService::SendGrid::Newsletter::Base';
sub new {
my ($class, %args) = @_;
my $
nto JSON
$args{data} = to_json($args{data}, $self->{sgn}{json_options});
}
elsif (ref $args{data} eq 'ARRAY') {
# Data is an arrayref of hashrefs -- turn each item into JSON
$args{data} = [
map { to_json($_, $self->{sgn}{json_options}); } @{$args{data}}
];
}
return $self->{sgn}->_send_request('lists/email/add', %args);
}
1;
__END__