Class: GunsruAPI
- Inherits:
-
Object
- Object
- GunsruAPI
- Defined in:
- lib/gunsru_api.rb
Overview
This class allows to access forum.guns.ru via JSON API
every instance method returns pair (HTTPResponse.code, Hash)
Instance Method Summary collapse
- #addMessageToTopic ⇒ Object
- #addTopicToFavourites ⇒ Object
-
#getActiveTopics(from = 0, to = 20) ⇒ Object
Arguments: from, to Cacheable: yes Returns: hash { timestamp: <unixtime>, topics: [ { type: “topic”, title: <string>, id: <integer>, modificationTime: <unixtime>, postCount: <integer>, author: <string>, lastPost: <string> (author) }]}.
-
#getAllCategories ⇒ Object
Arguments: none Cacheable: yes Returns: hash { timestamp: <unixtime>, categories: [ { type: “category”, title: <string>, id: <integer>, sections: [ { type: <string>, title: <string>, id: <integer>, modificationTime: <unixtime>, categoryId: <integer> }]}]}.
- #getConversationById ⇒ Object
- #getConversations ⇒ Object
-
#getFavoritesSections ⇒ Object
favorite sections manipulation.
- #getFavoriteTopics ⇒ Object
- #getFullMessageById ⇒ Object
-
#getLastTopics ⇒ Object
news & last topics.
- #getLinkedSectionsById(*args) ⇒ Object
- #getLinkedTopicsById ⇒ Object
- #getNewMessageCount ⇒ Object
- #getNews ⇒ Object
- #getPostById ⇒ Object
-
#getPostsByTopicId(id, direction = 1, count = 1024) ⇒ Object
Arguments: id, direction, count.
- #getSectionById ⇒ Object
- #getTopicById ⇒ Object
-
#getTopicsBySectionId(id, from = 0, to = 20) ⇒ Object
Arguments: id, from, to Cacheable: yes Returns: hash { timestamp: <unixtime>, section_id: <unixtime>, topics: [ { type: “topic”, topic_type: <string>, title: <string>, id: <integer>, element_number: <integer>, modificationTime: <unixtime>, postCount: <integer>, author: <string>, lastPost: <string> (author) }]}.
-
#getUserProfileById ⇒ Object
personal messages.
-
#initialize(base_uri = "forum.guns.ru", api_uri = "/api/1.0/") ⇒ GunsruAPI
constructor
Creates new JSON API accessor.
- #logout ⇒ Object
-
#registerIosDevice ⇒ Object
push notifications.
- #removeTopicFromFavourites ⇒ Object
- #unRegisterIosDevice ⇒ Object
Constructor Details
#initialize(base_uri = "forum.guns.ru", api_uri = "/api/1.0/") ⇒ GunsruAPI
Creates new JSON API accessor
14 15 16 17 18 19 20 21 22 |
# File 'lib/gunsru_api.rb', line 14 def initialize(base_uri = "forum.guns.ru", api_uri = "/api/1.0/") @base_uri = base_uri @api_uri = api_uri #@logger = Logger.new(STDOUT) #@logger.formatter = proc do |sev, date, progname, msg| #"#{msg}\n" #end @etags = {} end |
Instance Method Details
#addMessageToTopic ⇒ Object
149 150 151 152 |
# File 'lib/gunsru_api.rb', line 149 def addMessageToTopic() return -1, {} getResponse end |
#addTopicToFavourites ⇒ Object
141 142 143 144 |
# File 'lib/gunsru_api.rb', line 141 def addTopicToFavourites() return -1, {} getResponse end |
#getActiveTopics(from = 0, to = 20) ⇒ Object
Arguments: from, to Cacheable: yes Returns: hash
{
timestamp: <unixtime>,
topics: [ {
type: "topic",
title: <string>,
id: <integer>,
modificationTime: <unixtime>,
postCount: <integer>,
author: <string>,
lastPost: <string> (author)
}]}
109 110 111 |
# File 'lib/gunsru_api.rb', line 109 def getActiveTopics(from=0, to=20) getResponse('from', from, 'to', to) end |
#getAllCategories ⇒ Object
Arguments: none Cacheable: yes Returns: hash
{
timestamp: <unixtime>,
categories: [ {
type: "category",
title: <string>,
id: <integer>,
sections: [ {
type: <string>,
title: <string>,
id: <integer>,
modificationTime: <unixtime>,
categoryId: <integer>
}]}]}
66 67 68 |
# File 'lib/gunsru_api.rb', line 66 def getAllCategories() getResponse() end |
#getConversationById ⇒ Object
186 187 188 189 |
# File 'lib/gunsru_api.rb', line 186 def getConversationById() return -1, {} getResponse end |
#getConversations ⇒ Object
182 183 184 185 |
# File 'lib/gunsru_api.rb', line 182 def getConversations() return -1, {} getResponse end |
#getFavoritesSections ⇒ Object
favorite sections manipulation
200 201 202 203 |
# File 'lib/gunsru_api.rb', line 200 def getFavoritesSections() return -1, {} getResponse end |
#getFavoriteTopics ⇒ Object
204 205 206 207 |
# File 'lib/gunsru_api.rb', line 204 def getFavoriteTopics() return -1, {} getResponse end |
#getFullMessageById ⇒ Object
190 191 192 193 |
# File 'lib/gunsru_api.rb', line 190 def getFullMessageById() return -1, {} getResponse end |
#getLastTopics ⇒ Object
news & last topics
168 169 170 171 |
# File 'lib/gunsru_api.rb', line 168 def getLastTopics() return -1, {} getResponse end |
#getLinkedSectionsById(*args) ⇒ Object
137 138 139 140 |
# File 'lib/gunsru_api.rb', line 137 def getLinkedSectionsById(*args) return -1, {} getResponse end |
#getLinkedTopicsById ⇒ Object
145 146 147 148 |
# File 'lib/gunsru_api.rb', line 145 def getLinkedTopicsById() return -1, {} getResponse end |
#getNewMessageCount ⇒ Object
194 195 196 197 |
# File 'lib/gunsru_api.rb', line 194 def getNewMessageCount() return -1, {} getResponse end |
#getNews ⇒ Object
172 173 174 175 |
# File 'lib/gunsru_api.rb', line 172 def getNews() return -1, {} getResponse end |
#getPostById ⇒ Object
161 162 163 164 |
# File 'lib/gunsru_api.rb', line 161 def getPostById() return -1, {} getResponse end |
#getPostsByTopicId(id, direction = 1, count = 1024) ⇒ Object
Arguments: id, direction, count. Optional: number, start_msg_id Cacheable: yes Returns: hash
{
timestamp: <unixtime>,
topic_id: <integer>,
messages: [ {
type: "post",
body: <string>,
id: <integer>,
element_number: <integer>,
createTime: <unixtime>,
author: { [
nickname: <string>,
id: <integer>,
userpic: [ { ... }],
]}
}]}
133 134 135 |
# File 'lib/gunsru_api.rb', line 133 def getPostsByTopicId(id, direction=1, count=1024) getResponse('id', id, 'direction', direction, 'count', count) end |
#getSectionById ⇒ Object
153 154 155 156 |
# File 'lib/gunsru_api.rb', line 153 def getSectionById() return -1, {} getResponse end |
#getTopicById ⇒ Object
157 158 159 160 |
# File 'lib/gunsru_api.rb', line 157 def getTopicById() return -1, {} getResponse end |
#getTopicsBySectionId(id, from = 0, to = 20) ⇒ Object
Arguments: id, from, to Cacheable: yes Returns: hash
{
timestamp: <unixtime>,
section_id: <unixtime>,
topics: [ {
type: "topic",
topic_type: <string>,
title: <string>,
id: <integer>,
element_number: <integer>,
modificationTime: <unixtime>,
postCount: <integer>,
author: <string>,
lastPost: <string> (author)
}]}
89 90 91 |
# File 'lib/gunsru_api.rb', line 89 def getTopicsBySectionId(id, from=0, to=20) getResponse('id', id, 'from', from, 'to', to) end |
#getUserProfileById ⇒ Object
personal messages
178 179 180 181 |
# File 'lib/gunsru_api.rb', line 178 def getUserProfileById() return -1, {} getResponse end |
#logout ⇒ Object
221 222 223 224 |
# File 'lib/gunsru_api.rb', line 221 def logout() return -1, {} getResponse end |
#registerIosDevice ⇒ Object
push notifications
213 214 215 216 |
# File 'lib/gunsru_api.rb', line 213 def registerIosDevice() return -1, {} getResponse end |
#removeTopicFromFavourites ⇒ Object
208 209 210 211 |
# File 'lib/gunsru_api.rb', line 208 def removeTopicFromFavourites() return -1, {} getResponse end |
#unRegisterIosDevice ⇒ Object
217 218 219 220 |
# File 'lib/gunsru_api.rb', line 217 def unRegisterIosDevice() return -1, {} getResponse end |