Module: MjClient

Defined in:
lib/mjclient.rb,
lib/mjclient/version.rb

Constant Summary collapse

VERSION =
"0.0.5"

Class Method Summary collapse

Class Method Details

.get_article(id, params = {}, accept = :html) ⇒ Object



100
101
102
103
104
105
106
107
# File 'lib/mjclient.rb', line 100

def self.get_article(id, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/show/#{id}", @headers)
    resource.get( :params => params, :accept => accept )
  rescue => e
    e.message
  end
end

.get_article_comments(id, params = {}, accept = :html) ⇒ Object



109
110
111
112
113
114
115
116
# File 'lib/mjclient.rb', line 109

def self.get_article_comments(id, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/comments/#{id}", @headers)
    resource.get( :params => params, :accept => accept )
  rescue => e
    e.message
  end
end

.get_article_url(id, params = {}, accept = :html) ⇒ Object



118
119
120
121
122
123
124
125
# File 'lib/mjclient.rb', line 118

def self.get_article_url(id, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/url/#{id}", @headers)
    resource.get( :params => params, :accept => accept )
  rescue => e
    e.message
  end
end

.get_categories(params = {}, accept = :html) ⇒ Object



82
83
84
85
86
87
88
89
# File 'lib/mjclient.rb', line 82

def self.get_categories(params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/categories", @headers)
    resource.get( :params => params, :accept => accept )
  rescue => e
    e.message
  end
end

.get_list(id, limit, params = {}, accept = :html) ⇒ Object



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

def self.get_list(id, limit, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/list/#{id}/show/#{limit}", @headers)
    resource.get( :params => params, :accept => accept )
  rescue => e
    e.message
  end
end

.get_list_by_author(author, limit, params = {}, accept = :html) ⇒ Object



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

def self.get_list_by_author(author, limit, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/listbyauthor/#{author}/show/#{limit}", @headers)
    resource.get( :params => params, :accept => accept )
  rescue => e
    e.message
  end
end

.get_list_by_city(city, limit, params = {}, accept = :html) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/mjclient.rb', line 46

def self.get_list_by_city(city, limit, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/listbycity/#{city}/show/#{limit}", @headers)
    resource.get( :params => params, :accept => accept )
  rescue => e
    e.message
  end
end

.get_list_by_rating(rating, limit, params = {}, accept = :html) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/mjclient.rb', line 64

def self.get_list_by_rating(rating, limit, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/listbyrating/#{rating}/show/#{limit}", @headers)
    resource.get( :params => params, :accept => accept )
  rescue => e
    e.message
  end
end

.get_list_by_tag(tag, limit, params = {}, accept = :html) ⇒ Object



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

def self.get_list_by_tag(tag, limit, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/listbytag/#{tag}/show/#{limit}", @headers)
    resource.get( :params => params, :accept => accept )
  rescue => e
    e.message
  end
end

.get_list_by_type(type, limit, params = {}, accept = :html) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/mjclient.rb', line 55

def self.get_list_by_type(type, limit, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/listbytype/#{type}/show/#{limit}", @headers)
    resource.get( :params => params, :accept => accept )
  rescue => e
    e.message
  end
end

.get_search(searchQuery, limit, params = {}, accept = :html) ⇒ Object



73
74
75
76
77
78
79
80
# File 'lib/mjclient.rb', line 73

def self.get_search(searchQuery, limit, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/search/#{searchQuery}/show/#{limit}", @headers)
    resource.get( :params => params, :accept => accept )
  rescue => e
    e.message
  end
end

.get_tags(params = {}, accept = :html) ⇒ Object



91
92
93
94
95
96
97
98
# File 'lib/mjclient.rb', line 91

def self.get_tags(params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/tags", @headers)
    resource.get( :params => params, :accept => accept )
  rescue => e
    e.message
  end
end

.initialize(user_name, user_pass, url) ⇒ Object



5
6
7
8
9
10
# File 'lib/mjclient.rb', line 5

def self.initialize(user_name, user_pass, url)
    @url     = url
    @headers = {:user => user_name, 
               :password => user_pass, 
               :content_type => "application/x-www-form-urlencoded"}
end

.new(user_name, user_pass, url) ⇒ Object



12
13
14
15
16
17
# File 'lib/mjclient.rb', line 12

def self.new(user_name, user_pass, url)
    @url     = url
    @headers = {:user => user_name, 
               :password => user_pass, 
               :content_type => "application/x-www-form-urlencoded"}
end

.post_article_comment(id, params = {}, accept = :html) ⇒ Object



136
137
138
139
140
141
142
143
# File 'lib/mjclient.rb', line 136

def self.post_article_comment(id, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/comment/#{id}", @headers)
    resource.post( params, :accept => accept )
  rescue => e
    "#{e.inspect}"
  end
end

.post_article_like(id, params = {}, accept = :html) ⇒ Object



127
128
129
130
131
132
133
134
# File 'lib/mjclient.rb', line 127

def self.post_article_like(id, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/like/#{id}", @headers)
    resource.post( params, :accept => accept )
  rescue => e
    e.message
  end
end

.post_article_rating(id, number, params = {}, accept = :html) ⇒ Object



145
146
147
148
149
150
151
152
# File 'lib/mjclient.rb', line 145

def self.post_article_rating(id, number, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/rating/#{id}/#{number}", @headers)
    resource.post( params, :accept => accept )
  rescue => e
    e.message
  end
end

.put_article_shareurl(id, params = {}, accept = :html) ⇒ Object



154
155
156
157
158
159
160
161
# File 'lib/mjclient.rb', line 154

def self.put_article_shareurl(id, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/shareurl/#{id}", @headers)
    resource.put( params, :accept => accept )
  rescue => e
    e.message
  end
end

.put_article_views(id, params = {}, accept = :html) ⇒ Object



163
164
165
166
167
168
169
170
# File 'lib/mjclient.rb', line 163

def self.put_article_views(id, params = {}, accept = :html)
  begin
    resource = RestClient::Resource.new(@url + "/ar/views/#{id}", @headers)
    resource.put( params, :accept => accept )
  rescue => e
    e.message
  end
end