kintone 0.1.0 → 0.1.1

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: a164c300acd21a0f68fd1c1bd5c44ec1bafe48f7
4
- data.tar.gz: 6bea016672ebf7fc90e4f488f47a81f576b1cab4
3
+ metadata.gz: eff478f183ba34b92fbe55e9cfc9430abc9b3bec
4
+ data.tar.gz: 2b3d0878d64405acf03a17d3cb9a222e341c0497
5
5
  SHA512:
6
- metadata.gz: 2d6fbb16fb2f20c48b1b0e726794991ea487f24f98134844fa54f6c24ac1ece0a415494633814b454be19bb50fd2d9705ca9669da4637686e4323c63bb4f15a1
7
- data.tar.gz: 0a65774ec1a15d1efa4729cd5178445e7a52bcc2d2d4aeaeeb015a315c8d0237bcf2f17a460064722c17bd65d88daa11d7606390345a00e8105f3ecfed550f0a
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
@@ -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: "https://#{domain}",
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
@@ -65,6 +65,10 @@ class Kintone::Api
65
65
  Kintone::Command::App.new(self)
66
66
  end
67
67
 
68
+ def apps
69
+ Kintone::Command::Apps.new(self)
70
+ end
71
+
68
72
  def_delegators :@api, :get, :post, :put, :delete
69
73
  end
70
74
  end
@@ -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
@@ -25,7 +25,6 @@ class Kintone::Command::Records < Kintone::Command
25
25
 
26
26
  def delete(app, ids)
27
27
  params = { app: app, ids: ids }
28
- # ids.each_with_index { |v, i| params["ids[#{i}]"] = v }
29
28
  @api.delete(@url, params)
30
29
  end
31
30
  end
@@ -1,3 +1,3 @@
1
1
  module Kintone
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -170,4 +170,10 @@ describe Kintone::Api::Guest do
170
170
 
171
171
  it { is_expected.to be_a_kind_of(Kintone::Command::App) }
172
172
  end
173
+
174
+ describe '#apps' do
175
+ subject { target.apps }
176
+
177
+ it { is_expected.to be_a_kind_of(Kintone::Command::Apps) }
178
+ end
173
179
  end
@@ -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.0
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: 2014-11-17 00:00:00.000000000 Z
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