kintone 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf4c8005133bbbca3d1167a4d6b0465f01154176
4
- data.tar.gz: 5ffb28f4d5f8c50e13d5c67beb5d8bdee900b497
3
+ metadata.gz: e8c6531671baef8c02b16c44f8c97eb94fb8661b
4
+ data.tar.gz: 842dfa2299afbb03b96e711794681763011a9ef3
5
5
  SHA512:
6
- metadata.gz: 6a5a62448f89a07c5fb8c6638e77f2dcbbeb813ce2698003ea92f27c55d35714644d5a059be98343ea5c63d21429a0b0163a1b9e0c77b01d069f510521212fa6
7
- data.tar.gz: b4fe9f583b016bd39c86a9dac52b40c0c7d56dd449434c17cd74676bb8cb7294b8cb3636a802fe22e31ba345b835f2355794c0366808d98fe57c9acf558598fe
6
+ metadata.gz: f58df87bf47682c15223ceb026674d8199b58d3bc2230402bc0680562d090cec2acf1a8500d2759948eb0fec1ef0ccc02008e6b3537967be01f893f7b6386114
7
+ data.tar.gz: dd16a9a45c84bf9e468164dc980fccfcd7044901c9158055e055e601bcdf211153e1c8155f6063fdb636b497c75b69cb540818f3ffc665435b4f4ba0ad4ba642
data/.travis.yml CHANGED
@@ -10,4 +10,5 @@ rvm:
10
10
  - 2.1.6
11
11
  - 2.2.0
12
12
  - 2.2.1
