Sha256: e9e36d07aee711e1ea2b0751cbc44a49790a268e3b3f865efaaf26d3b79f40a9
Contents?: true
Size: 1.63 KB
Versions: 5
Compression:
Stored size: 1.63 KB
Contents
require 'net/http' require 'multi_json' module Namba module APIMethods def get_user_info name = self.username get_response_from "http://api.namba.#{self.locale}/getUserInfo.php?username=" + name end def get_user_video name = self.username get_response_from "http://api.namba.#{self.locale}/getVideo.php?username=" + name end def get_user_photo name = self.username get_response_from "http://api.namba.#{self.locale}/getPhoto.php?username=" + name end def get_friends_list name = self.username get_response_from "http://api.namba.#{self.locale}/friends.php?username=" + name end def set_status text post_data_to "http://api.namba.#{self.locale}/setStatus.php", { :username => self.username, :password => self.password, :status => text } end def get_events post_data_to "http://api.namba.#{self.locale}/getEvents.php" end def get_new_mail_count post_data_to "http://api.namba.#{self.locale}/getNewMailCount.php" end def get_last_mail post_data_to "http://api.namba.#{self.locale}/getLastMail.php" end private def get_response_from url response = Net::HTTP.get_response(URI.parse(url)) raise InvalidResponseError, "Invalid response from service" unless response.code == "200" MultiJson.decode(response.body) end def post_data_to url, params = { :username => self.username, :password => self.password } response = Net::HTTP.post_form(URI.parse(url), params) raise InvalidResponseError, "Invalid response from service" unless response.code == "200" MultiJson.decode(response.body) end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
namba-1.3.1 | lib/namba/api_methods.rb |
namba-1.3.0 | lib/namba/api_methods.rb |
namba-1.2.0 | lib/namba/api_methods.rb |
namba-1.1.0 | lib/namba/api_methods.rb |
namba-1.0.1 | lib/namba/api_methods.rb |