ringcentral-rss 0.0.2 → 0.0.3

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: 3d844f42c65b7365305378fcf2cd7d0415b22f09
4
- data.tar.gz: 370dd56d4b7c40a60c134564935009d2933108f2
3
+ metadata.gz: db25e81b6d8b5ae39d1d9600fa87b4b31de905f8
4
+ data.tar.gz: f2dc8d51fbbffc5a2740061a70a9349465ac6588
5
5
  SHA512:
6
- metadata.gz: 0cec2cecf9aa6f228dd652691a62c02746b9a7db46893c00e3c5eb00bb146d6f9132a1230da7093ae7f6ec740cf76b0756fa053747040fb88cca99b679ed63b7
7
- data.tar.gz: 77b292b6f30e799c2d7d9eded33f673608cfa350a228c837fcbead940775fa22e98bb8a5c57d58c05ebe6e246f2754493dc7a26cbc656333c873b0caaed2e33c
6
+ metadata.gz: da8609e3c27717d33c5c76509d2f58dc058f752f0e93714e9eb4ea589b43560d8d03076565ab05081c386683e3731665b86ce0929d9d807d6fb34fe1d4f55dcf
7
+ data.tar.gz: d950ba999e5dacd84cb1ab5d8986480c07d3d14cb1e2630ccba2fdb3b9e2124cfde29c1ce26ab626dae9cdfb5e67e729f17aee8bd4059a11435dfe7142985f5c
data/README.md CHANGED
@@ -39,9 +39,9 @@ res = client.http.get do |req|
39
39
  end
40
40
 
41
41
  rc_feed = RingCentral::RSS::AtomFeed.new res
42
- xml = rc_feed.feed.to_xml
42
+ xml = rc_feed.to_xml
43
43
 
