kintone 0.1.0 → 0.1.1
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 +3 -0
- data/lib/kintone/api.rb +8 -3
- data/lib/kintone/api/guest.rb +4 -0
- data/lib/kintone/command/apps.rb +20 -0
- data/lib/kintone/command/records.rb +0 -1
- data/lib/kintone/version.rb +1 -1
- data/spec/kintone/api/guest_spec.rb +6 -0
- data/spec/kintone/api_spec.rb +6 -0
- data/spec/kintone/command/apps_spec.rb +54 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eff478f183ba34b92fbe55e9cfc9430abc9b3bec
|
4
|
+
data.tar.gz: 2b3d0878d64405acf03a17d3cb9a222e341c0497
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d6b91023cb5a2ce0a2a176b95bef60d32572f34e1125f5213469cebfbc5256fa3f7997fc2fe32a163d840548e1162a939620c28e542357e153fd5cbe8a4f783
|
7
|
+
data.tar.gz: 82a7ea80e96892f8975a08be637a4f12bbf084b907abf64b464f6ce8d5b3231b2340ce381a20dabdeb423e709da82ba479ce0bcac3b6c870ecf605362eb48a67
|
data/README.md
CHANGED
@@ -269,6 +269,9 @@ api.guests.delete(guests) # => {}
|
|
269
269
|
```ruby
|
270
270
|
id = 4
|
271
271
|
api.app.get(id) # => {"appId" => "4", "code" => "", ...}
|
272
|
+
|
273
|
+
name = "test"; codes = ["FOO", "BAR"]
|
274
|
+
api.apps.get({ name: name, codes: codes }) # => { "apps" => [{...}, ...] }
|
272
275
|
```
|
273
276
|
|
274
277
|
### <a name="api_information"> API information
|
data/lib/kintone/api.rb
CHANGED
@@ -15,6 +15,7 @@ require 'kintone/command/space_thread'
|
|
15
15
|
require 'kintone/command/space_members'
|
16
16
|
require 'kintone/command/guests'
|
17
17
|
require 'kintone/command/app'
|
18
|
+
require 'kintone/command/apps'
|
18
19
|
require 'kintone/command/apis'
|
19
20
|
require 'kintone/api/guest'
|
20
21
|
require 'kintone/query'
|
@@ -25,10 +26,10 @@ class Kintone::Api
|
|
25
26
|
|
26
27
|
def initialize(domain, user, password)
|
27
28
|
token = Base64.encode64("#{user}:#{password}")
|
29
|
+
url = "https://#{domain}"
|
30
|
+
headers = { 'X-Cybozu-Authorization' => token }
|
28
31
|
@connection =
|
29
|
-
Faraday.new(url:
|
30
|
-
headers: { 'X-Cybozu-Authorization' => token },
|
31
|
-
ssl: false) do |builder|
|
32
|
+
Faraday.new(url: url, headers: headers) do |builder|
|
32
33
|
builder.adapter :net_http
|
33
34
|
builder.request :url_encoded
|
34
35
|
builder.response :json
|
@@ -134,6 +135,10 @@ class Kintone::Api
|
|
134
135
|
Kintone::Command::App.new(self)
|
135
136
|
end
|
136
137
|
|
138
|
+
def apps
|
139
|
+
Kintone::Command::Apps.new(self)
|
140
|
+
end
|
141
|
+
|
137
142
|
def apis
|
138
143
|
Kintone::Command::Apis.new(self)
|
139
144
|
end
|
data/lib/kintone/api/guest.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'kintone/command'
|
2
|
+
|
3
|
+
class Kintone::Command::Apps < Kintone::Command
|
4
|
+
def self.path
|
5
|
+
'apps'
|
6
|
+
end
|
7
|
+
|
8
|
+
def get(params = {})
|
9
|
+
query = {}
|
10
|
+
params.keys.each do |key|
|
11
|
+
if params[key].is_a?(Array)
|
12
|
+
params[key].each_with_index { |v, i| query["#{key}[#{i}]"] = v }
|
13
|
+
else
|
14
|
+
query[key] = params[key]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
response = @api.get(@url, query)
|
18
|
+
response['apps']
|
19
|
+
end
|
20
|
+
end
|
data/lib/kintone/version.rb
CHANGED
data/spec/kintone/api_spec.rb
CHANGED
@@ -231,6 +231,12 @@ describe Kintone::Api do
|
|
231
231
|
it { is_expected.to be_a_kind_of(Kintone::Command::App) }
|
232
232
|
end
|
233
233
|
|
234
|
+
describe '#apps' do
|
235
|
+
subject { target.apps }
|
236
|
+
|
237
|
+
it { is_expected.to be_a_kind_of(Kintone::Command::Apps) }
|
238
|
+
end
|
239
|
+
|
234
240
|
describe '#apis' do
|
235
241
|
subject { target.apis }
|
236
242
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'kintone/command/apps'
|
3
|
+
|
4
|
+
describe Kintone::Command::Apps do
|
5
|
+
let(:target) { Kintone::Command::Apps.new(api) }
|
6
|
+
let(:api) { Kintone::Api.new('example.cybozu.com', 'Administrator', 'cybozu') }
|
7
|
+
|
8
|
+
describe '#get' do
|
9
|
+
subject { target.get(params) }
|
10
|
+
|
11
|
+
context '引数にHashのデータを指定した場合' do
|
12
|
+
before(:each) do
|
13
|
+
stub_request(
|
14
|
+
:get,
|
15
|
+
'https://example.cybozu.com/k/v1/apps.json'
|
16
|
+
)
|
17
|
+
.with(query: query)
|
18
|
+
.to_return(body: { apps: [] }.to_json, status: 200)
|
19
|
+
end
|
20
|
+
|
21
|
+
where(:params, :query) do
|
22
|
+
[
|
23
|
+
[{ ids: [100, 200] }, 'ids[0]=100&ids[1]=200'],
|
24
|
+
[{ ids: [] }, nil],
|
25
|
+
[{ ids: nil }, 'ids='],
|
26
|
+
[{ codes: ['AAA', 'BBB'] }, 'codes[0]=AAA&codes[1]=BBB'],
|
27
|
+
[{ codes: [] }, nil],
|
28
|
+
[{ codes: nil }, 'codes='],
|
29
|
+
[{ name: '名前' }, 'name=名前'],
|
30
|
+
[{ name: '' }, 'name='],
|
31
|
+
[{ name: nil }, 'name='],
|
32
|
+
[{ spaceIds: [100, 200] }, 'spaceIds[0]=100&spaceIds[1]=200'],
|
33
|
+
[{ spaceIds: [] }, nil],
|
34
|
+
[{ spaceIds: nil }, 'spaceIds='],
|
35
|
+
[{ limit: 100 }, 'limit=100'],
|
36
|
+
[{ limit: nil }, 'limit='],
|
37
|
+
[{ offset: 100 }, 'offset=100'],
|
38
|
+
[{ offset: nil }, 'offset='],
|
39
|
+
[{}, nil]
|
40
|
+
]
|
41
|
+
end
|
42
|
+
|
43
|
+
with_them do
|
44
|
+
it { is_expected.to be_a_kind_of(Array) }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context '引数にnilを指定した場合' do
|
49
|
+
let(:params) { nil }
|
50
|
+
|
51
|
+
it { expect { subject }.to raise_error NoMethodError }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rikiya Kawakami
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- lib/kintone/command/apis.rb
|
175
175
|
- lib/kintone/command/app.rb
|
176
176
|
- lib/kintone/command/app_acl.rb
|
177
|
+
- lib/kintone/command/apps.rb
|
177
178
|
- lib/kintone/command/field_acl.rb
|
178
179
|
- lib/kintone/command/form.rb
|
179
180
|
- lib/kintone/command/guests.rb
|
@@ -199,6 +200,7 @@ files:
|
|
199
200
|
- spec/kintone/command/apis_spec.rb
|
200
201
|
- spec/kintone/command/app_acl_spec.rb
|
201
202
|
- spec/kintone/command/app_spec.rb
|
203
|
+
- spec/kintone/command/apps_spec.rb
|
202
204
|
- spec/kintone/command/field_acl_spec.rb
|
203
205
|
- spec/kintone/command/form_spec.rb
|
204
206
|
- spec/kintone/command/guests_spec.rb
|
@@ -244,6 +246,7 @@ test_files:
|
|
244
246
|
- spec/kintone/command/apis_spec.rb
|
245
247
|
- spec/kintone/command/app_acl_spec.rb
|
246
248
|
- spec/kintone/command/app_spec.rb
|
249
|
+
- spec/kintone/command/apps_spec.rb
|
247
250
|
- spec/kintone/command/field_acl_spec.rb
|
248
251
|
- spec/kintone/command/form_spec.rb
|
249
252
|
- spec/kintone/command/guests_spec.rb
|