kintone 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/kintone/api.rb +12 -5
- data/lib/kintone/version.rb +1 -1
- data/spec/kintone/api_spec.rb +333 -199
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b117f1c781845b8712805c6ede66ed44d8b44382
|
4
|
+
data.tar.gz: 2f3151d4228579e118fec2564f55f93b1eef955b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd4fb7e33d330c4922c26b16449cd4ea5ef3998c2eda3376f127fafffcefb5193604f9cce5c381f0e86b239b859f1fe23979827c053edcf1f70cdeda8144f232
|
7
|
+
data.tar.gz: 34b39834c77beddbd95b4ebeff58483663210185a781f1c5e72a2a7213ddb9b67fe66e6a43dd047405f4eb2b23563c7f0a145e33bac209b63cf56ad4c54dd865
|
data/README.md
CHANGED
@@ -20,7 +20,12 @@ or execute `bundle install` command after you insert the following into Gemfile
|
|
20
20
|
|
21
21
|
```ruby
|
22
22
|
require 'kintone'
|
23
|
+
|
24
|
+
# Use password authentication
|
23
25
|
api = Kintone::Api.new("example.cybozu.com", "Administrator", "cybozu")
|
26
|
+
|
27
|
+
# Use token authentication
|
28
|
+
api = Kintone::Api.new("example.cybozu.com", "authtoken")
|
24
29
|
```
|
25
30
|
|
26
31
|
### Supported API
|
data/lib/kintone/api.rb
CHANGED
@@ -30,12 +30,9 @@ class Kintone::Api
|
|
30
30
|
:file
|
31
31
|
].freeze
|
32
32
|
|
33
|
-
def initialize(domain, user, password)
|
34
|
-
token = Base64.encode64("#{user}:#{password}")
|
35
|
-
url = "https://#{domain}"
|
36
|
-
headers = { 'X-Cybozu-Authorization' => token }
|
33
|
+
def initialize(domain, user, password = nil)
|
37
34
|
@connection =
|
38
|
-
Faraday.new(url:
|
35
|
+
Faraday.new(url: "https://#{domain}", headers: build_headers(user, password)) do |builder|
|
39
36
|
builder.request :url_encoded
|
40
37
|
builder.request :multipart
|
41
38
|
builder.response :json, content_type: /\bjson$/
|
@@ -113,4 +110,14 @@ class Kintone::Api
|
|
113
110
|
class CommandAccessor
|
114
111
|
extend Kintone::Command::Accessor
|
115
112
|
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def build_headers(user, password)
|
117
|
+
if password # パスワード認証
|
118
|
+
{ 'X-Cybozu-Authorization' => Base64.encode64("#{user}:#{password}") }
|
119
|
+
else # APIトークン認証
|
120
|
+
{ 'X-Cybozu-API-Token' => user }
|
121
|
+
end
|
122
|
+
end
|
116
123
|
end
|
data/lib/kintone/version.rb
CHANGED
data/spec/kintone/api_spec.rb
CHANGED
@@ -7,287 +7,421 @@ require 'kintone/command/records'
|
|
7
7
|
describe Kintone::Api do
|
8
8
|
let(:target) { Kintone::Api.new(domain, user, password) }
|
9
9
|
let(:domain) { 'www.example.com' }
|
10
|
-
let(:user) { 'Administrator' }
|
11
|
-
let(:password) { 'cybozu' }
|
12
10
|
|
13
|
-
|
14
|
-
|
11
|
+
context 'ユーザー認証の時' do
|
12
|
+
let(:user) { 'Administrator' }
|
13
|
+
let(:password) { 'cybozu' }
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
describe '#get_url' do
|
16
|
+
subject { target.get_url(command) }
|
17
|
+
|
18
|
+
context '' do
|
19
|
+
let(:command) { 'path' }
|
20
|
+
it { is_expected.to eq('/k/v1/path.json') }
|
21
|
+
end
|
19
22
|
end
|
20
|
-
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
describe '#guest' do
|
25
|
+
subject { target.guest(space) }
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
+
context '引数が数値の1の時' do
|
28
|
+
let(:space) { 1 }
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
it { is_expected.to be_a_kind_of(Kintone::Api::Guest) }
|
31
|
+
it { expect(subject.instance_variable_get(:@guest_path)).to eq('/k/guest/1/v1/') }
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
context '引数がnilの時' do
|
35
|
+
let(:space) { nil }
|
36
|
+
xit { expect(subject.instance_variable_get(:@guest_path)).to eq('/k/guest//v1/') }
|
37
|
+
end
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
context '引数に数字以外の文字が含まれる時' do
|
40
|
+
let(:space) { '2.1' }
|
41
|
+
xit { expect(subject.instance_variable_get(:@guest_path)).to eq('/k/guest//v1/') }
|
42
|
+
end
|
40
43
|
end
|
41
|
-
end
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
)
|
49
|
-
.with(
|
50
|
-
query: query,
|
51
|
-
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }
|
45
|
+
describe '#get' do
|
46
|
+
before(:each) do
|
47
|
+
stub_request(
|
48
|
+
:get,
|
49
|
+
'https://www.example.com/k/v1/path'
|
52
50
|
)
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
.with(
|
52
|
+
query: query,
|
53
|
+
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }
|
54
|
+
)
|
55
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200,
|
56
|
+
headers: { 'Content-type' => 'application/json' })
|
57
|
+
end
|
56
58
|
|
57
|
-
|
59
|
+
subject { target.get(path, params) }
|
58
60
|
|
59
|
-
|
61
|
+
let(:path) { '/k/v1/path' }
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
63
|
+
context 'with some params' do
|
64
|
+
let(:params) { { 'p1' => 'abc', 'p2' => 'def' } }
|
65
|
+
let(:query) { 'p1=abc&p2=def' }
|
64
66
|
|
65
|
-
|
67
|
+
it { is_expected.to eq 'abc' => 'def' }
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'with empty params' do
|
71
|
+
let(:params) { {} }
|
72
|
+
let(:query) { nil }
|
73
|
+
|
74
|
+
it { is_expected.to eq 'abc' => 'def' }
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'with nil' do
|
78
|
+
let(:params) { nil }
|
79
|
+
let(:query) { nil }
|
80
|
+
|
81
|
+
it { expect { subject }.to raise_error NoMethodError }
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'with no params' do
|
85
|
+
subject { target.get(path) }
|
86
|
+
|
87
|
+
let(:query) { nil }
|
88
|
+
|
89
|
+
it { is_expected.to eq 'abc' => 'def' }
|
90
|
+
end
|
66
91
|
end
|
67
92
|
|
68
|
-
|
69
|
-
|
70
|
-
|
93
|
+
describe '#post' do
|
94
|
+
before(:each) do
|
95
|
+
stub_request(
|
96
|
+
:post,
|
97
|
+
'https://www.example.com/k/v1/path'
|
98
|
+
)
|
99
|
+
.with(
|
100
|
+
headers: {
|
101
|
+
'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=',
|
102
|
+
'Content-Type' => 'application/json'
|
103
|
+
},
|
104
|
+
body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
|
105
|
+
)
|
106
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200,
|
107
|
+
headers: { 'Content-type' => 'application/json' })
|
108
|
+
end
|
109
|
+
|
110
|
+
subject { target.post(path, body) }
|
111
|
+
let(:path) { '/k/v1/path' }
|
112
|
+
let(:body) { { 'p1' => 'abc', 'p2' => 'def' } }
|
71
113
|
|
72
114
|
it { is_expected.to eq 'abc' => 'def' }
|
73
115
|
end
|
74
116
|
|
75
|
-
|
76
|
-
|
77
|
-
|
117
|
+
describe '#put' do
|
118
|
+
before(:each) do
|
119
|
+
stub_request(
|
120
|
+
:put,
|
121
|
+
'https://www.example.com/k/v1/path'
|
122
|
+
)
|
123
|
+
.with(
|
124
|
+
headers: {
|
125
|
+
'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=',
|
126
|
+
'Content-Type' => 'application/json'
|
127
|
+
},
|
128
|
+
body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
|
129
|
+
)
|
130
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200,
|
131
|
+
headers: { 'Content-type' => 'application/json' })
|
132
|
+
end
|
78
133
|
|
79
|
-
|
134
|
+
subject { target.put(path, body) }
|
135
|
+
let(:path) { '/k/v1/path' }
|
136
|
+
let(:body) { { 'p1' => 'abc', 'p2' => 'def' } }
|
137
|
+
|
138
|
+
it { is_expected.to eq 'abc' => 'def' }
|
80
139
|
end
|
81
140
|
|
82
|
-
|
83
|
-
|
141
|
+
describe '#delete' do
|
142
|
+
before(:each) do
|
143
|
+
stub_request(
|
144
|
+
:delete,
|
145
|
+
'https://www.example.com/k/v1/path'
|
146
|
+
)
|
147
|
+
.with(
|
148
|
+
body: { 'p1' => 'abc', 'p2' => 'def' }.to_json,
|
149
|
+
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }
|
150
|
+
)
|
151
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200,
|
152
|
+
headers: { 'Content-type' => 'application/json' })
|
153
|
+
end
|
84
154
|
|
85
|
-
|
155
|
+
subject { target.delete(path, params) }
|
156
|
+
let(:path) { '/k/v1/path' }
|
157
|
+
let(:params) { { 'p1' => 'abc', 'p2' => 'def' } }
|
86
158
|
|
87
159
|
it { is_expected.to eq 'abc' => 'def' }
|
88
160
|
end
|
89
|
-
end
|
90
161
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
)
|
97
|
-
.with(
|
98
|
-
headers: {
|
99
|
-
'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=',
|
100
|
-
'Content-Type' => 'application/json'
|
101
|
-
},
|
102
|
-
body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
|
162
|
+
describe '#post_file' do
|
163
|
+
before(:each) do
|
164
|
+
stub_request(
|
165
|
+
:post,
|
166
|
+
'https://www.example.com/k/v1/path'
|
103
167
|
)
|
104
|
-
|
105
|
-
|
168
|
+
.with(headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }) do
|
169
|
+
attachment
|
170
|
+
end
|
171
|
+
.to_return(body: "{\"fileKey\":\"abc\"}", status: 200,
|
172
|
+
headers: { 'Content-type' => 'application/json' })
|
173
|
+
|
174
|
+
expect(Faraday::UploadIO).to receive(:new)
|
175
|
+
.with(path, content_type, original_filename,
|
176
|
+
'Content-Disposition' => 'form-data')
|
177
|
+
.and_return(attachment)
|
178
|
+
end
|
179
|
+
|
180
|
+
subject { target.post_file(url, path, content_type, original_filename) }
|
181
|
+
let(:attachment) { double('attachment') }
|
182
|
+
let(:url) { '/k/v1/path' }
|
183
|
+
let(:path) { '/path/to/file.txt' }
|
184
|
+
let(:content_type) { 'text/plain' }
|
185
|
+
let(:original_filename) { 'fileName.txt' }
|
186
|
+
|
187
|
+
it { is_expected.to eq 'abc' }
|
106
188
|
end
|
107
189
|
|
108
|
-
|
109
|
-
|
110
|
-
let(:body) { { 'p1' => 'abc', 'p2' => 'def' } }
|
190
|
+
describe '#record' do
|
191
|
+
subject { target.record }
|
111
192
|
|
112
|
-
|
113
|
-
|
193
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::Record) }
|
194
|
+
end
|
114
195
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
'https://www.example.com/k/v1/path'
|
120
|
-
)
|
121
|
-
.with(
|
122
|
-
headers: {
|
123
|
-
'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=',
|
124
|
-
'Content-Type' => 'application/json'
|
125
|
-
},
|
126
|
-
body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
|
127
|
-
)
|
128
|
-
.to_return(body: "{\"abc\":\"def\"}", status: 200,
|
129
|
-
headers: { 'Content-type' => 'application/json' })
|
196
|
+
describe '#records' do
|
197
|
+
subject { target.records }
|
198
|
+
|
199
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::Records) }
|
130
200
|
end
|
131
201
|
|
132
|
-
|
133
|
-
|
134
|
-
let(:body) { { 'p1' => 'abc', 'p2' => 'def' } }
|
202
|
+
describe '#form' do
|
203
|
+
subject { target.form }
|
135
204
|
|
136
|
-
|
137
|
-
|
205
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::Form) }
|
206
|
+
end
|
138
207
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
'https://www.example.com/k/v1/path'
|
144
|
-
)
|
145
|
-
.with(
|
146
|
-
body: { 'p1' => 'abc', 'p2' => 'def' }.to_json,
|
147
|
-
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }
|
148
|
-
)
|
149
|
-
.to_return(body: "{\"abc\":\"def\"}", status: 200,
|
150
|
-
headers: { 'Content-type' => 'application/json' })
|
208
|
+
describe '#app_acl' do
|
209
|
+
subject { target.app_acl }
|
210
|
+
|
211
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::AppAcl) }
|
151
212
|
end
|
152
213
|
|
153
|
-
|
154
|
-
|
155
|
-
let(:params) { { 'p1' => 'abc', 'p2' => 'def' } }
|
214
|
+
describe '#record_acl' do
|
215
|
+
subject { target.record_acl }
|
156
216
|
|
157
|
-
|
158
|
-
|
217
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::RecordAcl) }
|
218
|
+
end
|
159
219
|
|
160
|
-
|
161
|
-
|
162
|
-
stub_request(
|
163
|
-
:post,
|
164
|
-
'https://www.example.com/k/v1/path'
|
165
|
-
)
|
166
|
-
.with { attachment }
|
167
|
-
.to_return(body: "{\"fileKey\":\"abc\"}", status: 200,
|
168
|
-
headers: { 'Content-type' => 'application/json' })
|
220
|
+
describe '#field_acl' do
|
221
|
+
subject { target.field_acl }
|
169
222
|
|
170
|
-
|
171
|
-
.with(path, content_type, original_filename,
|
172
|
-
'Content-Disposition' => 'form-data')
|
173
|
-
.and_return(attachment)
|
223
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::FieldAcl) }
|
174
224
|
end
|
175
225
|
|
176
|
-
|
177
|
-
|
178
|
-
let(:url) { '/k/v1/path' }
|
179
|
-
let(:path) { '/path/to/file.txt' }
|
180
|
-
let(:content_type) { 'text/plain' }
|
181
|
-
let(:original_filename) { 'fileName.txt' }
|
226
|
+
describe '#template_space' do
|
227
|
+
subject { target.template_space }
|
182
228
|
|
183
|
-
|
184
|
-
|
229
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::TemplateSpace) }
|
230
|
+
end
|
185
231
|
|
186
|
-
|
187
|
-
|
232
|
+
describe '#space' do
|
233
|
+
subject { target.space }
|
188
234
|
|
189
|
-
|
190
|
-
|
235
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::Space) }
|
236
|
+
end
|
191
237
|
|
192
|
-
|
193
|
-
|
238
|
+
describe '#space_body' do
|
239
|
+
subject { target.space_body }
|
194
240
|
|
195
|
-
|
196
|
-
|
241
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::SpaceBody) }
|
242
|
+
end
|
197
243
|
|
198
|
-
|
199
|
-
|
244
|
+
describe '#space_thread' do
|
245
|
+
subject { target.space_thread }
|
200
246
|
|
201
|
-
|
202
|
-
|
247
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::SpaceThread) }
|
248
|
+
end
|
203
249
|
|
204
|
-
|
205
|
-
|
250
|
+
describe '#space_members' do
|
251
|
+
subject { target.space_members }
|
206
252
|
|
207
|
-
|
208
|
-
|
253
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::SpaceMembers) }
|
254
|
+
end
|
209
255
|
|
210
|
-
|
211
|
-
|
256
|
+
describe '#guests' do
|
257
|
+
subject { target.guests }
|
212
258
|
|
213
|
-
|
214
|
-
|
259
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::Guests) }
|
260
|
+
end
|
215
261
|
|
216
|
-
|
217
|
-
|
262
|
+
describe '#app' do
|
263
|
+
subject { target.app }
|
218
264
|
|
219
|
-
|
220
|
-
|
265
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::App) }
|
266
|
+
end
|
221
267
|
|
222
|
-
|
223
|
-
|
268
|
+
describe '#apps' do
|
269
|
+
subject { target.apps }
|
224
270
|
|
225
|
-
|
226
|
-
|
271
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::Apps) }
|
272
|
+
end
|
227
273
|
|
228
|
-
|
229
|
-
|
274
|
+
describe '#apis' do
|
275
|
+
subject { target.apis }
|
230
276
|
|
231
|
-
|
232
|
-
|
277
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::Apis) }
|
278
|
+
end
|
233
279
|
|
234
|
-
|
235
|
-
|
280
|
+
describe '#bulk_request' do
|
281
|
+
subject { target.bulk_request }
|
236
282
|
|
237
|
-
|
238
|
-
|
283
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::BulkRequest) }
|
284
|
+
end
|
239
285
|
|
240
|
-
|
241
|
-
|
286
|
+
describe '#bulk' do
|
287
|
+
subject { target.bulk }
|
242
288
|
|
243
|
-
|
244
|
-
|
289
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::BulkRequest) }
|
290
|
+
end
|
245
291
|
|
246
|
-
|
247
|
-
|
292
|
+
describe '#file' do
|
293
|
+
subject { target.file }
|
248
294
|
|
249
|
-
|
295
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::File) }
|
296
|
+
end
|
250
297
|
end
|
251
298
|
|
252
|
-
|
253
|
-
|
299
|
+
context 'APIトークン認証の時' do
|
300
|
+
let(:user) { 'token-api' }
|
301
|
+
let(:password) { nil }
|
254
302
|
|
255
|
-
|
256
|
-
|
303
|
+
describe '#get' do
|
304
|
+
before(:each) do
|
305
|
+
stub_request(
|
306
|
+
:get,
|
307
|
+
'https://www.example.com/k/v1/path'
|
308
|
+
)
|
309
|
+
.with(
|
310
|
+
query: query,
|
311
|
+
headers: { 'X-Cybozu-API-Token' => 'token-api' }
|
312
|
+
)
|
313
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200,
|
314
|
+
headers: { 'Content-type' => 'application/json' })
|
315
|
+
end
|
257
316
|
|
258
|
-
|
259
|
-
subject { target.app }
|
317
|
+
subject { target.get(path, params) }
|
260
318
|
|
261
|
-
|
262
|
-
end
|
319
|
+
let(:path) { '/k/v1/path' }
|
263
320
|
|
264
|
-
|
265
|
-
|
321
|
+
context 'with no params' do
|
322
|
+
subject { target.get(path) }
|
266
323
|
|
267
|
-
|
268
|
-
end
|
324
|
+
let(:query) { nil }
|
269
325
|
|
270
|
-
|
271
|
-
|
326
|
+
it { is_expected.to eq 'abc' => 'def' }
|
327
|
+
end
|
328
|
+
end
|
272
329
|
|
273
|
-
|
274
|
-
|
330
|
+
describe '#post' do
|
331
|
+
before(:each) do
|
332
|
+
stub_request(
|
333
|
+
:post,
|
334
|
+
'https://www.example.com/k/v1/path'
|
335
|
+
)
|
336
|
+
.with(
|
337
|
+
headers: {
|
338
|
+
'X-Cybozu-API-Token' => 'token-api',
|
339
|
+
'Content-Type' => 'application/json'
|
340
|
+
},
|
341
|
+
body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
|
342
|
+
)
|
343
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200,
|
344
|
+
headers: { 'Content-type' => 'application/json' })
|
345
|
+
end
|
346
|
+
|
347
|
+
subject { target.post(path, body) }
|
348
|
+
let(:path) { '/k/v1/path' }
|
349
|
+
let(:body) { { 'p1' => 'abc', 'p2' => 'def' } }
|
275
350
|
|
276
|
-
|
277
|
-
|
351
|
+
it { is_expected.to eq 'abc' => 'def' }
|
352
|
+
end
|
278
353
|
|
279
|
-
|
280
|
-
|
354
|
+
describe '#put' do
|
355
|
+
before(:each) do
|
356
|
+
stub_request(
|
357
|
+
:put,
|
358
|
+
'https://www.example.com/k/v1/path'
|
359
|
+
)
|
360
|
+
.with(
|
361
|
+
headers: {
|
362
|
+
'X-Cybozu-API-Token' => 'token-api',
|
363
|
+
'Content-Type' => 'application/json'
|
364
|
+
},
|
365
|
+
body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
|
366
|
+
)
|
367
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200,
|
368
|
+
headers: { 'Content-type' => 'application/json' })
|
369
|
+
end
|
370
|
+
|
371
|
+
subject { target.put(path, body) }
|
372
|
+
let(:path) { '/k/v1/path' }
|
373
|
+
let(:body) { { 'p1' => 'abc', 'p2' => 'def' } }
|
281
374
|
|
282
|
-
|
283
|
-
|
375
|
+
it { is_expected.to eq 'abc' => 'def' }
|
376
|
+
end
|
284
377
|
|
285
|
-
|
286
|
-
|
378
|
+
describe '#delete' do
|
379
|
+
before(:each) do
|
380
|
+
stub_request(
|
381
|
+
:delete,
|
382
|
+
'https://www.example.com/k/v1/path'
|
383
|
+
)
|
384
|
+
.with(
|
385
|
+
body: { 'p1' => 'abc', 'p2' => 'def' }.to_json,
|
386
|
+
headers: { 'X-Cybozu-API-Token' => 'token-api' }
|
387
|
+
)
|
388
|
+
.to_return(body: "{\"abc\":\"def\"}", status: 200,
|
389
|
+
headers: { 'Content-type' => 'application/json' })
|
390
|
+
end
|
391
|
+
|
392
|
+
subject { target.delete(path, params) }
|
393
|
+
let(:path) { '/k/v1/path' }
|
394
|
+
let(:params) { { 'p1' => 'abc', 'p2' => 'def' } }
|
287
395
|
|
288
|
-
|
289
|
-
|
396
|
+
it { is_expected.to eq 'abc' => 'def' }
|
397
|
+
end
|
290
398
|
|
291
|
-
|
399
|
+
describe '#post_file' do
|
400
|
+
before(:each) do
|
401
|
+
stub_request(
|
402
|
+
:post,
|
403
|
+
'https://www.example.com/k/v1/path'
|
404
|
+
)
|
405
|
+
.with(
|
406
|
+
headers: { 'X-Cybozu-API-Token' => 'token-api' }
|
407
|
+
)
|
408
|
+
.to_return(body: "{\"fileKey\":\"abc\"}", status: 200,
|
409
|
+
headers: { 'Content-type' => 'application/json' })
|
410
|
+
|
411
|
+
expect(Faraday::UploadIO).to receive(:new)
|
412
|
+
.with(path, content_type, original_filename,
|
413
|
+
'Content-Disposition' => 'form-data')
|
414
|
+
.and_return(attachment)
|
415
|
+
end
|
416
|
+
|
417
|
+
subject { target.post_file(url, path, content_type, original_filename) }
|
418
|
+
let(:attachment) { double('attachment') }
|
419
|
+
let(:url) { '/k/v1/path' }
|
420
|
+
let(:path) { '/path/to/file.txt' }
|
421
|
+
let(:content_type) { 'text/plain' }
|
422
|
+
let(:original_filename) { 'fileName.txt' }
|
423
|
+
|
424
|
+
it { is_expected.to eq 'abc' }
|
425
|
+
end
|
292
426
|
end
|
293
427
|
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.1.
|
4
|
+
version: 0.1.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: 2016-
|
11
|
+
date: 2016-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -241,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
241
|
version: '0'
|
242
242
|
requirements: []
|
243
243
|
rubyforge_project:
|
244
|
-
rubygems_version: 2.
|
244
|
+
rubygems_version: 2.2.2
|
245
245
|
signing_key:
|
246
246
|
specification_version: 4
|
247
247
|
summary: kintone API client for Ruby.
|