package Opals::SIF::HTTPService;

# Version number
$VERSION   = 0.01;

use warnings;
use strict;

use LWP::UserAgent;
use HTTP::Request::Common;
use URI::Escape;
use REST::Client;
use MIME::Base64;


# REF :http://search.cpan.org/~mcrawfor/REST-Client-88/lib/REST/Client.pm


#################################################################
sub new {
    my ($class) = @_;
    my $self={};
    
    $self->{'client'} = REST::Client->new({timeout => 60});
    bless $self, $class;
    return $self;
}


#################################################################
sub post{
    my ($self,$zoneInfo,$sifMsg)=@_;
    my $url=$zoneInfo->{'url'};
    my $header={};
    if(defined $zoneInfo->{'username'} && $zoneInfo->{'username'} ne '' && $zoneInfo->{'password'} ne ''){
        my $encoded_auth = encode_base64($zoneInfo->{'username'} . ":" . $zoneInfo->{'password'},'');
        $header->{'Authorization'}= "Basic $encoded_auth";
    }
    $self->{'client'}->POST($url, $sifMsg,$header);
    return  $self->{'client'}->responseContent;


}

1;
