X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Facct_google.pm;h=d153728e90976eb85ca87f1adb53006a39422160;hp=f7a11818d4916c1e9e536a4346ce44f10aff9577;hb=5372897f367498972c96f5494e142e6e11b29eb8;hpb=b3e430d72c5988d2e8d7f0cb9e0548d745195da8 diff --git a/FS/FS/part_export/acct_google.pm b/FS/FS/part_export/acct_google.pm index f7a11818d..d153728e9 100644 --- a/FS/FS/part_export/acct_google.pm +++ b/FS/FS/part_export/acct_google.pm @@ -3,6 +3,7 @@ package FS::part_export::acct_google; use strict; use vars qw(%info %SIG $CACHE); use Tie::IxHash; + use base 'FS::part_export'; tie my %options, 'Tie::IxHash', @@ -15,10 +16,12 @@ tie my %options, 'Tie::IxHash', # admin logins. %info = ( - 'svc' => 'svc_acct', - 'desc' => 'Google hosted mail', - 'options' => \%options, - 'nodomain' => 'Y', + 'svc' => 'svc_acct', + 'desc' => 'Google hosted mail', + 'options' => \%options, + 'nodomain' => 'Y', + 'no_machine' => 1, + 'default_svc_class' => 'Email', 'notes' => <<'END' Export accounts to the Google Provisioning API. Requires REST::Google::Apps::Provisioning from CPAN. @@ -88,15 +91,18 @@ sub _export_unsuspend { ); } -sub captcha_url { +sub auth_error { my $self = shift; my $google = $self->google_handle; - if (exists ($google->{'captcha_url'}) ) { - return 'http://www.google.com/accounts/'.$google->{'captcha_url'}; - } - else { - return ''; + if ( $google->{'error'} ) { + my $url = $google->{'captcha_url'} || ''; + $url = "http://www.google.com/accounts/$url" if $url; + return { 'captcha_url' => $url, + 'message' => + 'Unable to connect to the Google API: '.$google->{'error'}.'.', + }; } + return; #nothing on success } sub captcha_auth { @@ -151,16 +157,23 @@ sub google_request { sub google_handle { my $self = shift; - my $class = 'REST::Google::Apps::Provisioning'; my %opt = @_; - eval "use $class"; - - die "failed to load $class\n" if $@; + my @class = ( + 'REST::Google::Apps::Provisioning', + 'Cache::FileCache', + 'LWP::UserAgent 5.815', + ); + foreach (@class) { + eval "use $_"; + die "failed to load $_\n" if $@; + } $CACHE ||= new Cache::FileCache( { 'namespace' => __PACKAGE__, 'cache_root' => "$FS::UID::cache_dir/cache.$FS::UID::datasrc", } ); - my $google = $class->new( 'domain' => $self->option('domain') ); + my $google = REST::Google::Apps::Provisioning->new( + 'domain' => $self->option('domain') + ); # REST::Google::Apps::Provisioning lacks error reporting. We deal # with that by hooking HTTP::Response to throw a useful fatal error