class Avod::Client

Constants

API_INSTALLIIONS_URL
API_OBJECT_URL
API_URL
API_USER_URL
BASE_URL
VERSION_CODE

Public Class Methods

new(app_id, app_key, master_key) click to toggle source
# File lib/avod/client.rb, line 16
def initialize(app_id, app_key, master_key)
        @app_id = app_id
        @app_key = app_key
        @master_key = master_key
end

Public Instance Methods

create_object(class_name, object) click to toggle source
# File lib/avod/client.rb, line 34
def create_object(class_name, object)
        post API_OBJECT_URL + class_name, object.to_json
end
delete_object(class_name, object_id) click to toggle source
# File lib/avod/client.rb, line 46
def delete_object(class_name, object_id)
        delete API_OBJECT_URL + class_name + "/" + object_id
end
delete_user(user_id, session) click to toggle source
# File lib/avod/client.rb, line 98
def delete_user(user_id, session) #untest
        url = API_USER_URL + user_id
        result =  RestClient.delete url ,
        :"content-type" => "application/json", 
        :"X-AVOSCloud-Application-Id" => @app_id,
        :"X-AVOSCloud-Application-Key" => @app_key,
        :"X-AVOSCloud-Session-Token" => session
        result.code == 200
end
get_all_object(name) click to toggle source

/1/classes/<className> POST 创建对象 /1/classes/<className>/<objectId> GET 获取对象 /1/classes/<className>/<objectId> PUT 更新对象 /1/classes/<className> GET 查询对象 /1/classes/<className>/<objectId> DELETE 删除对象

# File lib/avod/client.rb, line 30
def get_all_object(name)
        get API_OBJECT_URL + name
end
get_all_users() click to toggle source
# File lib/avod/client.rb, line 73
def get_all_users 
        get API_USER_URL
end
get_install(object_id) click to toggle source
# File lib/avod/client.rb, line 151
def get_install(object_id) 
        get API_INSTALLIIONS_URL + "/" + object_id
end
get_installations() click to toggle source

URL HTTP 功能 /1/installations POST 上传安装数据 /1/installations/<objectId> GET 获取安装数据 /1/installations/<objectId> PUT 更新安装数据 /1/installations GET 查询安装数据 /1/installations/<objectId> DELETE 删除安装数据

# File lib/avod/client.rb, line 147
def get_installations
        private_get  API_INSTALLIIONS_URL 
end
get_object(class_name, object_id) click to toggle source
# File lib/avod/client.rb, line 38
def get_object(class_name, object_id)
        get  API_OBJECT_URL + class_name + "/"  + object_id
end
get_user(object_id) click to toggle source
# File lib/avod/client.rb, line 77
def get_user(object_id)  
        get API_USER_URL + "/" +  object_id
end
register_user(username, password, email, *opt) click to toggle source
# File lib/avod/client.rb, line 81
def register_user(username, password, email, *opt) #untest
        if opt 
                params = opt
        else 
                params = Hash.new
        end
        params[:password] = password
        params[:username] = username                 
        post API_USER_URL, params
end
reset_email(email) click to toggle source
# File lib/avod/client.rb, line 108
def reset_email(email) #faild
        url = "https://cn.avoscloud.com/1/requestPasswordReset"
        params = {"email" => email}
        result =  RestClient.post url , params, 
        :"content-type" => "application/json", 
        :"X-AVOSCloud-Application-Id" => @app_id,
        :"X-AVOSCloud-Application-Key" => @app_key,
        :"X-AVOSCloud-Master-Key" => @master_key
        result.code == 200
end
rest_password(email) click to toggle source
# File lib/avod/client.rb, line 93
def  rest_password(email) #untest
        params = {"email" => email}
        post API_URL + "requestPasswordReset", params
end
update_install(object_id, params) click to toggle source
# File lib/avod/client.rb, line 155
def update_install(object_id, params) #untest
        put API_INSTALLIIONS_URL + "/" + params["objectId"], params
end
update_object(class_name, object_id, object) click to toggle source
# File lib/avod/client.rb, line 42
def update_object(class_name, object_id, object)
        put API_OBJECT_URL + class_name + "/" + object_id, object.to_json
end
update_user(user_id, params, session) click to toggle source

URL HTTP 功能 /1/users POST 用户注册 用户连接 /1/login GET 用户登录 /1/users/<objectId> GET 获取用户 /1/users/<objectId> PUT 更新用户 用户连接 验证Email /1/users GET 查询用户 /1/users/<objectId> DELETE 删除用户 /1/requestPasswordReset POST 请求密码重设

# File lib/avod/client.rb, line 63
def update_user(user_id, params, session) #untest
        url = API_USER_URL + user_id
        result =  RestClient.put url , params,
        :"content-type" => "application/json", 
        :"X-AVOSCloud-Application-Id" => @app_id,
        :"X-AVOSCloud-Application-Key" => @app_key,
        :"X-AVOSCloud-Session-Token" => session
        return to_json(params)
end

Protected Instance Methods

delete(url) click to toggle source
# File lib/avod/client.rb, line 214
def delete(url)
        result =  RestClient.delete url ,
        :"content-type" => "application/json", 
        :"X-AVOSCloud-Application-Id" => @app_id,
        :"X-AVOSCloud-Application-Key" => @app_key
        result.code == 200
end
get(url) click to toggle source
# File lib/avod/client.rb, line 196
def get(url)
        result =  RestClient.get url ,
        :"content-type" => "application/json", 
        :"X-AVOSCloud-Application-Id" => @app_id,
        :"X-AVOSCloud-Application-Key" => @app_key
        to_json(result)
end
post(url, params) click to toggle source
# File lib/avod/client.rb, line 187
def post(url, params)
        result =  RestClient.post url , params,
        :"content-type" => "application/json", 
        :"X-AVOSCloud-Application-Id" => @app_id,
        :"X-AVOSCloud-Application-Key" => @app_key
        to_json(result)

end
private_get(url) click to toggle source
# File lib/avod/client.rb, line 205
def private_get(url)
        result =  RestClient.get url ,
        :"content-type" => "application/json", 
        :"X-AVOSCloud-Application-Id" => @app_id,
        :"X-AVOSCloud-Application-Key" => @app_key,
        :"X-AVOSCloud-Master-Key" => @master_key
        to_json(result)
end
private_post(url, params) click to toggle source
# File lib/avod/client.rb, line 177
def private_post(url, params)
        result =  RestClient.post url , params,
        :"content-type" => "application/json", 
        :"X-AVOSCloud-Application-Id" => @app_id,
        :"X-AVOSCloud-Application-Key" => @app_key,
        :"X-AVOSCloud-Master-Key" => @master_key
        to_json(result)

end
put(url, params) click to toggle source
# File lib/avod/client.rb, line 222
def put(url, params)
        result =  RestClient.put url , params,
        :"content-type" => "application/json", 
        :"X-AVOSCloud-Application-Id" => @app_id,
        :"X-AVOSCloud-Application-Key" => @app_key
        to_json(result)
end
to_json(str) click to toggle source

URL HTTP 功能 /1/functions POST 调用Cloud Code函数

# File lib/avod/client.rb, line 172
def to_json(str)
        return JSON.parse(str)
end