// {{folder_name}} API 客户端
// Generated by apifox-flow, do not edit manually
{{#if imports}}
{{#each imports}}
import { {{this}} } from '{{@root.import_path}}';
{{/each}}

{{/if}}
export class {{class_name}} {
  private baseUrl: string;
  private headers: Record<string, string>;

  constructor(baseUrl: string = '{{default_base_url}}', headers: Record<string, string> = {}) {
    this.baseUrl = baseUrl;
    this.headers = { 'Content-Type': 'application/json', ...headers };
  }

{{#each methods}}
  // {{summary}}
  async {{method_name}}({{#if parameters}}params: { {{#each parameters}}{{name}}{{#unless required}}?{{/unless}}: {{type_}}{{#unless @last}}, {{/unless}}{{/each}} }}{{/if}}): Promise<{{response_type}}> {
    const response = await fetch(`${this.baseUrl}{{path}}`, {
      method: '{{http_method}}',
      headers: this.headers,{{#unless is_get}}
      body: JSON.stringify(params),{{/unless}}
    });
    return response.json();
  }

{{/each}}
}
