class Libfchat::WebAPI
Attributes
baseurl[R]
ticket[R]
Public Class Methods
new(baseurl="https://www.f-list.net")
click to toggle source
# File lib/libfchat/webapi.rb, line 14 def initialize(baseurl="https://www.f-list.net") @baseurl = baseurl end
Public Instance Methods
bookmark_add(name)
click to toggle source
Bookmarks
# File lib/libfchat/webapi.rb, line 58 def bookmark_add(name) return self.post("/json/api/bookmark-add.php", 'name' => name) end
bookmark_list()
click to toggle source
# File lib/libfchat/webapi.rb, line 63 def bookmark_list() return self.get("/json/api/bookmark-list.php") end
bookmark_remove(name)
click to toggle source
# File lib/libfchat/webapi.rb, line 67 def bookmark_remove(name) return self.post("/json/api/bookmark-remove.php", 'name' => name) end
character_data(name)
click to toggle source
Character data
# File lib/libfchat/webapi.rb, line 73 def character_data(name) return self.post("/json/api/character-data.php", 'name' => name) end
character_list()
click to toggle source
# File lib/libfchat/webapi.rb, line 78 def character_list() return self.get("/json/api/character-list.php") end
friend_list()
click to toggle source
Handling friend requests, friend list data
# File lib/libfchat/webapi.rb, line 104 def friend_list() return self.get("/json/api/friend-list.php") end
friend_remove(source_name, dest_name)
click to toggle source
# File lib/libfchat/webapi.rb, line 108 def friend_remove(source_name, dest_name) return self.post("/json/api/friend-remove.php", "source_name" => source_name, "dest_name" => dest_name) end
get(endpoint)
click to toggle source
# File lib/libfchat/webapi.rb, line 31 def get(endpoint) uri = URI(@baseurl) res = Net::HTTP.get(uri) json = MultiJson.load(res.body) if json['error'] != "" raise json['error'] end return json end
getApiTicket(account, password)
click to toggle source
# File lib/libfchat/webapi.rb, line 46 def getApiTicket(account, password) json = self.post("/json/getApiTicket.php", 'account' => account, 'password' => password) if json['ticket'] @ticket = json['ticket'] return json end end
get_ticket(account, password)
click to toggle source
# File lib/libfchat/webapi.rb, line 41 def get_ticket(account, password) # Deprecated return self.getApiTicket(account, password) end
group_list()
click to toggle source
Misc data
# File lib/libfchat/webapi.rb, line 83 def group_list() return self.get("/json/api/group-list.php") end
ignore_list()
click to toggle source
# File lib/libfchat/webapi.rb, line 87 def ignore_list() return self.get("/json/api/ignore-list.php") end
info_list()
click to toggle source
# File lib/libfchat/webapi.rb, line 91 def info_list() return self.get("/json/api/info-list.php") end
kink_list()
click to toggle source
# File lib/libfchat/webapi.rb, line 95 def kink_list() return self.get("/json/api/kink-list.php") end
mapping_list()
click to toggle source
# File lib/libfchat/webapi.rb, line 99 def mapping_list() return self.get("/json/api/mapping-list.php") end
post(endpoint, params)
click to toggle source
# File lib/libfchat/webapi.rb, line 18 def post(endpoint, params) uri = URI("#{@baseurl}#{endpoint}") if @ticket params['ticket'] = @ticket end res = Net::HTTP.post_form(uri, params) json = MultiJson.load(res.body) if json['error'] != "" raise json['error'] end return json end
request_accept(request_id)
click to toggle source
# File lib/libfchat/webapi.rb, line 114 def request_accept(request_id) return self.post("/json/api/request-accept.php", "request_id" => request_id) end
request_cancel(request_id)
click to toggle source
# File lib/libfchat/webapi.rb, line 119 def request_cancel(request_id) return self.post("/json/api/request-cancel.php", "request_id" => request_id) end
request_deny(request_id)
click to toggle source
# File lib/libfchat/webapi.rb, line 124 def request_deny(request_id) return self.post("/json/api/request-deny.php", "request_id" => request_id) end
request_list()
click to toggle source
# File lib/libfchat/webapi.rb, line 129 def request_list() return self.get("/json/api/request-list.php") end
request_pending()
click to toggle source
# File lib/libfchat/webapi.rb, line 133 def request_pending() return self.get("/json/api/request-pending.php") end
request_send()
click to toggle source
# File lib/libfchat/webapi.rb, line 137 def request_send() return self.get("/json/api/request-send.php") end