File size: 2,514 Bytes
1477a90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.

import { type Client } from '../core.js'
import { unwrap, type RequestOptions } from '../lib/types.js'
import { paginatePages } from '../lib/paginate.js'
import {
  createTaxCode,
  getTaxCode,
  listTaxCodes,
  upsertTaxCode,
  deleteTaxCode,
} from '../funcs/tax.js'
import type {
  CreateTaxCodeRequest,
  CreateTaxCodeResponse,
  GetTaxCodeRequest,
  GetTaxCodeResponse,
  ListTaxCodesRequest,
  ListTaxCodesResponse,
  UpsertTaxCodeRequest,
  UpsertTaxCodeResponse,
  DeleteTaxCodeRequest,
  DeleteTaxCodeResponse,
} from '../models/operations/tax.js'
import type { TaxCode } from '../models/types.js'

export class Tax {
  constructor(private readonly _client: Client) {}

  /**
   * Create tax code
   *
   * POST /openmeter/tax-codes
   */
  async createCode(
    request: CreateTaxCodeRequest,
    options?: RequestOptions,
  ): Promise<CreateTaxCodeResponse> {
    return unwrap(await createTaxCode(this._client, request, options))
  }

  /**
   * Get tax code
   *
   * GET /openmeter/tax-codes/{taxCodeId}
   */
  async getCode(
    request: GetTaxCodeRequest,
    options?: RequestOptions,
  ): Promise<GetTaxCodeResponse> {
    return unwrap(await getTaxCode(this._client, request, options))
  }

  /**
   * List tax codes
   *
   * GET /openmeter/tax-codes
   */
  async listCodes(
    request?: ListTaxCodesRequest,
    options?: RequestOptions,
  ): Promise<ListTaxCodesResponse> {
    return unwrap(await listTaxCodes(this._client, request, options))
  }

  /**
   * List tax codes
   *
   * Iterates every item across all pages, fetching more as the returned iterable is consumed.
   *
   * GET /openmeter/tax-codes
   */
  listCodesAll(
    request?: ListTaxCodesRequest,
    options?: RequestOptions,
  ): AsyncIterable<TaxCode> {
    return paginatePages(
      (req, opts) => listTaxCodes(this._client, req, opts),
      request ?? {},
      options,
    )
  }

  /**
   * Upsert tax code
   *
   * PUT /openmeter/tax-codes/{taxCodeId}
   */
  async upsertCode(
    request: UpsertTaxCodeRequest,
    options?: RequestOptions,
  ): Promise<UpsertTaxCodeResponse> {
    return unwrap(await upsertTaxCode(this._client, request, options))
  }

  /**
   * Delete tax code
   *
   * DELETE /openmeter/tax-codes/{taxCodeId}
   */
  async deleteCode(
    request: DeleteTaxCodeRequest,
    options?: RequestOptions,
  ): Promise<DeleteTaxCodeResponse> {
    return unwrap(await deleteTaxCode(this._client, request, options))
  }
}