ringcentral-rss 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c6627647cd565186e2efd9299aa2591d25768ce5
4
+ data.tar.gz: e8629c4031f2bebf5858260d5f379ee8b1506812
5
+ SHA512:
6
+ metadata.gz: df0121ba74796b9a7fa15ed395193e818f21dc79a1d52bd492f25e2cf8170a7d27dc0b6016fe85c38900337b42acbe6b9da9ccfc3634896da8dfdb331e9a9a8d
7
+ data.tar.gz: 20498982cf5f979acdbcebda2ab94900ed2a3c504a8bd4ac8680da6e45615db9636882de3e64eaa32e79854f0127fdb97a4c87092760959d32c8e4175bab4c45
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ CHANGELOG
2
+ ---------
3
+ - **2016-01-07**: 0.0.1
4
+ - Misc
5
+ - 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,92 @@
1
+ RingCentral RSS
2
+ ===============
3
+
4
+ [![Gem Version][gem-version-svg]][gem-version-link]
5
+ [![Build Status][build-status-svg]][build-status-link]
6
+ [![Coverage Status][coverage-status-svg]][coverage-status-link]
7
+ [![Dependency Status][dependency-status-svg]][dependency-status-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
+ Ruby library to create XML syndication feeds for RingCentral `message-store` REST API responses.
15
+
16
+ This library was originally created in response to a question on (archiving RingCentral SMS data using Smarsh via a RSS feed](https://devcommunity.ringcentral.com/ringcentraldev/topics/archive-sms-using-rss).
17
+
18
+ ## Usage
19
+
20
+ ```ruby
21
+ client = RingCentralSdk.new [...]
22
+ client.authorize [...]
23
+
24
+ res = client.http.get do |req|
25
+ req.url = 'account/~/extension/~/message-store'
26
+ req.params['direction'] = 'Outbound'
27
+ req.params['messageType'] = 'SMS'
28
+ end
29
+
30
+ rc_feed = RingCentral::RSS::AtomFeed.new res
31
+ xml = rc_feed.feed.to_xml
32
+
33
+ xml = RingCentral::RSS::AtomFeed.new(res).feed.to_xml
34
+ ```
35
+
36
+ ## Demo Scripts
37
+
38
+ Demo scripts are located in the [`scripts` directory of the GitHub repo](https://github.com/ringcentral-ruby/ringcentral-rss-ruby/tree/master/scripts). The following demos are included:
39
+
40
+ * CLI script to retrieve `message-store` endpoint and print out XML
41
+ * Sinatra web service to display XML
42
+
43
+ ### Change Log
44
+
45
+ See [CHANGELOG.md](CHANGELOG.md)
46
+
47
+ ## Links
48
+
49
+ Project Repo
50
+
51
+ * https://github.com/ringcentral-ruby/ringcentral-rss
52
+
53
+ RingCentral API Docs
54
+
55
+ * https://developers.ringcentral.com/library.html
56
+
57
+ RingCentral Official SDKs
58
+
59
+ * https://github.com/ringcentral
60
+
61
+ ## Contributing
62
+
63
+ 1. Fork it ( http://github.com/ringcentral-ruby/ringcentral-rss/fork )
64
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
65
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
66
+ 4. Push to the branch (`git push origin my-new-feature`)
67
+ 5. Create new Pull Request
68
+
69
+ ## License
70
+
71
+ RingCentral RSS is available under an MIT-style license. See [LICENSE.md](LICENSE.md) for details.
72
+
73
+ RingCentral RSS © 2016 by John Wang
74
+
75
+ [gem-version-svg]: https://badge.fury.io/rb/ringcentral-rss.svg
76
+ [gem-version-link]: http://badge.fury.io/rb/ringcentral-rss
77
+ [downloads-svg]: http://ruby-gem-downloads-badge.herokuapp.com/ringcentral-rss
78
+ [downloads-link]: https://rubygems.org/gems/ringcentral-rss
79
+ [build-status-svg]: https://api.travis-ci.org/ringcentral-ruby/ringcentral-rss-ruby.svg?branch=master
80
+ [build-status-link]: https://travis-ci.org/ringcentral-ruby/ringcentral-rss-ruby
81
+ [coverage-status-svg]: https://coveralls.io/repos/ringcentral-ruby/ringcentral-rss-ruby/badge.svg?branch=master
82
+ [coverage-status-link]: https://coveralls.io/r/ringcentral-ruby/ringcentral-rss-ruby?branch=master
83
+ [dependency-status-svg]: https://gemnasium.com/ringcentral-ruby/ringcentral-rss-ruby.svg
84
+ [dependency-status-link]: https://gemnasium.com/ringcentral-ruby/ringcentral-rss-ruby
85
+ [codeclimate-status-svg]: https://codeclimate.com/github/ringcentral-ruby/ringcentral-rss-ruby/badges/gpa.svg
86
+ [codeclimate-status-link]: https://codeclimate.com/github/ringcentral-ruby/ringcentral-rss-ruby
87
+ [scrutinizer-status-svg]: https://scrutinizer-ci.com/g/ringcentral-ruby/ringcentral-rss-ruby/badges/quality-score.png?b=master
88
+ [scrutinizer-status-link]: https://scrutinizer-ci.com/g/ringcentral-ruby/ringcentral-rss-ruby/?branch=master
89
+ [docs-rubydoc-svg]: https://img.shields.io/badge/docs-rubydoc-blue.svg
90
+ [docs-rubydoc-link]: http://www.rubydoc.info/gems/ringcentral-rss/
91
+ [license-svg]: https://img.shields.io/badge/license-MIT-blue.svg
92
+ [license-link]: https://github.com/ringcentral-ruby/ringcentral-rss-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,43 @@
1
+ require 'atom'
2
+
3
+ module RingCentral
4
+ module RSS
5
+ class AtomEntry
6
+ attr_accessor :entry
7
+
8
+ def initialize(data = nil)
9
+ load_message(data) unless data.nil?
10
+ end
11
+
12
+ def load_message(data)
13
+ raise 'Data is not a hash' unless data.is_a? Hash
14
+
15
+ @entry = Atom::Entry.new do |e|
16
+ e.title = build_title data
17
+ e.links << Atom::Link.new(href: data['uri'])
18
+ e.id = data['id']
19
+ e.updated = Time.parse(data['lastModifiedTime'])
20
+ e.summary = data['subject']
21
+ end
22
+ end
23
+
24
+ def build_title(data)
25
+ raise 'Data is not a hash' unless data.is_a? Hash
26
+
27
+ parts = []
28
+
29
+ if data.key?('to') && (data['to'].length > 0) && data['to'][0]['phoneNumber']
30
+ to_phone_number = "#{data['to'][0]['phoneNumber']}"
31
+ parts << "To: #{to_phone_number}" unless to_phone_number.empty?
32
+ end
33
+
34
+ if data.key?('from') && !data['from']['phoneNumber'].empty?
35
+ from_phone_number = "#{data['from']['phoneNumber']}"
36
+ parts << "From: #{from_phone_number}"
37
+ end
38
+
39
+ "[#{data['direction']} #{data['type']}] " + parts.join('; ')
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,29 @@
1
+ require 'atom'
2
+
3
+ module RingCentral
4
+ module RSS
5
+ class AtomFeed
6
+ attr_accessor :feed
7
+
8
+ def initialize(response = nil, opts = {})
9
+ if opts.key?(:feed_name) && opts[:feed_name]
10
+ @feed_name = opts[:feed_name]
11
+ else
12
+ @feed_name = 'RingCentral Feed'
13
+ end
14
+ load_message_store_response(response) unless response.nil?
15
+ end
16
+
17
+ def load_message_store_response(response)
18
+ @feed = Atom::Feed.new do |f|
19
+ f.title = @feed_name
20
+ f.links << Atom::Link.new(href: "#{response.body['uri']}")
21
+ f.updated = Time.parse("#{response.headers['date']}")
22
+ response.body['records'].each do |message|
23
+ f.entries << RingCentral::RSS::AtomEntry.new(message).entry
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,8 @@
1
+ require 'ringcentral-rss/atom_entry'
2
+ require 'ringcentral-rss/atom_feed'
3
+
4
+ module RingCentral
5
+ module RSS
6
+ VERSION = '0.0.1'.freeze
7
+ end
8
+ end
data/test/test_base.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ require 'test/unit'
5
+ require 'ringcentral-rss'
@@ -0,0 +1,13 @@
1
+ require './test/test_base.rb'
2
+ require 'ringcentral-rss'
3
+
4
+ class RingCentralRSSTest < Test::Unit::TestCase
5
+
6
+ def test_main
7
+ feed = RingCentral::RSS::AtomFeed.new
8
+ assert_equal 'RingCentral::RSS::AtomFeed', feed.class.name
9
+
10
+ entry = RingCentral::RSS::AtomEntry.new
11
+ assert_equal 'RingCentral::RSS::AtomEntry', entry.class.name
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ringcentral-rss
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-11-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ratom
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.9.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.9.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: coveralls
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '11'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '11'
61
+ - !ruby/object:Gem::Dependency
62
+ name: simplecov
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: test-unit
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3'
89
+ description: Convert RingCentral Message Store Results to RSS
90
+ email: johncwang@gmail.com
91
+ executables: []
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - CHANGELOG.md
96
+ - Gemfile
97
+ - LICENSE.md
98
+ - README.md
99
+ - Rakefile
100
+ - lib/ringcentral-rss.rb
101
+ - lib/ringcentral-rss/atom_entry.rb
102
+ - lib/ringcentral-rss/atom_feed.rb
103
+ - test/test_base.rb
104
+ - test/test_setup.rb
105
+ homepage: https://github.com/grokify/
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 2.2.2
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.6.7
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: RingCentral RSS - Convert RingCentral Message Store Results to RSS
129
+ test_files: []