Class: Cloudflare::RealtimeKit::App

Inherits:
Cloudflare::Resource show all
Defined in:
lib/cloudflare/realtime_kit/app.rb

Overview

An app in your Cloudflare RealtimeKit account. Apps are the top-level tenant — meetings, sessions, recordings, presets, webhooks, livestreams, and analytics all live underneath an app.

Apps are list+create only; the API doesn’t expose a member endpoint (no GET /apps/Cloudflare::Resource#id, no PATCH, no DELETE).

Cloudflare.configure do |c|
  c.api_token  = ENV["CLOUDFLARE_API_TOKEN"]
  c. = ENV["CLOUDFLARE_ACCOUNT_ID"]
end

app = Cloudflare::RealtimeKit::App.create(name: "Production")
app.id         # => "abc123"
app.name       # => "Production"
app.created_at # => Time

Cloudflare::RealtimeKit::App.all

Constant Summary

Constants inherited from Cloudflare::Resource

Cloudflare::Resource::ENVELOPE_KEYS

Instance Attribute Summary

Attributes inherited from Cloudflare::Resource

#scope

Class Method Summary collapse

Methods inherited from Cloudflare::Resource

#==, #[], attribute, attributes, #attributes, collection_path, #destroy, find, has_many, has_one, #hash, #id, #initialize, member_path, read_only, read_only?, #reload, scope_params, scope_required, #set_attrs_from_response, #to_h, to_wire_keys, unwrap_envelope, #update, wire_kwarg, wire_name_for_request, wire_name_for_response

Constructor Details

This class inherits a constructor from Cloudflare::Resource

Class Method Details

.all(account_id: nil) ⇒ Object

GET /accounts/account_id/realtime/kit/apps



42
43
44
45
46
# File 'lib/cloudflare/realtime_kit/app.rb', line 42

def all(account_id: nil)
  scope    = build_scope(account_id: )
  response = Connection.instance.request(:get, interpolate(_collection_path, scope))
  Array(unwrap_envelope(response)).map { new(_1, scope: scope) }
end

.create(name:, account_id: nil) ⇒ Object

POST /accounts/account_id/realtime/kit/apps

The create response double-wraps the app payload as { data: { app: {…} } }, so we peel both layers before constructing the instance. List responses use the standard { data: […] } envelope and don’t need this dance.



35
36
37
38
39
# File 'lib/cloudflare/realtime_kit/app.rb', line 35

def create(name:, account_id: nil)
  scope    = build_scope(account_id: )
  response = Connection.instance.request(:post, interpolate(_collection_path, scope), body: { "name" => name })
  new(unwrap_create_payload(response), scope: scope)
end