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
# File 'lib/meshx-plugin-sdk.rb', line 336

def initialize()
end

Instance Method Details

#display_response(response) ⇒ Object



346
347
348
349
350
# File 'lib/meshx-plugin-sdk.rb', line 346

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

#file_cache_read(uri, destination) ⇒ Object



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

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



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

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_messagesObject



352
353
354
355
356
357
# File 'lib/meshx-plugin-sdk.rb', line 352

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

#pase_response(response) ⇒ Object



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

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

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

#send_complete_eventsObject



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

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



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

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



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

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



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

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