| 1 | package Net::Amazon::MechanicalTurk::Command::ListOperations; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | our $VERSION = '1.00'; | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | Net::Amazon::MechanicalTurk::Command::ListOperations - Lists MechanicalTurk | ||
| 10 | requester operations. | ||
| 11 | |||
| 12 | Returns a list of method names that may be called against the requester API. | ||
| 13 | |||
| 14 | This method parses the WSDL used for the MechanicalTurk soap endpoint. | ||
| 15 | This method may fail while attempting to download the WSDL document. | ||
| 16 | |||
| 17 | =head1 SYNOPSIS | ||
| 18 | |||
| 19 | print "Methods for web service version: ", $mturk->serviceVersion, "\n"; | ||
| 20 | foreach my $operation ($mturk->listOperations) { | ||
| 21 | print $operation, "\n"; | ||
| 22 | } | ||
| 23 | |||
| 24 | =cut | ||
| 25 | |||
| 26 | sub listOperations { | ||
| 27 | my $mturk = shift; | ||
| 28 | my $wsdlUrl = shift; | ||
| 29 | if (!defined($wsdlUrl)) { | ||
| 30 | $wsdlUrl = "https://mechanicalturk.amazonaws.com/AWSMechanicalTurk/" . $mturk->serviceVersion . "/AWSMechanicalTurkRequester.wsdl"; | ||
| 31 | } | ||
| 32 | my $parser = Net::Amazon::MechanicalTurk::XMLParser->new; | ||
| 33 | my $wsdl = $parser->parseURL($wsdlUrl); | ||
| 34 | my @operationNames; | ||
| 35 | my $operations = $wsdl->{binding}[0]{operation}; | ||
| 36 | foreach my $operation (@$operations) { | ||
| 37 | push(@operationNames, $operation->{name}[0]); | ||
| 38 | } | ||
| 39 | return sort(@operationNames); | ||
| 40 | } | ||
| 41 | |||
| 42 | return 1; |