class Clarinet::Inputs
Public Class Methods
new(app, raw_data = [])
click to toggle source
@!visibility private
# File lib/clarinet/inputs.rb, line 23 def initialize(app, raw_data = []) @app = app @raw_data = raw_data @inputs = raw_data.map do |input_data| Clarinet::Input.new app, input_data end end
Public Instance Methods
create(inputs)
click to toggle source
Adds an input or multiple inputs @return [Clarinet::Inputs] Instance of Inputs
# File lib/clarinet/inputs.rb, line 35 def create(inputs) inputs = [inputs] unless inputs.is_a? Array inputs = inputs.map { |input| Clarinet::Utils.format_input(input) } data = @app.client.inputs_create inputs Clarinet::Inputs.new data[:inputs] end
delete(id)
click to toggle source
Delete an input or a list of inputs by id @return [Hash] API response
# File lib/clarinet/inputs.rb, line 45 def delete(id) @app.client.input_delete id if id.is_a? String @app.client.inputs_delete id if id.is_a? Array end
delete_all()
click to toggle source
Delete all inputs @return [Hash] API response
# File lib/clarinet/inputs.rb, line 52 def delete_all @app.client.inputs_delete_all end
delete_concepts(inputs)
click to toggle source
# File lib/clarinet/inputs.rb, line 88 def delete_concepts(inputs) update 'remove', inputs end
get(id)
click to toggle source
Get input by id @param id [String] The input id @return [Clarinet::Input] Input
instance
# File lib/clarinet/inputs.rb, line 69 def get(id) data = @app.client.input id Clarinet::Input.new @app, data[:input] end
list(options = { page: 1, per_page: 20 })
click to toggle source
Get all inputs in app @param options [Hash] Listing options @option options [Int] :page (1) The page number @option options [Int] :per_page (20) Number of models to return per page @return [Clarinet::Inputs] Inputs
instance
# File lib/clarinet/inputs.rb, line 61 def list(options = { page: 1, per_page: 20 }) data = @app.client.inputs options Clarinet::Inputs.new @app, data[:inputs] end
merge_concepts(inputs)
click to toggle source
# File lib/clarinet/inputs.rb, line 80 def merge_concepts(inputs) update 'merge', inputs end
overwrite_concepts(inputs)
click to toggle source
# File lib/clarinet/inputs.rb, line 84 def overwrite_concepts(inputs) update 'overwrite', inputs end
status()
click to toggle source
Get inputs status (number of uploaded, in process or failed inputs) @return [Hash] API response
# File lib/clarinet/inputs.rb, line 76 def status @app.client.inputs_status end
Private Instance Methods
update(action, inputs)
click to toggle source
# File lib/clarinet/inputs.rb, line 94 def update(action, inputs) inputs = [inputs] unless inputs.is_a? Array inputs = inputs.map { |input| Clarinet::Utils.format_input(input) } data = { action: action, inputs: inputs } response_data = @app.client.inputs_update data Clarinet::Inputs.new @app, response_data[:inputs] end