Module: Kinja::Author

Included in:
Client
Defined in:
lib/kinja/author.rb

Instance Method Summary collapse

Instance Method Details

#get_all_author_posts(id, max = 100) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kinja/author.rb', line 15

def get_all_author_posts(id, max=100)
  posts = []
  feed = get_author_posts(id, nil, max)
  posts.push feed["items"]
  next_one = feed["pagination"]["next"]["startTime"]
  loop do
    feed = get_author_posts(id, next_one, max)
    posts.push feed["items"]
    posts = posts.flatten

    break if feed["pagination"]["next"].nil?
    next_one = feed["pagination"]["next"]["startTime"]
    puts posts.length
    puts "Getting next one #{next_one}"
  end
  posts.flatten
end

#get_author(user) ⇒ Object



3
4
5
# File 'lib/kinja/author.rb', line 3

def get_author(user)
  HTTParty.get(author_path(user["id"]))["data"]
end

#get_author_id(name) ⇒ Object



7
8
9
# File 'lib/kinja/author.rb', line 7

def get_author_id(name)
  HTTParty.get(author_name_path(name))["data"]["id"]
end

#get_author_posts(id, start = nil, max = 20) ⇒ Object



33
34
35
# File 'lib/kinja/author.rb', line 33

def get_author_posts(id, start=nil, max=20)
  HTTParty.get(author_posts_path(id, start, max))["data"]
end

#get_default_blog_id(user) ⇒ Object



11
12
13
# File 'lib/kinja/author.rb', line 11

def get_default_blog_id(user)
  get_author(user)[0]["defaultBlogId"]
end