Commits

Anonymous committed 5878067

Instead of prompting for a password - read it from a JSON file.

  • Participants
  • Parent commits ed55e7f

Comments (0)

Files changed (1)

lib/Shlomif/Homepage/Amazon.pm

 use strict;
 use warnings;
 
+
+
 sub import
 {
     my ($module, $args) = @_; 
 
 use Moose;
 
+use JSON qw(decode_json);
+
 use XML::Grammar::ProductsSyndication;
 use XML::LibXML::XPathContext;
 use Term::ReadPassword;
 
 }
 
+sub _utf8_slurp
+{
+    my $filename = shift;
+
+    open my $in, '<', $filename
+        or die "Cannot open '$filename' for slurping - $!";
+
+    binmode $in, ':encoding(utf8)';
+
+    local $/;
+    my $contents = <$in>;
+
+    close($in);
+
+    return $contents;
+}
+
 sub process
 {
     my ($self) = @_;
 
+    my $config = decode_json(_utf8_slurp($ENV{HOME}.'/.shlomifish-amazon-sak.json'));
+
     if (!$self->ps->is_valid())
     {
         die "Not valid.";
             },
             'amazon_token' => "0VRRHTFJECHSKYNYD282",
             'amazon_associate' => "shlomifishhom-20",
-            'amazon_sak' => read_password('Secret Access Key: '),
+            'amazon_sak' => $config->{'amazon_sak'},
         }
     );