kintone 0.0.3 → 0.0.4
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/README.md +44 -26
- data/lib/kintone/api.rb +24 -9
- data/lib/kintone/api/guest.rb +12 -0
- data/lib/kintone/command/app_acl.rb +15 -0
- data/lib/kintone/command/field_acl.rb +15 -0
- data/lib/kintone/command/record_acl.rb +15 -0
- data/lib/kintone/version.rb +1 -1
- data/spec/api/guest_spec.rb +36 -0
- data/spec/api_spec.rb +18 -0
- data/spec/command/app_acl_spec.rb +28 -0
- data/spec/command/field_acl_spec.rb +28 -0
- data/spec/command/record_acl_spec.rb +28 -0
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 802b3540fa57136b666301320c4a78bb5254084f
|
4
|
+
data.tar.gz: 101a717cecfbd0c2f2db6793aeb37444a7b71379
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85af72a3f02848b43e58286fc938858f488bf750da800a69133839b0ad92f5ee8165321420060df870dd9dd83cde7eaf5810d0f364d6ec4d044fd229e099ed8e
|
7
|
+
data.tar.gz: 7c58ccadb6289b95ba65fdc27d34869e2c7c320eb8c2ecbfe33853e78a55cf1803fb6870598d54743bfe553c7e29ff2dd7d12a0281f7039313194aeff329161a
|
data/README.md
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
# kintone
|
2
2
|
|
3
|
-
|
3
|
+
A Ruby gem for communicating with the [kintone](https://kintone.cybozu.com/us/) REST API
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
gem install kintone
|
8
8
|
|
9
|
-
|
9
|
+
or execute `bundle install` command after you insert the following into Gemfile
|
10
10
|
|
11
11
|
gem 'kintone'
|
12
12
|
|
13
|
-
と書いて、`bundle install` コマンドを実行してください。
|
14
|
-
|
15
13
|
## Usage
|
16
14
|
|
17
15
|
```ruby
|
@@ -19,85 +17,105 @@ require 'kintone'
|
|
19
17
|
api = Kintone::Api.new("example.cybozu.com", "Administrator", "cybozu")
|
20
18
|
```
|
21
19
|
|
22
|
-
###
|
23
|
-
-
|
24
|
-
-
|
25
|
-
-
|
26
|
-
-
|
27
|
-
-
|
20
|
+
### Supported API
|
21
|
+
- Record retrieval
|
22
|
+
- Record register
|
23
|
+
- Record update
|
24
|
+
- Record delete
|
25
|
+
- Format retrieval
|
26
|
+
- Permissions
|
28
27
|
|
29
|
-
###
|
28
|
+
### Record retrieval
|
30
29
|
|
31
30
|
```ruby
|
32
|
-
#
|
31
|
+
# Record retrieval(Assign by Record Number)
|
33
32
|
app = 8; id = 100
|
34
33
|
api.record.get(app, id) # => {"record" => {"record_id" => {"type" => "RECORD_NUMBER", "value" => "1"}}}
|
35
34
|
|
36
|
-
#
|
35
|
+
# Records retrieval(Assign by Conditions by Query Strings)
|
37
36
|
app = 8; fields = ["record_id", "created_time", "dropdown"]
|
38
37
|
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"
|
39
38
|
api.records.get(app, query, fields) # => {"records" => [{...}, ...]}
|
40
39
|
```
|
41
40
|
|
42
|
-
###
|
41
|
+
### Record register
|
43
42
|
|
44
43
|
```ruby
|
45
|
-
#
|
44
|
+
# Record register(single record)
|
46
45
|
app = 7
|
47
46
|
record = {"number" => {"value" => "123456"}}
|
48
47
|
api.record.create(app, record) # => {"id" => "100"}
|
49
48
|
|
50
|
-
#
|
49
|
+
# Records register(batch)
|
51
50
|
app = 7
|
52
51
|
records = [{"number" => {"value" => "123456"}}, {"number" => {"value" => "7890"}}]
|
53
52
|
api.records.create(app, records) # => {"ids" => ["100", "101"]}
|
54
53
|
```
|
55
54
|
|
56
|
-
###
|
55
|
+
### Record update
|
57
56
|
|
58
57
|
```ruby
|
59
|
-
#
|
58
|
+
# Record update(single record)
|
60
59
|
app = 4; id = 1
|
61
60
|
record = {"string_multi" => {"value" => "changed!"}}
|
62
61
|
api.record.update(app, id, record) # => {}
|
63
62
|
|
64
|
-
#
|
63
|
+
# Records update(batch)
|
65
64
|
app = 4
|
66
65
|
records = [{"id" => 1, "string_multi" => {"value" => "abcdef"}}, {"id" => 2, "string_multi" => {"value" => "opqrstu"}}]
|
67
66
|
api.records.update(app, records) # => {}
|
68
67
|
```
|
69
68
|
|
70
|
-
###
|
69
|
+
### Record delete
|
71
70
|
|
72
71
|
```ruby
|
73
72
|
app = 8; ids = [100, 80]
|
74
73
|
api.records.delete(app, ids) # => {}
|
75
74
|
```
|
76
75
|
|
77
|
-
###
|
76
|
+
### Format retrieval
|
78
77
|
|
79
78
|
```ruby
|
80
79
|
app = 4
|
81
80
|
api.form.get(app) # => {"properties" => [{...}, ...]}
|
82
81
|
```
|
83
82
|
|
84
|
-
###
|
83
|
+
### Permissions
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
# App
|
87
|
+
app = 1
|
88
|
+
rights = [{"entity" => {"type" => "USER", "code" => "user1"}, "appEditable" => true, ...}, ...]
|
89
|
+
api.app_acl.update(app, rights) # => {}
|
90
|
+
|
91
|
+
# Records
|
92
|
+
id = 1
|
93
|
+
rights = [{"filterCond" => "...", "entities" => [{"entity" => {...}, "viewable" => false, ...}, ...]}, ...]
|
94
|
+
api.record_acl.update(id, rights) # => {}
|
95
|
+
|
96
|
+
#Fields
|
97
|
+
id = 1
|
98
|
+
rights = [{"code" => "Single_line_text_0", "entities" => [{"entity" => {...}, "accesibility" => "WRITE"}, ...]}, ...]
|
99
|
+
api.field_acl.update(id, rights) # => {}
|
100
|
+
```
|
101
|
+
|
102
|
+
### Other examples
|
85
103
|
|
86
104
|
```ruby
|
87
|
-
#
|
105
|
+
# Format retrieval
|
88
106
|
url = api.get_url("form")
|
89
107
|
api.get(url, {"app" => 4}) # => {"properties" => [{...}, ...]}
|
90
108
|
|
91
|
-
#
|
109
|
+
# Batch record register
|
92
110
|
url = api.get_url("records")
|
93
111
|
body = {"app" => 7, "records" => [{...}, ...]}
|
94
112
|
api.post(url, body) # => {"ids" => ["100","101"]}
|
95
113
|
```
|
96
114
|
|
97
|
-
###
|
115
|
+
### Access to guest spaces
|
98
116
|
|
99
117
|
```ruby
|
100
118
|
api.guest(1).record.get(8, 100)
|
101
119
|
```
|
102
120
|
|
103
|
-
|
121
|
+
see also [kintone developers](https://developers.kintone.com/)
|
data/lib/kintone/api.rb
CHANGED
@@ -5,6 +5,9 @@ require 'json'
|
|
5
5
|
require 'kintone/command/record'
|
6
6
|
require 'kintone/command/records'
|
7
7
|
require 'kintone/command/form'
|
8
|
+
require 'kintone/command/app_acl'
|
9
|
+
require 'kintone/command/record_acl'
|
10
|
+
require 'kintone/command/field_acl'
|
8
11
|
require 'kintone/api/guest'
|
9
12
|
|
10
13
|
class Kintone::Api
|
@@ -12,9 +15,11 @@ class Kintone::Api
|
|
12
15
|
COMMAND = "%s.json"
|
13
16
|
|
14
17
|
def initialize(domain, user, password)
|
15
|
-
|
18
|
+
token = Base64.encode64("#{user}:#{password}")
|
16
19
|
@connection =
|
17
|
-
Faraday.new(:url => "https://#{domain}",
|
20
|
+
Faraday.new(:url => "https://#{domain}",
|
21
|
+
:headers => {"X-Cybozu-Authorization" => token},
|
22
|
+
:ssl => false) do |builder|
|
18
23
|
builder.adapter :net_http
|
19
24
|
builder.request :url_encoded
|
20
25
|
builder.response :json
|
@@ -35,7 +40,6 @@ class Kintone::Api
|
|
35
40
|
@connection.get do |request|
|
36
41
|
request.url url
|
37
42
|
request.params = params
|
38
|
-
request.headers = {"X-Cybozu-Authorization" => @token}
|
39
43
|
end
|
40
44
|
return response.body
|
41
45
|
end
|
@@ -44,7 +48,7 @@ class Kintone::Api
|
|
44
48
|
response =
|
45
49
|
@connection.post do |request|
|
46
50
|
request.url url
|
47
|
-
request.headers
|
51
|
+
request.headers["Content-Type"] = "application/json"
|
48
52
|
request.body = body.to_json
|
49
53
|
end
|
50
54
|
return response.body
|
@@ -54,7 +58,7 @@ class Kintone::Api
|
|
54
58
|
response =
|
55
59
|
@connection.put do |request|
|
56
60
|
request.url url
|
57
|
-
request.headers
|
61
|
+
request.headers["Content-Type"] = "application/json"
|
58
62
|
request.body = body.to_json
|
59
63
|
end
|
60
64
|
return response.body
|
@@ -65,20 +69,31 @@ class Kintone::Api
|
|
65
69
|
@connection.delete do |request|
|
66
70
|
request.url url
|
67
71
|
request.params = params
|
68
|
-
request.headers = {"X-Cybozu-Authorization" => @token}
|
69
72
|
end
|
70
73
|
return response.body
|
71
74
|
end
|
72
75
|
|
73
76
|
def record
|
74
|
-
Kintone::Command::Record.new(self)
|
77
|
+
return Kintone::Command::Record.new(self)
|
75
78
|
end
|
76
79
|
|
77
80
|
def records
|
78
|
-
Kintone::Command::Records.new(self)
|
81
|
+
return Kintone::Command::Records.new(self)
|
79
82
|
end
|
80
83
|
|
81
84
|
def form
|
82
|
-
Kintone::Command::Form.new(self)
|
85
|
+
return Kintone::Command::Form.new(self)
|
86
|
+
end
|
87
|
+
|
88
|
+
def app_acl
|
89
|
+
return Kintone::Command::AppAcl.new(self)
|
90
|
+
end
|
91
|
+
|
92
|
+
def record_acl
|
93
|
+
return Kintone::Command::RecordAcl.new(self)
|
94
|
+
end
|
95
|
+
|
96
|
+
def field_acl
|
97
|
+
return Kintone::Command::FieldAcl.new(self)
|
83
98
|
end
|
84
99
|
end
|
data/lib/kintone/api/guest.rb
CHANGED
@@ -28,6 +28,18 @@ class Kintone::Api
|
|
28
28
|
return Kintone::Command::Form.new(self)
|
29
29
|
end
|
30
30
|
|
31
|
+
def app_acl
|
32
|
+
return Kintone::Command::AppAcl.new(self)
|
33
|
+
end
|
34
|
+
|
35
|
+
def record_acl
|
36
|
+
return Kintone::Command::RecordAcl.new(self)
|
37
|
+
end
|
38
|
+
|
39
|
+
def field_acl
|
40
|
+
return Kintone::Command::FieldAcl.new(self)
|
41
|
+
end
|
42
|
+
|
31
43
|
def_delegators :@api, :get, :post, :put, :delete
|
32
44
|
end
|
33
45
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'kintone/command'
|
2
|
+
require 'kintone/api'
|
3
|
+
|
4
|
+
class Kintone::Command::AppAcl
|
5
|
+
PATH = "app/acl"
|
6
|
+
|
7
|
+
def initialize(api)
|
8
|
+
@api = api
|
9
|
+
@url = @api.get_url(PATH)
|
10
|
+
end
|
11
|
+
|
12
|
+
def update(app, rights)
|
13
|
+
@api.put(@url, {:app => app, :rights => rights})
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'kintone/command'
|
2
|
+
require 'kintone/api'
|
3
|
+
|
4
|
+
class Kintone::Command::FieldAcl
|
5
|
+
PATH = "field/acl"
|
6
|
+
|
7
|
+
def initialize(api)
|
8
|
+
@api = api
|
9
|
+
@url = @api.get_url(PATH)
|
10
|
+
end
|
11
|
+
|
12
|
+
def update(id, rights)
|
13
|
+
@api.put(@url, {:id => id, :rights => rights})
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'kintone/command'
|
2
|
+
require 'kintone/api'
|
3
|
+
|
4
|
+
class Kintone::Command::RecordAcl
|
5
|
+
PATH = "record/acl"
|
6
|
+
|
7
|
+
def initialize(api)
|
8
|
+
@api = api
|
9
|
+
@url = @api.get_url(PATH)
|
10
|
+
end
|
11
|
+
|
12
|
+
def update(id, rights)
|
13
|
+
@api.put(@url, {:id => id, :rights => rights})
|
14
|
+
end
|
15
|
+
end
|
data/lib/kintone/version.rb
CHANGED
data/spec/api/guest_spec.rb
CHANGED
@@ -15,4 +15,40 @@ describe Kintone::Api::Guest do
|
|
15
15
|
it { expect(subject).to eq("/k/guest/1/v1/path.json") }
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
19
|
+
describe "#record" do
|
20
|
+
subject { target.record }
|
21
|
+
|
22
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::Record) }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#records" do
|
26
|
+
subject { target.records }
|
27
|
+
|
28
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::Records) }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#form" do
|
32
|
+
subject { target.form }
|
33
|
+
|
34
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::Form) }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#app_acl" do
|
38
|
+
subject { target.app_acl }
|
39
|
+
|
40
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::AppAcl) }
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#record_acl" do
|
44
|
+
subject { target.record_acl }
|
45
|
+
|
46
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::RecordAcl) }
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#field_acl" do
|
50
|
+
subject { target.field_acl }
|
51
|
+
|
52
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::FieldAcl) }
|
53
|
+
end
|
18
54
|
end
|
data/spec/api_spec.rb
CHANGED
@@ -127,4 +127,22 @@ describe Kintone::Api do
|
|
127
127
|
|
128
128
|
it { expect(subject).to be_a_kind_of(Kintone::Command::Form) }
|
129
129
|
end
|
130
|
+
|
131
|
+
describe "#app_acl" do
|
132
|
+
subject { target.app_acl }
|
133
|
+
|
134
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::AppAcl) }
|
135
|
+
end
|
136
|
+
|
137
|
+
describe "#record_acl" do
|
138
|
+
subject { target.record_acl }
|
139
|
+
|
140
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::RecordAcl) }
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "#field_acl" do
|
144
|
+
subject { target.field_acl }
|
145
|
+
|
146
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::FieldAcl) }
|
147
|
+
end
|
130
148
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'kintone/command/app_acl'
|
3
|
+
require 'kintone/api'
|
4
|
+
|
5
|
+
describe Kintone::Command::AppAcl do
|
6
|
+
let(:target) { Kintone::Command::AppAcl.new(api) }
|
7
|
+
let(:api) { Kintone::Api.new("example.cybozu.com", "Administrator", "cybozu") }
|
8
|
+
|
9
|
+
describe "#update" do
|
10
|
+
subject { target.update(app, rights) }
|
11
|
+
|
12
|
+
context "" do
|
13
|
+
before(:each) do
|
14
|
+
stub_request(
|
15
|
+
:put,
|
16
|
+
"https://example.cybozu.com/k/v1/app/acl.json"
|
17
|
+
).
|
18
|
+
with(:body => {"app" => 1, "rights" => {"p1" => "abc", "p2" => "def"}}.to_json).
|
19
|
+
to_return(:body => "{}", :status => 200)
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:app) { 1 }
|
23
|
+
let(:rights) { {"p1" => "abc", "p2" => "def"} }
|
24
|
+
|
25
|
+
it { expect(subject).to eq({}) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'kintone/command/field_acl'
|
3
|
+
require 'kintone/api'
|
4
|
+
|
5
|
+
describe Kintone::Command::FieldAcl do
|
6
|
+
let(:target) { Kintone::Command::FieldAcl.new(api) }
|
7
|
+
let(:api) { Kintone::Api.new("example.cybozu.com", "Administrator", "cybozu") }
|
8
|
+
|
9
|
+
describe "#update" do
|
10
|
+
subject { target.update(id, rights) }
|
11
|
+
|
12
|
+
context "" do
|
13
|
+
before(:each) do
|
14
|
+
stub_request(
|
15
|
+
:put,
|
16
|
+
"https://example.cybozu.com/k/v1/field/acl.json"
|
17
|
+
).
|
18
|
+
with(:body => {"id" => 1, "rights" => {"p1" => "abc", "p2" => "def"}}.to_json).
|
19
|
+
to_return(:body => "{}", :status => 200)
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:id) { 1 }
|
23
|
+
let(:rights) { {"p1" => "abc", "p2" => "def"} }
|
24
|
+
|
25
|
+
it { expect(subject).to eq({}) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'kintone/command/record_acl'
|
3
|
+
require 'kintone/api'
|
4
|
+
|
5
|
+
describe Kintone::Command::RecordAcl do
|
6
|
+
let(:target) { Kintone::Command::RecordAcl.new(api) }
|
7
|
+
let(:api) { Kintone::Api.new("example.cybozu.com", "Administrator", "cybozu") }
|
8
|
+
|
9
|
+
describe "#update" do
|
10
|
+
subject { target.update(id, rights) }
|
11
|
+
|
12
|
+
context "" do
|
13
|
+
before(:each) do
|
14
|
+
stub_request(
|
15
|
+
:put,
|
16
|
+
"https://example.cybozu.com/k/v1/record/acl.json"
|
17
|
+
).
|
18
|
+
with(:body => {"id" => 1, "rights" => {"p1" => "abc", "p2" => "def"}}.to_json).
|
19
|
+
to_return(:body => "{}", :status => 200)
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:id) { 1 }
|
23
|
+
let(:rights) { {"p1" => "abc", "p2" => "def"} }
|
24
|
+
|
25
|
+
it { expect(subject).to eq({}) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kintone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rikiya Kawakami
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -112,13 +112,19 @@ files:
|
|
112
112
|
- lib/kintone/api.rb
|
113
113
|
- lib/kintone/api/guest.rb
|
114
114
|
- lib/kintone/command.rb
|
115
|
+
- lib/kintone/command/app_acl.rb
|
116
|
+
- lib/kintone/command/field_acl.rb
|
115
117
|
- lib/kintone/command/form.rb
|
116
118
|
- lib/kintone/command/record.rb
|
119
|
+
- lib/kintone/command/record_acl.rb
|
117
120
|
- lib/kintone/command/records.rb
|
118
121
|
- lib/kintone/version.rb
|
119
122
|
- spec/api/guest_spec.rb
|
120
123
|
- spec/api_spec.rb
|
124
|
+
- spec/command/app_acl_spec.rb
|
125
|
+
- spec/command/field_acl_spec.rb
|
121
126
|
- spec/command/form_spec.rb
|
127
|
+
- spec/command/record_acl_spec.rb
|
122
128
|
- spec/command/record_spec.rb
|
123
129
|
- spec/command/records_spec.rb
|
124
130
|
- spec/spec_helper.rb
|
@@ -149,7 +155,10 @@ summary: kintone API client for Ruby.
|
|
149
155
|
test_files:
|
150
156
|
- spec/api/guest_spec.rb
|
151
157
|
- spec/api_spec.rb
|
158
|
+
- spec/command/app_acl_spec.rb
|
159
|
+
- spec/command/field_acl_spec.rb
|
152
160
|
- spec/command/form_spec.rb
|
161
|
+
- spec/command/record_acl_spec.rb
|
153
162
|
- spec/command/record_spec.rb
|
154
163
|
- spec/command/records_spec.rb
|
155
164
|
- spec/spec_helper.rb
|