Class: Infrawrench::BillingNamespace

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

Overview

client.billing

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ BillingNamespace

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

Parameters:



2280
2281
2282
2283
# File 'lib/infrawrench/client.rb', line 2280

def initialize(transport)
  @transport = transport
  @capacity = BillingCapacityNamespace.new(@transport)
end

Instance Attribute Details

#capacityBillingCapacityNamespace (readonly)

Returns client.billing.capacity.

Returns:



2276
2277
2278
# File 'lib/infrawrench/client.rb', line 2276

def capacity
  @capacity
end

Instance Method Details

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

Start a Stripe Checkout session

Rejected with 400 for complimentary organizations — they are never billed.

Requires permission: billing:write.

POST /api/org/orgId/billing/checkout

Raises on 400: Bad request

Raises on 500: Server error

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 StripeRedirectUrl — see sig/infrawrench/sdk.rbs.

Raises:



2302
2303
2304
2305
2306
2307
2308
2309
# File 'lib/infrawrench/client.rb', line 2302

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

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

Get a Stripe customer portal URL

Requires permission: billing:write.

POST /api/org/orgId/billing/portal

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.

  • 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 StripeRedirectUrl — see sig/infrawrench/sdk.rbs.

Raises:



2324
2325
2326
2327
2328
2329
2330
2331
# File 'lib/infrawrench/client.rb', line 2324

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

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

Get the org's billing status (complimentary flag + subscription or null)

Requires permission: billing:read.

GET /api/org/orgId/billing/status

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 BillingStatus — see sig/infrawrench/sdk.rbs.

Raises:



2344
2345
2346
2347
2348
2349
2350
2351
# File 'lib/infrawrench/client.rb', line 2344

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