All Downloads are FREE. Search and download functionalities are using the official Maven repository.

htmlDocs2.sample_csharp.mustache Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
using System;
using System.Diagnostics;
using {{packageName}}.Api;
using {{packageName}}.Client;
using {{packageName}}.Model;

namespace Example
{
    public class {{operationId}}Example
    {
        public void main()
        {
            {{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}
            // Configure HTTP basic authorization: {{{name}}}
            Configuration.Default.Username = "YOUR_USERNAME";
            Configuration.Default.Password = "YOUR_PASSWORD";{{/isBasic}}{{#isApiKey}}
            // Configure API key authorization: {{{name}}}
            Configuration.Default.ApiKey.Add("{{{keyParamName}}}", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer");{{/isApiKey}}{{#isOAuth}}
            // Configure OAuth2 access token for authorization: {{{name}}}
            Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";{{/isOAuth}}{{/authMethods}}
            {{/hasAuthMethods}}

            var apiInstance = new {{classname}}();
            {{#allParams}}
            {{#isPrimitiveType}}
            var {{paramName}} = {{{example}}};  // {{{dataType}}} | {{{unescapedDescription}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
            {{/isPrimitiveType}}
            {{^isPrimitiveType}}
            var {{paramName}} = new {{{dataType}}}(); // {{{dataType}}} | {{{unescapedDescription}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
            {{/isPrimitiveType}}
            {{/allParams}}

            try
            {
                {{#summary}}
                // {{{.}}}
                {{/summary}}
                {{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
                Debug.WriteLine(result);{{/returnType}}
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message );
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy