kintone_rb 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/.github/dependabot.yml +7 -0
  3. data/.github/workflows/rspec.yml +28 -0
  4. data/.gitignore +20 -0
  5. data/.rspec +1 -0
  6. data/.rubocop.yml +47 -0
  7. data/.ruby-version +1 -0
  8. data/CHANGELOG.md +4 -0
  9. data/Gemfile +4 -0
  10. data/LICENSE.txt +22 -0
  11. data/README.md +361 -0
  12. data/Rakefile +6 -0
  13. data/kintone.gemspec +30 -0
  14. data/lib/kintone/api/guest.rb +44 -0
  15. data/lib/kintone/api.rb +121 -0
  16. data/lib/kintone/command/accessor.rb +109 -0
  17. data/lib/kintone/command/apis.rb +22 -0
  18. data/lib/kintone/command/app.rb +11 -0
  19. data/lib/kintone/command/app_acl.rb +11 -0
  20. data/lib/kintone/command/apps.rb +12 -0
  21. data/lib/kintone/command/bulk_request.rb +12 -0
  22. data/lib/kintone/command/field_acl.rb +11 -0
  23. data/lib/kintone/command/file.rb +15 -0
  24. data/lib/kintone/command/form.rb +11 -0
  25. data/lib/kintone/command/guests.rb +17 -0
  26. data/lib/kintone/command/preview_form.rb +11 -0
  27. data/lib/kintone/command/record.rb +23 -0
  28. data/lib/kintone/command/record_acl.rb +11 -0
  29. data/lib/kintone/command/records.rb +29 -0
  30. data/lib/kintone/command/space.rb +15 -0
  31. data/lib/kintone/command/space_body.rb +11 -0
  32. data/lib/kintone/command/space_guests.rb +11 -0
  33. data/lib/kintone/command/space_members.rb +16 -0
  34. data/lib/kintone/command/space_thread.rb +14 -0
  35. data/lib/kintone/command/template_space.rb +12 -0
  36. data/lib/kintone/command.rb +12 -0
  37. data/lib/kintone/kintone_error.rb +12 -0
  38. data/lib/kintone/query/extension.rb +23 -0
  39. data/lib/kintone/query.rb +152 -0
  40. data/lib/kintone/type/extension/enumerable.rb +5 -0
  41. data/lib/kintone/type/extension/hash.rb +5 -0
  42. data/lib/kintone/type/extension/object.rb +5 -0
  43. data/lib/kintone/type/record.rb +11 -0
  44. data/lib/kintone/type.rb +6 -0
  45. data/lib/kintone/version.rb +3 -0
  46. data/lib/kintone_rb.rb +7 -0
  47. data/spec/kintone/api/guest_spec.rb +289 -0
  48. data/spec/kintone/api_spec.rb +566 -0
  49. data/spec/kintone/command/apis_spec.rb +179 -0
  50. data/spec/kintone/command/app_acl_spec.rb +43 -0
  51. data/spec/kintone/command/app_spec.rb +54 -0
  52. data/spec/kintone/command/apps_spec.rb +90 -0
  53. data/spec/kintone/command/bulk_request_spec.rb +92 -0
  54. data/spec/kintone/command/field_acl_spec.rb +47 -0
  55. data/spec/kintone/command/file_spec.rb +65 -0
  56. data/spec/kintone/command/form_spec.rb +47 -0
  57. data/spec/kintone/command/guests_spec.rb +107 -0
  58. data/spec/kintone/command/preview_form_spec.rb +30 -0
  59. data/spec/kintone/command/record_acl_spec.rb +48 -0
  60. data/spec/kintone/command/record_spec.rb +210 -0
  61. data/spec/kintone/command/records_spec.rb +463 -0
  62. data/spec/kintone/command/space_body_spec.rb +47 -0
  63. data/spec/kintone/command/space_guests_spec.rb +55 -0
  64. data/spec/kintone/command/space_members_spec.rb +117 -0
  65. data/spec/kintone/command/space_spec.rb +86 -0
  66. data/spec/kintone/command/space_thread_spec.rb +77 -0
  67. data/spec/kintone/command/template_space_spec.rb +59 -0
  68. data/spec/kintone/kintone_error_spec.rb +93 -0
  69. data/spec/kintone/query_spec.rb +506 -0
  70. data/spec/kintone/type/record_spec.rb +38 -0
  71. data/spec/spec_helper.rb +4 -0
  72. metadata +250 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8b8182c7791ee8596bf2bd0317ef11308369ed1f88e0958e8efc3bacecf20de3
