///
/// Copyright (c) 2016 Dropbox, Inc. All rights reserved.
///
/// Auto-generated by Stone, do not modify.
///

import Foundation

/// Routes for the {{ class_name(namespace.name) }} namespace
/// For Objective-C compatible routes see DB{{ fmt_class(namespace.name) }}Routes
public class {{ fmt_class(class_name(namespace.name)) }}Routes: DropboxTransportClientOwning {
    public let client: {{ transport_client_name }}
    required init(client: {{ transport_client_name }}) {
        self.client = client
    }

    {% for route in namespace.routes %}
    {% if valid_route_for_auth_type(route) %}
    {% for args_data in route_client_args(route) %}
    {{ route_doc(route) }}
    ///
    {% if route.attrs.get('scope') is not none %}
    /// - scope: {{ route.attrs.get('scope') }}
    ///
    {% endif %}
    {% for route_param_doc in route_param_docs(namespace, route, args_data) %}
    {{ route_param_doc }}
    {% endfor %}
    ///
    {{ route_returns_doc(route) }}
    {% if route.deprecated %}
    {{ deprecation_warning(route) }}
    {% endif %}
    @discardableResult public func {{ fmt_func(route.name, route.version) }}({{ route_args(namespace, route, args_data) }}) -> {{ request_object_name(route, args_data) }}<{{ fmt_serial_type(route.result_data_type) }}, {{ fmt_serial_type(route.error_data_type) }}> {
        let route = {{ fmt_class(namespace.name) }}.{{ fmt_func(route.name, route.version) }}
        {% if is_struct_type(route.arg_data_type) %}
        let serverArgs = {{ fmt_type(route.arg_data_type) }}({{ server_args(route) }})
        {% elif is_union_type(route.arg_data_type) %}
        let serverArgs = {{ fmt_var(route.arg_data_type.name) }}
        {% endif %}
        return client.request({{ return_args(route, args_data) }})
    }

    {% endfor %}
    {% endif %}
    {% endfor %}
}

