Class: Contacts

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

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ Contacts



4
5
6
7
8
# File 'lib/contacts.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



26
27
28
# File 'lib/contacts.rb', line 26

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

#add_group(groupName, descriptions, showToChilds) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/contacts.rb', line 19

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

#change(options) ⇒ Object



45
46
47
# File 'lib/contacts.rb', line 45

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

#check_mobile_exist(mobileNumber) ⇒ Object



29
30
31
32
33
# File 'lib/contacts.rb', line 29

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

#execute(method, data) ⇒ Object



15
16
17
18
# File 'lib/contacts.rb', line 15

def execute(method,data)
    response = @client.call(method, message:data.merge(get_data))
    response.body
end

#get(groupId, keyword, from, count) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/contacts.rb', line 34

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/contacts.rb', line 9

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

#get_events(contactId) ⇒ Object



53
54
55
56
57
# File 'lib/contacts.rb', line 53

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

#get_groupsObject



42
43
44
# File 'lib/contacts.rb', line 42

def get_groups
    execute(:get_groups,{})
end

#remove(mobileNumber) ⇒ Object



48
49
50
51
52
# File 'lib/contacts.rb', line 48

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