README.md in buttercms-ruby-1.3.2 vs README.md in buttercms-ruby-1.4

- old
+ new

@@ -28,39 +28,77 @@ # ButterCMS::read_timeout = 5.0 ``` ## Pages +https://buttercms.com/docs/api/?ruby#pages + + ```ruby -params = {foo: 'bar'} # optional +params = {page: 1, page_size: 10, locale: 'en', preview: 1, fields.headline: 'foo bar', levels: 2} # optional pages = ButterCMS::Page.list('news', params) page = ButterCMS::Page.get('news', 'hello-world', params) ``` -## Content Fields +## Collections +https://buttercms.com/docs/api/?ruby#retrieve-a-collection + ```ruby -ButterCMS::Content.fetch(['homepage_headline']) +params = {page: 1, page_size: 10, locale: 'en', preview: 1, fields.headline: 'foo bar', levels: 2} # optional +ButterCMS::Content.fetch(['testimonials'], params) -# Localization -ButterCMS::Content.fetch(['homepage_headline'], locale: 'es') - -# Test mode can be used to setup a staging website for previewing Content Fields or for testing content during local development. To fetch content from test mode add the following configuration: +# Test mode can be used to setup a staging website for previewing Collections or for testing content during local development. To fetch content from test mode add the following configuration: ButterCMS::test_mode = true ``` ## Blog Engine +https://buttercms.com/docs/api/?ruby#blog-engine + ```ruby posts = ButterCMS::Post.all({:page => 1, :page_size => 10}) puts posts.first.title puts posts.meta.next_page posts = ButterCMS::Post.search("my favorite post", {page: 1, page_size: 10}) puts posts.first.title post = ButterCMS::Post.find("post-slug") puts post.title + +# Create a Post. +ButterCMS::write_api_token = "YourWriteToken" +ButterCMS::Post.create({ + slug: 'blog-slug', + title: 'blog-title' +}) + +# Update a Post +ButterCMS::Post.update('blog-slug', { + title: 'blog-title-v2' +}) + +# Create a page +ButterCMS::Page.create({ + slug: 'page-slug', + title: 'page-title', + status: 'published', + "page-type": 'page_type', + fields: { + meta_title: 'test meta title' + } +}) + +# update a Page +ButterCMS::Page.update('page-slug-2', { + status: 'published', + fields: { + meta_title: 'test meta title' + } +}) + + author = ButterCMS::Author.find("author-slug") puts author.first_name category = ButterCMS::Category.find("category-slug")