Skip to content

Commit 49dcc05

Browse files
author
CleanTalk
committed
Merge pull request #2 from VladCleantalk/master
Added Response class
2 parents d959481 + 6d2a651 commit 49dcc05

1 file changed

Lines changed: 113 additions & 0 deletions

File tree

cleantalk.class.rb

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
2+
3+
class CleantalkResponse {
4+
5+
#
6+
# Is stop words
7+
#@var int
8+
#
9+
@stop_words = nil
10+
11+
#
12+
#Cleantalk comment
13+
#@var string
14+
#
15+
@comment = nil
16+
17+
#
18+
#Is blacklisted
19+
#@var int
20+
#
21+
@blacklisted = nil
22+
23+
#
24+
#Is allow, 1|0
25+
#@var int
26+
#
27+
@allow = nil
28+
29+
#
30+
#Request ID
31+
#@var int
32+
#
33+
@id = nil
34+
35+
#
36+
#Request errno
37+
#@var int
38+
#
39+
@errno = nil
40+
41+
#
42+
#Error string
43+
#@var string
44+
#
45+
@errstr = nil
46+
47+
#
48+
#Is fast submit, 1|0
49+
#@var string
50+
#
51+
@fast_submit = nil
52+
53+
#
54+
#Is spam comment
55+
#@var string
56+
#
57+
@spam = nil
58+
59+
#
60+
#Is JS
61+
#@var type
62+
#
63+
@js_disabled = nil
64+
65+
#
66+
#Stop queue message, 1|0
67+
#@var int
68+
#
69+
@stop_queue = nil
70+
71+
#
72+
#Account shuld by deactivated after registration, 1|0
73+
#@var int
74+
#
75+
@inactive = nil
76+
77+
#
78+
#Account status
79+
#@var int
80+
#
81+
@account_status = -1
82+
83+
#
84+
#Create server response
85+
#@param type response
86+
#@param type obj
87+
#
88+
def initialize(response = nil, obl = nil)
89+
if (response.length > 0)
90+
response.each_index{|elem|@elem = response.at(elem)}
91+
else
92+
@errno = obj.errno
93+
@errstr = obj.errstr
94+
95+
@errstr = @errstr.gsub(/.+(\*\*\*.+\*\*\*).+/, \1, @errstr)
96+
97+
obj.stop_words.empty ? @stop_words = obj.stop_words : @stop_words = nil
98+
obj.comment.empty ? @comment = obj.comment : @comment = nil
99+
obj.blacklisted.empty ? @blacklisted = obj.blacklisted : @blacklisted = nil
100+
obj.allow.empty ? @allow = obj.allow : @allow = 0
101+
obj.id.empty ? @id = obj.id : @id = nil
102+
obj.fast_submit.empty ? @fast_submit = obj.fast_submit : @fast_submit = 0
103+
obj.spam.empty ? @spam = obj.spam : @spam = 0
104+
obj.js_disabled.empty ? @js_disabled = obj.js_disabled : @js_disabled = 0
105+
obj.stop_queue.empty ? @stop_queue = obj.stop_queue : @stop_queue = 0
106+
obj.inactive.empty ? @inactive = obj.inactive : @inactive = 0
107+
obj.account_status.empty ? @account_status = obj.account_status : @account_status = -1
108+
109+
if (@errno !== 0 && @errstr !== nil && @comment === nil)
110+
@comment = '*** ' + @errstr + ' Antispam service cleantalk.org ***'
111+
end
112+
end
113+
end

0 commit comments

Comments
 (0)