# 代码溯源 添加用户
class Trace::AddUserService  < Trace::ClientService

  # 用户名 密码 单位 手机号 邮箱 昵称
  attr_accessor :username, :password, :unit, :telnumber, :email, :name

  def initialize(username, password, unit, telnumber, email, name) 
    @username = username 
    @password = password
    @unit = unit 
    @telnumber = telnumber
    @email = email 
    @name = name
  end

  def call 
    result = post(url, {data: request_params})
    response = render_response(result)
  end

  private 

  def request_params 
    {
      username: username,
      password: password, 
      unit: unit, 
      telnumber: telnumber,
      email: email,
      name: name
    }
  end

  def url
    "/user/getHSToken".freeze
  end
end