13
- - 2.2.2
13
+ - 2.2.2
14
+ - 2.3.0
data/README.md CHANGED
@@ -29,6 +29,7 @@ api = Kintone::Api.new("example.cybozu.com", "Administrator", "cybozu")
29
29
  - [Record update](#record_update)
30
30
  - [Record delete](#record_delete)
31
31
  - [Bulk request](#bulk_request)
32
+ - [File](#file)
32
33
  - [Format retrieval](#format_retrieval)
33
34
  - [Permissions](#permissions)
34
35
  - [Space management](#space_management)
@@ -157,10 +158,6 @@ records = [
157
158
  Kintone::Type::Record.new(number: "7890")
158
159
  ]
159
160
  api.records.register(app, records) # => {"ids" => ["100", "101"], "revisions" => ["1", "1"]}
160
-
161
- # Deprecated
162
- api.record.create(app, record)
163
- api.records.create(app, records)
164
161
  ```
165
162
 
166
163
  ### <a name="record_update"> Record update
@@ -223,6 +220,16 @@ requests = {"requests" => [{"method" => "POST", ...}, {"method" => "PUT", ...}]}
223
220
  api.bulk.request(requests) # => {"results" => [...]}
224
221
  ```
225
222
 
223
+ ### <a name="file"> File
224
+
225
+ ```ruby
226
+ # File upload
227
+ file_key = api.file.register("/path/to/file", "text/plain", "file.txt")
228
+
229
+ # File download
230
+ file = api.file.get(file_key)
231
+ ```
232
+
226
233
  ### <a name="format_retrieval"> Format retrieval
227
234
 
228
235
  ```ruby
@@ -291,7 +298,7 @@ api.space.delete(id) # => {}
291
298
  ```ruby
292
299
  # Add guest
293
300
  guests = [{code: "hoge@example.com", password: "p@ssword", timezone: "Asia/Tokyo", name: "Tokyo, Saburo", ...}, ...]
294
- api.guests.create(guests) # => {}
301
+ api.guests.register(guests) # => {}
295
302
 
296
303
  # delete guest
297
304
  guests = ["hoge@example.com", "fuga@example.com"]
data/kintone.gemspec CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_runtime_dependency 'faraday', '>=0.8.9'
23
- spec.add_runtime_dependency 'faraday_middleware', '>=0.9.0'
22
+ spec.add_runtime_dependency 'faraday', '>=0.9.2'
23
+ spec.add_runtime_dependency 'faraday_middleware', '>=0.10.0'
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 1.5'
26
26
  spec.add_development_dependency 'rake'
data/lib/kintone/api.rb CHANGED
@@ -26,7 +26,8 @@ class Kintone::Api
26
26
  :apps,
27
27
  :apis,
28
28
  :bulk_request,
29
- :bulk
29
+ :bulk,
30
+ :file
30
31
  ].freeze
31
32
 
32
33
  def initialize(domain, user, password)
@@ -35,9 +36,10 @@ class Kintone::Api
35
36
  headers = { 'X-Cybozu-Authorization' => token }
36
37
  @connection =
37
38
  Faraday.new(url: url, headers: headers) do |builder|
38
- builder.adapter :net_http
39
39
  builder.request :url_encoded
40
- builder.response :json
40
+ builder.request :multipart
41
+ builder.response :json, content_type: /\bjson$/
42
+ builder.adapter :net_http
41
43
  end
42
44
  end
43
45
 
@@ -88,6 +90,18 @@ class Kintone::Api
88
90
  response.body
89
91
  end
90
92
 
93
+ def post_file(url, path, content_type, original_filename)
94
+ response =
95
+ @connection.post do |request|
96
+ request.url url
97
+ request.headers['Content-Type'] = 'multipart/form-data'
98
+ request.body = { file: Faraday::UploadIO.new(
99
+ path, content_type, original_filename,
100
+ 'Content-Disposition' => 'form-data') }
101
+ end
102
+ response.body['fileKey']
103
+ end
104
+
91
105
  def method_missing(name, *args)
92
106
  if ACCESSIBLE_COMMAND.include?(name)
93
107
  CommandAccessor.send(name, self)
@@ -22,10 +22,11 @@ class Kintone::Api
22
22
  :app,
23
23
  :apps,
24
24
  :bulk_request,
25
- :bulk
25
+ :bulk,
26
+ :file
26
27
  ].freeze
27
28
 
28
- def_delegators :@api, :get, :post, :put, :delete
29
+ def_delegators :@api, :get, :post, :put, :delete, :post_file
29
30
 
30
31
  def initialize(space_id, api)
31
32
  @api = api
@@ -13,6 +13,7 @@ class Kintone::Command
13
13
  autoload :SpaceBody, 'kintone/command/space_body'
14
14
  autoload :SpaceThread, 'kintone/command/space_thread'
15
15
  autoload :SpaceMembers, 'kintone/command/space_members'
16
+ autoload :File, 'kintone/command/file'
16
17
 
17
18
  # other than guest
18
19
  autoload :TemplateSpace, 'kintone/command/template_space'
@@ -76,6 +77,10 @@ class Kintone::Command
76
77
  SpaceMembers.new(api)
77
78
  end
78
79
 
80
+ def file(api)
81
+ File.new(api)
82
+ end
83
+
79
84
  # other than guest
80
85
  def template_space(api)
81
86
  TemplateSpace.new(api)
@@ -0,0 +1,15 @@
1
+ require 'kintone/command'
2
+
3
+ class Kintone::Command::File < Kintone::Command
4
+ def self.path
5
+ 'file'
6
+ end
7
+
8
+ def get(file_key)
9
+ @api.get(@url, fileKey: file_key)
10
+ end
11
+
12
+ def register(path, content_type, original_filename)
13
+ @api.post_file(@url, path, content_type, original_filename)
14
+ end
15
+ end
@@ -5,11 +5,13 @@ class Kintone::Command::Guests < Kintone::Command
5
5
  'guests'
6
6
  end
7
7
 
8
- def create(guests)
8
+ def register(guests)
9
9
  @api.post(@url, guests: guests)
10
10
  end
11
11
 
12
12
  def delete(guests)
13
13
  @api.delete(@url, guests: guests)
14
14
  end
15
+
16
+ alias_method :create, :register
15
17
  end
@@ -13,13 +13,11 @@ class Kintone::Command::Record < Kintone::Command
13
13
  @api.post(@url, app: app, record: record.to_kintone)
14
14
  end
15
15
 
16
- def create(app, record)
17
- register(app, record)
18
- end
19
-
20
16
  def update(app, id, record, revision: nil)
21
17
  body = { app: app, id: id, record: record.to_kintone }
22
18
  body[:revision] = revision if revision
23
19
  @api.put(@url, body)
24
20
  end
21
+
22
+ alias_method :create, :register
25
23
  end
@@ -15,10 +15,6 @@ class Kintone::Command::Records < Kintone::Command
15
15
  @api.post(@url, app: app, records: records.to_kintone)
16
16
  end
17
17
 
18
- def create(app, records)
19
- register(app, records)
20
- end
21
-
22
18
  def update(app, records)
23
19
  @api.put(@url, app: app, records: records.to_kintone)
24
20
  end
@@ -28,4 +24,6 @@ class Kintone::Command::Records < Kintone::Command
28
24
  params[:revisions] = revisions if revisions
29
25
  @api.delete(@url, params)
30
26
  end
27
+
28
+ alias_method :create, :register
31
29
  end
@@ -1,3 +1,3 @@
1
1
  module Kintone
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -25,7 +25,8 @@ describe Kintone::Api::Guest do
25
25
  headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' },
26
26
  query: params
27
27
  )
28
- .to_return(body: "{\"abc\":\"def\"}", status: 200)
28
+ .to_return(body: "{\"abc\":\"def\"}", status: 200,
29
+ headers: { 'Content-type' => 'application/json' })
29
30
  end
30
31
 
31
32
  subject { target.get(path, params) }
@@ -46,7 +47,8 @@ describe Kintone::Api::Guest do
46
47
  headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' },
47
48
  body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
48
49
  )
49
- .to_return(body: "{\"abc\":\"def\"}", status: 200)
50
+ .to_return(body: "{\"abc\":\"def\"}", status: 200,
51
+ headers: { 'Content-type' => 'application/json' })
50
52
  end
51
53
 
52
54
  subject { target.post(path, body) }
@@ -67,7 +69,8 @@ describe Kintone::Api::Guest do
67
69
  headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' },
68
70
  body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
69
71
  )
70
- .to_return(body: "{\"abc\":\"def\"}", status: 200)
72
+ .to_return(body: "{\"abc\":\"def\"}", status: 200,
73
+ headers: { 'Content-type' => 'application/json' })
71
74
  end
72
75
 
73
76
  subject { target.put(path, body) }
@@ -88,7 +91,8 @@ describe Kintone::Api::Guest do
88
91
  body: { 'p1' => 'abc', 'p2' => 'def' }.to_json,
89
92
  headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }
90
93
  )
