Class: Infrawrench::CurrencyNamespace

Inherits:
Object
  • Object
show all
Defined in:
lib/infrawrench/client.rb,
sig/infrawrench/sdk.rbs

Overview

client.currency

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ CurrencyNamespace

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CurrencyNamespace.

Parameters:



5442
5443
5444
5445
# File 'lib/infrawrench/client.rb', line 5442

def initialize(transport)
  @transport = transport
  @rates = CurrencyRatesNamespace.new(@transport)
end

Instance Attribute Details

#ratesCurrencyRatesNamespace (readonly)

Returns client.currency.rates.

Returns:



5438
5439
5440
# File 'lib/infrawrench/client.rb', line 5438

def rates
  @rates
end

Instance Method Details

#get(org_id: nil, request_options: nil) ⇒ Hash

The org's display currency and exchange rate table

Readable with costs:read rather than a settings permission: anyone who can see a converted total has to be able to see what it was converted at, or the number is unauditable.

Requires permission: costs:read.

GET /api/org/orgId/currency

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as CurrencyConfig — see sig/infrawrench/sdk.rbs.

Raises:



5462
5463
5464
5465
5466
5467
5468
5469
# File 'lib/infrawrench/client.rb', line 5462

def get(org_id: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/currency",
    path_params: { "orgId" => org_id },
    request_options: request_options
  )
end

#update(body:, org_id: nil, request_options: nil) ⇒ Hash

Set or clear the org's display currency

Setting a currency opts the organization into converted totals; null turns conversion off everywhere and restores the per-currency view. Clearing does not delete the rate table, so conversion can be turned back on without re-stating anything. Only currencies with a configured rate are converted — Infrawrench never fetches live exchange rates.

Requires permission: org:settings:write.

PUT /api/org/orgId/currency

Raises on 400: Bad request

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • body (Hash)

    Request body, shaped as CurrencySettings.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • body: (currency_settings)
  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as CurrencySettings — see sig/infrawrench/sdk.rbs.

Raises:



5491
5492
5493
5494
5495
5496
5497
5498
5499
# File 'lib/infrawrench/client.rb', line 5491

def update(body:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "PUT",
    path: "/api/org/{orgId}/currency",
    path_params: { "orgId" => org_id },
    body: body,
    request_options: request_options
  )
end