Module: Shikimori::API::V1::Topics
- Included in:
- Shikimori::API::V1
- Defined in:
- lib/shikimori/api/v1/topics.rb
Overview
Methods for the Topics API
Constant Summary collapse
- TOPIC_TYPES_MAP =
{ 'topic' => 'Topic', 'club_user' => 'Topics::ClubUserTopic', 'entry_topic' => 'Topics::EntryTopic', 'anime' => 'Topics::EntryTopics::AnimeTopic', 'article' => 'Topics::EntryTopics::ArticleTopic', 'character' => 'Topics::EntryTopics::CharacterTopic', 'club_page' => 'Topics::EntryTopics::ClubPageTopic', 'club' => 'Topics::EntryTopics::ClubTopic', 'collection' => 'Topics::EntryTopics::CollectionTopic', 'contest' => 'Topics::EntryTopics::ContestTopic', 'cosplay_gallery' => 'Topics::EntryTopics::CosplayGalleryTopic', 'manga' => 'Topics::EntryTopics::MangaTopic', 'person' => 'Topics::EntryTopics::PersonTopic', 'ranobe' => 'Topics::EntryTopics::RanobeTopic', 'critique' => 'Topics::EntryTopics::CritiqueTopic', 'review' => 'Topics::EntryTopics::ReviewTopic', 'news' => 'Topics::NewsTopic', 'contest_status' => 'Topics::NewsTopics::ContestStatusTopic' }.freeze
Instance Method Summary collapse
-
#create_topic(topic, headers: nil, **query) ⇒ Hash
Create a topic.
-
#delete_topic(id, headers: nil, **query) ⇒ Boolean
Delete Topic.
-
#hot_topics(headers: nil, **query) ⇒ Array<Hash>
Get hot topics.
-
#topic(id, headers: nil, **query) ⇒ Hash
Get an topic by id.
-
#topics(type: nil, headers: nil, **query) ⇒ Array<Hash>
Get list of topics.
-
#topics_updates(headers: nil, **query) ⇒ Array<Hash>
Get topics updates.
-
#update_topic(id, topic, headers: nil, **query) ⇒ Hash
Update Topic Requires ‘topics` oauth scope.
Instance Method Details
#create_topic(topic, headers: nil, **query) ⇒ Hash
Create a topic. Requires ‘topics` oauth scope
130 131 132 133 134 135 136 |
# File 'lib/shikimori/api/v1/topics.rb', line 130 def create_topic(topic, headers: nil, **query) rest.post( base_url.join('topics').url, { topic: topic }.compact, headers: headers, query: query ) end |
#delete_topic(id, headers: nil, **query) ⇒ Boolean
Delete Topic
190 191 192 |
# File 'lib/shikimori/api/v1/topics.rb', line 190 def delete_topic(id, headers: nil, **query) rest.delete base_url.join('topics', id.to_s).url, headers: headers, query: query end |
#hot_topics(headers: nil, **query) ⇒ Array<Hash>
Get hot topics
231 232 233 |
# File 'lib/shikimori/api/v1/topics.rb', line 231 def hot_topics(headers: nil, **query) rest.get base_url.join('topics', 'hot').url, headers: headers, query: query end |
#topic(id, headers: nil, **query) ⇒ Hash
Get an topic by id
89 90 91 |
# File 'lib/shikimori/api/v1/topics.rb', line 89 def topic(id, headers: nil, **query) rest.get base_url.join('topics', id.to_s).url, headers: headers, query: query end |
#topics(type: nil, headers: nil, **query) ⇒ Array<Hash>
Get list of topics
65 66 67 68 69 70 71 |
# File 'lib/shikimori/api/v1/topics.rb', line 65 def topics(type: nil, headers: nil, **query) topic_type = type && TOPIC_TYPES_MAP[type] rest.get base_url.join('topics').url, headers: headers, query: query.merge( type: topic_type ).compact end |
#topics_updates(headers: nil, **query) ⇒ Array<Hash>
Get topics updates
211 212 213 |
# File 'lib/shikimori/api/v1/topics.rb', line 211 def topics_updates(headers: nil, **query) rest.get base_url.join('topics', 'updates').url, headers: headers, query: query end |
#update_topic(id, topic, headers: nil, **query) ⇒ Hash
Update Topic Requires ‘topics` oauth scope
170 171 172 |
# File 'lib/shikimori/api/v1/topics.rb', line 170 def update_topic(id, topic, headers: nil, **query) rest.put base_url.join('topics', id.to_s).url, { topic: topic }, headers: headers, query: query end |