class RestAsync

Public Class Methods

new(username, password) click to toggle source
# File lib/restAsync.rb, line 6
def initialize(username, password)
   @username = username
   @password = password
end

Public Instance Methods

get_base_price() click to toggle source
# File lib/restAsync.rb, line 82
def get_base_price
    url = sprintf @@path,"GetBasePrice"
    result = nil
    t = Thread.new{ result = request(url,get_data) }
    t.join
    result
end
get_credit() click to toggle source
# File lib/restAsync.rb, line 74
def get_credit
    url = sprintf @@path,"GetCredit"
    result = nil
    t = Thread.new{ result = request(url,get_data) }
    t.join
    result
end
get_data() click to toggle source
# File lib/restAsync.rb, line 11
def get_data
    {
        :username => @username,
        :password => @password
    }
end
get_messages(location, index, count, from="") click to toggle source
# File lib/restAsync.rb, line 60
def get_messages(location, index, count, from="")
    url = sprintf @@path,"GetMessages"
    data = {
        :location=>location,
        :index=> index,
        :count=> count,
        :from=> from
    }
    result = nil
    t = Thread.new{ result = request(url,data.merge(get_data)) }
    t.join
    result
end
get_numbers() click to toggle source
# File lib/restAsync.rb, line 90
def get_numbers
    url = sprintf @@path,"GetUserNumbers"
    result = nil
    t = Thread.new{ result = request(url,get_data) }
    t.join
    result
end
is_delivered(recId) click to toggle source
# File lib/restAsync.rb, line 49
def is_delivered(recId)
    url = sprintf @@path,"GetDeliveries2"
    data = {
        :recId=>recId,
    }
    result = nil
    t = Thread.new{ result = request(url,data.merge(get_data)) }
    t.join
    result
end
request(url,params) click to toggle source
# File lib/restAsync.rb, line 18
def request(url,params)
    HTTP.post(url, :form => params).parse
end
send(to,from,text,isFlash=false) click to toggle source
# File lib/restAsync.rb, line 22
def send(to,from,text,isFlash=false)
    url = sprintf @@path,"SendSMS"
    data = {
        :to=>to,
        :from=>from,
        :text=>text,
        :isFlash=>isFlash
    }
    result = nil
    t = Thread.new{ result = request(url,data.merge(get_data)) }
    t.join
    result
end
send_by_base_number(text, to, bodyId) click to toggle source
# File lib/restAsync.rb, line 36
def send_by_base_number(text, to, bodyId)
    url = sprintf @@path,"BaseServiceNumber"
    data = {
        :text=>text,
        :to=>to,
        :bodyId=>bodyId
    }
    result = nil
    t = Thread.new{ result = request(url,data.merge(get_data)) }
    t.join
    result
end