| 1 | package Google::Cloud::Actions::Sdk::V2::ActionsTestingClient; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 0 | ▶ | use Google::gRPC::Client; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 7 | use Google::Cloud::REST::Client; | ||
| 8 | use Google::Auth; | ||
| 9 | use Carp qw(croak); | ||
| 10 | |||
| 11 | use Protobuf; | ||
| 12 | use Google::Api::Common; | ||
| 13 | use Google::Actions::Sdk::V2::Manifest; | ||
| 14 | use Google::Actions::Sdk::V2::Conversation::Suggestion; | ||
| 15 | use Google::Actions::Sdk::V2::DataFile; | ||
| 16 | use Google::Actions::Sdk::V2::Action; | ||
| 17 | use Google::Actions::Sdk::V2::Conversation::Simple; | ||
| 18 | use Google::Actions::Sdk::V2::ValidationResults; | ||
| 19 | use Google::Actions::Sdk::V2::ThemeCustomization; | ||
| 20 | use Google::Actions::Sdk::V2::AccountLinkingSecret; | ||
| 21 | use Google::Actions::Sdk::V2::Conversation::Image; | ||
| 22 | use Google::Actions::Sdk::V2::Conversation::List; | ||
| 23 | use Google::Actions::Sdk::V2::Surface; | ||
| 24 | use Google::Actions::Sdk::V2::Interactionmodel::Prompt::StaticLinkPrompt; | ||
| 25 | use Google::Actions::Sdk::V2::Conversation::Link; | ||
| 26 | use Google::Actions::Sdk::V2::Conversation::Intent; | ||
| 27 | use Google::Actions::Sdk::V2::Conversation::Canvas; | ||
| 28 | use Google::Actions::Sdk::V2::Interactionmodel::Prompt::StaticCanvasPrompt; | ||
| 29 | use Google::Actions::Sdk::V2::LocalizedSettings; | ||
| 30 | use Google::Actions::Sdk::V2::Interactionmodel::Type::ClassReference; | ||
| 31 | use Google::Actions::Sdk::V2::Interactionmodel::Prompt::StaticSimplePrompt; | ||
| 32 | use Google::Actions::Sdk::V2::Interactionmodel::Prompt::SurfaceCapabilities; | ||
| 33 | use Google::Actions::Sdk::V2::Webhook; | ||
| 34 | use Google::Actions::Sdk::V2::Interactionmodel::Type::EntityDisplay; | ||
| 35 | use Google::Actions::Sdk::V2::Interactionmodel::EntitySet; | ||
| 36 | use Google::Actions::Sdk::V2::AccountLinking; | ||
| 37 | use Google::Actions::Sdk::V2::Interactionmodel::Prompt::Suggestion; | ||
| 38 | use Google::Actions::Sdk::V2::Interactionmodel::Prompt::StaticImagePrompt; | ||
| 39 | use Google::Actions::Sdk::V2::Conversation::Media; | ||
| 40 | use Google::Actions::Sdk::V2::Conversation::Collection; | ||
| 41 | use Google::Actions::Sdk::V2::ReleaseChannel; | ||
| 42 | use Google::Actions::Sdk::V2::Version; | ||
| 43 | use Google::Actions::Sdk::V2::Conversation::Card; | ||
| 44 | use Google::Actions::Sdk::V2::Conversation::Table; | ||
| 45 | use Google::Actions::Sdk::V2::Interactionmodel::Intent; | ||
| 46 | use Google::Actions::Sdk::V2::Interactionmodel::Type::SynonymType; | ||
| 47 | use Google::Actions::Sdk::V2::Interactionmodel::Type::RegularExpressionType; | ||
| 48 | use Google::Actions::Sdk::V2::Interactionmodel::Type::FreeTextType; | ||
| 49 | use Google::Actions::Sdk::V2::Settings; | ||
| 50 | use Google::Actions::Sdk::V2::Interactionmodel::Prompt::StaticMediaPrompt; | ||
| 51 | use Google::Actions::Sdk::V2::Interactionmodel::Prompt::StaticCollectionPrompt; | ||
| 52 | use Google::Actions::Sdk::V2::Interactionmodel::Prompt::StaticCardPrompt; | ||
| 53 | use Google::Actions::Sdk::V2::Interactionmodel::Prompt::StaticListPrompt; | ||
| 54 | use Google::Actions::Sdk::V2::Interactionmodel::Prompt::StaticCollectionBrowsePrompt; | ||
| 55 | use Google::Actions::Sdk::V2::Interactionmodel::Prompt::StaticTablePrompt; | ||
| 56 | use Google::Actions::Sdk::V2::Conversation::Content; | ||
| 57 | use Google::Actions::Sdk::V2::Interactionmodel::Type::Type; | ||
| 58 | use Google::Actions::Sdk::V2::Interactionmodel::Prompt::StaticContentPrompt; | ||
| 59 | use Google::Actions::Sdk::V2::Conversation::Prompt; | ||
| 60 | use Google::Actions::Sdk::V2::Interactionmodel::Prompt::StaticPrompt; | ||
| 61 | use Google::Actions::Sdk::V2::Conversation::Scene; | ||
| 62 | use Google::Actions::Sdk::V2::Interactionmodel::EventHandler; | ||
| 63 | use Google::Actions::Sdk::V2::EventLogs; | ||
| 64 | use Google::Actions::Sdk::V2::Interactionmodel::IntentEvent; | ||
| 65 | use Google::Actions::Sdk::V2::Interactionmodel::ConditionalEvent; | ||
| 66 | use Google::Actions::Sdk::V2::Interactionmodel::Slot; | ||
| 67 | use Google::Actions::Sdk::V2::Interactionmodel::GlobalIntentEvent; | ||
| 68 | use Google::Actions::Sdk::V2::ActionsTesting; | ||
| 69 | use Google::Actions::Sdk::V2::Interactionmodel::Scene; | ||
| 70 | use Google::Actions::Sdk::V2::ConfigFile; | ||
| 71 | use Google::Actions::Sdk::V2::Files; | ||
| 72 | use Google::Actions::Sdk::V2::ActionsSdk; | ||
| 73 | |||
| 74 | our $VERSION = '0.06'; | ||
| 75 | |||
| 76 | has credentials => ( is => 'ro', required => 0 ); | ||
| 77 | has transport => ( is => 'rw' ); | ||
| 78 | |||
| 79 | sub BUILD { | ||
| 80 | my ($self) = @_; | ||
| 81 | |||
| 82 | my $auth = $self->credentials; | ||
| 83 | if (!defined $auth) { | ||
| 84 | $auth = Google::Auth->default(); | ||
| 85 | } elsif (!eval { $auth->can('get_token') }) { | ||
| 86 | croak 'Invalid credentials object: must implement get_token()'; | ||
| 87 | } | ||
| 88 | my $token = $auth->get_token(); | ||
| 89 | |||
| 90 | my $target = 'actions.googleapis.com:443'; | ||
| 91 | my $t = $self->transport || 'grpc'; | ||
| 92 | |||
| 93 | if (ref($t) && eval { $t->can('call') }) { | ||
| 94 | # Already a transport object | ||
| 95 | } elsif (lc($t) eq 'rest') { | ||
| 96 | my $client = Google::Cloud::REST::Client->new( | ||
| 97 | target => $target, | ||
| 98 | auth_token => $token, | ||
| 99 | ); | ||
| 100 | $self->transport($client); | ||
| 101 | } else { | ||
| 102 | my $client = Google::gRPC::Client->new( | ||
| 103 | target => $target, | ||
| 104 | auth_token => $token, | ||
| 105 | ); | ||
| 106 | $self->transport($client); | ||
| 107 | } | ||
| 108 | } | ||
| 109 | |||
| 110 | sub send_interaction { | ||
| 111 | my ($self, %params) = @_; | ||
| 112 | |||
| 113 | my $request_class = 'Google::Actions::Sdk::V2::ActionsTesting::SendInteractionRequest'; | ||
| 114 | my $request = eval { $request_class->new(\%params) }; | ||
| 115 | my $new_err = $@; | ||
| 116 | if (!$request) { | ||
| 117 | $request = eval { $request_class->new(%params) }; | ||
| 118 | $new_err ||= $@; | ||
| 119 | } | ||
| 120 | if (!$request) { | ||
| 121 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 122 | } | ||
| 123 | |||
| 124 | my $response_class = 'Google::Actions::Sdk::V2::ActionsTesting::SendInteractionResponse'; | ||
| 125 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 126 | return $self->transport->call({ | ||
| 127 | http_method => 'POST', | ||
| 128 | path => '/google.actions.sdk.v2.ActionsTesting/SendInteraction', | ||
| 129 | request => $request, | ||
| 130 | response_class => $response_class, | ||
| 131 | }); | ||
| 132 | } | ||
| 133 | |||
| 134 | my $response = $self->transport->call({ | ||
| 135 | service => 'google.actions.sdk.v2.ActionsTesting', | ||
| 136 | method => 'SendInteraction', | ||
| 137 | request => $request, | ||
| 138 | response_class => $response_class, | ||
| 139 | }); | ||
| 140 | |||
| 141 | return $response; | ||
| 142 | } | ||
| 143 | |||
| 144 | sub match_intents { | ||
| 145 | my ($self, %params) = @_; | ||
| 146 | |||
| 147 | my $request_class = 'Google::Actions::Sdk::V2::ActionsTesting::MatchIntentsRequest'; | ||
| 148 | my $request = eval { $request_class->new(\%params) }; | ||
| 149 | my $new_err = $@; | ||
| 150 | if (!$request) { | ||
| 151 | $request = eval { $request_class->new(%params) }; | ||
| 152 | $new_err ||= $@; | ||
| 153 | } | ||
| 154 | if (!$request) { | ||
| 155 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 156 | } | ||
| 157 | |||
| 158 | my $response_class = 'Google::Actions::Sdk::V2::ActionsTesting::MatchIntentsResponse'; | ||
| 159 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 160 | return $self->transport->call({ | ||
| 161 | http_method => 'POST', | ||
| 162 | path => '/google.actions.sdk.v2.ActionsTesting/MatchIntents', | ||
| 163 | request => $request, | ||
| 164 | response_class => $response_class, | ||
| 165 | }); | ||
| 166 | } | ||
| 167 | |||
| 168 | my $response = $self->transport->call({ | ||
| 169 | service => 'google.actions.sdk.v2.ActionsTesting', | ||
| 170 | method => 'MatchIntents', | ||
| 171 | request => $request, | ||
| 172 | response_class => $response_class, | ||
| 173 | }); | ||
| 174 | |||
| 175 | return $response; | ||
| 176 | } | ||
| 177 | |||
| 178 | sub set_web_and_app_activity_control { | ||
| 179 | my ($self, %params) = @_; | ||
| 180 | |||
| 181 | my $request_class = 'Google::Actions::Sdk::V2::ActionsTesting::SetWebAndAppActivityControlRequest'; | ||
| 182 | my $request = eval { $request_class->new(\%params) }; | ||
| 183 | my $new_err = $@; | ||
| 184 | if (!$request) { | ||
| 185 | $request = eval { $request_class->new(%params) }; | ||
| 186 | $new_err ||= $@; | ||
| 187 | } | ||
| 188 | if (!$request) { | ||
| 189 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 190 | } | ||
| 191 | |||
| 192 | my $response_class = 'Google::Protobuf::Empty::Empty'; | ||
| 193 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 194 | return $self->transport->call({ | ||
| 195 | http_method => 'POST', | ||
| 196 | path => '/google.actions.sdk.v2.ActionsTesting/SetWebAndAppActivityControl', | ||
| 197 | request => $request, | ||
| 198 | response_class => $response_class, | ||
| 199 | }); | ||
| 200 | } | ||
| 201 | |||
| 202 | my $response = $self->transport->call({ | ||
| 203 | service => 'google.actions.sdk.v2.ActionsTesting', | ||
| 204 | method => 'SetWebAndAppActivityControl', | ||
| 205 | request => $request, | ||
| 206 | response_class => $response_class, | ||
| 207 | }); | ||
| 208 | |||
| 209 | return $response; | ||
| 210 | } | ||
| 211 | 1; # End of Google::Cloud::Actions::Sdk::V2::ActionsTestingClient | ||
| 212 | |||
| 213 | __END__ | ||