API-Handle

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

      },
      "develop" : {
         "requires" : {
            "Test::Pod" : "1.41"
         }
      },
      "runtime" : {
         "requires" : {
            "Carp" : "0",
            "Data::Dumper" : "0",
            "HTTP::Request" : "0",
            "JSON::XS" : "0",
            "LWP::UserAgent" : "0",
            "Moose" : "0",
            "Moose::Role" : "0",
            "Nour::Config" : "0",
            "Nour::Database" : "0",
            "Nour::Printer" : "0",
            "OX::OAuth" : "0",
            "String::CamelCase" : "0",
            "Tie::Hash::Indexed" : "0",

META.yml  view on Meta::CPAN

dynamic_config: 0
generated_by: 'Dist::Zilla version 4.300028, CPAN::Meta::Converter version 2.120921'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: 1.4
name: API-Handle
requires:
  Carp: 0
  Data::Dumper: 0
  HTTP::Request: 0
  JSON::XS: 0
  LWP::UserAgent: 0
  Moose: 0
  Moose::Role: 0
  Nour::Config: 0
  Nour::Database: 0
  Nour::Printer: 0
  OX::OAuth: 0
  String::CamelCase: 0
  Tie::Hash::Indexed: 0

Makefile.PL  view on Meta::CPAN

  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => "6.30"
  },
  "DISTNAME" => "API-Handle",
  "EXE_FILES" => [],
  "LICENSE" => "perl",
  "NAME" => "API::Handle",
  "PREREQ_PM" => {
    "Carp" => 0,
    "Data::Dumper" => 0,
    "HTTP::Request" => 0,
    "JSON::XS" => 0,
    "LWP::UserAgent" => 0,
    "Moose" => 0,
    "Moose::Role" => 0,
    "Nour::Config" => 0,
    "Nour::Database" => 0,
    "Nour::Printer" => 0,
    "OX::OAuth" => 0,
    "String::CamelCase" => 0,
    "Tie::Hash::Indexed" => 0,

lib/API/Handle.pm  view on Meta::CPAN

package API::Handle;
{
  $API::Handle::VERSION = '0.02';
}

use Moose::Role;
use namespace::autoclean;
use HTTP::Request;
use bytes;
use feature ':5.10';
use String::CamelCase qw/camelize decamelize/;
use Tie::Hash::Indexed;

has _config => (
	is => 'rw'
	, isa => 'Nour::Config'
	, handles => [ qw/config/ ]
	, required => 1

lib/API/Handle.pm  view on Meta::CPAN

			# Set Content-Length header.
			if ( my $data = $req->content ) {
				$req->headers->header( 'Content-Length' => $self->_bytes( $data ) );
			}
		}
	);
}

sub req {
	my ( $self, %args ) = @_;
	my $req = new HTTP::Request;

	$args{content} ||= $args{data} ||= $args{body};
	$args{method}  ||= $args{type};
	$args{uri}     ||= $self->_join_uri( $args{path} );

	# Preserve hash order. Maybe needed for SOAP.
	if ( defined $args{content} and (
			( ref $args{content} eq 'ARRAY' ) or # Deprecated - backwards compatibility
			( ref $args{content} eq 'REF' and ref ${ $args{content} } eq 'ARRAY' ) # New style ? => \[]
		)

lib/API/Handle/Google/DFP.pm  view on Meta::CPAN

package API::Handle::Google::DFP;
{
  $API::Handle::Google::DFP::VERSION = '0.02';
}
use Moose;
use namespace::autoclean;
use HTTP::Request;
use Carp;
use Data::Dumper;
use feature ':5.10';

with 'API::Handle';
has _config => (
	is => 'rw'
	, isa => 'Nour::Config'
	, handles => {
		  config => 'config'

lib/API/Handle/Google/DFP.pm  view on Meta::CPAN

	my $conf = $self->config;
	my $time = time;

	# Uncomment this to view loaded configuration.
	# $self->dumper( 'config', $conf );

	if ( $conf->{auth}{token}{access_token} and $conf->{auth}{token}{expires_at} and $conf->{auth}{token}{expires_at} > $time ) {
		$self->ua->default_header( 'Authorization' => "$conf->{auth}{token}{token_type} $conf->{auth}{token}{access_token}" );
	}
	elsif ( $conf->{auth}{token}{refresh_token} ) {
		my $req = new HTTP::Request;

		$req->headers->header( 'Content-Type' => 'application/x-www-form-urlencoded' );
		$req->method( 'POST' );
		$req->uri( $conf->{auth}{uri}{token} );

		my $data = $self->_encode( type => 'form', data => {
			grant_type => 'refresh_token'
			, client_id => $conf->{auth}{client}{id}
			, client_secret => $conf->{auth}{client}{secret}
			, refresh_token => $conf->{auth}{token}{refresh_token}



( run in 0.286 second using v1.01-cache-2.11-cpan-4505f990765 )