4
+ data.tar.gz: 1f9add3df139ff19c6cc5a967994be3592a38d4a088829b1bcd34f8d0f065be4
5
+ SHA512:
6
+ metadata.gz: 7c07ecaba30e8038b956705bca54a4a6a33ab260ca2c3af720891d238eb4f68a5980fd6e492797c197773871230346ba95b89279fad43ac521d0f716766e9a1d
7
+ data.tar.gz: 502112ccc0c9e772e8827541939afbf87a30c5c3393be264b1f2492a34345ee64828ac14dfc293d1b35b14702de1325a0ff92c09cb8ab421e44c60aca14a548a
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ # Check for updates to GitHub Actions every weekday
7
+ interval: "daily"
@@ -0,0 +1,28 @@
1
+ name: Build
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+
8
+ jobs:
9
+ rspec:
10
+ runs-on: ubuntu-latest
11
+ env:
12
+ BUNDLE_JOBS: 4
13
+ BUNDLE_RETRY: 3
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ ruby: ["2.7", "3.0", "3.1"]
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+
27
+ - name: Run rspec
28
+ run: bundle exec rspec
data/.gitignore ADDED
@@ -0,0 +1,20 @@
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
+ .rbenv-gemsets
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ -c -f doc
data/.rubocop.yml ADDED
@@ -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
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ ## 1.0.0
2
+
3
+ - Drop support faraday v1
4
+ - Rename gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kintone.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Rikiya Kawakami
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,361 @@
1
+ # kintone_rb
2
+
3
+ A Ruby gem for communicating with the [kintone](https://kintone.cybozu.com/us/) REST API
4
+
5
+ forked from [jue58/kintone](https://github.com/jue58/kintone)
6
+
7
+ ## Requirements
8
+
9
+ - ruby 2.7.0 or later
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'kintone_rb', github: 'SonicGarden/kintone_rb'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ ```
22
+ $ bundle
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```ruby
28
+ require 'kintone_rb'
29
+
30
+ # Use password authentication
31
+ api = Kintone::Api.new("example.cybozu.com", "Administrator", "cybozu")
32
+
33
+ # Use token authentication
34
+ api = Kintone::Api.new("example.cybozu.com", "authtoken")
35
+ ```
36
+
37
+ ### Supported API
38
+ - [Record retrieval](#record_retrieval)
39
+ - [Record register](#record_register)
40
+ - [Record update](#record_update)
41
+ - [Record delete](#record_delete)
42
+ - [Bulk request](#bulk_request)
43
+ - [File](#file)
44
+ - [Permissions](#permissions)
45
+ - [Space management](#space_management)
46
+ - [Guests](#guests)
47
+ - [Application information](#application_information)
48
+ - [Form structure](#form_structure)
49
+ - [API information](#api_information)
50
+
51
+ ### <a name="record_retrieval"> Record retrieval
52
+
53
+ ```ruby
54
+ # Record retrieval(Assign by Record Number)
55
+ app = 8; id = 100
56
+ api.record.get(app, id) # => {"record" => {"record_id" => {"type" => "RECORD_NUMBER", "value" => "1"}}}
57
+
58
+ # Records retrieval(Assign by Conditions by Query Strings)
59
+ app = 8; fields = ["record_id", "created_time", "dropdown"]
60
+ 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"
61
+ api.records.get(app, query, fields) # => {"records" => [{...}, ...]}
62
+ ```
63
+
64
+ Query helper
65
+
66
+ ```ruby
67
+ query =
68
+ Kintone::Query.new do
69
+ field(:updated_time) > "2012-02-03T09:00:00+0900"
70
+ and!
71
+ field(:updated_time) < "2012-02-03T10:00:00+0900"
72
+ order_by(:record_id)
73
+ limit(10)
74
+ offset(20)
75
+ end
76
+ # or
77
+ query =
78
+ Kintone::Query.new do
79
+ f(:updated_time) > "2012-02-03T09:00:00+0900"
80
+ and!
81
+ f(:updated_time) < "2012-02-03T10:00:00+0900"
82
+ order_by(:record_id)
83
+ limit(10)
84
+ offset(20)
85
+ end
86
+ 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"
87
+ api.records.get(app, query, fields)
88
+
89
+ # Example
90
+ Kintone::Query.new do
91
+ field(:Created_datetime) >= last_month
92
+ and!
93
+ precede do
94
+ field(:text).like("Hello")
95
+ and!
96
+ field(:number) == 200
97
+ end
98
+ or!
99
+ precede do
100
+ field(:number) > 100
101
+ and!
102
+ field(:Created_by).in([login_user])
103
+ end
104
+ order_by(:record_id, :desc)
105
+ limit(10)
106
+ offset(20)
107
+ end
108
+ # => "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"
109
+ ```
110
+
111
+ operator symbol | query helper
112
+ --- | ---
113
+ = | field(:code) == other
114
+ != | field(:code) != other
115
+ &gt; | field(:code) > other
116
+ < | field(:code) < other
117
+ &gt;= | field(:code) >= other
118
+ <= | field(:code) <= other
119
+ in | field(:code).in(["A", "B"])
120
+ not in | field(:code).not_in(["A", "B"])
121
+ like | field(:code).like("Hello")
122
+ not like | field(:code).not_like("Hello")
123
+ and | and!
124
+ or | or!
125
+ () | precede do; end
126
+
127
+ function | query helper
128
+ --- | ---
129
+ LOGINUSER() | login_user
130
+ PRIMARY_ORGANIZATION() | primary_organization
131
+ NOW() | now
132
+ TODAY() | today
133
+ THIS_MONTH() | this_month
134
+ LAST_MONTH() | last_month
135
+ THIS_YEAR() | this_year
136
+
137
+ option | query helper
138
+ --- | ---
139
+ order by | order_by(:code, :asc or :desc)
140
+ limit | limit(20)
141
+ offset | offset(30)
142
+
143
+ ### <a name="record_register"> Record register
144
+
145
+ ```ruby
146
+ # Record register(single record)
147
+ # Use Hash
148
+ app = 7
149
+ record = {"number" => {"value" => "123456"}}
150
+ api.record.register(app, record) # => {"id" => "100", "revision" => "1"}
151
+
152
+ # Use Kintone::Type::Record
153
+ app = 7
154
+ record = Kintone::Type::Record.new(number: "123456")
155
+ api.record.register(app, record) # => {"id" => "100", "revision" => "1"}
156
+
157
+ # Records register(batch)
158
+ # Use Hash
159
+ app = 7
160
+ records = [
161
+ {"number" => {"value" => "123456"}},
162
+ {"number" => {"value" => "7890"}}
163
+ ]
164
+ api.records.register(app, records) # => {"ids" => ["100", "101"], "revisions" => ["1", "1"]}
165
+
166
+ # Use Kintone::Type::Record
167
+ app = 7
168
+ records = [
169
+ Kintone::Type::Record.new(number: "123456"),
170
+ Kintone::Type::Record.new(number: "7890")
171
+ ]
172
+ api.records.register(app, records) # => {"ids" => ["100", "101"], "revisions" => ["1", "1"]}
173
+ ```
174
+
175
+ ### <a name="record_update"> Record update
176
+
177
+ ```ruby
178
+ # Record update(single record)
179
+ # Use Hash
180
+ app = 4; id = 1
181
+ record = {"string_multi" => {"value" => "changed!"}}
182
+ api.record.update(app, id, record) # => {"revision" => "2"}
183
+
184
+ # Use Kintone::Type::Record
185
+ app = 4; id = 1
186
+ record = Kintone::Type::Record.new({string_multi: "changed!"})
187
+ api.record.update(app, id, record) # => {"revision" => "2"}
188
+
189
+ # With revision
190
+ api.record.update(app, id, record, revision: 1)
191
+
192
+ # Records update(batch)
193
+ # Use Hash
194
+ app = 4
195
+ records = [
196
+ {"id" => 1, "record" => {"string_multi" => {"value" => "abcdef"}}},
197
+ {"id" => 2, "record" => {"string_multi" => {"value" => "opqrstu"}}}
198
+ ]
199
+ api.records.update(app, records) # => {"records" => [{"id" => "1", "revision" => "2"}, {"id" => "2", "revision" => "2"}]}
200
+
201
+ # Use Kintone::Type::Record
202
+ app = 4
203
+ records = [
204
+ {id: 1, record: Kintone::Type::Record.new(string_multi: "abcdef")},
205
+ {id: 2, record: Kintone::Type::Record.new(string_multi: "opqrstu")}
206
+ ]
207
+ api.records.update(app, records) # => {"records" => [{"id" => "1", "revision" => "2"}, {"id" => "2", "revision" => "2"}]}
208
+
209
+ # with revision
210
+ records = [
211
+ {id: 1, revision: 1, record: Kintone::Type::Record.new(string_multi: "abcdef")},
212
+ {id: 2, revision: 1, record: Kintone::Type::Record.new(string_multi: "opqrstu")}
213
+ ]
214
+ api.records.update(app, records)
215
+ ```
216
+
217
+ ### <a name="record_delete"> Record delete
218
+
219
+ ```ruby
220
+ app = 8; ids = [100, 80]
221
+ api.records.delete(app, ids) # => {}
222
+
223
+ # With revision
224
+ revisions = [1, 1]
225
+ api.records.delete(app, ids, revisions: revisions)
226
+ ```
227
+
228
+ ### <a name="bulk_request"> Bulk request
229
+
230
+ ```ruby
231
+ requests = [{"method" => "POST", ...}, {"method" => "PUT", ...}]
232
+ api.bulk.request(requests) # => [...]
233
+ ```
234
+
235
+ ### <a name="file"> File
236
+
237
+ ```ruby
238
+ # File upload
239
+ file_key = api.file.register("/path/to/file", "text/plain", "file.txt")
240
+
241
+ # File download
242
+ file = api.file.get(file_key)
243
+ ```
244
+
245
+ ### <a name="permissions"> Permissions
246
+
247
+ ```ruby
248
+ # App
249
+ app = 1
250
+ rights = [{"entity" => {"type" => "USER", "code" => "user1"}, "appEditable" => true, ...}, ...]
251
+ api.app_acl.update(app, rights) # => {}
252
+
253
+ # Records
254
+ id = 1
255
+ rights = [{"filterCond" => "...", "entities" => [{"entity" => {...}, "viewable" => false, ...}, ...]}, ...]
256
+ api.record_acl.update(id, rights) # => {}
257
+
258
+ #Fields
259
+ id = 1
260
+ rights = [{"code" => "Single_line_text_0", "entities" => [{"entity" => {...}, "accesibility" => "WRITE"}, ...]}, ...]
261
+ api.field_acl.update(id, rights) # => {}
262
+ ```
263
+
264
+ ### <a name="space_management"> Space management
265
+
266
+ ```ruby
267
+ # Space information
268
+ id = 1
269
+ api.space.get(id) # => { "id" => "1", "name" => "space", "defaultThread" => "3", "isPrivate" => true, ...}
270
+
271
+ # Create space
272
+ id = 1; name = "sample space"
273
+ members = [{"entity" => {"type" => "USER", "code" => "user1"}, "isAdmin": true}, ...]
274
+ api.template_space.create(id, name, members, is_guest: true, fixed_member: false) # => {"id" => "1"}
275
+
276
+ # Space body update
277
+ id = 1; body = "<b>awesome space!</b>"
278
+ api.space_body.update(id, body) # => {}
279
+
280
+ # Space members
281
+ id = 1
282
+ members = api.space_members.get(id) # => {"members"=>[{"entity"=>{"type"=>"USER", "code"=> "user1"}, ...}, ...]}
283
+ members << {"entity" => {"type" => "GROUP", "code" => "group1"}}
284
+ members = api.space_members.update(id, members) # => {}
285
+
286
+ # Space thread update
287
+ id = 1; name = "thread name"
288
+ body = "<b>awesome thread!</b>"
289
+ api.space_thread.update(id, name: name, body: body) # => {}
290
+
291
+ # Space guests
292
+ id = 1
293
+ guests = ["hoge@example.com"]
294
+ api.guest(1).space_guests.update(id, guests) # => {}
295
+
296
+ # Space delete
297
+ id = 1
298
+ api.space.delete(id) # => {}
299
+ ```
300
+
301
+ ### <a name="guests"> Guests
302
+
303
+ ```ruby
304
+ # Add guest
305
+ guests = [{code: "hoge@example.com", password: "p@ssword", timezone: "Asia/Tokyo", name: "Tokyo, Saburo", ...}, ...]
306
+ api.guests.register(guests) # => {}
307
+
308
+ # delete guest
309
+ guests = ["hoge@example.com", "fuga@example.com"]
310
+ api.guests.delete(guests) # => {}
311
+ ```
312
+
313
+ ### <a name="application_information"> Application information
314
+
315
+ ```ruby
316
+ id = 4
317
+ api.app.get(id) # => {"appId" => "4", "code" => "", ...}
318
+
319
+ name = "test"; codes = ["FOO", "BAR"]
320
+ api.apps.get({ name: name, codes: codes }) # => { "apps" => [{...}, ...] }
321
+ ```
322
+
323
+ ### <a name="form_structure"> Form structure
324
+
325
+ ```ruby
326
+ app = 1
327
+ api.form.get(app) # => {"properties" => [{...}, ...]}
328
+
329
+ api.preview_form.get(app) # => {"properties" => [{...}, ...]}
330
+ ```
331
+
332
+ ### <a name="api_information"> API information
333
+
334
+ ```ruby
335
+ api.apis.get # => {"baseUrl" => "https://example.cybozu.com/k/v1/", "apis" => {"records/get" => {"link" => "apis/records/get.json"}}}
336
+
337
+ api.apis.get_details_of("apis/records/get.json") # => {"id" => "GetRecords", "baseUrl" => "https://example.cybozu.com/k/v1/", ...}
338
+
339
+ api.apis.get_details_of_key("records/get") # => {"id" => "GetRecords", "baseUrl" => "https://example.cybozu.com/k/v1/", ...}
340
+ ```
341
+
342
+ ### Other examples
343
+
344
+ ```ruby
345
+ # Format retrieval
346
+ url = api.get_url("form")
347
+ api.get(url, {"app" => 4}) # => {"properties" => [{...}, ...]}
348
+
349
+ # Batch record register
350
+ url = api.get_url("records")
351
+ body = {"app" => 7, "records" => [{...}, ...]}
352
+ api.post(url, body) # => {"ids" => ["100","101"]}
353
+ ```
354
+
355
+ ### Access to guest spaces
356
+
357
+ ```ruby
358
+ api.guest(1).record.get(8, 100)
359
+ ```
360
+
361
+ see also [kintone developers](http://developers.kintone.com/)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/kintone.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kintone/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'kintone_rb'
8
+ spec.version = Kintone::VERSION
9
+ spec.authors = ['aki77']
10
+ spec.email = ['akira@sonicgarden.jp']
11
+ spec.summary = 'kintone API client for Ruby.'
12
+ spec.description = 'kintone API client for Ruby.'
13
+ spec.homepage = 'https://github.com/SonicGarden/kintone_rb'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'faraday', '>=2.0.0'
22
+ spec.add_runtime_dependency 'faraday-multipart'
23
+
24
+ spec.add_development_dependency 'bundler'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rspec', '~> 3'
27
+ spec.add_development_dependency 'rubocop', '~> 0.44.1'
28
+ spec.add_development_dependency 'webmock', '~> 2.3'
29
+ spec.add_development_dependency 'rspec-parameterized', '~> 0.1.2'
30
+ end
@@ -0,0 +1,44 @@
1
+ require 'forwardable'
2
+ require 'kintone/api'
3
+ require 'kintone/command/accessor'
4
+
5
+ class Kintone::Api
6
+ class Guest
7
+ extend Forwardable
8
+
9
+ GUEST_PATH = '/k/guest/%s/v1/'.freeze
10
+ ACCESSIBLE_COMMAND = [
11
+ :record, :records, :form, :app_acl, :record_acl,
12
+ :field_acl, :space, :space_body, :space_thread, :space_members,
13
+ :space_guests, :app, :apps, :bulk_request, :bulk,
14
+ :file, :preview_form
15
+ ].freeze
16
+
17
+ def_delegators :@api, :get, :post, :put, :delete, :post_file
18
+
19
+ def initialize(space_id, api)
20
+ @api = api
21
+ @guest_path = GUEST_PATH % space_id.to_i
22
+ end
23
+
24
+ def get_url(command)
25
+ @guest_path + (COMMAND % command)
26
+ end
27
+
28
+ def method_missing(name, *args)
29
+ if ACCESSIBLE_COMMAND.include?(name)
30
+ CommandAccessor.send(name, self)
31
+ else
32
+ super
33
+ end
34
+ end
35
+
36
+ def respond_to_missing?(name, *args)
37
+ ACCESSIBLE_COMMAND.include?(name) || super
38
+ end
39
+
40
+ class CommandAccessor
41
+ extend Kintone::Command::Accessor
42
+ end
43
+ end
44
+ end