Class: ContactsAsync

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

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ ContactsAsync

Returns a new instance of ContactsAsync.



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

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

Instance Method Details

#add(options) ⇒ Object



28
29
30
# File 'lib/contactsAsync.rb', line 28

def add(options)
    execute(:add_contact,options)
end

#add_group(groupName, descriptions, showToChilds) ⇒ Object



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

def add_group(groupName, descriptions, showToChilds)
    execute(:add_group,{
        :groupName => groupName,
        :Descriptions => descriptions,
        :showToChilds => showToChilds
    })
end

#change(options) ⇒ Object



47
48
49
# File 'lib/contactsAsync.rb', line 47

def change(options)
    execute(:change_contact,options)
end

#check_mobile_exist(mobileNumber) ⇒ Object



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

def check_mobile_exist(mobileNumber)
    execute(:check_mobile_exist_in_contact,{
        :mobileNumber => mobileNumber
    })
end

#execute(method, data) ⇒ Object



15
16
17
18
19
20
# File 'lib/contactsAsync.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(groupId, keyword, from, count) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/contactsAsync.rb', line 36

def get(groupId, keyword, from, count)
    execute(:get_contacts,{
        :groupId => groupId,
        :keyword => keyword,
        :from => from,
        :count => count,
    })
end

#get_dataObject



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

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

#get_events(contactId) ⇒ Object



55
56
57
58
59
# File 'lib/contactsAsync.rb', line 55

def get_events(contactId)
    execute(:get_contact_events,{
        :contactId => contactId
    })
end

#get_groupsObject



44
45
46
# File 'lib/contactsAsync.rb', line 44

def get_groups
    execute(:get_groups,{})
end

#remove(mobileNumber) ⇒ Object



50
51
52
53
54
# File 'lib/contactsAsync.rb', line 50

def remove(mobileNumber)
    execute(:remove_contact,{
        :mobileNumber => mobileNumber
    })
end