class BSClient::CLI

Public Instance Methods

create_user_image(account, text, size="30", color="red") click to toggle source
# File lib/bsclient/cli.rb, line 30
def create_user_image(account, text, size="30", color="red")
  req_content = {account: account, text: text, fontSize: size, fontColor: color}.to_json
  app = App.new(options, Config.create(options[:env]))
  print app.create_user_image(req_content)
end
download_user_image(account) click to toggle source
# File lib/bsclient/cli.rb, line 37
def download_user_image(account)
  params = {account: account, imageName: ''}
  app = App.new(options, Config.create(options[:env]))
  print app.download_user_image(params)
end
get(url, *raw_params) click to toggle source
# File lib/bsclient/cli.rb, line 44
def get(url, *raw_params)
  params = raw_params.each_with_object({}) do |param, h|
    k, v = param.split('=')
    h[k.to_sym] = v
  end
  app = App.new(options, Config.create(options[:env]))
  print app.get(url, params)
end
post(url, *args) click to toggle source
# File lib/bsclient/cli.rb, line 54
def post(url, *args)
  if not STDIN.isatty
    params = JSON.parse(STDIN.read)
  elsif File.exist?(args.first)
    params = File.read(args.first)
  else
    params = args.each_with_object({}) do |param, h|
      k, v = param.split('=')
      value = v
      value = JSON.parse(v[1..-1]) if v[0] == ':'
      h[k.to_sym] = value
    end
  end
  app = App.new(options, Config.create(options[:env]))
  print app.post_json(url, params)
end
query_registration(task_id, account) click to toggle source
# File lib/bsclient/cli.rb, line 24
def query_registration(task_id, account)
  app = App.new(options, Config.create(options[:env]))
  print app.query_registration(task_id, account)
end
register_account(filename = nil) click to toggle source
# File lib/bsclient/cli.rb, line 12
def register_account(filename = nil)
  req_content = if filename
                  IO.read(filename)
                else
                  STDIN.read
                end
  req_content = JSON.generate(JSON.parse(req_content))
  app = App.new(options, Config.create(options[:env]))
  print app.register_account(req_content)
end