91
- .to_return(body: "{\"abc\":\"def\"}", status: 200)
94
+ .to_return(body: "{\"abc\":\"def\"}", status: 200,
95
+ headers: { 'Content-type' => 'application/json' })
92
96
  end
93
97
 
94
98
  subject { target.delete(path, params) }
@@ -50,7 +50,8 @@ describe Kintone::Api do
50
50
  query: query,
51
51
  headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }
52
52
  )
53
- .to_return(body: "{\"abc\":\"def\"}", status: 200)
53
+ .to_return(body: "{\"abc\":\"def\"}", status: 200,
54
+ headers: { 'Content-type' => 'application/json' })
54
55
  end
55
56
 
56
57
  subject { target.get(path, params) }
@@ -100,7 +101,8 @@ describe Kintone::Api do
100
101
  },
101
102
  body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
102
103
  )
103
- .to_return(body: "{\"abc\":\"def\"}", status: 200)
104
+ .to_return(body: "{\"abc\":\"def\"}", status: 200,
105
+ headers: { 'Content-type' => 'application/json' })
104
106
  end
105
107
 
106
108
  subject { target.post(path, body) }
@@ -123,7 +125,8 @@ describe Kintone::Api do
123
125
  },
124
126
  body: "{\"p1\":\"abc\",\"p2\":\"def\"}"
125
127
  )
126
- .to_return(body: "{\"abc\":\"def\"}", status: 200)
128
+ .to_return(body: "{\"abc\":\"def\"}", status: 200,
129
+ headers: { 'Content-type' => 'application/json' })
127
130
  end
128
131
 
129
132
  subject { target.put(path, body) }
@@ -143,7 +146,8 @@ describe Kintone::Api do
143
146
  body: { 'p1' => 'abc', 'p2' => 'def' }.to_json,
144
147
  headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }
145
148
  )
146
- .to_return(body: "{\"abc\":\"def\"}", status: 200)
149
+ .to_return(body: "{\"abc\":\"def\"}", status: 200,
150
+ headers: { 'Content-type' => 'application/json' })
147
151
  end
148
152
 
149
153
  subject { target.delete(path, params) }
@@ -153,6 +157,32 @@ describe Kintone::Api do
153
157
  it { is_expected.to eq 'abc' => 'def' }
154
158
  end
155
159
 
