Module: Async::Matrix::Api

Defined in:
lib/async/matrix/api.rb,
lib/async/matrix/api/chain.rb,
lib/async/matrix/api/concat.rb,
lib/async/matrix/api/path_tree.rb

Overview

Runtime-generated Matrix Client-Server API built from official OpenAPI schemas.

Loads the OpenAPI 3.1.0 YAML files from data/matrix-spec/api/client-server/ at require-time and builds a PathTree trie of all valid endpoints. API calls are constructed via StringBuilder method chains, validated against the tree, and terminated by .get(), .post(), .put(), or .delete().

Usage:

# Via Client:
client.api..whoami.get
client.api.createRoom.post(name: "Pub", preset: "public_chat")
client.api.rooms("!room:ex.com").ban.post(user_id: "@bad:ex.com")
client.api.rooms("!room:ex.com").messages.get(dir: "b", limit: 10)

# Standalone (for inspection):
gateway = Async::Matrix::Api::Gateway.new(client)
chain = gateway.chain
chain.rooms("!room:ex.com").state("m.room.name", "").get

Defined Under Namespace

Classes: Chain, Concat, Gateway, PathTree

Class Method Summary collapse

Class Method Details

.path_treeObject

The shared PathTree instance, loaded once from the bundled schemas.



32
33
34
# File 'lib/async/matrix/api.rb', line 32

def self.path_tree
  @path_tree ||= PathTree.load
end

.reset!Object

Reset the cached path tree (useful for testing or reloading schemas).



37
38
39
# File 'lib/async/matrix/api.rb', line 37

def self.reset!
  @path_tree = nil
end