Class: BranchAsync

Inherits:
Object
  • Object
show all
Defined in:
lib/branchAsync.rb

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ BranchAsync

Returns a new instance of BranchAsync.



4
5
6
7
8
# File 'lib/branchAsync.rb', line 4

def initialize(username, password)
    @username = username
    @password = password
    @client = Savon.client(wsdl: "http://api.payamak-panel.com/post/Actions.asmx?wsdl")
end

Instance Method Details

#add(branchName, owner) ⇒ Object



31
32
33
34
35
36
# File 'lib/branchAsync.rb', line 31

def add(branchName, owner)
    execute(:add_branch,{
        :branchName => branchName,
        :owner => owner
    })
end

#add_number(mobileNumbers, branchId) ⇒ Object



37
38
39
40
41
42
# File 'lib/branchAsync.rb', line 37

def add_number(mobileNumbers, branchId)
    execute(:add_number,{
        :mobileNumbers => mobileNumbers,
        :branchId => branchId
    })
end

#execute(method, data) ⇒ Object



15
16
17
18
19
20
# File 'lib/branchAsync.rb', line 15

def execute(method,data)
    response = nil
    t = Thread.new{response = @client.call(method, message:data.merge(get_data))}
    t.join
    response.body
end

#get(owner) ⇒ Object



21
22
23
24
25
# File 'lib/branchAsync.rb', line 21

def get(owner)
    execute(:get_branchs,{
        :owner => owner
    })
end

#get_bulk_count(branch, rangeFrom, rangeTo) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/branchAsync.rb', line 71

def get_bulk_count(branch, rangeFrom, rangeTo)
    execute(:get_bulk_count,{
        :branch => branch,
        :rangeFrom => rangeFrom,
        :rangeTo => rangeTo
    })
end

#get_bulk_receptions(bulkId, fromRows) ⇒ Object



78
79
80
81
82
83
# File 'lib/branchAsync.rb', line 78

def get_bulk_receptions(bulkId, fromRows)
    execute(:get_bulk_receptions,{
        :bulkId => bulkId,
        :fromRows => fromRows
    })
end

#get_bulk_status(bulkId) ⇒ Object



84
85
86
87
88
# File 'lib/branchAsync.rb', line 84

def get_bulk_status(bulkId)
    execute(:get_bulk_status,{
        :bulkId => bulkId
    })
end

#get_dataObject



9
10
11
12
13
14
# File 'lib/branchAsync.rb', line 9

def get_data
    {
        :username => @username,
        :password => @password
    }
end

#get_today_sentObject



89
90
91
# File 'lib/branchAsync.rb', line 89

def get_today_sent
    execute(:get_today_sent,{})
end

#get_total_sentObject



92
93
94
# File 'lib/branchAsync.rb', line 92

def get_total_sent
    execute(:get_total_sent,{})
end

#remove(branchId) ⇒ Object



26
27
28
29
30
# File 'lib/branchAsync.rb', line 26

def remove(branchId)
    execute(:remove_branch,{
        :branchId => branchId
    })
end

#remove_bulk(bulkId) ⇒ Object



95
96
97
98
99
# File 'lib/branchAsync.rb', line 95

def remove_bulk(bulkId)
    execute(:remove_bulk,{
        :bulkId => bulkId
    })
end

#send_bulk(from, title, message, branch, dateToSend, requestCount, bulkType, rowFrom, rangeFrom, rangeTo) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/branchAsync.rb', line 43

def send_bulk(from, title, message, branch, dateToSend, requestCount, bulkType, rowFrom, rangeFrom, rangeTo)
    execute(:add_bulk,{
        :from => from,
        :title => title,
        :message => message,
        :branch => branch,
        :DateToSend => dateToSend,
        :requestCount => requestCount,
        :bulkType => bulkType,
        :rowFrom => rowFrom,
        :rangeFrom => rangeFrom,
        :rangeTo => rangeTo
    })
end

#send_bulk2(from, title, message, branch, dateToSend, requestCount, bulkType, rowFrom, rangeFrom, rangeTo) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/branchAsync.rb', line 57

def send_bulk2(from, title, message, branch, dateToSend, requestCount, bulkType, rowFrom, rangeFrom, rangeTo)
    execute(:add_bulk2,{
        :from => from,
        :title => title,
        :message => message,
        :branch => branch,
        :DateToSend => dateToSend,
        :requestCount => requestCount,
        :bulkType => bulkType,
        :rowFrom => rowFrom,
        :rangeFrom => rangeFrom,
        :rangeTo => rangeTo
    })
end

#send_multiple_sms(to, from, text, isflash, udh) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/branchAsync.rb', line 100

def send_multiple_sms(to, from, text, isflash, udh)
    data = {
        :to => to,
        :from => from,
        :text => text,
        :isflash => isflash,
        :udh => udh
    }
    if from.kind_of?(Array)
        execute(:send_multiple_sms2,data)
    else
        execute(:send_multiple_sms,data)
    end
end

#update_bulk_delivery(bulkId) ⇒ Object



114
115
116
117
118
# File 'lib/branchAsync.rb', line 114

def update_bulk_delivery(bulkId)
    execute(:update_bulk_delivery,{
        :bulkId => bulkId
    })
end