Module: Monkeylearn::WorkflowData

Extended by:
Requests
Defined in:
lib/monkeylearn/workflows.rb

Class Method Summary collapse

Methods included from Requests

get_connection, get_exception_class, raise_for_status, request, throttled?

Class Method Details

.build_endpoint(module_id, *args) ⇒ Object



100
101
102
# File 'lib/monkeylearn/workflows.rb', line 100

def build_endpoint(module_id, *args)
  File.join('workflows', module_id, 'data', *args.collect { |x| x.to_s }) + '/'
end

.create(module_id, options = {}) ⇒ Object



104
105
106
107
108
109
# File 'lib/monkeylearn/workflows.rb', line 104

def create(module_id, options = {})
  data = {
      data: options[:data],
  }.delete_if { |k,v| v.nil? }
  request(:post, build_endpoint(module_id), data)
end

.list(module_id, options = {}) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/monkeylearn/workflows.rb', line 111

def list(module_id, options = {})
  query_params = {
    batch_id: options[:batch_id],
    is_processed: options[:is_processed],
    sent_to_process_date_from: options[:sent_to_process_date_from],
    sent_to_process_date_to: options[:sent_to_process_date_to],
    page: options[:page],
    per_page: options[:per_page],
  }.delete_if { |k,v| v.nil? }

  request(:get, build_endpoint(module_id), nil, query_params)
end