160
+ describe '#post_file' do
161
+ before(:each) do
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' })
169
+
170
+ expect(Faraday::UploadIO).to receive(:new)
171
+ .with(path, content_type, original_filename,
172
+ 'Content-Disposition' => 'form-data')
173
+ .and_return(attachment)
174
+ end
175
+
176
+ subject { target.post_file(url, path, content_type, original_filename) }
177
+ let(:attachment) { double('attachment') }
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' }
182
+
183
+ it { is_expected.to eq 'abc' }
184
+ end
185
+
156
186
  describe '#record' do
157
187
  subject { target.record }
158
188
 
@@ -254,4 +284,10 @@ describe Kintone::Api do
254
284
 
255
285
  it { is_expected.to be_a_kind_of(Kintone::Command::BulkRequest) }
256
286
  end
287
+
288
+ describe '#file' do
289
+ subject { target.file }
290
+
291
+ it { is_expected.to be_a_kind_of(Kintone::Command::File) }
292
+ end
257
293
  end
@@ -11,7 +11,8 @@ describe Kintone::Command::Apis do
11
11
  :get,
12
12
  'https://example.cybozu.com/k/v1/apis.json'
13
13
  )
14
- .to_return(body: response_data.to_json, status: 200)
14
+ .to_return(body: response_data.to_json, status: 200,
15
+ headers: { 'Content-type' => 'application/json' })
15
16
  end
16
17
 
17
18
  subject { target.get }
@@ -36,7 +37,8 @@ describe Kintone::Command::Apis do
36
37
  :get,
37
38
  'https://example.cybozu.com/k/v1/apis/records/get.json'
38
39
  )
39
- .to_return(body: response_data.to_json, status: 200)
40
+ .to_return(body: response_data.to_json, status: 200,
41
+ headers: { 'Content-type' => 'application/json' })
40
42
  end
41
43
 
42
44
  subject { target.get_details_of(link) }
@@ -61,13 +63,15 @@ describe Kintone::Command::Apis do
61
63
  :get,
62
64
  'https://example.cybozu.com/k/v1/apis.json'
63
65
  )
64
- .to_return(body: apis_response_data.to_json, status: 200)
66
+ .to_return(body: apis_response_data.to_json, status: 200,
67
+ headers: { 'Content-type' => 'application/json' })
65
68
 
66
69
  stub_request(
67
70
  :get,
68
71
  'https://example.cybozu.com/k/v1/apis/records/get.json'
69
72
  )
70
- .to_return(body: api_response_data.to_json, status: 200)
73
+ .to_return(body: api_response_data.to_json, status: 200,
74
+ headers: { 'Content-type' => 'application/json' })
71
75
  end
72
76
 
73
77
  subject { target.get_details_of_key(key) }
@@ -16,7 +16,7 @@ describe Kintone::Command::AppAcl do
16
16
  'https://example.cybozu.com/k/v1/app/acl.json'
17
17
  )
18
18
  .with(body: { 'app' => 1, 'rights' => { 'p1' => 'abc', 'p2' => 'def' } }.to_json)
19
- .to_return(body: '{}', status: 200)
19
+ .to_return(body: '{}', status: 200, headers: { 'Content-type' => 'application/json' })
20
20
  end
21
21
 
22
22
  let(:app) { 1 }
@@ -12,7 +12,8 @@ describe Kintone::Command::App do
12
12
  'https://example.cybozu.com/k/v1/app.json'
13
13
  )
14
14
  .with(query: { id: id })
15
- .to_return(body: response_data.to_json, status: 200)
15
+ .to_return(body: response_data.to_json, status: 200,
16
+ headers: { 'Content-type' => 'application/json' })
16
17
  end
17
18
 
18
19
  subject { target.get(id) }
@@ -15,27 +15,28 @@ describe Kintone::Command::Apps do
15
15
  'https://example.cybozu.com/k/v1/apps.json'
16
16
  )
17
17
  .with(query: query)
18
- .to_return(body: { apps: [] }.to_json, status: 200)
18
+ .to_return(body: { apps: [] }.to_json, status: 200,
19
+ headers: { 'Content-type' => 'application/json' })
19
20
  end
20
21
 
21
22
  where(:params, :query) do
