Class: Infrawrench::CurrencyRatesNamespace

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

Overview

client.currency.rates

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ CurrencyRatesNamespace

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 CurrencyRatesNamespace.

Parameters:



5298
5299
5300
# File 'lib/infrawrench/client.rb', line 5298

def initialize(transport)
  @transport = transport
end

Instance Method Details

#delete(rate_id:, org_id: nil, request_options: nil) ⇒ Hash

Delete one exchange rate

Removing a rate makes the days it covered fall back to the next-older rate, or to unconverted if none remains. Spend never disappears — it reverts to its own currency.

Requires permission: org:settings:write.

DELETE /api/org/orgId/currency/rates/rateId

Raises on 404: Not found

Parameters:

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

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

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

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

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

Returns:

  • (Hash)

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

Raises:



5320
5321
5322
5323
5324
5325
5326
5327
# File 'lib/infrawrench/client.rb', line 5320

def delete(rate_id:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "DELETE",
    path: "/api/org/{orgId}/currency/rates/{rateId}",
    path_params: { "orgId" => org_id, "rateId" => rate_id },
    request_options: request_options
  )
end

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

Create or replace one exchange rate

Upserts on (fromCurrency, toCurrency, effectiveFrom) — one rate per pair per day, so correcting a rate replaces it rather than adding a second one whose precedence a reader would have to guess. Rates are stated to the display currency in one hop: nothing inverts a rate or chains two, because both produce a number you never stated.

Requires permission: org:settings:write.

PUT /api/org/orgId/currency/rates

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 ExchangeRateInput.

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

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

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

Returns:

  • (Hash)

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

Raises:



5349
5350
5351
5352
5353
5354
5355
5356
5357
# File 'lib/infrawrench/client.rb', line 5349

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