kintone-oauth-extension 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/gem-push.yml +37 -0
  3. data/.github/workflows/test.yml +21 -0
  4. data/.gitignore +21 -0
  5. data/.rspec +1 -0
  6. data/.rubocop.yml +47 -0
  7. data/CHANGELOG.md +13 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/Gemfile +4 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +374 -0
  12. data/bin/console +4 -0
  13. data/bin/setup +6 -0
  14. data/kintone.gemspec +38 -0
  15. data/lib/kintone.rb +8 -0
  16. data/lib/kintone/api.rb +121 -0
  17. data/lib/kintone/api/guest.rb +44 -0
  18. data/lib/kintone/command.rb +12 -0
  19. data/lib/kintone/command/accessor.rb +109 -0
  20. data/lib/kintone/command/apis.rb +22 -0
  21. data/lib/kintone/command/app.rb +11 -0
  22. data/lib/kintone/command/app_acl.rb +11 -0
  23. data/lib/kintone/command/apps.rb +12 -0
  24. data/lib/kintone/command/bulk_request.rb +12 -0
  25. data/lib/kintone/command/field_acl.rb +11 -0
  26. data/lib/kintone/command/file.rb +15 -0
  27. data/lib/kintone/command/form.rb +11 -0
  28. data/lib/kintone/command/guests.rb +17 -0
  29. data/lib/kintone/command/preview_form.rb +11 -0
  30. data/lib/kintone/command/record.rb +23 -0
  31. data/lib/kintone/command/record_acl.rb +11 -0
  32. data/lib/kintone/command/records.rb +29 -0
  33. data/lib/kintone/command/space.rb +15 -0
  34. data/lib/kintone/command/space_body.rb +11 -0
  35. data/lib/kintone/command/space_guests.rb +11 -0
  36. data/lib/kintone/command/space_members.rb +16 -0
  37. data/lib/kintone/command/space_thread.rb +14 -0
  38. data/lib/kintone/command/template_space.rb +12 -0
  39. data/lib/kintone/kintone_error.rb +12 -0
  40. data/lib/kintone/oauth_api.rb +91 -0
  41. data/lib/kintone/query.rb +152 -0
  42. data/lib/kintone/query/extension.rb +23 -0
  43. data/lib/kintone/type.rb +6 -0
  44. data/lib/kintone/type/extension/enumerable.rb +5 -0
  45. data/lib/kintone/type/extension/hash.rb +5 -0
  46. data/lib/kintone/type/extension/object.rb +5 -0
  47. data/lib/kintone/type/record.rb +11 -0
  48. data/lib/kintone/version.rb +3 -0
  49. data/spec/kintone/api/guest_spec.rb +289 -0
  50. data/spec/kintone/api_spec.rb +566 -0
  51. data/spec/kintone/command/apis_spec.rb +179 -0
  52. data/spec/kintone/command/app_acl_spec.rb +43 -0
  53. data/spec/kintone/command/app_spec.rb +54 -0
  54. data/spec/kintone/command/apps_spec.rb +90 -0
  55. data/spec/kintone/command/bulk_request_spec.rb +92 -0
  56. data/spec/kintone/command/field_acl_spec.rb +47 -0
  57. data/spec/kintone/command/file_spec.rb +65 -0
  58. data/spec/kintone/command/form_spec.rb +47 -0
  59. data/spec/kintone/command/guests_spec.rb +107 -0
  60. data/spec/kintone/command/preview_form_spec.rb +30 -0
  61. data/spec/kintone/command/record_acl_spec.rb +48 -0
  62. data/spec/kintone/command/record_spec.rb +210 -0
  63. data/spec/kintone/command/records_spec.rb +463 -0
  64. data/spec/kintone/command/space_body_spec.rb +47 -0
  65. data/spec/kintone/command/space_guests_spec.rb +55 -0
  66. data/spec/kintone/command/space_members_spec.rb +117 -0
  67. data/spec/kintone/command/space_spec.rb +86 -0
  68. data/spec/kintone/command/space_thread_spec.rb +77 -0
  69. data/spec/kintone/command/template_space_spec.rb +59 -0
  70. data/spec/kintone/kintone_error_spec.rb +93 -0
  71. data/spec/kintone/oauth_api_spec.rb +164 -0
  72. data/spec/kintone/query_spec.rb +506 -0
  73. data/spec/kintone/type/record_spec.rb +38 -0
  74. data/spec/spec_helper.rb +10 -0
  75. metadata +302 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ee744c1f9e1ef957970753bbb6fde98153b504e05e912d32d82172c6f7b59f89
