WordpressClient

:warning: This project is in "maintenance mode" meaning that no patches will be accepted unless security related. We do not recommend using this gem, current users are recommended to migrate to another solution.

WordpressClient is a very simple client for the Wordpress REST API.

Circle CI Code Climate Gem Version

Usage

Read the full API documentation

Initialize a client with a user name, password and API URL. You can then search for posts.

client = WordpressClient.new(
  url: "https://example.com/wp-json/",
  username: "example",
  password: "example",
)

client.posts(per_page: 5) # => [WordpressClient::Post, WordpressClient::Post]

Creating a post

You can create posts by calling create_post.

data = {
  author: "Name",
  # ...
}

post = client.create_post(data) # => WordpressClient::Post
updated_post = client.update_post(post.id, title: "Updated") # => WordpressClient::Post

updated_post.author # => "Name"
updated_post.title_html # => "Updated"

Running tests

You need to install Docker and set it up for your machine.

Run tests using the normal rspec command after installing all bundles.

bundle exec rspec

You can also run bundle exec guard to have tests run automatically when you change files in the repo. If you tag your examples with focus: true, Guard will only run those tests. This can help when doing very focused coding, but remember to remove the filter before you commit and let the entire suite run.

describe Foo, focus: true do
  # ...
end

The normal rspec command will not use this filter in case it is ever committed accidentally, so CI can catch any problems.

Releasing a new version

The normal gem release cycle works using rake release.

If you make changes to the docker image, you can release it using rake docker:release.

Copyright © 2015-2017 Hemnet Service HNS AB

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.