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
@@ -1,15 +1,11 @@
|
|
1
1
|
require 'kintone/command'
|
2
|
-
require 'kintone/api'
|
3
2
|
|
4
|
-
class Kintone::Command::FieldAcl
|
5
|
-
|
6
|
-
|
7
|
-
def initialize(api)
|
8
|
-
@api = api
|
9
|
-
@url = @api.get_url(PATH)
|
3
|
+
class Kintone::Command::FieldAcl < Kintone::Command
|
4
|
+
def self.path
|
5
|
+
'field/acl'
|
10
6
|
end
|
11
7
|
|
12
8
|
def update(id, rights)
|
13
|
-
@api.put(@url,
|
9
|
+
@api.put(@url, id: id, rights: rights)
|
14
10
|
end
|
15
11
|
end
|
data/lib/kintone/command/form.rb
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
require 'kintone/command'
|
2
|
-
require 'kintone/api'
|
3
2
|
|
4
|
-
class Kintone::Command::Form
|
5
|
-
|
6
|
-
|
7
|
-
def initialize(api)
|
8
|
-
@api = api
|
9
|
-
@url = @api.get_url(PATH)
|
3
|
+
class Kintone::Command::Form < Kintone::Command
|
4
|
+
def self.path
|
5
|
+
'form'
|
10
6
|
end
|
11
7
|
|
12
8
|
def get(app)
|
13
|
-
@api.get(@url,
|
9
|
+
@api.get(@url, app: app)
|
14
10
|
end
|
15
11
|
end
|
@@ -1,23 +1,19 @@
|
|
1
1
|
require 'kintone/command'
|
2
|
-
require 'kintone/api'
|
3
2
|
|
4
|
-
class Kintone::Command::Record
|
5
|
-
|
6
|
-
|
7
|
-
def initialize(api)
|
8
|
-
@api = api
|
9
|
-
@url = @api.get_url(PATH)
|
3
|
+
class Kintone::Command::Record < Kintone::Command
|
4
|
+
def self.path
|
5
|
+
'record'
|
10
6
|
end
|
11
7
|
|
12
8
|
def get(app, id)
|
13
|
-
@api.get(@url,
|
9
|
+
@api.get(@url, app: app, id: id)
|
14
10
|
end
|
15
11
|
|
16
12
|
def create(app, record)
|
17
|
-
@api.post(@url,
|
13
|
+
@api.post(@url, app: app, record: record)
|
18
14
|
end
|
19
15
|
|
20
16
|
def update(app, id, record)
|
21
|
-
@api.put(@url,
|
17
|
+
@api.put(@url, app: app, id: id, record: record)
|
22
18
|
end
|
23
19
|
end
|
@@ -1,15 +1,11 @@
|
|
1
1
|
require 'kintone/command'
|
2
|
-
require 'kintone/api'
|
3
2
|
|
4
|
-
class Kintone::Command::RecordAcl
|
5
|
-
|
6
|
-
|
7
|
-
def initialize(api)
|
8
|
-
@api = api
|
9
|
-
@url = @api.get_url(PATH)
|
3
|
+
class Kintone::Command::RecordAcl < Kintone::Command
|
4
|
+
def self.path
|
5
|
+
'record/acl'
|
10
6
|
end
|
11
7
|
|
12
8
|
def update(id, rights)
|
13
|
-
@api.put(@url,
|
9
|
+
@api.put(@url, id: id, rights: rights)
|
14
10
|
end
|
15
11
|
end
|
@@ -1,31 +1,27 @@
|
|
1
1
|
require 'kintone/command'
|
2
|
-
require 'kintone/api'
|
3
2
|
|
4
|
-
class Kintone::Command::Records
|
5
|
-
|
6
|
-
|
7
|
-
def initialize(api)
|
8
|
-
@api = api
|
9
|
-
@url = @api.get_url(PATH)
|
3
|
+
class Kintone::Command::Records < Kintone::Command
|
4
|
+
def self.path
|
5
|
+
'records'
|
10
6
|
end
|
11
7
|
|
12
8
|
def get(app, query, fields)
|
13
|
-
params = {:
|
14
|
-
fields.each_with_index {|v, i| params["fields[#{i}]"] = v}
|
15
|
-
|
9
|
+
params = { app: app, query: query }
|
10
|
+
fields.each_with_index { |v, i| params["fields[#{i}]"] = v }
|
11
|
+
@api.get(@url, params)
|
16
12
|
end
|
17
13
|
|
18
14
|
def create(app, records)
|
19
|
-
|
15
|
+
@api.post(@url, app: app, records: records)
|
20
16
|
end
|
21
17
|
|
22
18
|
def update(app, records)
|
23
|
-
|
19
|
+
@api.put(@url, app: app, records: records)
|
24
20
|
end
|
25
21
|
|
26
22
|
def delete(app, ids)
|
27
|
-
params = {:app
|
28
|
-
ids.each_with_index {|v, i| params["ids[#{i}]"] = v}
|
29
|
-
|
23
|
+
params = { app: app }
|
24
|
+
ids.each_with_index { |v, i| params["ids[#{i}]"] = v }
|
25
|
+
@api.delete(@url, params)
|
30
26
|
end
|
31
27
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'kintone/command'
|
2
|
+
|
3
|
+
class Kintone::Command::TemplateSpace < Kintone::Command
|
4
|
+
def self.path
|
5
|
+
'template/space'
|
6
|
+
end
|
7
|
+
|
8
|
+
def create(id, name, members, is_guest: false, fixed_member: false)
|
9
|
+
body = { id: id, name: name, members: members, isGuest: is_guest, fixedMember: fixed_member }
|
10
|
+
@api.post(@url, body)
|
11
|
+
end
|
12
|
+
end
|
data/lib/kintone/version.rb
CHANGED
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'kintone/api/guest'
|
3
|
+
require 'kintone/api'
|
4
|
+
|
5
|
+
describe Kintone::Api::Guest do
|
6
|
+
let(:target) { Kintone::Api::Guest.new(space, api) }
|
7
|
+
let(:space) { 1 }
|
8
|
+
let(:api) { Kintone::Api.new('example.cybozu.com', 'Administrator', 'cybozu') }
|
9
|
+
|
10
|
+
describe '#get_url' do
|
11
|
+
subject { target.get_url(command) }
|
12
|
+
|
13
|
+
let(:command) { 'path' }
|
14
|
+
|
15
|
+
it { expect(subject).to eq('/k/guest/1/v1/path.json') }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#get' do
|
19
|
+
before(:each) do
|
20
|
+
stub_request(
|
21
|
+
:get,
|
22
|
+
'https://example.cybozu.com/k/guest/1/v1/path.json'
|
23
|
+
)
|
24
|
+
.with(
|
25
|
+
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' },
|
26
|
+
query: params
|
27
|
+
)
|
28
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200)
|
29
|
+
end
|
30
|
+
|
31
|
+
subject { target.get(path, params) }
|
32
|
+
|
33
|
+
let(:path) { '/k/guest/1/v1/path.json' }
|
34
|
+
let(:params) { { p1: 'abc', p2: 'def' } }
|
35
|
+
|
36
|
+
it { expect(subject).to eq 'abc' => 'def' }
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#post' do
|
40
|
+
before(:each) do
|
41
|
+
stub_request(
|
42
|
+
:post,
|
43
|
+
'https://example.cybozu.com/k/guest/1/v1/path.json'
|
44
|
+
)
|
45
|
+
.with(
|
46
|
+
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' },
|
47
|
+
body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
|
48
|
+
)
|
49
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200)
|
50
|
+
end
|
51
|
+
|
52
|
+
subject { target.post(path, body) }
|
53
|
+
|
54
|
+
let(:path) { '/k/guest/1/v1/path.json' }
|
55
|
+
let(:body) { { 'p1' => 'abc', 'p2' => 'def' } }
|
56
|
+
|
57
|
+
it { expect(subject).to eq 'abc' => 'def' }
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#put' do
|
61
|
+
before(:each) do
|
62
|
+
stub_request(
|
63
|
+
:put,
|
64
|
+
'https://example.cybozu.com/k/guest/1/v1/path.json'
|
65
|
+
)
|
66
|
+
.with(
|
67
|
+
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' },
|
68
|
+
body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
|
69
|
+
)
|
70
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200)
|
71
|
+
end
|
72
|
+
|
73
|
+
subject { target.put(path, body) }
|
74
|
+
|
75
|
+
let(:path) { '/k/guest/1/v1/path.json' }
|
76
|
+
let(:body) { { 'p1' => 'abc', 'p2' => 'def' } }
|
77
|
+
|
78
|
+
it { expect(subject).to eq 'abc' => 'def' }
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#delete' do
|
82
|
+
before(:each) do
|
83
|
+
stub_request(
|
84
|
+
:delete,
|
85
|
+
'https://example.cybozu.com/k/guest/1/v1/path.json?p1=abc&p2=def'
|
86
|
+
)
|
87
|
+
.with(headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' })
|
88
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200)
|
89
|
+
end
|
90
|
+
|
91
|
+
subject { target.delete(path, params) }
|
92
|
+
|
93
|
+
let(:path) { '/k/guest/1/v1/path.json' }
|
94
|
+
let(:params) { { 'p1' => 'abc', 'p2' => 'def' } }
|
95
|
+
|
96
|
+
it { expect(subject).to eq 'abc' => 'def' }
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#record' do
|
100
|
+
subject { target.record }
|
101
|
+
|
102
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::Record) }
|
103
|
+
end
|
104
|
+
|
105
|
+
describe '#records' do
|
106
|
+
subject { target.records }
|
107
|
+
|
108
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::Records) }
|
109
|
+
end
|
110
|
+
|
111
|
+
describe '#form' do
|
112
|
+
subject { target.form }
|
113
|
+
|
114
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::Form) }
|
115
|
+
end
|
116
|
+
|
117
|
+
describe '#app_acl' do
|
118
|
+
subject { target.app_acl }
|
119
|
+
|
120
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::AppAcl) }
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '#record_acl' do
|
124
|
+
subject { target.record_acl }
|
125
|
+
|
126
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::RecordAcl) }
|
127
|
+
end
|
128
|
+
|
129
|
+
describe '#field_acl' do
|
130
|
+
subject { target.field_acl }
|
131
|
+
|
132
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::FieldAcl) }
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'kintone/api'
|
3
|
+
require 'kintone/api/guest'
|
4
|
+
require 'kintone/command/record'
|
5
|
+
require 'kintone/command/records'
|
6
|
+
|
7
|
+
describe Kintone::Api do
|
8
|
+
let(:target) { Kintone::Api.new(domain, user, password) }
|
9
|
+
let(:domain) { 'www.example.com' }
|
10
|
+
let(:user) { 'Administrator' }
|
11
|
+
let(:password) { 'cybozu' }
|
12
|
+
|
13
|
+
describe '#get_url' do
|
14
|
+
subject { target.get_url(command) }
|
15
|
+
|
16
|
+
context '' do
|
17
|
+
let(:command) { 'path' }
|
18
|
+
it { expect(subject).to eq('/k/v1/path.json') }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#guest' do
|
23
|
+
subject { target.guest(space) }
|
24
|
+
|
25
|
+
context '引数が数値の1の時' do
|
26
|
+
let(:space) { 1 }
|
27
|
+
|
28
|
+
it { expect(subject).to be_a_kind_of(Kintone::Api::Guest) }
|
29
|
+
it { expect(subject.instance_variable_get(:@guest_path)).to eq('/k/guest/1/v1/') }
|
30
|
+
end
|
31
|
+
|
32
|
+
context '引数がnilの時' do
|
33
|
+
let(:space) { nil }
|
34
|
+
xit { expect(subject.instance_variable_get(:@guest_path)).to eq('/k/guest//v1/') }
|
35
|
+
end
|
36
|
+
|
37
|
+
context '引数に数字以外の文字が含まれる時' do
|
38
|
+
let(:space) { '2.1' }
|
39
|
+
xit { expect(subject.instance_variable_get(:@guest_path)).to eq('/k/guest//v1/') }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#get' do
|
44
|
+
before(:each) do
|
45
|
+
stub_request(
|
46
|
+
:get,
|
47
|
+
'https://www.example.com/k/v1/path?p1=abc&p2=def'
|
48
|
+
)
|
49
|
+
.with(headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' })
|
50
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200)
|
51
|
+
end
|
52
|
+
|
53
|
+
subject { target.get(path, params) }
|
54
|
+
let(:path) { '/k/v1/path' }
|
55
|
+
let(:params) { { 'p1' => 'abc', 'p2' => 'def' } }
|
56
|
+
|
57
|
+
it { expect(subject).to eq 'abc' => 'def' }
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#post' do
|
61
|
+
before(:each) do
|
62
|
+
stub_request(
|
63
|
+
:post,
|
64
|
+
'https://www.example.com/k/v1/path'
|
65
|
+
)
|
66
|
+
.with(
|
67
|
+
headers: {
|
68
|
+
'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=',
|
69
|
+
'Content-Type' => 'application/json'
|
70
|
+
},
|
71
|
+
body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
|
72
|
+
)
|
73
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200)
|
74
|
+
end
|
75
|
+
|
76
|
+
subject { target.post(path, body) }
|
77
|
+
let(:path) { '/k/v1/path' }
|
78
|
+
let(:body) { { 'p1' => 'abc', 'p2' => 'def' } }
|
79
|
+
|
80
|
+
it { expect(subject).to eq 'abc' => 'def' }
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#put' do
|
84
|
+
before(:each) do
|
85
|
+
stub_request(
|
86
|
+
:put,
|
87
|
+
'https://www.example.com/k/v1/path'
|
88
|
+
)
|
89
|
+
.with(
|
90
|
+
headers: {
|
91
|
+
'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=',
|
92
|
+
'Content-Type' => 'application/json'
|
93
|
+
},
|
94
|
+
body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
|
95
|
+
)
|
96
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200)
|
97
|
+
end
|
98
|
+
|
99
|
+
subject { target.put(path, body) }
|
100
|
+
let(:path) { '/k/v1/path' }
|
101
|
+
let(:body) { { 'p1' => 'abc', 'p2' => 'def' } }
|
102
|
+
|
103
|
+
it { expect(subject).to eq 'abc' => 'def' }
|
104
|
+
end
|
105
|
+
|
106
|
+
describe '#delete' do
|
107
|
+
before(:each) do
|
108
|
+
stub_request(
|
109
|
+
:delete,
|
110
|
+
'https://www.example.com/k/v1/path?p1=abc&p2=def'
|
111
|
+
)
|
112
|
+
.with(headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' })
|
113
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200)
|
114
|
+
end
|
115
|
+
|
116
|
+
subject { target.delete(path, params) }
|
117
|
+
let(:path) { '/k/v1/path' }
|
118
|
+
let(:params) { { 'p1' => 'abc', 'p2' => 'def' } }
|
119
|
+
|
120
|
+
it { expect(subject).to eq 'abc' => 'def' }
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '#record' do
|
124
|
+
subject { target.record }
|
125
|
+
|
126
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::Record) }
|
127
|
+
end
|
128
|
+
|
129
|
+
describe '#records' do
|
130
|
+
subject { target.records }
|
131
|
+
|
132
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::Records) }
|
133
|
+
end
|
134
|
+
|
135
|
+
describe '#form' do
|
136
|
+
subject { target.form }
|
137
|
+
|
138
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::Form) }
|
139
|
+
end
|
140
|
+
|
141
|
+
describe '#app_acl' do
|
142
|
+
subject { target.app_acl }
|
143
|
+
|
144
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::AppAcl) }
|
145
|
+
end
|
146
|
+
|
147
|
+
describe '#record_acl' do
|
148
|
+
subject { target.record_acl }
|
149
|
+
|
150
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::RecordAcl) }
|
151
|
+
end
|
152
|
+
|
153
|
+
describe '#field_acl' do
|
154
|
+
subject { target.field_acl }
|
155
|
+
|
156
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::FieldAcl) }
|
157
|
+
end
|
158
|
+
|
159
|
+
describe '#template_space' do
|
160
|
+
subject { target.template_space }
|
161
|
+
|
162
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::TemplateSpace) }
|
163
|
+
end
|
164
|
+
|
165
|
+
describe '#space' do
|
166
|
+
subject { target.space }
|
167
|
+
|
168
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::Space) }
|
169
|
+
end
|
170
|
+
|
171
|
+
describe '#space_body' do
|
172
|
+
subject { target.space_body }
|
173
|
+
|
174
|
+
it { expect(subject).to be_a_kind_of(Kintone::Command::SpaceBody) }
|
175
|
+
end
|
176
|
+
end
|