glip_sdk 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 875cea0d1c078c80163b1a99dd5c00c996320ed3
4
+ data.tar.gz: 6492df46ba246d9fdf4cdd73fa3e41da54152c5f
5
+ SHA512:
6
+ metadata.gz: 03af44af79822d893d37892becb248b1148d422a03656c8a57bc25100af41cbdccad709351d984d8fd1d40b729051fb4b661dda068b92b24a66820fcd014df8e
7
+ data.tar.gz: b077f7b493dcecf824fba4836afe77319149cffa0719a8bba2587bfd94a8d9e58eccb5ded5c62c10ff425384f86629bb8271fb235e3f489fe75db74f99bd2cf1
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ CHANGELOG
2
+ ---------
3
+ - **2016-12-31**: 0.0.1
4
+ - Initial commit
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source ENV['GEM_SOURCE'] || 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 John Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ Glip SDK for Ruby
2
+ =================
3
+
4
+ [![Gem Version][gem-version-svg]][gem-version-link]
5
+ [![Build Status][build-status-svg]][build-status-link]
6
+ [![Dependency Status][dependency-status-svg]][dependency-status-link]
7
+ [![Codacy Badge][codacy-svg]][codacy-link]
8
+ [![Code Climate][codeclimate-status-svg]][codeclimate-status-link]
9
+ [![Scrutinizer Code Quality][scrutinizer-status-svg]][scrutinizer-status-link]
10
+ [![Downloads][downloads-svg]][downloads-link]
11
+ [![Docs][docs-rubydoc-svg]][docs-rubydoc-link]
12
+ [![License][license-svg]][license-link]
13
+
14
+ Glip SDK for Glip collaboration (https://glip.com).
15
+
16
+ More documentation will be added soon. For now see the example and SDK code.
17
+
18
+ ## Usage
19
+
20
+ ```ruby
21
+ rc_sdk = RingCentralSdk::REST::Client.new [...]
22
+ glip = GlipSdk::REST::Client.new rc_sdk
23
+ res = glip.posts.post group_id: '12345', text: 'Hi there!'
24
+ ```
25
+
26
+ ## Example Scripts
27
+
28
+ Example scripts can be found in the `scripts` directory.
29
+
30
+ ### Change Log
31
+
32
+ See [CHANGELOG.md](CHANGELOG.md)
33
+
34
+ ## Links
35
+
36
+ Project Repo
37
+
38
+ * https://github.com/ringcentral-ruby/glip-sdk-ruby
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it ( http://github.com/ringcentral-ruby/glip-sdk-ruby/fork )
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create new Pull Request
47
+
48
+ ## License
49
+
50
+ Glip SDK is available under the MIT license. See [LICENSE.md](LICENSE.md) for details.
51
+
52
+ Glip SDK © 2016 by John Wang
53
+
54
+ [gem-version-svg]: https://badge.fury.io/rb/glip_sdk.svg
55
+ [gem-version-link]: http://badge.fury.io/rb/glip_sdk
56
+ [downloads-svg]: http://ruby-gem-downloads-badge.herokuapp.com/glip_sdk
57
+ [downloads-link]: https://rubygems.org/gems/glip_sdk
58
+ [build-status-svg]: https://api.travis-ci.org/ringcentral-ruby/glip-sdk-ruby.svg?branch=master
59
+ [build-status-link]: https://travis-ci.org/ringcentral-ruby/glip-sdk-ruby
60
+ [coverage-status-svg]: https://coveralls.io/repos/ringcentral-ruby/glip-sdk-ruby/badge.svg?branch=master
61
+ [coverage-status-link]: https://coveralls.io/r/ringcentral-ruby/glip-sdk-ruby?branch=master
62
+ [dependency-status-svg]: https://gemnasium.com/ringcentral-ruby/glip-sdk-ruby.svg
63
+ [dependency-status-link]: https://gemnasium.com/ringcentral-ruby/glip-sdk-ruby
64
+ [codacy-svg]: https://api.codacy.com/project/badge/Grade/eb469b5958d04fd188c37a999ac3620d
65
+ [codacy-link]: https://www.codacy.com/app/ringcentral-ruby/glip-sdk-ruby
66
+ [codeclimate-status-svg]: https://codeclimate.com/github/ringcentral-ruby/glip-sdk-ruby/badges/gpa.svg
67
+ [codeclimate-status-link]: https://codeclimate.com/github/ringcentral-ruby/glip-sdk-ruby
68
+ [scrutinizer-status-svg]: https://scrutinizer-ci.com/g/ringcentral-ruby/glip-sdk-ruby/badges/quality-score.png?b=master
69
+ [scrutinizer-status-link]: https://scrutinizer-ci.com/g/ringcentral-ruby/glip-sdk-ruby/?branch=master
70
+ [docs-readthedocs-svg]: https://img.shields.io/badge/docs-readthedocs-blue.svg
71
+ [docs-rubydoc-link]: http://www.rubydoc.info/gems/ringcentral_sdk/
72
+ [license-svg]: https://img.shields.io/badge/license-MIT-blue.svg
73
+ [license-link]: https://github.com/ringcentral-ruby/glip-sdk-ruby/blob/master/LICENSE.md
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+
4
+ desc 'Default: run unit tests.'
5
+ task default: :test
6
+
7
+ desc 'Test the library.'
8
+ Rake::TestTask.new do |t|
9
+ t.libs << 'lib'
10
+ t.pattern = 'test/**/test_*.rb'
11
+ t.verbose = false
12
+ end
13
+
14
+ desc 'Generate YARD documentation.'
15
+ task :gendoc do
16
+ # puts 'yard doc generation disabled until JRuby build native extensions for redcarpet or yard removes the dependency.'
17
+ system 'yardoc'
18
+ system 'yard stats --list-undoc'
19
+ end
@@ -0,0 +1,37 @@
1
+ module GlipSdk::REST::Cache
2
+ class Groups
3
+ attr_accessor :groups
4
+ attr_accessor :groups_name2id
5
+ attr_accessor :teams
6
+ attr_accessor :teams_name2id
7
+ def initialize
8
+ @groups = {}
9
+ @teams = {}
10
+ @teams_name2id = {}
11
+ @groups_name2id = {}
12
+ end
13
+
14
+ def load_groups(groups)
15
+ groups.each { |g| load_group g }
16
+ end
17
+
18
+ def load_group(group)
19
+ if group.key? 'id'
20
+ id = group['id']
21
+ type = group['type']
22
+ if type.to_s.downcase == 'team'
23
+ @teams[id.to_s] = group
24
+ @teams_name2id[group['name']] = id.to_s
25
+ else
26
+ @groups[id.to_s] = group
27
+ @groups_name2id[group['name']] = id.to_s
28
+ end
29
+ end
30
+ end
31
+
32
+ def team_by_name(name)
33
+ # Innovation & Ops Extended Staff
34
+ @teams[name.to_s]
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,7 @@
1
+ module GlipSdk
2
+ module REST
3
+ module Cache
4
+ autoload :Groups, 'glip_sdk/rest/cache/groups'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,54 @@
1
+ module GlipSdk
2
+ module REST
3
+ class Client
4
+ attr_accessor :api
5
+ attr_accessor :logger
6
+ attr_accessor :groups
7
+ attr_accessor :persons
8
+ attr_accessor :posts
9
+
10
+ def initialize(rc_sdk)
11
+ @api = rc_sdk
12
+ @logger = @api.config.logger
13
+ @groups = GlipSdk::REST::Groups.new @api
14
+ @persons = GlipSdk::REST::Persons.new @api
15
+ @posts = GlipSdk::REST::Posts.new @api
16
+ end
17
+
18
+ def load_groups
19
+ res = @groups.get.http.get 'glip/groups'
20
+ @groups_cache = GlipSdk::REST::Cache::Groups.new
21
+ @groups.load_groups(res.body['records'])
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ =begin
28
+ def post_message(opts = {})
29
+ unless opts.key? :text
30
+ fail "Text must be provided to post message"
31
+ end
32
+
33
+ unless opts.key?(:group_id) || opts.key?(:group_name)
34
+ fail "Group Id or Group Name must be provided"
35
+ end
36
+
37
+ group_id = (opts.key?(:group_name) && !opts.key?(:group_id)) \
38
+ ? @groups.groups_name2id[opts[:group_name]] : opts[:group_id]
39
+
40
+ @api.http.post do |req|
41
+ req.url 'glip/posts'
42
+ req.headers['Content-Type'] = 'application/json'
43
+ req.body = { groupId: group_id, text: opts[:text] }
44
+ end
45
+ end
46
+
47
+ def observe(observer)
48
+ @subscription = @api.create_subscription()
49
+ @subscription.subscribe([
50
+ "/restapi/v1.0/account/~/extension/~/glip/posts"
51
+ ])
52
+ @subscription.add_observer observer
53
+ end
54
+ =end
@@ -0,0 +1,24 @@
1
+ module GlipSdk
2
+ module REST
3
+ class Groups
4
+ attr_accessor :subscription
5
+
6
+ def initialize(rc_sdk)
7
+ @api = rc_sdk
8
+ end
9
+
10
+ def get(opts = {})
11
+ if opts.key? :groupId
12
+ return @api.http.get "glip/groups/#{opts[:groupId]}"
13
+ end
14
+ @api.http.get 'glip/groups', opts
15
+ end
16
+
17
+ def observe(observer)
18
+ @subscription = @api.create_subscription
19
+ @subscription.subscribe ['/restapi/v1.0/account/~/extension/~/glip/groups']
20
+ @subscription.add_observer observer
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ module GlipSdk
2
+ module REST
3
+ class Persons
4
+ def initialize(rc_sdk)
5
+ @api = rc_sdk
6
+ end
7
+
8
+ def get(opts = {})
9
+ if opts.key? :personId
10
+ return @api.http.get "glip/persons/#{opts[:personId]}"
11
+ end
12
+ nil
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,45 @@
1
+ module GlipSdk
2
+ module REST
3
+ class Posts
4
+ def initialize(rc_sdk)
5
+ @api = rc_sdk
6
+ end
7
+
8
+ def post(opts = {})
9
+ unless opts.key? :text
10
+ raise ArgumentError, "Text must be provided to post message"
11
+ end
12
+
13
+ unless opts.key?(:groupId) || opts.key?(:groupName)
14
+ raise ArgumentError, "Group Id or Group Name must be provided"
15
+ end
16
+
17
+ group_id = (opts.key?(:groupName) && !opts.key?(:groupId)) \
18
+ ? @groups.groups_name2id[opts[:groupName]] : opts[:groupId]
19
+
20
+ @api.http.post do |req|
21
+ req.url 'glip/posts'
22
+ req.headers['Content-Type'] = 'application/json'
23
+ req.body = { groupId: group_id, text: opts[:text] }
24
+ end
25
+ end
26
+
27
+ def get(opts = {})
28
+ if opts.key? :postId
29
+ return @api.http.get "glip/posts/#{opts[:postId]}"
30
+ end
31
+ @api.http.get do |req|
32
+ req.url "glip/posts"
33
+ req.headers['Content-Type'] = 'application/json'
34
+ req.body = opts
35
+ end
36
+ end
37
+
38
+ def observe(observer)
39
+ @subscription = @api.create_subscription()
40
+ @subscription.subscribe(['/restapi/v1.0/account/~/extension/~/glip/posts'])
41
+ @subscription.add_observer observer
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,11 @@
1
+ module GlipSdk
2
+ # REST is the namespace for the RingCentral REST API class in the
3
+ # RingCentral Ruby SDK
4
+ module REST
5
+ autoload :Cache, 'glip_sdk/rest/cache'
6
+ autoload :Client, 'glip_sdk/rest/client'
7
+ autoload :Groups, 'glip_sdk/rest/groups'
8
+ autoload :Persons, 'glip_sdk/rest/persons'
9
+ autoload :Posts, 'glip_sdk/rest/posts'
10
+ end
11
+ end
data/lib/glip_sdk.rb ADDED
@@ -0,0 +1,11 @@
1
+ module GlipSdk
2
+ VERSION = '0.0.1'
3
+
4
+ autoload :REST, 'glip_sdk/rest'
5
+
6
+ class << self
7
+ def new(client, opts = {})
8
+ GlipSdk::REST::Client.new client, opts
9
+ end
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: glip_sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - John Wang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ringcentral_sdk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1'
47
+ - !ruby/object:Gem::Dependency
48
+ name: coveralls
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: mocha
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rake
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '12'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '12'
89
+ - !ruby/object:Gem::Dependency
90
+ name: simplecov
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: test-unit
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '3'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '3'
117
+ description: A Ruby SDK for the Glip collaboration solution
118
+ email: johncwang@gmail.com
119
+ executables: []
120
+ extensions: []
121
+ extra_rdoc_files: []
122
+ files:
123
+ - CHANGELOG.md
124
+ - Gemfile
125
+ - LICENSE.md
126
+ - README.md
127
+ - Rakefile
128
+ - lib/glip_sdk.rb
129
+ - lib/glip_sdk/rest.rb
130
+ - lib/glip_sdk/rest/cache.rb
131
+ - lib/glip_sdk/rest/cache/groups.rb
132
+ - lib/glip_sdk/rest/client.rb
133
+ - lib/glip_sdk/rest/groups.rb
134
+ - lib/glip_sdk/rest/persons.rb
135
+ - lib/glip_sdk/rest/posts.rb
136
+ homepage: https://github.com/grokify/
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: 2.2.2
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.5.2
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Glip SDK client for Ruby
160
+ test_files: []