22
23
  [
23
24
  [{ ids: [100, 200] }, 'ids[0]=100&ids[1]=200'],
24
25
  [{ ids: [] }, nil],
25
- [{ ids: nil }, 'ids='],
26
+ [{ ids: nil }, 'ids'],
26
27
  [{ codes: ['AAA', 'BBB'] }, 'codes[0]=AAA&codes[1]=BBB'],
27
28
  [{ codes: [] }, nil],
28
- [{ codes: nil }, 'codes='],
29
+ [{ codes: nil }, 'codes'],
29
30
  [{ name: '名前' }, 'name=名前'],
30
31
  [{ name: '' }, 'name='],
31
- [{ name: nil }, 'name='],
32
+ [{ name: nil }, 'name'],
32
33
  [{ spaceIds: [100, 200] }, 'spaceIds[0]=100&spaceIds[1]=200'],
33
34
  [{ spaceIds: [] }, nil],
34
- [{ spaceIds: nil }, 'spaceIds='],
35
+ [{ spaceIds: nil }, 'spaceIds'],
35
36
  [{ limit: 100 }, 'limit=100'],
36
- [{ limit: nil }, 'limit='],
37
+ [{ limit: nil }, 'limit'],
37
38
  [{ offset: 100 }, 'offset=100'],
38
- [{ offset: nil }, 'offset='],
39
+ [{ offset: nil }, 'offset'],
39
40
  [{}, nil]
40
41
  ]
41
42
  end
@@ -13,7 +13,8 @@ describe Kintone::Command::BulkRequest do
13
13
  'https://example.cybozu.com/k/v1/bulkRequest.json'
14
14
  )
15
15
  .with(body: { requests: requests }.to_json)
16
- .to_return(body: { 'results' => results }.to_json, status: 200)
16
+ .to_return(body: { 'results' => results }.to_json, status: 200,
17
+ headers: { 'Content-type' => 'application/json' })
17
18
  end
18
19
 
19
20
  subject { target.request(requests) }
@@ -16,7 +16,8 @@ describe Kintone::Command::FieldAcl do
16
16
  'https://example.cybozu.com/k/v1/field/acl.json'
17
17
  )
18
18
  .with(body: { 'id' => 1, 'rights' => { 'p1' => 'abc', 'p2' => 'def' } }.to_json)
19
- .to_return(body: '{}', status: 200)
19
+ .to_return(body: '{}', status: 200,
20
+ headers: { 'Content-type' => 'application/json' })
20
21
  end
21
22
 
22
23
  let(:id) { 1 }
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+ require 'kintone/command/file'
3
+ require 'kintone/api'
4
+
5
+ describe Kintone::Command::File do
6
+ let(:target) { Kintone::Command::File.new(api) }
7
+ let(:api) { Kintone::Api.new('example.cybozu.com', 'Administrator', 'cybozu') }
8
+
9
+ describe '#get' do
10
+ before(:each) do
11
+ stub_request(
12
+ :get,
13
+ 'https://example.cybozu.com/k/v1/file.json?fileKey=file-key-string'
14
+ )
15
+ .to_return(body: attachment, status: 200,
16
+ headers: { 'Content-type' => 'image/gif' })
17
+ end
18
+
19
+ subject { target.get(fileKey) }
20
+
21
+ let(:attachment) do
22
+ Base64.decode64('data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==')
23
+ end
24
+ let(:fileKey) { 'file-key-string' }
25
+
26
+ it { expect(subject).to eq attachment }
27
+ end
28
+
29
+ describe '#register' do
30
+ before(:each) do
31
+ expect(api).to receive(:post_file)
32
+ .with(
33
+ target.instance_variable_get('@url'),
34
+ path, content_type, original_filename)
35
+ .and_return('c15b3870-7505-4ab6-9d8d-b9bdbc74f5d6')
36
+ end
37
+
38
+ subject { target.register(path, content_type, original_filename) }
39
+
40
+ let(:path) { '/path/to/file.txt' }
41
+ let(:content_type) { 'text/plain' }
42
+ let(:original_filename) { 'fileName.txt' }
43
+
44
+ it { is_expected.to eq 'c15b3870-7505-4ab6-9d8d-b9bdbc74f5d6' }
45
+ end
46
+ end
@@ -15,7 +15,8 @@ describe Kintone::Command::Form do
15
15
  :get,
16
16
  'https://example.cybozu.com/k/v1/form.json?app=4'
17
17
  )
18
- .to_return(body: "{\"result\":\"ok\"}", status: 200)
18
+ .to_return(body: "{\"result\":\"ok\"}", status: 200,
19
+ headers: { 'Content-type' => 'application/json' })
19
20
  end
