Class: FloopFloop::Library
- Inherits:
-
Object
- Object
- FloopFloop::Library
- Defined in:
- lib/floopfloop/library.rb
Instance Method Summary collapse
- #clone(project_id, subdomain:) ⇒ Object
-
#initialize(client) ⇒ Library
constructor
A new instance of Library.
-
#list(**opts) ⇒ Object
Backend can emit either a bare Array or a => […] envelope — we tolerate both, matching the Node / Python / Go / Rust SDKs.
Constructor Details
#initialize(client) ⇒ Library
Returns a new instance of Library.
5 6 7 |
# File 'lib/floopfloop/library.rb', line 5 def initialize(client) @client = client end |
Instance Method Details
#clone(project_id, subdomain:) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/floopfloop/library.rb', line 29 def clone(project_id, subdomain:) @client.request( "POST", "/api/v1/library/#{url_encode(project_id)}/clone", body: { subdomain: subdomain }, ) end |
#list(**opts) ⇒ Object
Backend can emit either a bare Array or a => […] envelope —we tolerate both, matching the Node / Python / Go / Rust SDKs.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/floopfloop/library.rb', line 11 def list(**opts) query = {} query[:botType] = opts[:bot_type] if opts.key?(:bot_type) query[:search] = opts[:search] if opts.key?(:search) query[:sort] = opts[:sort] if opts.key?(:sort) query[:page] = opts[:page] if opts.key?(:page) query[:limit] = opts[:limit] if opts.key?(:limit) data = @client.request("GET", "/api/v1/library", query: query.empty? ? nil : query) return data if data.is_a?(Array) return data["items"] if data.is_a?(Hash) && data["items"].is_a?(Array) raise FloopFloop::Error.new( code: "UNKNOWN", message: "library list: unrecognised response shape", ) end |