melipayamak 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 247cc1eb9c1d51c7a8462a662cb8a7d1821043da90b9c2a34a0a381043a81228
4
+ data.tar.gz: eb7c9948258e2b19078a611035ac53148183209aa64a473e9338046928574cc5
5
+ SHA512:
6
+ metadata.gz: 02d2cc5349324d82fe0fd2f20bc339e50f7caf7ad9fe24902a06b0b27c389b461a1b5726bef72b2aae79dab7451c12582acbd5605faef6044d419d4e3c0c4f06
7
+ data.tar.gz: 8d13b369ca0cde3b445bb1de77b4cda456eebecd612803f01f6c0473fd7648b2416f959db9360690f66833fe3ea9675b0730e44c8367e27b44a1b0d8947d56f7
@@ -0,0 +1,117 @@
1
+ require 'savon'
2
+
3
+ class Branch
4
+ def initialize(username, password)
5
+ @username = username
6
+ @password = password
7
+ @client = Savon.client(wsdl: "http://api.payamak-panel.com/post/Actions.asmx?wsdl")
8
+ end
9
+ def get_data
10
+ {
11
+ :username => @username,
12
+ :password => @password
13
+ }
14
+ end
15
+ def execute(method,data)
16
+ response = @client.call(method, message:data.merge(get_data))
17
+ response.body
18
+ end
19
+ def get(owner)
20
+ execute(:get_branchs,{
21
+ :owner => owner
22
+ })
23
+ end
24
+ def remove(branchId)
25
+ execute(:remove_branch,{
26
+ :branchId => branchId
27
+ })
28
+ end
29
+ def add(branchName, owner)
30
+ execute(:add_branch,{
31
+ :branchName => branchName,
32
+ :owner => owner
33
+ })
34
+ end
35
+ def add_number(mobileNumbers, branchId)
36
+ execute(:add_number,{
37
+ :mobileNumbers => mobileNumbers,
38
+ :branchId => branchId
39
+ })
40
+ end
41
+ def send_bulk(from, title, message, branch, dateToSend, requestCount, bulkType, rowFrom, rangeFrom, rangeTo)
42
+ execute(:add_bulk,{
43
+ :from => from,
44
+ :title => title,
45
+ :message => message,
46
+ :branch => branch,
47
+ :DateToSend => dateToSend,
48
+ :requestCount => requestCount,
49
+ :bulkType => bulkType,
50
+ :rowFrom => rowFrom,
51
+ :rangeFrom => rangeFrom,
52
+ :rangeTo => rangeTo
53
+ })
54
+ end
55
+ def send_bulk2(from, title, message, branch, dateToSend, requestCount, bulkType, rowFrom, rangeFrom, rangeTo)
56
+ execute(:add_bulk2,{
57
+ :from => from,
58
+ :title => title,
59
+ :message => message,
60
+ :branch => branch,
61
+ :DateToSend => dateToSend,
62
+ :requestCount => requestCount,
63
+ :bulkType => bulkType,
64
+ :rowFrom => rowFrom,
65
+ :rangeFrom => rangeFrom,
66
+ :rangeTo => rangeTo
67
+ })
68
+ end
69
+ def get_bulk_count(branch, rangeFrom, rangeTo)
70
+ execute(:get_bulk_count,{
71
+ :branch => branch,
72
+ :rangeFrom => rangeFrom,
73
+ :rangeTo => rangeTo
74
+ })
75
+ end
76
+ def get_bulk_receptions(bulkId, fromRows)
77
+ execute(:get_bulk_receptions,{
78
+ :bulkId => bulkId,
79
+ :fromRows => fromRows
80
+ })
81
+ end
82
+ def get_bulk_status(bulkId)
83
+ execute(:get_bulk_status,{
84
+ :bulkId => bulkId
85
+ })
86
+ end
87
+ def get_today_sent
88
+ execute(:get_today_sent,{})
89
+ end
90
+ def get_total_sent
91
+ execute(:get_total_sent,{})
92
+ end
93
+ def remove_bulk(bulkId)
94
+ execute(:remove_bulk,{
95
+ :bulkId => bulkId
96
+ })
97
+ end
98
+ def send_multiple_sms(to, from, text, isflash, udh)
99
+ data = {
100
+ :to => to,
101
+ :from => from,
102
+ :text => text,
103
+ :isflash => isflash,
104
+ :udh => udh
105
+ }
106
+ if from.kind_of?(Array)
107
+ execute(:send_multiple_sms2,data)
108
+ else
109
+ execute(:send_multiple_sms,data)
110
+ end
111
+ end
112
+ def update_bulk_delivery(bulkId)
113
+ execute(:update_bulk_delivery,{
114
+ :bulkId => bulkId
115
+ })
116
+ end
117
+ end
@@ -0,0 +1,119 @@
1
+ require 'savon'
2
+
3
+ class BranchAsync
4
+ def initialize(username, password)
5
+ @username = username
6
+ @password = password
7
+ @client = Savon.client(wsdl: "http://api.payamak-panel.com/post/Actions.asmx?wsdl")
8
+ end
9
+ def get_data
10
+ {
11
+ :username => @username,
12
+ :password => @password
13
+ }
14
+ end
15
+ def execute(method,data)
16
+ response = nil
17
+ t = Thread.new{response = @client.call(method, message:data.merge(get_data))}
18
+ t.join
19
+ response.body
20
+ end
21
+ def get(owner)
22
+ execute(:get_branchs,{
23
+ :owner => owner
24
+ })
25
+ end
26
+ def remove(branchId)
27
+ execute(:remove_branch,{
28
+ :branchId => branchId
29
+ })
30
+ end
31
+ def add(branchName, owner)
32
+ execute(:add_branch,{
33
+ :branchName => branchName,
34
+ :owner => owner
35
+ })
36
+ end
37
+ def add_number(mobileNumbers, branchId)
38
+ execute(:add_number,{
39
+ :mobileNumbers => mobileNumbers,
40
+ :branchId => branchId
41
+ })
42
+ end
43
+ def send_bulk(from, title, message, branch, dateToSend, requestCount, bulkType, rowFrom, rangeFrom, rangeTo)
44
+ execute(:add_bulk,{
45
+ :from => from,
46
+ :title => title,
47
+ :message => message,
48
+ :branch => branch,
49
+ :DateToSend => dateToSend,
50
+ :requestCount => requestCount,
51
+ :bulkType => bulkType,
52
+ :rowFrom => rowFrom,
53
+ :rangeFrom => rangeFrom,
54
+ :rangeTo => rangeTo
55
+ })
56
+ end
57
+ def send_bulk2(from, title, message, branch, dateToSend, requestCount, bulkType, rowFrom, rangeFrom, rangeTo)
58
+ execute(:add_bulk2,{
59
+ :from => from,
60
+ :title => title,
61
+ :message => message,
62
+ :branch => branch,
63
+ :DateToSend => dateToSend,
64
+ :requestCount => requestCount,
65
+ :bulkType => bulkType,
66
+ :rowFrom => rowFrom,
67
+ :rangeFrom => rangeFrom,
68
+ :rangeTo => rangeTo
69
+ })
70
+ end
71
+ def get_bulk_count(branch, rangeFrom, rangeTo)
72
+ execute(:get_bulk_count,{
73
+ :branch => branch,
74
+ :rangeFrom => rangeFrom,
75
+ :rangeTo => rangeTo
76
+ })
77
+ end
78
+ def get_bulk_receptions(bulkId, fromRows)
79
+ execute(:get_bulk_receptions,{
80
+ :bulkId => bulkId,
81
+ :fromRows => fromRows
82
+ })
83
+ end
84
+ def get_bulk_status(bulkId)
85
+ execute(:get_bulk_status,{
86
+ :bulkId => bulkId
87
+ })
88
+ end
89
+ def get_today_sent
90
+ execute(:get_today_sent,{})
91
+ end
92
+ def get_total_sent
93
+ execute(:get_total_sent,{})
94
+ end
95
+ def remove_bulk(bulkId)
96
+ execute(:remove_bulk,{
97
+ :bulkId => bulkId
98
+ })
99
+ end
100
+ def send_multiple_sms(to, from, text, isflash, udh)
101
+ data = {
102
+ :to => to,
103
+ :from => from,
104
+ :text => text,
105
+ :isflash => isflash,
106
+ :udh => udh
107
+ }
108
+ if from.kind_of?(Array)
109
+ execute(:send_multiple_sms2,data)
110
+ else
111
+ execute(:send_multiple_sms,data)
112
+ end
113
+ end
114
+ def update_bulk_delivery(bulkId)
115
+ execute(:update_bulk_delivery,{
116
+ :bulkId => bulkId
117
+ })
118
+ end
119
+ end
@@ -0,0 +1,58 @@
1
+ require 'savon'
2
+
3
+ class Contacts
4
+ def initialize(username, password)
5
+ @username = username
6
+ @password = password
7
+ @client = Savon.client(wsdl: "http://api.payamak-panel.com/post/contacts.asmx?wsdl")
8
+ end
9
+ def get_data
10
+ {
11
+ :username => @username,
12
+ :password => @password
13
+ }
14
+ end
15
+ def execute(method,data)
16
+ response = @client.call(method, message:data.merge(get_data))
17
+ response.body
18
+ end
19
+ def add_group(groupName, descriptions, showToChilds)
20
+ execute(:add_group,{
21
+ :groupName => groupName,
22
+ :Descriptions => descriptions,
23
+ :showToChilds => showToChilds
24
+ })
25
+ end
26
+ def add(options)
27
+ execute(:add_contact,options)
28
+ end
29
+ def check_mobile_exist(mobileNumber)
30
+ execute(:check_mobile_exist_in_contact,{
31
+ :mobileNumber => mobileNumber
32
+ })
33
+ end
34
+ def get(groupId, keyword, from, count)
35
+ execute(:get_contacts,{
36
+ :groupId => groupId,
37
+ :keyword => keyword,
38
+ :from => from,
39
+ :count => count,
40
+ })
41
+ end
42
+ def get_groups
43
+ execute(:get_groups,{})
44
+ end
45
+ def change(options)
46
+ execute(:change_contact,options)
47
+ end
48
+ def remove(mobileNumber)
49
+ execute(:remove_contact,{
50
+ :mobileNumber => mobileNumber
51
+ })
52
+ end
53
+ def get_events(contactId)
54
+ execute(:get_contact_events,{
55
+ :contactId => contactId
56
+ })
57
+ end
58
+ end
@@ -0,0 +1,60 @@
1
+ require 'savon'
2
+
3
+ class ContactsAsync
4
+ def initialize(username, password)
5
+ @username = username
6
+ @password = password
7
+ @client = Savon.client(wsdl: "http://api.payamak-panel.com/post/contacts.asmx?wsdl")
8
+ end
9
+ def get_data
10
+ {
11
+ :username => @username,
12
+ :password => @password
13
+ }
14
+ end
15
+ def execute(method,data)
16
+ response = nil
17
+ t = Thread.new{response = @client.call(method, message:data.merge(get_data))}
18
+ t.join
19
+ response.body
20
+ end
21
+ def add_group(groupName, descriptions, showToChilds)
22
+ execute(:add_group,{
23
+ :groupName => groupName,
24
+ :Descriptions => descriptions,
25
+ :showToChilds => showToChilds
26
+ })
27
+ end
28
+ def add(options)
29
+ execute(:add_contact,options)
30
+ end
31
+ def check_mobile_exist(mobileNumber)
32
+ execute(:check_mobile_exist_in_contact,{
33
+ :mobileNumber => mobileNumber
34
+ })
35
+ end
36
+ def get(groupId, keyword, from, count)
37
+ execute(:get_contacts,{
38
+ :groupId => groupId,
39
+ :keyword => keyword,
40
+ :from => from,
41
+ :count => count,
42
+ })
43
+ end
44
+ def get_groups
45
+ execute(:get_groups,{})
46
+ end
47
+ def change(options)
48
+ execute(:change_contact,options)
49
+ end
50
+ def remove(mobileNumber)
51
+ execute(:remove_contact,{
52
+ :mobileNumber => mobileNumber
53
+ })
54
+ end
55
+ def get_events(contactId)
56
+ execute(:get_contact_events,{
57
+ :contactId => contactId
58
+ })
59
+ end
60
+ end
@@ -0,0 +1,58 @@
1
+ require_relative "branch"
2
+ require_relative "branchAsync"
3
+ require_relative "contacts"
4
+ require_relative "contactsAsync"
5
+ require_relative "rest"
6
+ require_relative "restAsync"
7
+ require_relative "soap"
8
+ require_relative "soapAsync"
9
+ require_relative "ticket"
10
+ require_relative "ticketAsync"
11
+ require_relative "users"
12
+ require_relative "usersAsync"
13
+
14
+ class Melipayamakapi
15
+ def initialize(username, password)
16
+ @username = username
17
+ @password = password
18
+ end
19
+ def sms(method="rest", type="sync")
20
+ if method=="soap"
21
+ if type=="async"
22
+ SoapAsync.new(@username,@password)
23
+ else
24
+ Soap.new(@username,@password)
25
+ end
26
+ else
27
+ if type=="async"
28
+ RestAsync.new(@username,@password)
29
+ else
30
+ Rest.new(@username,@password)
31
+ end
32
+ end
33
+ end
34
+ def branch
35
+ Branch.new(@username,@password)
36
+ end
37
+ def branchAsync
38
+ BranchAsync.new(@username,@password)
39
+ end
40
+ def contacts
41
+ Contacts.new(@username,@password)
42
+ end
43
+ def contactsAsync
44
+ ContactsAsync.new(@username,@password)
45
+ end
46
+ def ticket
47
+ Ticket.new(@username,@password)
48
+ end
49
+ def ticketAsync
50
+ TicketAsync.new(@username,@password)
51
+ end
52
+ def users
53
+ Users.new(@username,@password)
54
+ end
55
+ def usersAsync
56
+ UsersAsync.new(@username,@password)
57
+ end
58
+ end
@@ -0,0 +1,77 @@
1
+ require "http"
2
+
3
+ class Rest
4
+ @@path = "https://rest.payamak-panel.com/api/SendSMS/%s"
5
+
6
+ def initialize(username, password)
7
+ @username = username
8
+ @password = password
9
+ end
10
+
11
+ def get_data
12
+ {
13
+ :username => @username,
14
+ :password => @password
15
+ }
16
+ end
17
+
18
+ def request(url,params)
19
+ HTTP.post(url, :form => params).parse
20
+ end
21
+
22
+ def send(to,from,text,isFlash=false)
23
+ url = sprintf @@path,"SendSMS"
24
+ data = {
25
+ :to=>to,
26
+ :from=>from,
27
+ :text=>text,
28
+ :isFlash=>isFlash
29
+ }
30
+ request(url,data.merge(get_data))
31
+ end
32
+
33
+ def send_by_base_number(text, to, bodyId)
34
+ url = sprintf @@path,"BaseServiceNumber"
35
+ data = {
36
+ :text=>text,
37
+ :to=>to,
38
+ :bodyId=>bodyId
39
+ }
40
+ request(url,data.merge(get_data))
41
+ end
42
+
43
+ def is_delivered(recId)
44
+ url = sprintf @@path,"GetDeliveries2"
45
+ data = {
46
+ :recId=>recId,
47
+ }
48
+ request(url,data.merge(get_data))
49
+ end
50
+
51
+ def get_messages(location, index, count, from="")
52
+ url = sprintf @@path,"GetMessages"
53
+ data = {
54
+ :location=>location,
55
+ :index=> index,
56
+ :count=> count,
57
+ :from=> from
58
+ }
59
+ request(url,data.merge(get_data))
60
+ end
61
+
62
+ def get_credit
63
+ url = sprintf @@path,"GetCredit"
64
+ request(url,get_data)
65
+ end
66
+
67
+ def get_base_price
68
+ url = sprintf @@path,"GetBasePrice"
69
+ request(url,get_data)
70
+ end
71
+
72
+ def get_numbers
73
+ url = sprintf @@path,"GetUserNumbers"
74
+ request(url,get_data)
75
+ end
76
+
77
+ end