20
21
 
21
22
  let(:app) { 4 }
@@ -6,17 +6,18 @@ describe Kintone::Command::Guests do
6
6
  let(:target) { Kintone::Command::Guests.new(api) }
7
7
  let(:api) { Kintone::Api.new('example.cybozu.com', 'Administrator', 'cybozu') }
8
8
 
9
- describe '#create' do
9
+ describe '#register' do
10
10
  before(:each) do
11
11
  stub_request(
12
12
  :post,
13
13
  'https://example.cybozu.com/k/v1/guests.json'
14
14
  )
15
15
  .with(body: { guests: guests }.to_json)
16
- .to_return(body: '{}', status: 200)
16
+ .to_return(body: '{}', status: 200,
17
+ headers: { 'Content-type' => 'application/json' })
17
18
  end
18
19
 
19
- subject { target.create(guests) }
20
+ subject { target.register(guests) }
20
21
 
21
22
  let(:guests) do
22
23
  [
@@ -47,7 +48,8 @@ describe Kintone::Command::Guests do
47
48
  'https://example.cybozu.com/k/v1/guests.json'
48
49
  )
49
50
  .with(body: { guests: guests }.to_json)
50
- .to_return(body: '{}', status: 200)
51
+ .to_return(body: '{}', status: 200,
52
+ headers: { 'Content-type' => 'application/json' })
51
53
  end
52
54
 
53
55
  subject { target.delete(guests) }
@@ -16,7 +16,8 @@ describe Kintone::Command::RecordAcl do
16
16
  'https://example.cybozu.com/k/v1/record/acl.json'
17
17
  )
18
18
  .with(body: { 'id' => 1, 'rights' => { 'p1' => 'abc', 'p2' => 'def' } }.to_json)
19
- .to_return(body: '{}', status: 200)
19
+ .to_return(body: '{}', status: 200,
20
+ headers: { 'Content-type' => 'application/json' })
20
21
  end
21
22
 
22
23
  let(:id) { 1 }
@@ -13,7 +13,8 @@ describe Kintone::Command::Record do
13
13
  :get,
14
14
  'https://www.example.com/k/v1/record.json?app=8&id=100'
15
15
  )
16
- .to_return(body: "{\"result\":\"ok\"}", status: 200)
16
+ .to_return(body: "{\"result\":\"ok\"}", status: 200,
17
+ headers: { 'Content-type' => 'application/json' })
17
18
  end
18
19
 
19
20
  subject { target.get(app, id) }
@@ -37,7 +38,8 @@ describe Kintone::Command::Record do
37
38
  'https://www.example.com/k/v1/record.json'
38
39
  )
39
40
  .with(body: request_body.to_json)
40
- .to_return(body: response_body.to_json, status: 200)
41
+ .to_return(body: response_body.to_json, status: 200,
42
+ headers: { 'Content-type' => 'application/json' })
41
43
  end
42
44
 
43
45
  subject { target.register(app, record) }
@@ -87,7 +89,8 @@ describe Kintone::Command::Record do
87
89
  'https://www.example.com/k/v1/record.json'
88
90
  )
89
91
  .with(body: request_body.to_json)
90
- .to_return(body: response_body.to_json, status: 200)
92
+ .to_return(body: response_body.to_json, status: 200,
93
+ headers: { 'Content-type' => 'application/json' })
91
94
  end
92
95
 
93
96
  subject { target.update(app, id, record) }
@@ -19,7 +19,8 @@ describe Kintone::Command::Records do
19
19
  :get,
20
20
  'https://example.cybozu.com/k/v1/records.json?app=8&query='
21
21
  )
22
- .to_return(body: response_data.to_json, status: 200)
22
+ .to_return(body: response_data.to_json, status: 200,
23
+ headers: { 'Content-type' => 'application/json' })
23
24
  end
24
25
 
25
26
  def response_data
@@ -35,7 +36,8 @@ describe Kintone::Command::Records do
35
36
  :get,
36
37
  'https://example.cybozu.com/k/v1/records.json?app=8&query=updated_time%20%3e%20%222012%2d02%2d03T09%3a00%3a00%2b0900%22%20and%20updated_time%20%3c%20%222012%2d02%2d03T10%3a00%3a00%2b0900%22'
37
38
  )
