docbase-ruby

Build Status

DocBase API Client, written in Ruby.

Installation

Add this line to your application's Gemfile:

gem 'docbase'

And then execute:

$ bundle

Or install it yourself as:

$ gem install docbase

Usage

client = DocBase::Client.new(access_token: 'your_access_token', team: 'your_team')

or

ENV['DOCBASE_ACCESS_TOKEN'] = 'your_access_token'

client = DocBase::Client.new(team: 'your_team')

teams

client.teams.body
# => [{ domain: 'kray', name: 'kray' }, { domain: 'danny', name: 'danny' }]

users

client.users(q: 'name')
client.users(q: 'name', page: 2)
client.users(q: 'name', page: 1, per_page: 100)
client.users(q: 'name', page: 1, per_page: 100, include_user_groups: true)

tags

client.tags.body
# => [{ name: 'ruby' }, { name: 'rails' }]

groups

List

client.groups.body

Show

client.group(1).body

Create

params = {
  name: 'group',
  description: 'Important group.',
}

client.create_group(params)

Add users to group

params = {
  group_id: 1,
  user_ids: [10, 11, 12]
}

client.add_users_to_group(params)

Remove users from group

params = {
  group_id: 1,
  user_ids: [10, 11, 12]
}

client.remove_users_from_group(params)

posts

client.posts(q: 'body')
client.posts(q: 'body', page: 2)
client.posts(q: 'body', page: 1, per_page: 100)

Show

client.post(1)

Create

params = {
  title: 'memo title',
  body: 'memo body',
  draft: false,
  tags: ['rails', 'ruby'],
  scope: 'group',
  groups: [1],
  notice: true,
}

client.create_post(params)

Update

params = {
  id: 1,
  title: 'memo title',
  body: 'memo body',
  draft: false,
  tags: ['rails', 'ruby'],
  scope: 'group',
  groups: [1],
  notice: true,
}

client.update_post(params)

Archive

client.archive_post(1)

Unarchive

client.unarchive_post(1)

Delete

client.delete_post(1)

Comment

Create

params = {
  post_id: 1,
  body: 'GJ!!',
  notice: true,
}

client.create_comment(params)

Delete

client.delete_comment(1)

attachments

Create

client.upload('./test.jpg')
client.upload(['./test.jpg', './README.md'])

switch team

client = DocBase::Client.new(access_token: 'your_access_token', team: 'kray')
client.tags.body
# => [{ name: 'ruby' }, { name: 'rails' }]

client.team = 'danny'
client.tags.body
# => [{ name: 'javascript' }, { name: 'react' }]

API Document

https://help.docbase.io/posts/45703

License

The gem is available as open source under the terms of the MIT License.