cobot_client 0.8.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -4
- data/lib/cobot_client/navigation_link_service.rb +7 -22
- data/lib/cobot_client/version.rb +1 -1
- data/spec/cobot_client/navigation_link_service_spec.rb +10 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d97efe9d55e36afb226b47dfd1b27fb96a6ca8e5
|
4
|
+
data.tar.gz: a930cbe33ae0f205409e1e4c47ad627b4849b574
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9376fa5ff793d02f983d80b084f7349e3d6ba3c203915c24aaa56c249d6f932204f81a398b07837c22faf96ac0579f65cae0238d7ecc113e11942316c424b484
|
7
|
+
data.tar.gz: e390b92e01f27a8f3065bb78f68bc2b33981ede0e7914905ee5d37ef51abd3062417c1406e9554b9ab1d334bb6f7eea91e4d18a8aab90da2a008ea64c4ce54db
|
data/README.md
CHANGED
@@ -24,8 +24,8 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
You can install links to your app into the navigation on Cobot. When users click the link an iframe pointing to the given `iframe_url` will be shown.
|
26
26
|
|
27
|
-
client =
|
28
|
-
CobotClient::NavigationLinkService.new(client, '
|
27
|
+
client = CobotClient::ApiClient.new <access token>
|
28
|
+
CobotClient::NavigationLinkService.new(client, 'co-up').install_links [
|
29
29
|
CobotClient::NavigationLink.new(section: 'admin/manage', label: 'My App', iframe_url: 'http://example.com')]
|
30
30
|
|
31
31
|
### Setting up automatic iframe resizing
|
@@ -64,9 +64,15 @@ There is a module `CobotClient::UrlHelper`. After you include it you can call `c
|
|
64
64
|
|
65
65
|
### Calling the API
|
66
66
|
|
67
|
-
|
67
|
+
At the moment there are only a few high-level methods. For more details see the specs.
|
68
68
|
|
69
|
-
|
69
|
+
client = CobotClient::ApiClient.new('<access token>')
|
70
|
+
client.list_resources('<subdomain>')
|
71
|
+
|
72
|
+
For everything else you can use the low-level get/post/put/delete metods:
|
73
|
+
|
74
|
+
client.get 'www', '/user'
|
75
|
+
client.post 'my-subdomain', '/users', {"email": "joe@doe.com"}
|
70
76
|
|
71
77
|
## Contributing
|
72
78
|
|
@@ -3,13 +3,10 @@ require 'oauth2'
|
|
3
3
|
module CobotClient
|
4
4
|
# Used to install links into the Cobot navigation of a space.
|
5
5
|
class NavigationLinkService
|
6
|
-
|
7
|
-
|
8
|
-
# oauth_client - an OAuth2::Client
|
6
|
+
# oauth_client - an CobotClient::ApiClient
|
9
7
|
# access_token - an access token string (owner must be admin of the space to be used)
|
10
|
-
def initialize(
|
11
|
-
@
|
12
|
-
@access_token = access_token
|
8
|
+
def initialize(api_client, space_sudomain)
|
9
|
+
@api_client = api_client
|
13
10
|
@subdomain = space_sudomain
|
14
11
|
end
|
15
12
|
|
@@ -30,31 +27,19 @@ module CobotClient
|
|
30
27
|
private
|
31
28
|
|
32
29
|
def get_links
|
33
|
-
|
30
|
+
@api_client.get(@subdomain, "/navigation_links").map do |attributes|
|
34
31
|
NavigationLink.new attributes
|
35
32
|
end
|
36
33
|
end
|
37
34
|
|
38
35
|
def create_link(link)
|
39
|
-
response =
|
36
|
+
response = @api_client.post(@subdomain, '/navigation_links',
|
40
37
|
section: link.section,
|
41
38
|
label: link.label,
|
42
39
|
iframe_url: link.iframe_url
|
43
|
-
|
44
|
-
|
45
|
-
unless successful?(response)
|
46
|
-
raise "Error installing link: #{response.body}"
|
47
|
-
end
|
48
|
-
|
49
|
-
NavigationLink.new response.parsed
|
50
|
-
end
|
51
|
-
|
52
|
-
def token
|
53
|
-
@token ||= OAuth2::AccessToken.new(@oauth_client, @access_token)
|
54
|
-
end
|
40
|
+
)
|
55
41
|
|
56
|
-
|
57
|
-
[200, 201].include?(response.status)
|
42
|
+
NavigationLink.new response
|
58
43
|
end
|
59
44
|
end
|
60
45
|
end
|
data/lib/cobot_client/version.rb
CHANGED
@@ -1,23 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CobotClient::NavigationLinkService, '#install_links' do
|
4
|
-
let(:service) { CobotClient::NavigationLinkService.new(
|
5
|
-
let(:
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
@token = double(:token).as_null_object
|
9
|
-
OAuth2::AccessToken.stub(new: @token)
|
10
|
-
end
|
4
|
+
let(:service) { CobotClient::NavigationLinkService.new(api_client, 'co-up') }
|
5
|
+
let(:api_client) { double(:api_client) }
|
11
6
|
|
12
7
|
context 'when there are links already' do
|
13
8
|
before(:each) do
|
14
|
-
|
15
|
-
{label: 'test link'}]
|
16
|
-
end
|
9
|
+
api_client.stub(:get).with(
|
10
|
+
'co-up', '/navigation_links') { [{label: 'test link'}] }
|
17
11
|
end
|
18
12
|
|
19
13
|
it 'installs no links' do
|
20
|
-
|
14
|
+
api_client.should_not_receive(:post)
|
21
15
|
|
22
16
|
service.install_links [double(:link)]
|
23
17
|
end
|
@@ -29,21 +23,21 @@ describe CobotClient::NavigationLinkService, '#install_links' do
|
|
29
23
|
|
30
24
|
context 'when there are no links installed' do
|
31
25
|
let(:link) { double(:link, section: 'admin/manage', label: 'test link', iframe_url: '/test') }
|
26
|
+
|
32
27
|
before(:each) do
|
33
|
-
|
28
|
+
api_client.stub(:get).with('co-up', '/navigation_links') { [] }
|
34
29
|
end
|
35
30
|
|
36
31
|
it 'installs the links' do
|
37
|
-
|
32
|
+
api_client.should_receive(:post).with('co-up', '/navigation_links', {
|
38
33
|
section: 'admin/manage', label: 'test link', iframe_url: '/test'
|
39
|
-
}) {
|
34
|
+
}) { {} }
|
40
35
|
|
41
36
|
service.install_links [link]
|
42
37
|
end
|
43
38
|
|
44
39
|
it 'returns the links created' do
|
45
|
-
|
46
|
-
@token.stub(:post) { response }
|
40
|
+
api_client.stub(:post) { {label: 'test link'} }
|
47
41
|
|
48
42
|
expect(service.install_links([link]).map(&:label)).to eql(['test link'])
|
49
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cobot_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Lang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|