Module: Async::Discord::Api
- Defined in:
- lib/async/discord/api.rb,
lib/async/discord/api/path_tree.rb
Overview
Runtime-generated Discord HTTP API built from the official OpenAPI spec.
Loads the OpenAPI 3.1.0 JSON file from data/discord-api-spec/openapi.json at require-time and builds a PathTree trie of all valid endpoints. API calls are constructed via method chains (reusing Async::Matrix::Api::Chain), validated against the tree, and terminated by .get(), .post(), .put(), .patch(), or .delete().
Usage:
client.api.channels("123456")..post(content: "hello")
client.api.guilds("789").members.get(limit: 100)
client.api.users("@me").get
Defined Under Namespace
Class Method Summary collapse
-
.path_tree ⇒ Object
The shared PathTree instance, loaded once from the bundled spec.
-
.reset! ⇒ Object
Reset the cached path tree (useful for testing or reloading).
Class Method Details
.path_tree ⇒ Object
The shared PathTree instance, loaded once from the bundled spec.
27 28 29 |
# File 'lib/async/discord/api.rb', line 27 def self.path_tree @path_tree ||= PathTree.load end |
.reset! ⇒ Object
Reset the cached path tree (useful for testing or reloading).
32 33 34 |
# File 'lib/async/discord/api.rb', line 32 def self.reset! @path_tree = nil end |