class Crossbelt::Plugins::Exporters::Xbui

Public Class Methods

description() click to toggle source
# File lib/crossbelt/plugins/exporters/xbui.rb, line 30
def self.description
  'Outputs data to XBUI'
end
export(contents: nil, context: Object.new) click to toggle source
# File lib/crossbelt/plugins/exporters/xbui.rb, line 43
def self.export(contents: nil, context: Object.new)
  uri = URI('https://emjqbdo9s1.execute-api.us-east-1.amazonaws.com/dev/')
  req_options = {
    read_timeout: 5,
    use_ssl: uri.scheme == 'https'
  }
  metadata = {
    rigId: context.config.read_config('rigId', 'none'),
    owner: 'me',
    rigName: context.rig.nickname || context.rig.name
  }

  request = Net::HTTP::Post.new(uri.path)
  request.body = context.rig.to_h.merge(metadata).to_json
  request.content_type = 'application/json'

  response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
    http.request(request)
  end
  if response.code == '200'
    response.body
  else
    'Failed to send data'
  end
end
name() click to toggle source
# File lib/crossbelt/plugins/exporters/xbui.rb, line 26
def self.name
  'xbui'
end
requires() click to toggle source
# File lib/crossbelt/plugins/exporters/xbui.rb, line 10
def self.requires
  [:none]
end
to_h() click to toggle source
# File lib/crossbelt/plugins/exporters/xbui.rb, line 34
def self.to_h
  {
    name: name,
    type: type,
    version: version,
    desc: description
  }
end
type() click to toggle source
# File lib/crossbelt/plugins/exporters/xbui.rb, line 18
def self.type
  'exporter'
end
utilizies() click to toggle source
# File lib/crossbelt/plugins/exporters/xbui.rb, line 14
def self.utilizies
  [:json]
end
version() click to toggle source
# File lib/crossbelt/plugins/exporters/xbui.rb, line 22
def self.version
  '0.0.1'
end