Google-Checkout

 view release on metacpan or  search on metacpan

lib/Google/Checkout/Command/SendBuyerMessage.pm  view on Meta::CPAN


=item get_message

Returns the message.

=item set_message MESSAGE

Sets the message to be sent to the buyer.

=item should_send_email

Returns whether or not email should also be sent to the buyer.

=item set_send_email FLAG

Sets the flag to send email to the buyer.

=item to_xml

Return the XML that will be sent to Google Checkout. Note that 
this function should not be used directly. Instead, it's called 
indirectly by the C<Google::Checkout::General::GCO> object internally.

=back

=cut

=head1 COPYRIGHT

Copyright 2006 Google. All rights reserved.

=head1 SEE ALSO

Google::Checkout::Command::GCOCommand

=cut

#--
#--  <send-buyer-message> 
#--

use strict;
use warnings;

use Google::Checkout::XML::Constants;
use Google::Checkout::General::Util qw/is_gco_error/;

use Google::Checkout::Command::GCOCommand;
our @ISA = qw/Google::Checkout::Command::GCOCommand/;

use Google::Checkout::General::Error;

sub new 
{
  my ($class, %args) = @_;

  my $self = $class->SUPER::new(
               %args, 
               name => Google::Checkout::XML::Constants::SEND_BUYER_MESSAGE);

  $self = bless $self => $class;
  $self->set_message($args{message});
  $self->set_send_email($args{send_email});

  return $self;
}

sub get_message 
{ 
  my ($self) = @_;

  return $self->{message}; 
}

sub set_message
{
  my ($self, $message) = @_;

  $self->{message} = $message if $message;
}

sub should_send_email 
{ 
  my ($self) = @_;

  return $self->{should_send_email}; 
}

sub set_send_email
{
  my ($self, $should_send_email) = @_;

  $self->{should_send_email} = $should_send_email ? 'true' : 'false';
}

sub to_xml
{
  my ($self, @args) = @_;

  my $message = $self->get_message;

  return Google::Checkout::General::Error->new(
    @{$Google::Checkout::General::Error::ERRORS{MISSING_MESSAGE}}) unless $message;

  my $code = $self->SUPER::to_xml(@args);

  return $code if is_gco_error($code);

  $self->add_element(name => Google::Checkout::XML::Constants::MESSAGE, 
                     data => $message, close => 1);

  $self->add_element(name => Google::Checkout::XML::Constants::SEND_EMAIL, 
                     data => $self->should_send_email, close => 1);

  return $self->done;
}

1;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 2.735 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-f5108d614456 )