Module: WP::API::Endpoints

Included in:
Client
Defined in:
lib/wp/api/endpoints.rb

Instance Method Summary collapse

Instance Method Details

#post(id, query = {}) ⇒ Object



11
12
13
# File 'lib/wp/api/endpoints.rb', line 11

def post(id, query = {})
  WP::API::Post.new *get("posts/#{id}", query)
end

#post_named(slug) ⇒ Object



15
16
17
# File 'lib/wp/api/endpoints.rb', line 15

def post_named(slug)
  WP::API::Post.new *get("posts", name: slug).first
end

#posts(query = {}) ⇒ Object



4
5
6
7
8
9
# File 'lib/wp/api/endpoints.rb', line 4

def posts(query = {})
  posts, headers = get("posts", query)
  posts.collect do |hash|
    WP::API::Post.new(hash, headers)
  end
end