NAME

Amazon::Sites - A class to represent Amazon sites

SYNOPSIS

use Amazon::Sites;

my $sites = Amazon::Sites->new;
my @sites = $sites->sites;
my %sites = $sites->sites_hash;
my @codes = $sites->codes;

my $site  = $sites->site('UK');
say $site->currency; # GBP
say $site->tldn;     # co.uk
# etc

my %urls = $sites->asin_urls('XXXXXXX');
say $urls{UK}; # https://amazon.co.uk/dp/XXXXXXX
# etc

DESCRIPTION

A simple class that encapsulates information about Amazon sites.

METHODS

new

Creates a new Amazon::Sites object.

my $sites = Amazon::Sites->new;

You can also specify a list of sites to include or exclude:

# Only include the US site
my $sites = Amazon::Sites->new(include => [ 'US' ]);
# Exclude the US site
my $sites = Amazon::Sites->new(exclude => [ 'US' ]);

At most one of `include` or `exclude` can be specified.

You can also specify a hash of associate codes:

my $sites = Amazon::Sites->new(assoc_codes => {
  UK => 'My Associate Code',
});

sites_hash

Returns a hash where the keys are the two-letter country codes and the values are Amazon::Site objects.

site($code)

Given a two-letter country code, returns the corresponding Amazon::Site object.

sites

Returns a list of Amazon::Site objects, sorted by the sort order.

codes

Returns a list of the two-letter country codes, sorted by the sort order.

asin_urls

Given an ASIN, returns a hash where the keys are the two-letter country codes and the values are the corresponding ASIN URLs.

COPYRIGHT

Copyright 2024, Dave Cross. All rights reserved.

LICENCE

This program is free software; you can redistribute it and/or modify it under the terms of either:

  • the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or

  • the Artistic License version 2.0.