38
- .to_return(body: response_data.to_json, status: 200)
39
+ .to_return(body: response_data.to_json, status: 200,
40
+ headers: { 'Content-type' => 'application/json' })
39
41
  end
40
42
 
41
43
  let(:query) { "updated_time > \"2012-02-03T09:00:00+0900\" and updated_time < \"2012-02-03T10:00:00+0900\"" } # rubocop:disable Style/LineLength
@@ -53,7 +55,8 @@ describe Kintone::Command::Records do
53
55
  :get,
54
56
  'https://example.cybozu.com/k/v1/records.json?app=8&query=&fields%5b0%5d=%E3%83%AC%E3%82%B3%E3%83%BC%E3%83%89%E7%95%AA%E5%8F%B7&fields%5b1%5d=created_time&fields%5b2%5d=dropdown'
55
57
  )
56
- .to_return(body: response_data.to_json, status: 200)
58
+ .to_return(body: response_data.to_json, status: 200,
59
+ headers: { 'Content-type' => 'application/json' })
57
60
  end
58
61
 
59
62
  let(:fields) { %w(レコード番号 created_time dropdown) }
@@ -69,10 +72,11 @@ describe Kintone::Command::Records do
69
72
  before(:each) do
70
73
  stub_request(
71
74
  :get,
72
- 'https://example.cybozu.com/k/v1/records.json?'
75
+ 'https://example.cybozu.com/k/v1/records.json'
73
76
  )
74
- .with(query: { app: 8, query: nil })
75
- .to_return(body: response_data.to_json, status: 200)
77
+ .with(query: { app: 8, query: '' })
78
+ .to_return(body: response_data.to_json, status: 200,
79
+ headers: { 'Content-type' => 'application/json' })
76
80
  end
77
81
 
78
82
  let(:query) { nil }
@@ -98,7 +102,8 @@ describe Kintone::Command::Records do
98
102
  'https://example.cybozu.com/k/v1/records.json'
99
103
  )
100
104
  .with(body: request_body.to_json)
101
- .to_return(body: response_body.to_json, status: 200)
105
+ .to_return(body: response_body.to_json, status: 200,
106
+ headers: { 'Content-type' => 'application/json' })
102
107
  end
103
108
 
104
109
  subject { target.register(app, records) }
@@ -145,7 +150,8 @@ describe Kintone::Command::Records do
145
150
  'https://example.cybozu.com/k/v1/records.json'
146
151
  )
147
152
  .with(body: request_body.to_json)
148
- .to_return(body: response_body.to_json, status: 200)
153
+ .to_return(body: response_body.to_json, status: 200,
154
+ headers: { 'Content-type' => 'application/json' })
149
155
  end
150
156
 
151
157
  subject { target.update(app, records) }
@@ -247,7 +253,8 @@ describe Kintone::Command::Records do
247
253
  'https://example.cybozu.com/k/v1/records.json'
248
254
  )
249
255
  .with(body: request_body.to_json)
250
- .to_return(body: '{}', status: 200)
256
+ .to_return(body: '{}', status: 200,
257
+ headers: { 'Content-type' => 'application/json' })
251
258
  end
252
259
 
253
260
  context 'without revisions' do
@@ -16,7 +16,8 @@ describe Kintone::Command::SpaceBody do
16
16
  'https://example.cybozu.com/k/v1/space/body.json'
17
17
  )
18
18
  .with(body: { id: 1, body: '<b>総務課</b>専用のスペースです。' }.to_json)
19
- .to_return(body: '{}', status: 200)
19
+ .to_return(body: '{}', status: 200,
20
+ headers: { 'Content-type' => 'application/json' })
20
21
  end
21
22
 
22
23
  let(:id) { 1 }
@@ -15,7 +15,8 @@ describe Kintone::Command::SpaceGuests do
15
15
  'https://example.cybozu.com/k/guest/1/v1/space/guests.json'
16
16
  )
17
17
  .with(body: { id: id, guests: guests }.to_json)
18
- .to_return(body: '{}', status: 200)
18
+ .to_return(body: '{}', status: 200,
19
+ headers: { 'Content-type' => 'application/json' })
19
20
  end
20
21
 
21
22
  subject { target.update(id, guests) }
@@ -13,7 +13,8 @@ describe Kintone::Command::SpaceMembers do
13
13
  'https://example.cybozu.com/k/v1/space/members.json'