4
+ data.tar.gz: a437f27dbd27d4aad95e5e6019f3f78ad959d414e6aea5bcbdf9a9ec495d3604
5
+ SHA512:
6
+ metadata.gz: 603cc2cb7d028e0ad6452b0d57c8b4bd18ff539d190281d1060a5fa76b5782c56c2288fe6eab6376c0e7db9b4c91fe01a7f44e90302dd827c50630b95b90dd0e
7
+ data.tar.gz: 9529b5198422902acf0f79f9ac5c480a918b0f675fe841fc2c2be49222e78ad4d1d1bd7a0d4bbdd46ce99a73d393e29dca9934316c67cb1562657db583e09288
@@ -0,0 +1,37 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+
7
+ jobs:
8
+ build:
9
+ name: Build + Publish
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Set up Ruby 2.6
15
+ uses: actions/setup-ruby@v1
16
+ with:
17
+ ruby-version: 2.6
18
+
19
+ - name: Build and test
20
+ run: |
21
+ gem install bundler
22
+ bundle install --jobs 4 --retry 3
23
+ bundle exec rspec
24
+ env:
25
+ CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
26
+
27
+ - name: Publish to RubyGems
28
+ run: |
29
+ mkdir -p $HOME/.gem
30
+ touch $HOME/.gem/credentials
31
+ chmod 0600 $HOME/.gem/credentials
32
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
33
+ gem build *.gemspec
34
+ gem push *.gem
35
+ continue-on-error: true
36
+ env:
37
+ GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
@@ -0,0 +1,21 @@
1
+ name: Test
2
+
3
+ on: pull_request
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+ - name: Set up Ruby
12
+ uses: ruby/setup-ruby@v1
13
+ with:
14
+ ruby-version: 2.6
15
+ - name: Build and test
16
+ run: |
17
+ gem install bundler
18
+ bundle install --jobs 4 --retry 3
19
+ bundle exec rspec
20
+ env:
21
+ CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor/
19
+ sample/
20
+ .ruby-version
21
+ .rbenv-gemsets
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ -c -f doc
@@ -0,0 +1,47 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2014-07-24 11:44:58 +0900 using RuboCop version 0.24.1.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ AllCops:
9
+ Exclude:
10
+ - "Guardfile"
11
+ - "vendor/**/*"
12
+
13
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
14
+ Style/ClassAndModuleChildren:
15
+ EnforcedStyle: compact
16
+
17
+ Style/Documentation:
18
+ Enabled: false
19
+
20
+ # Configuration parameters: AllowURI.
21
+ Metrics/LineLength:
22
+ Max: 1_00
23
+
24
+ # Cop supports --auto-correct.
25
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
26
+ Style/StringLiterals:
27
+ EnforcedStyle: single_quotes
28
+
29
+ Style/WordArray:
30
+ Exclude:
31
+ - "spec/**/**"
32
+
33
+ Style/AsciiComments:
34
+ Enabled: false
35
+
36
+ CyclomaticComplexity:
37
+ Max: 10
38
+
39
+ Style/FrozenStringLiteralComment:
40
+ Enabled: false
41
+
42
+ Style/SymbolProc:
43
+ Exclude:
44
+ - "lib/kintone/query.rb"
45
+
46
+ Style/SignalException:
47
+ EnforcedStyle: only_raise
@@ -0,0 +1,13 @@
1
+ # CHANGELOG
2
+
3
+ ## 0.2.1 (2020-09-18)
4
+
5
+ rename gem to `kintone-oauth-extension`.
6
+
7
+ ## 0.2.0 (2020-09-14)
8
+
9
+ Initial release of koshilife-kintone
10
+
11
+ - support OAuth authentication.
12
+ - update gems.
13
+ - required_ruby_version is set to 2.4.
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at koshikawa2009@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kintone.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Kenji Koshikawa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,374 @@
1
+ # kintone
2
+
3
+ [![Test](https://github.com/koshilife/kintone/workflows/Test/badge.svg)](https://github.com/koshilife/kintone/actions?query=workflow%3ATest)
4
+ [![codecov](https://codecov.io/gh/koshilife/kintone/branch/master/graph/badge.svg)](https://codecov.io/gh/koshilife/kintone)
5
+ [![Gem Version](https://badge.fury.io/rb/kintone.svg)](http://badge.fury.io/rb/kintone-oauth-extension)
6
+ [![license](https://img.shields.io/github/license/koshilife/kintone)](https://github.com/koshilife/kintone/blob/master/LICENSE.txt)
7
+
8
+ A Ruby gem for communicating with the [kintone](https://kintone.cybozu.com/us/) REST API
9
+
10
+ ## Requirements
11
+
12
+ - ruby 2.4.0 or later
13
+
14
+ ## Installation
15
+
16
+ gem install kintone-oauth-extension
17
+
18
+ or execute `bundle install` command after you insert the following into Gemfile
19
+
20
+ gem 'kintone-oauth-extension'
21
+
22
+ ## Usage
23
+
24
+ ```ruby
25
+ require 'kintone'
26
+
27
+ # Use password authentication
28
+ api = Kintone::Api.new("example.cybozu.com", "Administrator", "cybozu")
29
+
30
+ # Use token authentication
31
+ api = Kintone::Api.new("example.cybozu.com", "authtoken")
32
+
33
+ # Use OAuth authentication
34
+ api = Kintone::OAuthApi.new("example.cybozu.com", "access_token")
35
+ # if set oauth options below, you can refresh the access_token.
36
+ oauth_options = {
37
+ client_id: 'client_id',
38
+ client_secret: 'client_secret',
39
+ refresh_token: 'refresh_token',
40
+ expires_at: 1599921045
41
+ }
42
+ api = Kintone::OAuthApi.new("example.cybozu.com", "access_token", oauth_options)
43
+ # get new token.
44
+ api.refresh!
45
+ api.access_token.token
46
+ # => "new_access_token"
47
+ ```
48
+
49
+ ### Supported API
50
+
51
+ - [Record retrieval](#record_retrieval)
52
+ - [Record register](#record_register)
53
+ - [Record update](#record_update)
54
+ - [Record delete](#record_delete)
55
+ - [Bulk request](#bulk_request)
56
+ - [File](#file)
57
+ - [Permissions](#permissions)
58
+ - [Space management](#space_management)
59
+ - [Guests](#guests)
60
+ - [Application information](#application_information)
61
+ - [Form structure](#form_structure)
62
+ - [API information](#api_information)
63
+
64
+ ### <a name="record_retrieval"> Record retrieval
65
+
66
+ ```ruby
67
+ # Record retrieval(Assign by Record Number)
68
+ app = 8; id = 100
69
+ api.record.get(app, id) # => {"record" => {"record_id" => {"type" => "RECORD_NUMBER", "value" => "1"}}}
70
+
71
+ # Records retrieval(Assign by Conditions by Query Strings)
72
+ app = 8; fields = ["record_id", "created_time", "dropdown"]
73
+ query = "updated_time > \"2012-02-03T09:00:00+0900\" and updated_time < \"2012-02-03T10:00:00+0900\" order by record_id asc limit 10 offset 20"
74
+ api.records.get(app, query, fields) # => {"records" => [{...}, ...]}
75
+ ```
76
+
77
+ Query helper
78
+
79
+ ```ruby
80
+ query =
81
+ Kintone::Query.new do
82
+ field(:updated_time) > "2012-02-03T09:00:00+0900"
83
+ and!
84
+ field(:updated_time) < "2012-02-03T10:00:00+0900"
85
+ order_by(:record_id)
86
+ limit(10)
87
+ offset(20)
88
+ end
89
+ # or
90
+ query =
91
+ Kintone::Query.new do
92
+ f(:updated_time) > "2012-02-03T09:00:00+0900"
93
+ and!
94
+ f(:updated_time) < "2012-02-03T10:00:00+0900"
95
+ order_by(:record_id)
96
+ limit(10)
97
+ offset(20)
98
+ end
99
+ query.to_s # => "updated_time > \"2012-02-03T09:00:00+0900\" and updated_time < \"2012-02-03T10:00:00+0900\" order by record_id asc limit 10 offset 20"
100
+ api.records.get(app, query, fields)
101
+
102
+ # Example
103
+ Kintone::Query.new do
104
+ field(:Created_datetime) >= last_month
105
+ and!
106
+ precede do
107
+ field(:text).like("Hello")
108
+ and!
109
+ field(:number) == 200
110
+ end
111
+ or!
112
+ precede do
113
+ field(:number) > 100
114
+ and!
115
+ field(:Created_by).in([login_user])
116
+ end
117
+ order_by(:record_id, :desc)
118
+ limit(10)
119
+ offset(20)
120
+ end
121
+ # => "Created_datetime >= LAST_MONTH() and (text like \"Hello\" and number = 200) or (number > 100 and Created_by in (LOGINUSER())) order by record_id desc limit 10 offset 20"
122
+ ```
123
+
124
+ | operator symbol | query helper |
125
+ | --------------- | ------------------------------- |
126
+ | = | field(:code) == other |
127
+ | != | field(:code) != other |
128
+ | &gt; | field(:code) > other |
129
+ | < | field(:code) < other |
130
+ | &gt;= | field(:code) >= other |
131
+ | <= | field(:code) <= other |
132
+ | in | field(:code).in(["A", "B"]) |
133
+ | not in | field(:code).not_in(["A", "B"]) |
134
+ | like | field(:code).like("Hello") |
135
+ | not like | field(:code).not_like("Hello") |
136
+ | and | and! |
137
+ | or | or! |
138
+ | () | precede do; end |
139
+
140
+ | function | query helper |
141
+ | ---------------------- | -------------------- |
142
+ | LOGINUSER() | login_user |
143
+ | PRIMARY_ORGANIZATION() | primary_organization |
144
+ | NOW() | now |
145
+ | TODAY() | today |
146
+ | THIS_MONTH() | this_month |
147
+ | LAST_MONTH() | last_month |
148
+ | THIS_YEAR() | this_year |
149
+
150
+ | option | query helper |
151
+ | -------- | ------------------------------ |
152
+ | order by | order_by(:code, :asc or :desc) |
153
+ | limit | limit(20) |
154
+ | offset | offset(30) |
155
+
156
+ ### <a name="record_register"> Record register
157
+
158
+ ```ruby
159
+ # Record register(single record)
160
+ # Use Hash
161
+ app = 7
162
+ record = {"number" => {"value" => "123456"}}
163
+ api.record.register(app, record) # => {"id" => "100", "revision" => "1"}
164
+
165
+ # Use Kintone::Type::Record
166
+ app = 7
167
+ record = Kintone::Type::Record.new(number: "123456")
168
+ api.record.register(app, record) # => {"id" => "100", "revision" => "1"}
169
+
170
+ # Records register(batch)
171
+ # Use Hash
172
+ app = 7
173
+ records = [
174
+ {"number" => {"value" => "123456"}},
175
+ {"number" => {"value" => "7890"}}
176
+ ]
177
+ api.records.register(app, records) # => {"ids" => ["100", "101"], "revisions" => ["1", "1"]}
178
+
179
+ # Use Kintone::Type::Record
180
+ app = 7
181
+ records = [
182
+ Kintone::Type::Record.new(number: "123456"),
183
+ Kintone::Type::Record.new(number: "7890")
184
+ ]
185
+ api.records.register(app, records) # => {"ids" => ["100", "101"], "revisions" => ["1", "1"]}
186
+ ```
187
+
188
+ ### <a name="record_update"> Record update
189
+
190
+ ```ruby
191
+ # Record update(single record)
192
+ # Use Hash
193
+ app = 4; id = 1
194
+ record = {"string_multi" => {"value" => "changed!"}}
195
+ api.record.update(app, id, record) # => {"revision" => "2"}
196
+
197
+ # Use Kintone::Type::Record
198
+ app = 4; id = 1
199
+ record = Kintone::Type::Record.new({string_multi: "changed!"})
200
+ api.record.update(app, id, record) # => {"revision" => "2"}
201
+
202
+ # With revision
203
+ api.record.update(app, id, record, revision: 1)
204
+
205
+ # Records update(batch)
206
+ # Use Hash
207
+ app = 4
208
+ records = [
209
+ {"id" => 1, "record" => {"string_multi" => {"value" => "abcdef"}}},
210
+ {"id" => 2, "record" => {"string_multi" => {"value" => "opqrstu"}}}
211
+ ]
212
+ api.records.update(app, records) # => {"records" => [{"id" => "1", "revision" => "2"}, {"id" => "2", "revision" => "2"}]}
213
+
214
+ # Use Kintone::Type::Record
215
+ app = 4
216
+ records = [
217
+ {id: 1, record: Kintone::Type::Record.new(string_multi: "abcdef")},
218
+ {id: 2, record: Kintone::Type::Record.new(string_multi: "opqrstu")}
219
+ ]
220
+ api.records.update(app, records) # => {"records" => [{"id" => "1", "revision" => "2"}, {"id" => "2", "revision" => "2"}]}
221
+
222
+ # with revision
223
+ records = [
224
+ {id: 1, revision: 1, record: Kintone::Type::Record.new(string_multi: "abcdef")},
225
+ {id: 2, revision: 1, record: Kintone::Type::Record.new(string_multi: "opqrstu")}
226
+ ]
227
+ api.records.update(app, records)
228
+ ```
229
+
230
+ ### <a name="record_delete"> Record delete
231
+
232
+ ```ruby
233
+ app = 8; ids = [100, 80]
234
+ api.records.delete(app, ids) # => {}
235
+
236
+ # With revision
237
+ revisions = [1, 1]
238
+ api.records.delete(app, ids, revisions: revisions)
239
+ ```
240
+
241
+ ### <a name="bulk_request"> Bulk request
242
+
243
+ ```ruby
244
+ requests = [{"method" => "POST", ...}, {"method" => "PUT", ...}]
245
+ api.bulk.request(requests) # => [...]
246
+ ```
247
+
248
+ ### <a name="file"> File
249
+
250
+ ```ruby
251
+ # File upload
252
+ file_key = api.file.register("/path/to/file", "text/plain", "file.txt")
253
+
254
+ # File download
255
+ file = api.file.get(file_key)
256
+ ```
257
+
258
+ ### <a name="permissions"> Permissions
259
+
260
+ ```ruby
261
+ # App
262
+ app = 1
263
+ rights = [{"entity" => {"type" => "USER", "code" => "user1"}, "appEditable" => true, ...}, ...]
264
+ api.app_acl.update(app, rights) # => {}
265
+
266
+ # Records
267
+ id = 1
268
+ rights = [{"filterCond" => "...", "entities" => [{"entity" => {...}, "viewable" => false, ...}, ...]}, ...]
269
+ api.record_acl.update(id, rights) # => {}
270
+
271
+ #Fields
272
+ id = 1
273
+ rights = [{"code" => "Single_line_text_0", "entities" => [{"entity" => {...}, "accesibility" => "WRITE"}, ...]}, ...]
274
+ api.field_acl.update(id, rights) # => {}
275
+ ```
276
+
277
+ ### <a name="space_management"> Space management
278
+
279
+ ```ruby
280
+ # Space information
281
+ id = 1
282
+ api.space.get(id) # => { "id" => "1", "name" => "space", "defaultThread" => "3", "isPrivate" => true, ...}
283
+
284
+ # Create space
285
+ id = 1; name = "sample space"
286
+ members = [{"entity" => {"type" => "USER", "code" => "user1"}, "isAdmin": true}, ...]
287
+ api.template_space.create(id, name, members, is_guest: true, fixed_member: false) # => {"id" => "1"}
288
+
289
+ # Space body update
290
+ id = 1; body = "<b>awesome space!</b>"
291
+ api.space_body.update(id, body) # => {}
292
+
293
+ # Space members
294
+ id = 1
295
+ members = api.space_members.get(id) # => {"members"=>[{"entity"=>{"type"=>"USER", "code"=> "user1"}, ...}, ...]}
296
+ members << {"entity" => {"type" => "GROUP", "code" => "group1"}}
297
+ members = api.space_members.update(id, members) # => {}
298
+
299
+ # Space thread update
300
+ id = 1; name = "thread name"
301
+ body = "<b>awesome thread!</b>"
302
+ api.space_thread.update(id, name: name, body: body) # => {}
303
+
304
+ # Space guests
305
+ id = 1
306
+ guests = ["hoge@example.com"]
307
+ api.guest(1).space_guests.update(id, guests) # => {}
308
+
309
+ # Space delete
310
+ id = 1
311
+ api.space.delete(id) # => {}
312
+ ```
313
+
314
+ ### <a name="guests"> Guests
315
+
316
+ ```ruby
317
+ # Add guest
318
+ guests = [{code: "hoge@example.com", password: "p@ssword", timezone: "Asia/Tokyo", name: "Tokyo, Saburo", ...}, ...]
319
+ api.guests.register(guests) # => {}
320
+
321
+ # delete guest
322
+ guests = ["hoge@example.com", "fuga@example.com"]
323
+ api.guests.delete(guests) # => {}
324
+ ```
325
+
326
+ ### <a name="application_information"> Application information
327
+
328
+ ```ruby
329
+ id = 4
330
+ api.app.get(id) # => {"appId" => "4", "code" => "", ...}
331
+
332
+ name = "test"; codes = ["FOO", "BAR"]
333
+ api.apps.get({ name: name, codes: codes }) # => { "apps" => [{...}, ...] }
334
+ ```
335
+
336
+ ### <a name="form_structure"> Form structure
337
+
338
+ ```ruby
339
+ app = 1
340
+ api.form.get(app) # => {"properties" => [{...}, ...]}
341
+
342
+ api.preview_form.get(app) # => {"properties" => [{...}, ...]}
343
+ ```
344
+
345
+ ### <a name="api_information"> API information
346
+
347
+ ```ruby
348
+ api.apis.get # => {"baseUrl" => "https://example.cybozu.com/k/v1/", "apis" => {"records/get" => {"link" => "apis/records/get.json"}}}
349
+
350
+ api.apis.get_details_of("apis/records/get.json") # => {"id" => "GetRecords", "baseUrl" => "https://example.cybozu.com/k/v1/", ...}
351
+
352
+ api.apis.get_details_of_key("records/get") # => {"id" => "GetRecords", "baseUrl" => "https://example.cybozu.com/k/v1/", ...}
353
+ ```
354
+
355
+ ### Other examples
356
+
357
+ ```ruby
358
+ # Format retrieval
359
+ url = api.get_url("form")
360
+ api.get(url, {"app" => 4}) # => {"properties" => [{...}, ...]}
361
+
362
+ # Batch record register
363
+ url = api.get_url("records")
364
+ body = {"app" => 7, "records" => [{...}, ...]}
365
+ api.post(url, body) # => {"ids" => ["100","101"]}
366
+ ```
367
+
368
+ ### Access to guest spaces
369
+
370
+ ```ruby
371
+ api.guest(1).record.get(8, 100)
372
+ ```
373
+
374
+ see also [kintone developers](http://developers.kintone.com/)