Apigee-Edge
view release on metacpan or search on metacpan
lib/Apigee/Edge/Helper.pm view on Meta::CPAN
{
name => $name,
callbackUrl => $callback_url,
$params{apiProducts} ? (apiProducts => $params{apiProducts}) : (),
});
if ($my_app->{message}) {
$errstr = $my_app->{message};
return;
}
$my_app->{display_name} = $name;
$errstr = "$name has been registered. New OAuth credentials are available";
}
return $my_app;
}
sub get_all_clients {
my ($self) = @_;
my $apps = $self->get_apps(
expand => 'true',
includeCred => 'true'
) or croak "Apigee::Edge failure: " . $self->errstr;
my $CLIENTS = {};
for my $app (@{$apps->{app}}) {
next unless $app->{status} eq 'approved';
my $consumerKey = eval {
my $credentials = $app->{credentials};
$credentials->[0]->{consumerKey};
} || next;
if (my $attrs = $app->{attributes}) {
my %attrs = map { $_->{name} => $_->{value} } @$attrs;
$app->{name} = $attrs{DisplayName} if $attrs{DisplayName};
}
$CLIENTS->{$consumerKey} = $app->{name};
}
return $CLIENTS;
}
xt/helper.t view on Meta::CPAN
firstName => 'Fayland',
lastName => 'Lam',
userName => 'fayland.binary',
);
# say Dumper(\$app);
ok($app->{appId});
is($app->{callbackUrl}, 'http://fayland.me/oauth/callback');
is($app->{name}, 'Fayland Test App');
is($app->{display_name}, 'Fayland Test App');
ok($app->{credentials});
ok($apigee->errstr =~ /registered/);
say "Get Clients...";
my $clients = $apigee->get_all_clients();
ok(grep { $_ eq $app->{credentials}->[0]->{consumerKey} } keys %$clients);
ok(grep { $_ eq 'Fayland Test App' } values %$clients);
say "Update Apps...";
$app = $apigee->refresh_developer_app(
app => $app,
email => $email,
name => 'Fayland Test App Changed',
callbackUrl => 'http://fayland.me/oauth/callback_changed',
# apiProducts => ['ProductName'],
firstName => 'Fayland',
lastName => 'Lam',
userName => 'fayland.binary',
);
# say Dumper(\$app);
ok($app->{appId});
is($app->{callbackUrl}, 'http://fayland.me/oauth/callback_changed');
is($app->{name}, 'Fayland Test App'); # this is not changed
is($app->{display_name}, 'Fayland Test App Changed');
ok($app->{credentials});
ok($apigee->errstr =~ /Update successful/);
say "Get Clients...";
my $clients = $apigee->get_all_clients();
ok(grep { $_ eq $app->{credentials}->[0]->{consumerKey} } keys %$clients);
ok(grep { $_ eq 'Fayland Test App Changed' } values %$clients);
done_testing();
1;
( run in 0.327 second using v1.01-cache-2.11-cpan-4d50c553e7e )