44
- xml = RingCentral::RSS::AtomFeed.new(res).feed.to_xml
44
+ xml = RingCentral::RSS::AtomFeed.new(res).to_xml
45
45
  ```
46
46
 
47
47
  ## Demo Scripts
@@ -55,9 +55,9 @@ Demo scripts are located in the [`scripts` directory of the GitHub repo](https:/
55
55
 
56
56
  The genesis of this is the requirement to have RingCentral SMS messages available via a RSS feed. There are 3 ways to accomplish this:
57
57
 
58
- 1. Have a proxy feed that always retrieves the message-store API response and converts it to RSS
59
- 1. Have a script that polls the message-store API and publishes to a remote feed
60
- 1. Have a script that subscribes to the message-store eventFilter and publishes to a remote feed
58
+ 1. Have a proxy feed that always retrieves the `message-store` API response and converts it to RSS
59
+ 1. Have a script that subscribes to the `message-store` eventFilter and publishes to a remote feed
60
+ 1. Have a script that polls the `message-store` API and publishes to a remote feed
61
61
 
62
62
  The library code will convert RingCentral message-store API response and message objects into an XML feed. The included Sinatra web service will host this as a proxy feed (option #1 above).
63
63
 
@@ -3,6 +3,6 @@ require 'ringcentral-rss/atom_feed'
3
3
 
4
4
  module RingCentral
5
5
  module RSS
6
- VERSION = '0.0.2'.freeze
6
+ VERSION = '0.0.3'.freeze
7
7
  end
8
8
  end
@@ -11,6 +11,7 @@ module RingCentral
11
11
  else
12
12
  @feed_name = 'RingCentral Feed'
13
13
  end
14
+ @feed = nil
14
15
  load_message_store_response(response) unless response.nil?
15
16
  end
16
17
 
@@ -24,6 +25,10 @@ module RingCentral
24
25
  end
25
26
  end
26
27
  end
28
+
29
+ def to_xml
30
+ (!@feed.nil? && @feed.is_a?(Atom::Feed)) ? @feed.to_xml : nil
31
+ end
27
32
  end
28
33
  end
29
34
  end
@@ -0,0 +1,31 @@
1
+ require './test/test_base.rb'
2
+ require 'ringcentral-rss'
3
+ require 'nokogiri'
4
+
5
+ class RingCentralRSSEntryTest < Test::Unit::TestCase
6
+
7
+ def test_main
8
+ message = {
9
+ 'to' => [{'phoneNumber' => '+16505551212'}],
10
+ 'from' => {'phoneNumber' => '+14155551212'},
11
+ 'subject' => 'hello world!',
12
+ 'direction' => 'Inbound',
13
+ 'type' => 'SMS',
14
+ 'lastModifiedTime' => '2015-01-01T00:00:00+0000'
15
+ }
16
+
17
+ entry = RingCentral::RSS::AtomEntry.new message
18
+ xml = entry.entry.to_xml
19
+
20
+ doc = Nokogiri::XML xml
21
+ doc.remove_namespaces!
22
+
23
+ doc.xpath('//summary').each do |el|
24
+ assert_equal message['subject'], el.text
25
+ end
26
+
27
+ doc.xpath('//title').each do |el|
28
+ assert_equal entry.build_title(message), el.text
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,62 @@
1
+ require './test/test_base.rb'
2
+ require 'faraday'
3
+ require 'nokogiri'
4
+ require 'ringcentral-rss'
5
+
6
+ class RingCentralRSSFeedTest < Test::Unit::TestCase
7
+
8
+ def test_main
9
+ headers = {'date' => 'Wed, 09 Nov 2016 06:46:16 GMT'}
10
+ xml_time = '2016-11-09T06:46:16+00:00'
11
+
12
+ message = {
13
+ 'to' => [{'phoneNumber' => '+16505551212'}],
14
+ 'from' => {'phoneNumber' => '+14155551212'},
15
+ 'subject' => 'hello world!',
16
+ 'direction' => 'Inbound',
17
+ 'type' => 'SMS',
18
+ 'lastModifiedTime' => '2015-01-01T00:00:00+0000'
19
+ }
20
+
21
+ body = {
22
+ 'uri' => 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/message-store',
23
+ 'records' => [ message ]
24
+ }
25
+
26
+ stubs = Faraday::Adapter::Test::Stubs.new do |stub|
27
+ stub.get('/message-store') { |env| [200, headers, body] }
28
+ end
29
+
30
+ test = Faraday.new do |builder|
31
+ builder.adapter :test, stubs
32
+ end
33
+
34
+ res = test.get '/message-store'
35
+
36
+ feed = RingCentral::RSS::AtomFeed.new
37
+ assert_equal nil, feed.to_xml
38
+
39
+ feed.load_message_store_response res
40
+
41
+ xml = feed.to_xml
42
+
43
+ doc = Nokogiri::XML xml
44
+ doc.remove_namespaces!
45
+
46
+ doc.xpath('//feed/link').each do |el|
47
+ assert_equal body['uri'], el.attribute('href').value
48
+ end
49
+
50
+ doc.xpath('//feed/title').each do |el|
51
+ assert_equal 'RingCentral Feed', el.text
52
+ end
53
+
54
+ doc.xpath('//feed/updated').each do |el|
55
+ assert_equal xml_time, el.text
56
+ end
57
+
58
+ doc.xpath('//feed/entry/summary').each do |el|
59
+ assert_equal message['subject'], el.text
60
+ end
61
+ end
62
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ringcentral-rss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-07 00:00:00.000000000 Z
11
+ date: 2016-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ratom
@@ -44,6 +44,34 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: faraday
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0.9'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0.9'
61
+ - !ruby/object:Gem::Dependency
62
+ name: nokogiri
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.6'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.6'
47
75
  - !ruby/object:Gem::Dependency
48
76
  name: rake
49
77
  requirement: !ruby/object:Gem::Requirement
@@ -101,6 +129,8 @@ files:
101
129
  - lib/ringcentral-rss/atom_entry.rb
102
130
  - lib/ringcentral-rss/atom_feed.rb
103
131
  - test/test_base.rb
132
+ - test/test_entry.rb
133
+ - test/test_feed.rb
104
134
  - test/test_setup.rb
105
135
  homepage: https://github.com/grokify/
106
136
  licenses: