Module: Redd::Client::Authenticated::Subreddits

Included in:
Redd::Client::Authenticated
Defined in:
lib/redd/client/authenticated/subreddits.rb

Instance Method Summary collapse

Instance Method Details

#edit_subscription(action, subreddit) ⇒ Object (private)



25
26
27
28
# File 'lib/redd/client/authenticated/subreddits.rb', line 25

def edit_subscription(action, subreddit)
  fullname = extract_fullname(subreddit)
  post "/api/subscribe", action: action, sr: fullname
end

#get_subreddits(where = :subscriber, params = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/redd/client/authenticated/subreddits.rb', line 13

def get_subreddits(where = :subscriber, params = {})
  path =
    if [:popular, :new].include?(where)
      "/subreddits/#{where}.json"
    elsif [:subscriber, :contributor, :moderator].include?(where)
      "/subreddits/mine/#{where}.json"
    end
  object_from_response(:get, path, params)
end

#subscribe(subreddit) ⇒ Object



5
6
7
# File 'lib/redd/client/authenticated/subreddits.rb', line 5

def subscribe(subreddit)
  edit_subscription(:sub, subreddit)
end

#unsubscribe(subreddit) ⇒ Object



9
10
11
# File 'lib/redd/client/authenticated/subreddits.rb', line 9

def unsubscribe(subreddit)
  edit_subscription(:unsub, subreddit)
end