API-Google

 view release on metacpan or  search on metacpan

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

  my ($class, $params) = @_;
  my $h = {};
  if ($params->{tokensfile}) {
  	$h->{tokensfile} = Config::JSON->new($params->{tokensfile});
  } else {
  	die 'no json file specified!';
  }
  $h->{ua} = Mojo::UserAgent->new();
  $h->{debug} = $params->{debug};
  $h->{max_refresh_attempts} = $params->{max_refresh_attempts} || 5;
  return bless $h, $class;
}



sub refresh_access_token {
  my ($self, $params) = @_;
  warn "Attempt to refresh access_token with params: ".Dumper $params if $self->{debug};
  $params->{grant_type} = 'refresh_token';
  $self->{ua}->post('https://www.googleapis.com/oauth2/v4/token' => form => $params)->res->json; # tokens
};

lib/API/Google/GCal.pm  view on Meta::CPAN


# ABSTRACT: Google Calendar API client




sub new {
    my ($class, $params) = @_;
    my $self = API::Google->new($params);
    $self->{api_base} = 'https://www.googleapis.com/calendar/v3';
    bless $self, $class;
    return $self; # just for clearance
}


sub get_calendars {
  my ($self, $user, $fields) = @_;
  my $res = $self->api_query({ 
  	method => 'get', 
  	route => $self->{api_base}.'/users/me/calendarList',
  	user => $user



( run in 0.553 second using v1.01-cache-2.11-cpan-de7293f3b23 )