The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

WebService::Tesco

VERSION

0.1

Simple wrapper for the Tesco API documented here:

http://www.tescolabs.com/?p=7171

methods

new

Parameters: my $tesco = WebService::Tesco->new({ dev_key => $dev_key, app_key => $app_key, });

auth

Called from new. You don't need this.

Parameters: my $res = $tesco->search({ searchtext => "Chef", page => 1 # defaults to 1 });

     $res is an array of hashrefs:

     {
       "StatusCode": 0,
       "StatusInfo": "Command Processed OK",
       "PageNumber": 1,
       "TotalPageCount": 1,
       "TotalProductCount": 1,
       "PageProductCount": 1,
       "Products":
          [
              {
                "BaseProductId": "77534748",
                "EANBarcode": "5055761903331",
                "CheaperAlternativeProductId": "",
                "HealthierAlternativeProductId": "",
                "ImagePath": "http://img.tesco.com/Groceries/pi/331/5055761903331/IDShot_90x90.jpg",
                "MaximumPurchaseQuantity": 99,
                "Name": "Chef Dvd",
                "OfferPromotion": "",
                "OfferValidity": "",
                "OfferLabelImagePath": "",
                "ShelfCategory": "",
                "ShelfCategoryName": "",
                "Price": 10,
                "PriceDescription": "10.00 each",
                "ProductId": "285334791",
                "ProductType": "QuantityOnlyProduct",
                "UnitPrice": 10,
                "UnitType": "EACH"
              }
           ]
     }

sub search { my ($self, $params) = @_ ;

  warn Dumper($params) ;

  my $str = $SEARCH . 
                    "&sessionkey=" . $self->{session} .
                    "&page=" . $params->{page}  .
                    "&searchtext=" . uri_escape("chef dvd");
  warn $str;

  my $ret = get($str) ;
  $ret = decode_json(encode_utf8($ret)) ;
  warn Dumper($ret);

  return $ret;
}

1;