Class: Api2Convert::Resource::Conversions
- Inherits:
-
Object
- Object
- Api2Convert::Resource::Conversions
- Defined in:
- lib/api2convert/resource/conversions.rb
Overview
The conversions catalog (GET /conversions).
The source of truth for which targets exist and which options each accepts.
Instance Method Summary collapse
-
#initialize(transport) ⇒ Conversions
constructor
A new instance of Conversions.
-
#list(category = nil, target = nil, page = 1) ⇒ Object
List supported conversions, optionally filtered by category/target.
-
#options(target, category = nil) ⇒ Object
The option schema (type / enum / default / range) for a single target.
Constructor Details
#initialize(transport) ⇒ Conversions
Returns a new instance of Conversions.
9 10 11 |
# File 'lib/api2convert/resource/conversions.rb', line 9 def initialize(transport) @transport = transport end |
Instance Method Details
#list(category = nil, target = nil, page = 1) ⇒ Object
List supported conversions, optionally filtered by category/target. Each
entry: { id, category, target, options }.
15 16 17 18 19 20 21 |
# File 'lib/api2convert/resource/conversions.rb', line 15 def list(category = nil, target = nil, page = 1) query = { "page" => page.to_s } query["category"] = category unless category.nil? query["target"] = target unless target.nil? rows = @transport.request("GET", "/conversions", nil, query) Support::Data.as_list(rows).grep(Hash) end |
#options(target, category = nil) ⇒ Object
The option schema (type / enum / default / range) for a single target.
category is optional — pass it only to disambiguate an ambiguous target.
25 26 27 28 29 30 |
# File 'lib/api2convert/resource/conversions.rb', line 25 def (target, category = nil) rows = list(category, target) first = rows.first || {} opts = first["options"] opts.is_a?(Hash) ? opts : {} end |