templates.ResolvedContext.hbs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of polyapi-maven-plugin Show documentation
Show all versions of polyapi-maven-plugin Show documentation
Maven plugin to run handle Poly API functions.
package {{packageName}};
import io.polyapi.commons.api.websocket.WebSocketClient;
import io.polyapi.client.internal.proxy.PolyProxyFactory;
import io.polyapi.client.internal.model.PolyContext;
import io.polyapi.client.api.AuthTokenEventConsumer;
import io.polyapi.client.api.model.PolyEntity;
import io.polyapi.client.api.AuthTokenOptions;
import io.polyapi.commons.api.model.PolyGeneratedClass;
{{~#each this.imports}}
import {{{this}}};
{{~/each}}
@PolyGeneratedClass
public class {{className}} extends PolyContext {
{{~#each functionSpecifications}}
private final {{this.className}} {{this.name}};
{{~/each}}
{{~#each standardAuthFunctionSpecifications}}
private final {{this.className}} {{this.name}};
{{~/each}}
{{~#each subresourceAuthFunctionSpecifications}}
private final {{this.className}} {{this.name}};
{{~/each}}
{{~#each serverVariableSpecifications}}
public final {{this.className}} {{this.name}};
{{~/each}}
{{~#each webhookHandlerSpecifications}}
private final {{this.className}} {{this.name}};
{{~/each}}
{{#each subcontexts}}
public final {{this.className}} {{this.name}};
{{~/each}}
public {{className}}(PolyProxyFactory proxyFactory, WebSocketClient webSocketClient) {
super(proxyFactory, webSocketClient);
{{~#each serverFunctionSpecifications}}
this.{{this.name}} = createServerFunctionProxy({{this.className}}.class);
{{~/each}}
{{~#each customFunctionSpecifications}}
this.{{this.name}} = createCustomFunctionProxy({{this.className}}.class);
{{~/each}}
{{~#each apiFunctionSpecifications}}
this.{{this.name}} = createApiFunctionProxy({{this.className}}.class);
{{~/each}}
{{~#each subresourceAuthFunctionSpecifications}}
this.{{this.name}} = createSubresourceAuthFunction({{this.className}}.class);
{{~/each}}
{{~#each standardAuthFunctionSpecifications}}
this.{{this.name}} = create{{#if audienceRequired}}Audience{{/if}}TokenAuthFunction({{this.className}}.class);
{{~/each}}
{{~#each serverVariableSpecifications}}
this.{{this.name}} = createServerVariableHandler({{this.className}}.class);
{{~/each}}
{{~#each webhookHandlerSpecifications}}
this.{{this.name}} = createPolyTriggerProxy({{this.className}}.class);
{{~/each}}
{{#each subcontexts}}
this.{{this.name}} = new {{this.className}}(proxyFactory, webSocketClient);
{{~/each}}
}
{{~#each functionSpecifications}}
public {{{this.returnType}}} {{{this.methodSignature}}} {
{{~#if this.returnsValue}}
return
{{~else}}
{{~/if}} this.{{this.name}}.{{this.name}}({{this.paramVariableNames}});
}
public {{{this.className}}} get{{{this.className}}}Function() {
return this.{{{this.name}}};
}
{{~/each}}
{{~#each subresourceAuthFunctionSpecifications}}
public void {{this.name}}(String token) {
this.{{this.name}}.{{this.name}}(token);
}
{{~/each}}
{{~#each standardAuthFunctionSpecifications}}
public void getToken(String clientId, String clientSecret{{#if this.audienceRequired}}, String audience{{/if}}, String[] scopes, AuthTokenEventConsumer callback) {
this.{{this.name}}.getToken(clientId, clientSecret{{#if this.audienceRequired}}, audience{{/if}}, scopes, callback);
}
public void getToken(String clientId, String clientSecret{{#if this.audienceRequired}}, String audience{{/if}}, String[] scopes, AuthTokenEventConsumer callback, AuthTokenOptions options) {
this.{{this.name}}.getToken(clientId, clientSecret{{#if this.audienceRequired}}, audience{{/if}}, scopes, callback, options);
}
{{~/each}}
{{~#each webhookHandlerSpecifications}}
public Handle handle{{this.className}}(Consumer<{{{this.eventType}}}> callback) {
return this.{{this.name}}.handle{{this.className}}(callback);
}
public Handle handle{{this.className}}(PolyEventConsumer<{{{this.eventType}}}> callback) {
return this.{{this.name}}.handle{{this.className}}(callback);
}
public void {{this.name}}(Consumer<{{{this.eventType}}}> callback) {
this.{{this.name}}.{{this.name}}(callback);
}
public void {{this.name}}(PolyEventConsumer<{{{this.eventType}}}> callback) {
this.{{this.name}}.{{this.name}}(callback);
}
{{~/each}}
{{~#each specifications}}
{{~#ifIsType this "AuthFunctionSpecification"}}
{{~#if subResource}}
public void {{name}}(String token) {
this.{{name}}.{{name}}(token);
}
{{~else}}
public void getToken(String clientId, String clientSecret{{#if
audienceRequired}}, String audience{{/if}}, String[] scopes, AuthTokenEventConsumer callback) {
this.{{name}}.getToken(clientId, clientSecret{{#if audienceRequired}}, audience{{/if}}, scopes, callback);
}
public void getToken(String clientId, String clientSecret{{#if
audienceRequired}}, String audience{{/if}}, String[] scopes, AuthTokenEventConsumer callback, AuthTokenOptions options) {
this.{{name}}.getToken(clientId, clientSecret{{#if
audienceRequired}}, audience{{/if}}, scopes, callback, options);
}
{{~/if}}
public {{{this.className}}} get{{{this.className}}}AuthFunction() {
return this.{{{this.name}}};
}
{{~/ifIsType}}
{{~/each}}
}