14
14
  )
15
15
  .with(query: { id: id })
16
- .to_return(body: response_data.to_json, status: 200)
16
+ .to_return(body: response_data.to_json, status: 200,
17
+ headers: { 'Content-type' => 'application/json' })
17
18
  end
18
19
 
19
20
  subject { target.get(id) }
@@ -46,7 +47,8 @@ describe Kintone::Command::SpaceMembers do
46
47
  'https://example.cybozu.com/k/v1/space/members.json'
47
48
  )
48
49
  .with(body: request_data.to_json)
49
- .to_return(body: '{}', status: 200)
50
+ .to_return(body: '{}', status: 200,
51
+ headers: { 'Content-type' => 'application/json' })
50
52
  end
51
53
 
52
54
  subject { target.update(id, members) }
@@ -16,7 +16,8 @@ describe Kintone::Command::Space do
16
16
  'https://example.cybozu.com/k/v1/space.json'
17
17
  )
18
18
  .with(query: { id: 1 })
19
- .to_return(body: result.to_json, status: 200)
19
+ .to_return(body: result.to_json, status: 200,
20
+ headers: { 'Content-type' => 'application/json' })
20
21
  end
21
22
 
22
23
  let(:id) { 1 }
@@ -42,7 +43,8 @@ describe Kintone::Command::Space do
42
43
  'https://example.cybozu.com/k/v1/space.json'
43
44
  )
44
45
  .with(body: { id: 1 }.to_json)
45
- .to_return(body: '{}', status: 200)
46
+ .to_return(body: '{}', status: 200,
47
+ headers: { 'Content-type' => 'application/json' })
46
48
  end
47
49
 
48
50
  let(:id) { 1 }
@@ -13,7 +13,8 @@ describe Kintone::Command::SpaceThread do
13
13
  'https://example.cybozu.com/k/v1/space/thread.json'
14
14
  )
15
15
  .with(body: request_body)
16
- .to_return(body: '{}', status: 200)
16
+ .to_return(body: '{}', status: 200,
17
+ headers: { 'Content-type' => 'application/json' })
17
18
  end
18
19
 
19
20
  subject { target.update(id, name: name, body: body) }
@@ -16,7 +16,8 @@ describe Kintone::Command::TemplateSpace do
16
16
  'https://example.cybozu.com/k/v1/template/space.json'
17
17
  )
18
18
  .with(body: request_data.to_json)
19
- .to_return(body: "{\"id\":\"1\"}", status: 200)
19
+ .to_return(body: "{\"id\":\"1\"}", status: 200,
20
+ headers: { 'Content-type' => 'application/json' })
20
21
  end
21
22
 
22
23
  let(:id) { 1 }
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rikiya Kawakami
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-10 00:00:00.000000000 Z
11
+ date: 2016-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.9
19
+ version: 0.9.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.9
26
+ version: 0.9.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday_middleware
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.0
33
+ version: 0.10.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.9.0
40
+ version: 0.10.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -178,6 +178,7 @@ files:
178
178
  - lib/kintone/command/apps.rb
179
179
  - lib/kintone/command/bulk_request.rb
180
180
  - lib/kintone/command/field_acl.rb
181
+ - lib/kintone/command/file.rb
181
182
  - lib/kintone/command/form.rb
182
183
  - lib/kintone/command/guests.rb
183
184
  - lib/kintone/command/record.rb
@@ -205,6 +206,7 @@ files:
205
206
  - spec/kintone/command/apps_spec.rb
206
207
  - spec/kintone/command/bulk_request_spec.rb
207
208
  - spec/kintone/command/field_acl_spec.rb
209
+ - spec/kintone/command/file_spec.rb
208
210
  - spec/kintone/command/form_spec.rb
209
211
  - spec/kintone/command/guests_spec.rb
210
212
  - spec/kintone/command/record_acl_spec.rb
@@ -252,6 +254,7 @@ test_files:
252
254
  - spec/kintone/command/apps_spec.rb
253
255
  - spec/kintone/command/bulk_request_spec.rb
254
256
  - spec/kintone/command/field_acl_spec.rb
257
+ - spec/kintone/command/file_spec.rb
255
258
  - spec/kintone/command/form_spec.rb
256
259
  - spec/kintone/command/guests_spec.rb
257
260
  - spec/kintone/command/record_acl_spec.rb