Google-Checkout

 view release on metacpan or  search on metacpan

lib/Google/Checkout/General/ParameterizedUrls.pm  view on Meta::CPAN


=item get_url

Returns tracking URL.

=item set_url

Sets the tracking URL. Please note that the URL must be properly URI escaped.

=item get_url_params

Returns all the additional tracking params as hash reference.

=item get_url_param

Given a key, returns the corresponding value in the tracking params. If
key is not found, returns an empty string.

=item set_url_param

Given a key / value pair, add them to the tracking params. If the key
already exists, it over writes the old value. Otherwise, it's added.

=back

=cut

=head1 COPYRIGHT

Copyright 2006 Google. All rights reserved.

=head1 SEE ALSO

Google::Checkout::General::MerchantCheckoutFlow

=cut

#--
#--   <parameterized-urls></parameterized-urls>
#--

use strict;
use warnings;

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

  my $self = {};

  #--
  #-- Note that URL *must* be properly URI escaped
  #--
  $self->{url} = $args{url};

  #--
  #-- This should be a hash reference
  #--
  $self->{url_params} = $args{url_params};

  return bless $self => $class;
}

sub get_url {
  my ($self) = @_;
  return $self->{url} || '';
}

sub set_url {
  my ($self, $url) = @_;
  $self->{url} = $url;
}

sub get_url_params {
  my ($self) = @_;
  return $self->{url_params} || {};
}

sub get_url_param {
  my ($self, $key) = @_;
  if ($self->{url_params} && defined $key) {
    if (exists $self->{url_params}->{$key}) {
      return $self->{url_params}->{$key};
    } else {
      return '';
    }
  } else {
    return '';
  }
}

sub set_url_param {
  my ($self, $key, $value) = @_;
  $self->{url_params}->{$key} = $value;
}

1;

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

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