Class: FoundationApi

Inherits:
Object
  • Object
show all
Defined in:
lib/meshx-plugin-sdk.rb

Instance Method Summary collapse

Constructor Details

#initializeFoundationApi

Returns a new instance of FoundationApi.



336
337
338
# File 'lib/meshx-plugin-sdk.rb', line 336

def initialize()
  @exit = false
end

Instance Method Details

#display_response(response) ⇒ Object



355
356
357
358
359
# File 'lib/meshx-plugin-sdk.rb', line 355

def display_response(response)
  puts("payload: #{response.payload}")
  puts("error: #{response.error}")
  puts("exit_code: #{response.exit_code}")
end

#exitObject



340
341
342
# File 'lib/meshx-plugin-sdk.rb', line 340

def exit()
  @exit = true
end

#file_cache_read(uri, destination) ⇒ Object



389
390
391
392
393
394
# File 'lib/meshx-plugin-sdk.rb', line 389

def file_cache_read(uri, destination)
  d, e = GoApi.file_cache_read(uri, destination)
  parsed = pase_response(d)
  display_response(parsed)
  return FileReadResult.new(parsed)
end

#file_cache_write(filename) ⇒ Object



396
397
398
399
400
401
# File 'lib/meshx-plugin-sdk.rb', line 396

def file_cache_write(filename)
  d, e = GoApi.file_cache_write(filename)
  parsed = pase_response(d)
  display_response(parsed)
  return FileWriteResult.new(parsed)
end

#get_exitObject



344
345
346
# File 'lib/meshx-plugin-sdk.rb', line 344

def get_exit()
  return @exit
end

#get_messagesObject



361
362
363
364
365
366
# File 'lib/meshx-plugin-sdk.rb', line 361

def get_messages()
  d, e = GoApi.get_messages()
  parsed = pase_response(d)
  display_response(parsed)
  return GetMessageResult.new(parsed)
end

#pase_response(response) ⇒ Object



348
349
350
351
352
353
# File 'lib/meshx-plugin-sdk.rb', line 348

def pase_response(response)
  data = JSON.parse(response)

  rtn = Response.new(data["payload"], data["error"], data["exit_code"])
  return rtn
end

#send_complete_eventsObject



403
404
405
406
407
408
# File 'lib/meshx-plugin-sdk.rb', line 403

def send_complete_events()
  d, e = GoApi.send_complete_events()
  parsed = pase_response(d)
  display_response(parsed)
  return SendCompleteResult.new(parsed)
end

#send_file_event(path, filename, originalpath, origin) ⇒ Object



375
376
377
378
379
380
# File 'lib/meshx-plugin-sdk.rb', line 375

def send_file_event(path, filename, originalpath, origin)
  d, e = GoApi.send_file_event(path, filename, originalpath, origin)
  parsed = pase_response(d)
  display_response(parsed)
  return SendMessageResult.new(parsed)
end

#send_folder_event(path, folder, originalpath, origin) ⇒ Object



382
383
384
385
386
387
# File 'lib/meshx-plugin-sdk.rb', line 382

def send_folder_event(path, folder, originalpath, origin)
  d, e = GoApi.send_folder_event(path, folder, originalpath, origin)
  parsed = pase_response(d)
  display_response(parsed)
  return SendFolderResult.new(parsed)
end

#send_message(data) ⇒ Object



368
369
370
371
372
373
# File 'lib/meshx-plugin-sdk.rb', line 368

def send_message(data)
  d, e = GoApi.send_message(data)
  parsed = pase_response(d)
  display_response(parsed)
  return SendMessageResult.new(parsed)
end