kintone 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +26 -0
- data/.travis.yml +4 -0
- data/Guardfile +10 -0
- data/README.md +35 -13
- data/Rakefile +9 -1
- data/kintone.gemspec +17 -14
- data/lib/kintone.rb +2 -2
- data/lib/kintone/api.rb +36 -22
- data/lib/kintone/api/guest.rb +16 -8
- data/lib/kintone/command.rb +11 -2
- data/lib/kintone/command/app_acl.rb +4 -8
- data/lib/kintone/command/field_acl.rb +4 -8
- data/lib/kintone/command/form.rb +4 -8
- data/lib/kintone/command/record.rb +6 -10
- data/lib/kintone/command/record_acl.rb +4 -8
- data/lib/kintone/command/records.rb +11 -15
- data/lib/kintone/command/space.rb +15 -0
- data/lib/kintone/command/space_body.rb +11 -0
- data/lib/kintone/command/template_space.rb +12 -0
- data/lib/kintone/version.rb +1 -1
- data/spec/kintone/api/guest_spec.rb +134 -0
- data/spec/kintone/api_spec.rb +176 -0
- data/spec/kintone/command/app_acl_spec.rb +28 -0
- data/spec/kintone/command/field_acl_spec.rb +28 -0
- data/spec/kintone/command/form_spec.rb +26 -0
- data/spec/kintone/command/record_acl_spec.rb +28 -0
- data/spec/kintone/command/record_spec.rb +93 -0
- data/spec/kintone/command/records_spec.rb +169 -0
- data/spec/kintone/command/space_body_spec.rb +28 -0
- data/spec/kintone/command/space_spec.rb +53 -0
- data/spec/kintone/command/template_space_spec.rb +41 -0
- metadata +75 -36
- data/spec/api/guest_spec.rb +0 -54
- data/spec/api_spec.rb +0 -148
- data/spec/command/app_acl_spec.rb +0 -28
- data/spec/command/field_acl_spec.rb +0 -28
- data/spec/command/form_spec.rb +0 -25
- data/spec/command/record_acl_spec.rb +0 -28
- data/spec/command/record_spec.rb +0 -92
- data/spec/command/records_spec.rb +0 -162
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24a441e5a7cd395f4b7e77d1ef6c8c5fc450ec57
|
4
|
+
data.tar.gz: d2c412b23b6685dde86ae1e68bee11897dc1f1ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e255c61c186000b3f8071555158bda3289b73e2bc4be110ca50403ac464bbbe1b86af3e6a0b302722f94f7568fe7cba4a8c4cf5734741359d86f38da0c4adf3
|
7
|
+
data.tar.gz: 8ff4d97a4355fc50a22080bee96331a7c0a662567faf5755abd79a1a59b7d4ad85395646aca1885b74eb5072891ecb38c5cf9f5415be0d35481df43fef1242da
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,26 @@
|
|
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
|
+
|
12
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
13
|
+
Style/ClassAndModuleChildren:
|
14
|
+
EnforcedStyle: compact
|
15
|
+
|
16
|
+
Style/Documentation:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
# Configuration parameters: AllowURI.
|
20
|
+
Style/LineLength:
|
21
|
+
Max: 1_00
|
22
|
+
|
23
|
+
# Cop supports --auto-correct.
|
24
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
25
|
+
Style/StringLiterals:
|
26
|
+
EnforcedStyle: single_quotes
|
data/.travis.yml
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
guard :rspec, all_after_pass: false, all_on_start: false do
|
2
|
+
watch(%r{spec/.+_spec\.rb$})
|
3
|
+
watch(%r{lib/(.+)\.rb$}) {|m| "spec/#{m[1]}_spec.rb"}
|
4
|
+
watch(%r{lib/(.+)/.+\.rb$}) {|m| "spec/#{m[1]}_spec.rb"}
|
5
|
+
end
|
6
|
+
|
7
|
+
guard :rubocop, all_on_start: false do
|
8
|
+
watch(%r{.+\.rb$})
|
9
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
10
|
+
end
|
data/README.md
CHANGED
@@ -18,14 +18,15 @@ api = Kintone::Api.new("example.cybozu.com", "Administrator", "cybozu")
|
|
18
18
|
```
|
19
19
|
|
20
20
|
### Supported API
|
21
|
-
- Record retrieval
|
22
|
-
- Record register
|
23
|
-
- Record update
|
24
|
-
- Record delete
|
25
|
-
- Format retrieval
|
26
|
-
- Permissions
|
21
|
+
- [Record retrieval](#record_retrieval)
|
22
|
+
- [Record register](#record_register)
|
23
|
+
- [Record update](#record_update)
|
24
|
+
- [Record delete](#record_delete)
|
25
|
+
- [Format retrieval](#format_retrieval)
|
26
|
+
- [Permissions](#permissions)
|
27
|
+
- [Space management]("space_management")
|
27
28
|
|
28
|
-
### Record retrieval
|
29
|
+
### <a name="record_retrieval"> Record retrieval
|
29
30
|
|
30
31
|
```ruby
|
31
32
|
# Record retrieval(Assign by Record Number)
|
@@ -38,7 +39,7 @@ query = "updated_time > \"2012-02-03T09:00:00+0900\" and updated_time < \"2012-0
|
|
38
39
|
api.records.get(app, query, fields) # => {"records" => [{...}, ...]}
|
39
40
|
```
|
40
41
|
|
41
|
-
### Record register
|
42
|
+
### <a name="record_register"> Record register
|
42
43
|
|
43
44
|
```ruby
|
44
45
|
# Record register(single record)
|
@@ -52,7 +53,7 @@ records = [{"number" => {"value" => "123456"}}, {"number" => {"value" => "7890"}
|
|
52
53
|
api.records.create(app, records) # => {"ids" => ["100", "101"]}
|
53
54
|
```
|
54
55
|
|
55
|
-
### Record update
|
56
|
+
### <a name="record_update"> Record update
|
56
57
|
|
57
58
|
```ruby
|
58
59
|
# Record update(single record)
|
@@ -66,21 +67,21 @@ records = [{"id" => 1, "string_multi" => {"value" => "abcdef"}}, {"id" => 2, "st
|
|
66
67
|
api.records.update(app, records) # => {}
|
67
68
|
```
|
68
69
|
|
69
|
-
### Record delete
|
70
|
+
### <a name="record_delete"> Record delete
|
70
71
|
|
71
72
|
```ruby
|
72
73
|
app = 8; ids = [100, 80]
|
73
74
|
api.records.delete(app, ids) # => {}
|
74
75
|
```
|
75
76
|
|
76
|
-
### Format retrieval
|
77
|
+
### <a name="format_retrieval"> Format retrieval
|
77
78
|
|
78
79
|
```ruby
|
79
80
|
app = 4
|
80
81
|
api.form.get(app) # => {"properties" => [{...}, ...]}
|
81
82
|
```
|
82
83
|
|
83
|
-
### Permissions
|
84
|
+
### <a name="permissions"> Permissions
|
84
85
|
|
85
86
|
```ruby
|
86
87
|
# App
|
@@ -99,6 +100,27 @@ rights = [{"code" => "Single_line_text_0", "entities" => [{"entity" => {...}, "a
|
|
99
100
|
api.field_acl.update(id, rights) # => {}
|
100
101
|
```
|
101
102
|
|
103
|
+
### <a name="space_management"> Space management
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
# Space information reference
|
107
|
+
id = 1
|
108
|
+
api.space.get(id) # => { "id" => "1", "name" => "space", "defaultThread" => "3", "isPrivate" => true, ...}
|
109
|
+
|
110
|
+
# Create space
|
111
|
+
id = 1; name = "sample space"
|
112
|
+
members = [{"entity" => {"type" => "USER", "code" => "user1"}, "isAdmin": true}, ...]
|
113
|
+
api.template_space.create(id, name, members, is_guest: true, fixed_member: false) # => {"id" => "1"}
|
114
|
+
|
115
|
+
# Space body update
|
116
|
+
id = 1; body = "<b>awesome space!</b>"
|
117
|
+
api.space_body.update(id, body) # => {}
|
118
|
+
|
119
|
+
# Space delete
|
120
|
+
id = 1
|
121
|
+
api.space.delete(id) # => {}
|
122
|
+
```
|
123
|
+
|
102
124
|
### Other examples
|
103
125
|
|
104
126
|
```ruby
|
@@ -118,4 +140,4 @@ api.post(url, body) # => {"ids" => ["100","101"]}
|
|
118
140
|
api.guest(1).record.get(8, 100)
|
119
141
|
```
|
120
142
|
|
121
|
-
see also [kintone developers](
|
143
|
+
see also [kintone developers](http://developers.kintone.com/)
|
data/Rakefile
CHANGED
data/kintone.gemspec
CHANGED
@@ -1,28 +1,31 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# rubocop:disable Style/RegexpLiteral
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'kintone/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'kintone'
|
8
9
|
spec.version = Kintone::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
10
|
+
spec.authors = ['Rikiya Kawakami']
|
11
|
+
spec.email = ['ricky.k.yang@gmail.com']
|
12
|
+
spec.summary = 'kintone API client for Ruby.'
|
13
|
+
spec.description = 'kintone API client for Ruby.'
|
14
|
+
spec.homepage = 'https://github.com/jue58/kintone'
|
15
|
+
spec.license = 'MIT'
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0")
|
17
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
20
|
+
spec.require_paths = ['lib']
|
20
21
|
|
21
|
-
spec.add_runtime_dependency 'faraday', '
|
22
|
-
spec.add_runtime_dependency 'faraday_middleware', '
|
22
|
+
spec.add_runtime_dependency 'faraday', '>=0.8.9'
|
23
|
+
spec.add_runtime_dependency 'faraday_middleware', '>=0.9.0'
|
23
24
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
26
|
+
spec.add_development_dependency 'rake'
|
27
|
+
spec.add_development_dependency 'rspec'
|
28
|
+
spec.add_development_dependency 'webmock'
|
29
|
+
spec.add_development_dependency 'guard-rspec'
|
30
|
+
spec.add_development_dependency 'guard-rubocop'
|
28
31
|
end
|
data/lib/kintone.rb
CHANGED
data/lib/kintone/api.rb
CHANGED
@@ -8,92 +8,106 @@ require 'kintone/command/form'
|
|
8
8
|
require 'kintone/command/app_acl'
|
9
9
|
require 'kintone/command/record_acl'
|
10
10
|
require 'kintone/command/field_acl'
|
11
|
+
require 'kintone/command/template_space'
|
12
|
+
require 'kintone/command/space'
|
13
|
+
require 'kintone/command/space_body'
|
11
14
|
require 'kintone/api/guest'
|
12
15
|
|
13
16
|
class Kintone::Api
|
14
|
-
BASE_PATH =
|
15
|
-
COMMAND =
|
17
|
+
BASE_PATH = '/k/v1/'
|
18
|
+
COMMAND = '%s.json'
|
16
19
|
|
17
20
|
def initialize(domain, user, password)
|
18
21
|
token = Base64.encode64("#{user}:#{password}")
|
19
22
|
@connection =
|
20
|
-
Faraday.new(:
|
21
|
-
:
|
22
|
-
:
|
23
|
+
Faraday.new(url: "https://#{domain}",
|
24
|
+
headers: { 'X-Cybozu-Authorization' => token },
|
25
|
+
ssl: false) do |builder|
|
23
26
|
builder.adapter :net_http
|
24
27
|
builder.request :url_encoded
|
25
28
|
builder.response :json
|
26
|
-
builder.response :logger
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
32
|
def get_url(command)
|
31
|
-
|
33
|
+
BASE_PATH + (COMMAND % command)
|
32
34
|
end
|
33
35
|
|
34
36
|
def guest(space_id)
|
35
|
-
|
37
|
+
Kintone::Api::Guest.new(space_id, self)
|
36
38
|
end
|
37
39
|
|
38
|
-
def get(url, params=nil)
|
40
|
+
def get(url, params = nil)
|
39
41
|
response =
|
40
42
|
@connection.get do |request|
|
41
43
|
request.url url
|
42
44
|
request.params = params
|
43
45
|
end
|
44
|
-
|
46
|
+
response.body
|
45
47
|
end
|
46
48
|
|
47
49
|
def post(url, body)
|
48
50
|
response =
|
49
51
|
@connection.post do |request|
|
50
52
|
request.url url
|
51
|
-
request.headers[
|
53
|
+
request.headers['Content-Type'] = 'application/json'
|
52
54
|
request.body = body.to_json
|
53
55
|
end
|
54
|
-
|
56
|
+
response.body
|
55
57
|
end
|
56
58
|
|
57
59
|
def put(url, body)
|
58
60
|
response =
|
59
61
|
@connection.put do |request|
|
60
62
|
request.url url
|
61
|
-
request.headers[
|
63
|
+
request.headers['Content-Type'] = 'application/json'
|
62
64
|
request.body = body.to_json
|
63
65
|
end
|
64
|
-
|
66
|
+
response.body
|
65
67
|
end
|
66
68
|
|
67
|
-
def delete(url, params=nil)
|
69
|
+
def delete(url, params = nil)
|
68
70
|
response =
|
69
71
|
@connection.delete do |request|
|
70
72
|
request.url url
|
71
73
|
request.params = params
|
72
74
|
end
|
73
|
-
|
75
|
+
response.body
|
74
76
|
end
|
75
77
|
|
76
78
|
def record
|
77
|
-
|
79
|
+
Kintone::Command::Record.new(self)
|
78
80
|
end
|
79
81
|
|
80
82
|
def records
|
81
|
-
|
83
|
+
Kintone::Command::Records.new(self)
|
82
84
|
end
|
83
85
|
|
84
86
|
def form
|
85
|
-
|
87
|
+
Kintone::Command::Form.new(self)
|
86
88
|
end
|
87
89
|
|
88
90
|
def app_acl
|
89
|
-
|
91
|
+
Kintone::Command::AppAcl.new(self)
|
90
92
|
end
|
91
93
|
|
92
94
|
def record_acl
|
93
|
-
|
95
|
+
Kintone::Command::RecordAcl.new(self)
|
94
96
|
end
|
95
97
|
|
96
98
|
def field_acl
|
97
|
-
|
99
|
+
Kintone::Command::FieldAcl.new(self)
|
100
|
+
end
|
101
|
+
|
102
|
+
def template_space
|
103
|
+
Kintone::Command::TemplateSpace.new(self)
|
104
|
+
end
|
105
|
+
|
106
|
+
def space
|
107
|
+
Kintone::Command::Space.new(self)
|
108
|
+
end
|
109
|
+
|
110
|
+
def space_body
|
111
|
+
Kintone::Command::SpaceBody.new(self)
|
98
112
|
end
|
99
113
|
end
|
data/lib/kintone/api/guest.rb
CHANGED
@@ -5,7 +5,7 @@ class Kintone::Api
|
|
5
5
|
class Guest
|
6
6
|
extend Forwardable
|
7
7
|
|
8
|
-
GUEST_PATH =
|
8
|
+
GUEST_PATH = '/k/guest/%s/v1/'
|
9
9
|
|
10
10
|
def initialize(space_id, api)
|
11
11
|
@api = api
|
@@ -13,31 +13,39 @@ class Kintone::Api
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def get_url(command)
|
16
|
-
|
16
|
+
@guest_path + (COMMAND % command)
|
17
17
|
end
|
18
18
|
|
19
19
|
def record
|
20
|
-
|
20
|
+
Kintone::Command::Record.new(self)
|
21
21
|
end
|
22
22
|
|
23
23
|
def records
|
24
|
-
|
24
|
+
Kintone::Command::Records.new(self)
|
25
25
|
end
|
26
26
|
|
27
27
|
def form
|
28
|
-
|
28
|
+
Kintone::Command::Form.new(self)
|
29
29
|
end
|
30
30
|
|
31
31
|
def app_acl
|
32
|
-
|
32
|
+
Kintone::Command::AppAcl.new(self)
|
33
33
|
end
|
34
34
|
|
35
35
|
def record_acl
|
36
|
-
|
36
|
+
Kintone::Command::RecordAcl.new(self)
|
37
37
|
end
|
38
38
|
|
39
39
|
def field_acl
|
40
|
-
|
40
|
+
Kintone::Command::FieldAcl.new(self)
|
41
|
+
end
|
42
|
+
|
43
|
+
def space
|
44
|
+
Kintone::Command::Space.new(self)
|
45
|
+
end
|
46
|
+
|
47
|
+
def space_body
|
48
|
+
Kintone::Command::SpaceBody.new(self)
|
41
49
|
end
|
42
50
|
|
43
51
|
def_delegators :@api, :get, :post, :put, :delete
|
data/lib/kintone/command.rb
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
require 'kintone/command'
|
2
|
-
require 'kintone/api'
|
3
2
|
|
4
|
-
class Kintone::Command::AppAcl
|
5
|
-
|
6
|
-
|
7
|
-
def initialize(api)
|
8
|
-
@api = api
|
9
|
-
@url = @api.get_url(PATH)
|
3
|
+
class Kintone::Command::AppAcl < Kintone::Command
|
4
|
+
def self.path
|
5
|
+
'app/acl'
|
10
6
|
end
|
11
7
|
|
12
8
|
def update(app, rights)
|
13
|
-
@api.put(@url,
|
9
|
+
@api.put(@url, app: app, rights: rights)
|
14
10
|
end
|
15
11
|
end
|