Skip to content

krayinc/docbase-ruby

Repository files navigation

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')

Docbase::Client.new options

  • access_token
    • access token
  • team
    • team subdomain
  • retry_on_rate_limit_exceeded
    • #16
    • true or false

profile

client.profile.body

users

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

所属グループはv3ではユーザー検索APIのレスポンスに含まれません。user_groupsを利用してください。

User groups

client.user_groups(1).body
client.user_groups(1, page: 2, per_page: 20).body

Delete user

client.delete_user(1)

tags

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

groups

List

client.groups.body
client.groups(name: 'developers').body
client.groups(page: 2, per_page: 10).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

Search

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)

Partial body update

params = {
  id: 1,
  operations: [
    {
      start: 3,
      end: 5,
      old_content: "line3\r\nline4\r\nline5",
      content: 'new text',
    },
  ],
  notice: true,
}

client.update_post_body(params)

Archive

client.archive_post(1)

Unarchive

client.unarchive_post(1)

Delete

client.delete_post(1)

Comment

List

client.comments(1).body
client.comments(1, page: 2, per_page: 20, order: 'desc').body

Create

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

client.create_comment(params)

Delete

client.delete_comment(1)

good jobs

List

client.good_jobs(1).body
client.good_jobs(1, page: 2, per_page: 100, order: 'desc').body

Create

client.create_good_job(1)
client.create_good_job(1, notice: false)

Delete

client.delete_good_job(1, 111)

attachments

Create

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

Download

response = client.attachment(file_id)
File.open(file_id, 'wb') { |f| f.write(response.body) }

switch team

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

client.team = 'danny'
client.access_token = 'danny_team_access_token'
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.

About

DocBase API Client, written in Ruby

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

 
 
 

Contributors