microCMS Ruby SDK.
See official tutorial.
Add this line to your application's Gemfile:
gem 'microcms-ruby-sdk'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install microcms-ruby-sdk
require 'microcms'
MicroCMS.service_domain = 'YOUR_DOMAIN' MicroCMS.api_key = 'YOUR_API_KEY'
Note that the YOUR_DOMAIN is the subdomain name of your service (not the FQDN).
puts MicroCMS.list('endpoint')
puts MicroCMS.list( 'endpoint', { draft_key: "abcd", limit: 100, offset: 1, orders: ['updatedAt'], q: 'Hello', fields: %w[id title], ids: ['foo'], filters: 'publishedAt[greater_than]2021年01月01日', depth: 1, }, )
puts MicroCMS.get('endpoint', 'ruby')
puts MicroCMS.get( 'endpoint', 'ruby', { draft_key: 'abcdef1234', fields: %w[title publishedAt], depth: 1, }, )
puts MicroCMS.get('endpoint')
puts MicroCMS.create('endpoint', { text: 'Hello, microcms-ruby-sdk!' })
puts MicroCMS.create( 'endpoint', { id: 'my-content-id', text: 'Hello, microcms-ruby-sdk!', }, )
puts MicroCMS.create( 'endpoint', { id: 'my-content-id', text: 'Hello, microcms-ruby-sdk!', }, { status: 'draft' }, )
puts MicroCMS.update( 'endpoint', { id: 'microcms-ruby-sdk', text: 'Hello, microcms-ruby-sdk update method!', }, )
puts MicroCMS.update('endpoint', { text: 'Hello, microcms-ruby-sdk update method!' })
MicroCMS.delete('endpoint', 'microcms-ruby-sdk')
After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/microcmsio/microcms-ruby-sdk.