Class: TicketAsync

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

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ TicketAsync

Returns a new instance of TicketAsync.



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

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

Instance Method Details

#add(title, content, aws = true) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/ticketAsync.rb', line 21

def add(title, content, aws=true)
    execute(:add_ticket,{
        :title => title,
        :content => content,
        :alertWithSms => alertWithSms
    })
end

#execute(method, data) ⇒ Object



15
16
17
18
19
20
# File 'lib/ticketAsync.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_dataObject



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

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

#get_received(ticketOwner, ticketType, keyword) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/ticketAsync.rb', line 28

def get_received(ticketOwner, ticketType, keyword)
    execute(:get_received_tickets,{
        :ticketOwner => ticketOwner,
        :ticketType => ticketType,
        :keyword => keyword
    })
end

#get_received_count(ticketType) ⇒ Object



35
36
37
38
39
# File 'lib/ticketAsync.rb', line 35

def get_received_count(ticketType)
    execute(:get_received_tickets_count,{
        :ticketType => ticketType
    })
end

#get_sent(ticketOwner, ticketType, keyword) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/ticketAsync.rb', line 40

def get_sent(ticketOwner, ticketType, keyword)
    execute(:get_sent_tickets,{
        :ticketOwner => ticketOwner,
        :ticketType => ticketType,
        :keyword => keyword
    })
end

#get_sent_count(ticketType) ⇒ Object



47
48
49
50
51
# File 'lib/ticketAsync.rb', line 47

def get_sent_count(ticketType)
    execute(:get_sent_tickets_count,{
        :ticketType => ticketType
    })
end

#response(ticketId, type, content, alertWithSms = true) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/ticketAsync.rb', line 52

def response(ticketId, type, content, alertWithSms=true)
    execute(:response_ticket,{
        :ticketId => ticketId,
        :content => content,
        :alertWithSms => alertWithSms,
        :type => type
    })
end