File size: 2,124 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
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.

import { type Client, http } from '../core.js'
import { type Result, type RequestOptions } from '../lib/types.js'
import { request } from '../lib/request.js'
import { toWire, fromWire, assertValid } from '../lib/wire.js'
import * as schemas from '../models/schemas.js'
import type {
  GetOrganizationDefaultTaxCodesRequest,
  GetOrganizationDefaultTaxCodesResponse,
  UpdateOrganizationDefaultTaxCodesRequest,
  UpdateOrganizationDefaultTaxCodesResponse,
} from '../models/operations/defaults.js'

/**
 * Get organization default tax codes
 *
 * GET /openmeter/defaults/tax-codes
 */
export function getOrganizationDefaultTaxCodes(
  client: Client,
  req: GetOrganizationDefaultTaxCodesRequest,
  options?: RequestOptions,
): Promise<Result<GetOrganizationDefaultTaxCodesResponse>> {
  return request(() =>
    http(client)
      .get('openmeter/defaults/tax-codes', options)
      .json()
      .then((data) => {
        if (client._options.validate) {
          assertValid(schemas.getOrganizationDefaultTaxCodesResponseWire, data)
        }
        return fromWire(data, schemas.getOrganizationDefaultTaxCodesResponse)
      }),
  )
}

/**
 * Update organization default tax codes
 *
 * PUT /openmeter/defaults/tax-codes
 */
export function updateOrganizationDefaultTaxCodes(
  client: Client,
  req: UpdateOrganizationDefaultTaxCodesRequest,
  options?: RequestOptions,
): Promise<Result<UpdateOrganizationDefaultTaxCodesResponse>> {
  return request(() => {
    const body = toWire(req, schemas.updateOrganizationDefaultTaxCodesBody)
    if (client._options.validate) {
      assertValid(schemas.updateOrganizationDefaultTaxCodesBodyWire, body)
    }
    return http(client)
      .put('openmeter/defaults/tax-codes', { ...options, json: body })
      .json()
      .then((data) => {
        if (client._options.validate) {
          assertValid(
            schemas.updateOrganizationDefaultTaxCodesResponseWire,
            data,
          )
        }
        return fromWire(data, schemas.updateOrganizationDefaultTaxCodesResponse)
      })
  })
}