connfu-client 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.
- data/.rspec +3 -0
- data/.rvmrc +2 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +120 -0
- data/LICENSE.txt +661 -0
- data/README.rdoc +398 -0
- data/Rakefile +38 -0
- data/bin/.DS_Store +0 -0
- data/bin/connfu-client +94 -0
- data/connfu-client.gemspec +41 -0
- data/examples/conference/application.rb +68 -0
- data/examples/conference/conference.rb +33 -0
- data/examples/conference/conference_app.rb +25 -0
- data/examples/conference/connfu.log +5 -0
- data/examples/conference/wall.rb +11 -0
- data/examples/provisioning/app/get.rb +29 -0
- data/examples/provisioning/channels/get.rb +34 -0
- data/examples/provisioning/rss/create.rb +28 -0
- data/examples/provisioning/rss/delete.rb +27 -0
- data/examples/provisioning/rss/get.rb +32 -0
- data/examples/provisioning/rss/put.rb +29 -0
- data/examples/provisioning/setup.rb +2 -0
- data/examples/provisioning/twitter/create.rb +31 -0
- data/examples/provisioning/twitter/delete.rb +27 -0
- data/examples/provisioning/twitter/get.rb +32 -0
- data/examples/provisioning/twitter/put.rb +29 -0
- data/examples/provisioning/voice/create.rb +26 -0
- data/examples/provisioning/voice/delete.rb +27 -0
- data/examples/provisioning/voice/get.rb +36 -0
- data/examples/provisioning/voice/phones/create.rb +26 -0
- data/examples/provisioning/voice/phones/delete.rb +28 -0
- data/examples/provisioning/voice/phones/get.rb +38 -0
- data/examples/provisioning/voice/put.rb +38 -0
- data/examples/provisioning/voice/whitelist/create.rb +26 -0
- data/examples/provisioning/voice/whitelist/delete.rb +27 -0
- data/examples/provisioning/voice/whitelist/get.rb +36 -0
- data/examples/provisioning/voice/whitelist/put.rb +27 -0
- data/lib/connfu.rb +134 -0
- data/lib/connfu/cli/generator.rb +71 -0
- data/lib/connfu/connfu_logger.rb +88 -0
- data/lib/connfu/connfu_message_formatter.rb +134 -0
- data/lib/connfu/connfu_stream.rb +182 -0
- data/lib/connfu/dispatcher.rb +164 -0
- data/lib/connfu/dsl.rb +84 -0
- data/lib/connfu/events.rb +32 -0
- data/lib/connfu/listener.rb +85 -0
- data/lib/connfu/listener_channel.rb +100 -0
- data/lib/connfu/message.rb +74 -0
- data/lib/connfu/provisioning.rb +12 -0
- data/lib/connfu/provisioning/application.rb +374 -0
- data/lib/connfu/provisioning/base.rb +95 -0
- data/lib/connfu/provisioning/channel.rb +79 -0
- data/lib/connfu/provisioning/phone.rb +55 -0
- data/lib/connfu/provisioning/rss.rb +21 -0
- data/lib/connfu/provisioning/twitter.rb +28 -0
- data/lib/connfu/provisioning/voice.rb +89 -0
- data/lib/connfu/provisioning/whitelist.rb +62 -0
- data/lib/connfu/version.rb +6 -0
- data/lib/rdoc/generator/template/connfu/_context.rhtml +209 -0
- data/lib/rdoc/generator/template/connfu/_head.rhtml +7 -0
- data/lib/rdoc/generator/template/connfu/class.rhtml +38 -0
- data/lib/rdoc/generator/template/connfu/file.rhtml +36 -0
- data/lib/rdoc/generator/template/connfu/index.rhtml +13 -0
- data/lib/rdoc/generator/template/connfu/resources/apple-touch-icon.png +0 -0
- data/lib/rdoc/generator/template/connfu/resources/css/github.css +129 -0
- data/lib/rdoc/generator/template/connfu/resources/css/main.css +339 -0
- data/lib/rdoc/generator/template/connfu/resources/css/panel.css +389 -0
- data/lib/rdoc/generator/template/connfu/resources/css/reset.css +53 -0
- data/lib/rdoc/generator/template/connfu/resources/favicon.ico +0 -0
- data/lib/rdoc/generator/template/connfu/resources/i/arrows.png +0 -0
- data/lib/rdoc/generator/template/connfu/resources/i/results_bg.png +0 -0
- data/lib/rdoc/generator/template/connfu/resources/i/tree_bg.png +0 -0
- data/lib/rdoc/generator/template/connfu/resources/js/highlight.pack.js +1 -0
- data/lib/rdoc/generator/template/connfu/resources/js/jquery-1.3.2.min.js +19 -0
- data/lib/rdoc/generator/template/connfu/resources/js/jquery-effect.js +593 -0
- data/lib/rdoc/generator/template/connfu/resources/js/main.js +20 -0
- data/lib/rdoc/generator/template/connfu/resources/js/searchdoc.js +628 -0
- data/lib/rdoc/generator/template/connfu/resources/panel/index.html +72 -0
- data/lib/rdoc/generator/template/connfu/se_index.rhtml +8 -0
- data/spec/connfu_message_formatter_spec.rb +88 -0
- data/spec/connfu_spec.rb +51 -0
- data/spec/connfu_stream_spec.rb +84 -0
- data/spec/dispatcher_spec.rb +227 -0
- data/spec/dsl_spec.rb +159 -0
- data/spec/listener_channel_spec.rb +130 -0
- data/spec/listener_spec.rb +67 -0
- data/spec/provisioning/application_spec.rb +47 -0
- data/spec/provisioning/channel_shared_examples.rb +52 -0
- data/spec/provisioning/channel_spec.rb +13 -0
- data/spec/provisioning/phone_spec.rb +88 -0
- data/spec/provisioning/voice_spec.rb +138 -0
- data/spec/provisioning_spec.rb +500 -0
- data/spec/spec_helper.rb +51 -0
- metadata +298 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#
|
|
2
|
+
# connFu is a platform of Telefonica delivered by Bluevia Labs
|
|
3
|
+
# Please, check out www.connfu.com and if you need more information
|
|
4
|
+
# contact us at mailto:support@connfu.com
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
require 'spec_helper'
|
|
8
|
+
require 'provisioning/channel_shared_examples'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
describe Connfu::Provisioning::Channel do
|
|
12
|
+
it_should_behave_like "Channel", Connfu::Provisioning::Channel.new(channel_attrs.merge({"uid" => CHANNEL_KEY, "type" => ""}))
|
|
13
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#
|
|
2
|
+
# connFu is a platform of Telefonica delivered by Bluevia Labs
|
|
3
|
+
# Please, check out www.connfu.com and if you need more information
|
|
4
|
+
# contact us at mailto:support@connfu.com
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
require 'connfu'
|
|
8
|
+
|
|
9
|
+
require 'spec_helper'
|
|
10
|
+
|
|
11
|
+
describe Connfu::Provisioning::Phone do
|
|
12
|
+
|
|
13
|
+
before(:each) do
|
|
14
|
+
@phone = Connfu::Provisioning::Phone.new(VOICE_KEY, PHONE_NUMBER, COUNTRY)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Matcher that helps to test if an Application instance is well defined after retrieving data using prov API
|
|
18
|
+
RSpec::Matchers.define :be_well_defined_as_phone do |voice_key, phone_number, country|
|
|
19
|
+
match do |phone|
|
|
20
|
+
phone.should be_instance_of(Connfu::Provisioning::Phone)
|
|
21
|
+
phone.voice.should eql(voice_key)
|
|
22
|
+
phone.phone_number.should eql(phone_number)
|
|
23
|
+
phone.country.should eql(country)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
context "while initializing" do
|
|
28
|
+
it "should set properly the instance attributes" do
|
|
29
|
+
@phone.should be_well_defined_as_phone(VOICE_KEY, PHONE_NUMBER, COUNTRY)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should retrieve the country instance variable using the [] method" do
|
|
33
|
+
@phone[:country].should eql(COUNTRY)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should retrieve the phone_number instance variable using the [] method" do
|
|
37
|
+
@phone[:phone_number].should eql(PHONE_NUMBER)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should retrieve the voice instance variable using the [] method" do
|
|
41
|
+
@phone[:voice].should eql(VOICE_KEY)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should retrieve nil using the [] method when the instance variable does not exists" do
|
|
45
|
+
@phone[:foo].should be_nil
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
context "while hashing" do
|
|
50
|
+
it "should include the country and phone_number" do
|
|
51
|
+
phone_hash = @phone.to_hash
|
|
52
|
+
phone_hash.should be_instance_of(Hash)
|
|
53
|
+
["country", "phone_number"].each{|key|
|
|
54
|
+
phone_hash.should have_key(key)
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should include the valid country value" do
|
|
59
|
+
phone_hash = @phone.to_hash
|
|
60
|
+
phone_hash["country"].should eql(COUNTRY)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "should include the valid phone_number value" do
|
|
64
|
+
phone_hash = @phone.to_hash
|
|
65
|
+
phone_hash["phone_number"].should eql(PHONE_NUMBER)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
context "while unmarshaling" do
|
|
70
|
+
let(:raw) {
|
|
71
|
+
{"phone_number" => PHONE_NUMBER, "country" => COUNTRY}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
it "should unmarshal successfully a single phone data" do
|
|
75
|
+
value = Connfu::Provisioning::Phone.unmarshal(VOICE_KEY, raw)
|
|
76
|
+
value.should be_well_defined_as_phone(VOICE_KEY, PHONE_NUMBER, COUNTRY)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "should unmarshal successfully a raw data with two phones" do
|
|
80
|
+
values = Connfu::Provisioning::Phone.unmarshal(VOICE_KEY, [raw, raw])
|
|
81
|
+
values.each{|value|
|
|
82
|
+
value.should be_well_defined_as_phone(VOICE_KEY, PHONE_NUMBER, COUNTRY)
|
|
83
|
+
}
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
end
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#
|
|
2
|
+
# connFu is a platform of Telefonica delivered by Bluevia Labs
|
|
3
|
+
# Please, check out www.connfu.com and if you need more information
|
|
4
|
+
# contact us at mailto:support@connfu.com
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
require 'spec_helper'
|
|
8
|
+
require 'provisioning/channel_shared_examples'
|
|
9
|
+
|
|
10
|
+
describe Connfu::Provisioning::Voice do
|
|
11
|
+
|
|
12
|
+
voice_attrs = channel_attrs.merge({:uid => VOICE_KEY,
|
|
13
|
+
:topic => TOPIC,
|
|
14
|
+
:welcome_message => WELCOME_MESSAGE,
|
|
15
|
+
:rejected_message => REJECTED_MESSAGE})
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
context "Voice" do
|
|
19
|
+
|
|
20
|
+
let(:phone) do
|
|
21
|
+
Connfu::Provisioning::Phone.new(VOICE_KEY, PHONE_NUMBER, COUNTRY)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
RSpec::Matchers.define :have_defined_voice_attributes do |expected|
|
|
25
|
+
match do |voice|
|
|
26
|
+
[:uid, :topic, :welcome_message, :rejected_message].each { |attribute|
|
|
27
|
+
voice.send(attribute).should eql(expected[attribute])
|
|
28
|
+
}
|
|
29
|
+
voice.type.should eql("voice")
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it_should_behave_like "Channel", Connfu::Provisioning::Voice.new(voice_attrs)
|
|
34
|
+
|
|
35
|
+
describe "while creating a Voice instance" do
|
|
36
|
+
it "should initialize properly the meaning attributes" do
|
|
37
|
+
voice = Connfu::Provisioning::Voice.new(voice_attrs)
|
|
38
|
+
|
|
39
|
+
voice.should be_instance_of(Connfu::Provisioning::Voice)
|
|
40
|
+
voice.should have_defined_voice_attributes voice_attrs
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should have an empty phones list" do
|
|
44
|
+
voice = Connfu::Provisioning::Voice.new(voice_attrs)
|
|
45
|
+
|
|
46
|
+
voice.phones.should be_instance_of(Array)
|
|
47
|
+
voice.phones.length.should eql(0)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe "handling phones" do
|
|
53
|
+
|
|
54
|
+
it "should be empty after initializing" do
|
|
55
|
+
voice = Connfu::Provisioning::Voice.new(voice_attrs)
|
|
56
|
+
voice.phones.should be_instance_of(Array)
|
|
57
|
+
voice.phones.length.should eql(0)
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should add a phone to the array phone list" do
|
|
62
|
+
voice = Connfu::Provisioning::Voice.new(voice_attrs)
|
|
63
|
+
|
|
64
|
+
voice.phones.push(phone)
|
|
65
|
+
voice.phones.length.should eql(1)
|
|
66
|
+
voice.phones[0].should be_instance_of(Connfu::Provisioning::Phone)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "should add a phone to the array phone list using the << method" do
|
|
70
|
+
voice = Connfu::Provisioning::Voice.new(voice_attrs)
|
|
71
|
+
|
|
72
|
+
voice << phone
|
|
73
|
+
voice.phones.length.should eql(1)
|
|
74
|
+
voice.phones[0].should be_instance_of(Connfu::Provisioning::Phone)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe "to_hash method" do
|
|
79
|
+
|
|
80
|
+
# Matcher that helps to test if a Voice channel is well defined after retrieving data using prov API
|
|
81
|
+
RSpec::Matchers.define :have_voice_details do |uid, phones|
|
|
82
|
+
match do |actual| # actual should be the Connfu::Provisioning::Voice instance
|
|
83
|
+
actual.should be_instance_of(Hash)
|
|
84
|
+
|
|
85
|
+
["uid", "type", "phones"].each{|key|
|
|
86
|
+
actual.should have_key(key)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
actual["uid"].should eql(uid)
|
|
90
|
+
actual["type"].should eql("voice")
|
|
91
|
+
|
|
92
|
+
actual["phones"].should be_instance_of(Array)
|
|
93
|
+
actual["phones"].length.should eql(phones.length)
|
|
94
|
+
|
|
95
|
+
actual["phones"].each_with_index{|phone, index|
|
|
96
|
+
phone.should be_instance_of(Hash)
|
|
97
|
+
["phone_number", "country"].each{|key|
|
|
98
|
+
phone.should have_key(key)
|
|
99
|
+
}
|
|
100
|
+
phone["phone_number"].should eql(phones[index][:phone_number])
|
|
101
|
+
phone["country"].should eql(phones[index][:country])
|
|
102
|
+
}
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "should retrieved uid, type and phones attributes (empty phones)" do
|
|
107
|
+
voice = Connfu::Provisioning::Voice.new(voice_attrs)
|
|
108
|
+
voice.to_hash.should have_voice_details(VOICE_KEY, [])
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it "should retrieved uid, type and phones attributes (phones with elements)" do
|
|
112
|
+
voice = Connfu::Provisioning::Voice.new(voice_attrs)
|
|
113
|
+
voice << phone
|
|
114
|
+
voice.to_hash.should have_voice_details(VOICE_KEY, [phone])
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it "should retrieved uid, type and phones attributes (phones two elements)" do
|
|
118
|
+
voice = Connfu::Provisioning::Voice.new(voice_attrs)
|
|
119
|
+
voice << phone
|
|
120
|
+
voice << phone
|
|
121
|
+
voice.to_hash.should have_voice_details(VOICE_KEY, [phone, phone])
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it "should retrieved uid, type and phones attributes (phones hundred elements)" do
|
|
125
|
+
voice = Connfu::Provisioning::Voice.new(voice_attrs)
|
|
126
|
+
data = []
|
|
127
|
+
100.times do
|
|
128
|
+
voice << phone
|
|
129
|
+
data << phone
|
|
130
|
+
end
|
|
131
|
+
voice.to_hash.should have_voice_details(VOICE_KEY, data)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
end
|
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
#
|
|
2
|
+
# connFu is a platform of Telefonica delivered by Bluevia Labs
|
|
3
|
+
# Please, check out www.connfu.com and if you need more information
|
|
4
|
+
# contact us at mailto:support@connfu.com
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
require 'spec_helper'
|
|
8
|
+
|
|
9
|
+
require 'webmock/rspec'
|
|
10
|
+
|
|
11
|
+
describe Connfu::Provisioning do
|
|
12
|
+
|
|
13
|
+
before(:each) do
|
|
14
|
+
@application = Connfu::Provisioning::Application.new(API_KEY, ENDPOINT)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Matcher that helps to test if a Voice channel is well defined after retrieving data using prov API
|
|
18
|
+
RSpec::Matchers.define :be_well_defined_as_voice do |uid, phones|
|
|
19
|
+
match do |actual| # actual should be the Connfu::Provisioning::Voice instance
|
|
20
|
+
actual.should be_instance_of(Connfu::Provisioning::Voice)
|
|
21
|
+
["uid", "type", "phones"].each { |key|
|
|
22
|
+
actual.to_hash.should have_key(key)
|
|
23
|
+
}
|
|
24
|
+
actual.uid.should eql(uid)
|
|
25
|
+
actual.type.should eql("voice")
|
|
26
|
+
|
|
27
|
+
actual.should respond_to("topic")
|
|
28
|
+
actual.should respond_to("welcome_message")
|
|
29
|
+
actual.should respond_to("rejected_message")
|
|
30
|
+
actual.should respond_to("privacy")
|
|
31
|
+
|
|
32
|
+
actual.phones.should be_instance_of(Array)
|
|
33
|
+
actual.phones.length.should eql(phones.length)
|
|
34
|
+
|
|
35
|
+
actual.phones.each_with_index { |phone, index|
|
|
36
|
+
["phone_number", "country"].each { |key|
|
|
37
|
+
phone.should respond_to(key.to_sym)
|
|
38
|
+
}
|
|
39
|
+
phone.phone_number.should eql(phones[index][:phone_number])
|
|
40
|
+
phone.country.should eql(phones[index][:country])
|
|
41
|
+
}
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Matcher that helps to test if a Twitter channel is well defined after retrieving data using prov API
|
|
46
|
+
RSpec::Matchers.define :be_well_defined_as_twitter do |uid, twitter_accounts|
|
|
47
|
+
match do |actual| # actual should be the Connfu::Provisioning::Twitter instance
|
|
48
|
+
actual.should be_instance_of(Connfu::Provisioning::Twitter)
|
|
49
|
+
["uid", "type", "accounts"].each { |key|
|
|
50
|
+
actual.to_hash.should have_key(key)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
actual.uid.should eql(uid)
|
|
54
|
+
actual.type.should eql("twitter")
|
|
55
|
+
|
|
56
|
+
actual.accounts.should be_instance_of(Array)
|
|
57
|
+
actual.accounts.length.should eql(twitter_accounts.length)
|
|
58
|
+
|
|
59
|
+
actual.accounts.each_with_index { |account, index|
|
|
60
|
+
account.should have_key("name")
|
|
61
|
+
account["name"].should eql(twitter_accounts[index])
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context "channels" do
|
|
67
|
+
|
|
68
|
+
context "all channels" do
|
|
69
|
+
it "should retrieve all the channels that owns an application" do
|
|
70
|
+
stub_request(:get, "#{ENDPOINT}/channels/?").
|
|
71
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
72
|
+
to_return(:status => 200, :body => '[{"accounts":[{"name":"juandebravo"},{"name":"connfudev"}],"created_at":"2011-07-26T22:13:06+03:00","filter":"","uid":"twitter","updated_at":"2011-08-07T13:07:57+03:00","user_id":"user_id","type":"twitter"},{"country":"uk","created_at":"2011-08-07T14:39:14+03:00","phone":"441111112222","topic":"conference","uid":"juan-voice","updated_at":"2011-08-07T14:41:25+03:00","user_id":"user_id","type":"voice"}]', :headers => {})
|
|
73
|
+
|
|
74
|
+
channels = @application.get_channels
|
|
75
|
+
channels.should be_instance_of(Array)
|
|
76
|
+
channels.length.should eql(2)
|
|
77
|
+
voice_channels = channels.select { |channel| channel.instance_of?(Connfu::Provisioning::Voice) }
|
|
78
|
+
twitter_channels = channels.select { |channel| channel.instance_of?(Connfu::Provisioning::Twitter) }
|
|
79
|
+
voice_channels.length.should eql(1)
|
|
80
|
+
twitter_channels.length.should eql(1)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
context "twitter" do
|
|
85
|
+
it "should create a Twitter channel application with one origin speficied as array" do
|
|
86
|
+
stub_request(:post, "#{ENDPOINT}/channels/twitter").
|
|
87
|
+
with(:body => create_twitter_channel_request(["juan"]), :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
88
|
+
to_return(:status => 201, :body => "", :headers => {:location => "#{ENDPOINT}/channels/twitter/#{TWITTER_KEY}"})
|
|
89
|
+
|
|
90
|
+
response = @application.create_twitter_channel(TWITTER_KEY, ["juan"])
|
|
91
|
+
response.should eql("#{ENDPOINT}/channels/twitter/#{TWITTER_KEY}")
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "should create a Twitter channel application with one origins speficied as hash (string)" do
|
|
95
|
+
stub_request(:post, "#{ENDPOINT}/channels/twitter").
|
|
96
|
+
with(:body => create_twitter_channel_request(["juan"]), :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
97
|
+
to_return(:status => 201, :body => "", :headers => {:location => "#{ENDPOINT}/channels/twitter/#{TWITTER_KEY}"})
|
|
98
|
+
|
|
99
|
+
response = @application.create_twitter_channel(TWITTER_KEY, {:origin => "juan"})
|
|
100
|
+
response.should eql("#{ENDPOINT}/channels/twitter/#{TWITTER_KEY}")
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "should create a Twitter channel application with one origins speficied as hash (array)" do
|
|
104
|
+
stub_request(:post, "#{ENDPOINT}/channels/twitter").
|
|
105
|
+
with(:body => create_twitter_channel_request(["juan"]), :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
106
|
+
to_return(:status => 201, :body => "", :headers => {:location => "#{ENDPOINT}/channels/twitter/#{TWITTER_KEY}"})
|
|
107
|
+
|
|
108
|
+
response = @application.create_twitter_channel(TWITTER_KEY, {:origin => ["juan"]})
|
|
109
|
+
response.should eql("#{ENDPOINT}/channels/twitter/#{TWITTER_KEY}")
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "should create a Twitter channel application with two origins speficied as Hash" do
|
|
113
|
+
stub_request(:post, "#{ENDPOINT}/channels/twitter").
|
|
114
|
+
with(:body => create_twitter_channel_request(["juan", "connfu"]), :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
115
|
+
to_return(:status => 201, :body => "", :headers => {:location => "#{ENDPOINT}/channels/twitter/#{TWITTER_KEY}"})
|
|
116
|
+
|
|
117
|
+
response = @application.create_twitter_channel(TWITTER_KEY, {:origin => ["juan", "connfu"]})
|
|
118
|
+
response.should eql("#{ENDPOINT}/channels/twitter/#{TWITTER_KEY}")
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it "should create a Twitter channel application with two origins speficied as Array" do
|
|
122
|
+
stub_request(:post, "#{ENDPOINT}/channels/twitter").
|
|
123
|
+
with(:body => create_twitter_channel_request(["juan", "connfu"]), :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
124
|
+
to_return(:status => 201, :body => "", :headers => {:location => "#{ENDPOINT}/channels/twitter/#{TWITTER_KEY}"})
|
|
125
|
+
|
|
126
|
+
response = @application.create_twitter_channel(TWITTER_KEY, ["juan", "connfu"])
|
|
127
|
+
response.should eql("#{ENDPOINT}/channels/twitter/#{TWITTER_KEY}")
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it "should create a Twitter channel application with one mention" do
|
|
131
|
+
stub_request(:post, "#{ENDPOINT}/channels/twitter").
|
|
132
|
+
with(:body => create_twitter_channel_request(["juan"], TWITTER_KEY, "(recipients:juan)"), :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
133
|
+
to_return(:status => 201, :body => "", :headers => {:location => "#{ENDPOINT}/channels/twitter/#{TWITTER_KEY}"})
|
|
134
|
+
|
|
135
|
+
response = @application.create_twitter_channel(TWITTER_KEY, {:mentions => ["juan"]})
|
|
136
|
+
response.should be_kind_of(Array)
|
|
137
|
+
response[0].should eql("#{ENDPOINT}/channels/twitter/#{TWITTER_KEY}")
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "should retrieve a channel information when the channel exists" do
|
|
141
|
+
stub_request(:get, "#{ENDPOINT}/channels/twitter/#{TWITTER_KEY}?").
|
|
142
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
143
|
+
to_return(:status => 200, :body => "{'accounts':[{'name':'juandebravo'}],'created_at':'2011-09-06T05:33:39+00:00','filter':'','uid':'#{TWITTER_KEY}','updated_at':'2011-09-06T05:33:39+00:00'}", :headers => {})
|
|
144
|
+
|
|
145
|
+
twitter = @application.get_twitter_channel(TWITTER_KEY)
|
|
146
|
+
|
|
147
|
+
twitter.should be_well_defined_as_twitter(TWITTER_KEY, ['juandebravo'])
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
it "should retrieve a list of one channel information when app has only one twitter channel" do
|
|
151
|
+
stub_request(:get, "#{ENDPOINT}/channels/twitter/?").
|
|
152
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
153
|
+
to_return(:status => 200, :body => "[{'accounts':[{'name':'juandebravo'}],'created_at':'2011-09-06T05:33:39+00:00','filter':'','uid':'#{TWITTER_KEY}','updated_at':'2011-09-06T05:33:39+00:00'}]", :headers => {})
|
|
154
|
+
|
|
155
|
+
twitters = @application.get_twitter_channel
|
|
156
|
+
|
|
157
|
+
twitters.should be_instance_of(Array)
|
|
158
|
+
twitters.length.should eql(1)
|
|
159
|
+
twitters[0].should be_well_defined_as_twitter(TWITTER_KEY, ['juandebravo'])
|
|
160
|
+
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it "should retrieve a list of twitter channels information" do
|
|
164
|
+
stub_request(:get, "#{ENDPOINT}/channels/twitter/?").
|
|
165
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
166
|
+
to_return(:status => 200, :body => "[{'accounts':[{'name':'juandebravo'}],'created_at':'2011-09-06T05:33:39+00:00','filter':'','uid':'#{TWITTER_KEY}-0','updated_at':'2011-09-06T05:33:39+00:00'},{'accounts':[{'name':'juandebravo'}],'created_at':'2011-09-06T05:33:39+00:00','filter':'','uid':'#{TWITTER_KEY}-1','updated_at':'2011-09-06T05:33:39+00:00'}]", :headers => {})
|
|
167
|
+
|
|
168
|
+
twitters = @application.get_twitter_channel
|
|
169
|
+
|
|
170
|
+
twitters.should be_instance_of(Array)
|
|
171
|
+
twitters.length.should eql(2)
|
|
172
|
+
twitters.each_with_index { |twitter, index|
|
|
173
|
+
twitter.should be_well_defined_as_twitter("#{TWITTER_KEY}-#{index}", ['juandebravo'])
|
|
174
|
+
}
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
context "voice" do
|
|
180
|
+
|
|
181
|
+
it "should create a Voice channel application with the default privacy attribute" do
|
|
182
|
+
stub_request(:post, "#{ENDPOINT}/channels/voice").
|
|
183
|
+
with(:body => "{\"uid\":\"#{VOICE_KEY}\",\"country\":\"de\",\"privacy\":\"whitelisted\"}", :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
184
|
+
to_return(:status => 201, :body => "", :headers => {:location => "#{ENDPOINT}/channels/voice/#{VOICE_KEY}"})
|
|
185
|
+
|
|
186
|
+
response = @application.create_voice_channel(VOICE_KEY, "de")
|
|
187
|
+
response.should eql("#{ENDPOINT}/channels/voice/#{VOICE_KEY}")
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it "should create a Voice channel application with a privacy attribute (public)" do
|
|
191
|
+
stub_request(:post, "#{ENDPOINT}/channels/voice").
|
|
192
|
+
with(:body => "{\"uid\":\"#{VOICE_KEY}\",\"country\":\"de\",\"privacy\":\"public\"}", :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
193
|
+
to_return(:status => 201, :body => "", :headers => {:location => "#{ENDPOINT}/channels/voice/#{VOICE_KEY}"})
|
|
194
|
+
|
|
195
|
+
response = @application.create_voice_channel(VOICE_KEY, "de", Connfu::Provisioning::Voice::Privacy::PUBLIC)
|
|
196
|
+
response.should eql("#{ENDPOINT}/channels/voice/#{VOICE_KEY}")
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
it "should create a Voice channel application with a privacy attribute (whitelisted)" do
|
|
200
|
+
stub_request(:post, "#{ENDPOINT}/channels/voice").
|
|
201
|
+
with(:body => "{\"uid\":\"#{VOICE_KEY}\",\"country\":\"de\",\"privacy\":\"whitelisted\"}", :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
202
|
+
to_return(:status => 201, :body => "", :headers => {:location => "#{ENDPOINT}/channels/voice/#{VOICE_KEY}"})
|
|
203
|
+
|
|
204
|
+
response = @application.create_voice_channel(VOICE_KEY, "de", Connfu::Provisioning::Voice::Privacy::WHITELIST)
|
|
205
|
+
response.should eql("#{ENDPOINT}/channels/voice/#{VOICE_KEY}")
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
it "should retrieve a channel information when the channel exists" do
|
|
209
|
+
stub_request(:get, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}?").
|
|
210
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
211
|
+
to_return(:status => 200, :body => "{'created_at':'2011-08-25T14:16:44+03:00','rejected_message':'You are not allowed to join this conference','privacy':'whitelisted','topic':'hello_man','uid':'#{VOICE_KEY}','updated_at':'2011-08-25T15:10:12+03:00','welcome_message':'Welcome to connFu, you are going to join the conference','phones':[{'country':'#{COUNTRY}','phone_number':'#{PHONE_NUMBER}'}]}", :headers => {})
|
|
212
|
+
|
|
213
|
+
voice = @application.get_voice_channel(VOICE_KEY)
|
|
214
|
+
|
|
215
|
+
voice.should be_well_defined_as_voice(VOICE_KEY, [{:phone_number => PHONE_NUMBER, :country => COUNTRY}])
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it "should retrieve a list of channels information" do
|
|
219
|
+
stub_request(:get, "#{ENDPOINT}/channels/voice/?").
|
|
220
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
221
|
+
to_return(:status => 200, :body => "[{'created_at':'2011-08-25T14:16:44+03:00','rejected_message':'You are not allowed to join this conference','topic':'hello_man','uid':'#{VOICE_KEY}-0','updated_at':'2011-08-25T15:10:12+03:00','welcome_message':'Welcome to connFu, you are going to join the conference','phones':[{'country':'#{COUNTRY}','phone_number':'#{PHONE_NUMBER}'}]}, {'created_at':'2011-08-25T14:16:44+03:00','rejected_message':'You are not allowed to join this conference','topic':'hello_man','uid':'#{VOICE_KEY}-1','updated_at':'2011-08-25T15:10:12+03:00','welcome_message':'Welcome to connFu, you are going to join the conference','phones':[{'country':'#{COUNTRY}','phone_number':'#{PHONE_NUMBER}'}]}]", :headers => {})
|
|
222
|
+
|
|
223
|
+
voices = @application.get_voice_channel
|
|
224
|
+
|
|
225
|
+
voices.should be_instance_of(Array)
|
|
226
|
+
voices.length.should eql(2)
|
|
227
|
+
voices.each_with_index { |voice, index|
|
|
228
|
+
voice.should be_well_defined_as_voice("#{VOICE_KEY}-#{index}", [{:phone_number => PHONE_NUMBER, :country => COUNTRY}])
|
|
229
|
+
}
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
it "should retrieve a list of one channel information when app has only one voice channel" do
|
|
233
|
+
stub_request(:get, "#{ENDPOINT}/channels/voice/?").
|
|
234
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
235
|
+
to_return(:status => 200, :body => "[{'created_at':'2011-08-25T14:16:44+03:00','rejected_message':'You are not allowed to join this conference','topic':'hello_man','uid':'#{VOICE_KEY}','updated_at':'2011-08-25T15:10:12+03:00','welcome_message':'Welcome to connFu, you are going to join the conference','phones':[{'country':'#{COUNTRY}','phone_number':'#{PHONE_NUMBER}'}]}]", :headers => {})
|
|
236
|
+
|
|
237
|
+
voice = @application.get_voice_channel
|
|
238
|
+
voice.should be_instance_of(Array)
|
|
239
|
+
voice.length.should eql(1)
|
|
240
|
+
voice = voice.pop
|
|
241
|
+
voice.should be_well_defined_as_voice(VOICE_KEY, [{:phone_number => PHONE_NUMBER, :country => COUNTRY}])
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
it "should delete a channel when the channel exists" do
|
|
245
|
+
stub_request(:delete, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}?").
|
|
246
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
247
|
+
to_return(:status => 200, :body => "", :headers => {})
|
|
248
|
+
|
|
249
|
+
response = @application.delete_voice_channel(VOICE_KEY)
|
|
250
|
+
response.should eql("")
|
|
251
|
+
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
it "should update a topic in a Voice channel application" do
|
|
255
|
+
stub_request(:put, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}").
|
|
256
|
+
with(:body => '{"topic":"new-topic"}', :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
257
|
+
to_return(:status => 200)
|
|
258
|
+
|
|
259
|
+
response = @application.update_voice_channel(VOICE_KEY, "new-topic")
|
|
260
|
+
response.should eql("")
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
it "should update a topic in a Voice channel application using a Hash parameter" do
|
|
264
|
+
stub_request(:put, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}").
|
|
265
|
+
with(:body => '{"topic":"new-topic"}', :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
266
|
+
to_return(:status => 200)
|
|
267
|
+
|
|
268
|
+
response = @application.update_voice_channel(VOICE_KEY, {"topic" => "new-topic"})
|
|
269
|
+
response.should eql("")
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
it "should update a welcome_message in a Voice channel application" do
|
|
273
|
+
stub_request(:put, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}").
|
|
274
|
+
with(:body => '{"welcome_message":"new-welcome_message"}', :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
275
|
+
to_return(:status => 200)
|
|
276
|
+
|
|
277
|
+
response = @application.update_voice_channel(VOICE_KEY, {:welcome_message => "new-welcome_message"})
|
|
278
|
+
response.should eql("")
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
it "should update a rejected_message in a Voice channel application" do
|
|
282
|
+
stub_request(:put, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}").
|
|
283
|
+
with(:body => '{"rejected_message":"new-rejected_message"}', :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
284
|
+
to_return(:status => 200)
|
|
285
|
+
|
|
286
|
+
response = @application.update_voice_channel(VOICE_KEY, {"rejected_message" => "new-rejected_message"})
|
|
287
|
+
response.should eql("")
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
it "should update a topic, welcome_message and rejected_message in a Voice channel application" do
|
|
291
|
+
stub_request(:put, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}").
|
|
292
|
+
with(:body => '{"topic":"new-topic","welcome_message":"new-welcome_message","rejected_message":"new-rejected_message"}', :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
293
|
+
to_return(:status => 200)
|
|
294
|
+
|
|
295
|
+
response = @application.update_voice_channel(VOICE_KEY, {"topic" => "new-topic", "welcome_message" => "new-welcome_message", "rejected_message" => "new-rejected_message"})
|
|
296
|
+
response.should eql("")
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
context "phone numbers" do
|
|
301
|
+
|
|
302
|
+
it "should process a phone number list with one number" do
|
|
303
|
+
stub_request(:get, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}/phones/?").
|
|
304
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
305
|
+
to_return(:status => 200, :body => "[{'country':'#{COUNTRY}','phone_number':'#{PHONE_NUMBER}'}]", :headers => {})
|
|
306
|
+
|
|
307
|
+
voice_numbers = @application.get_phones(VOICE_KEY)
|
|
308
|
+
voice_numbers.should be_an_instance_of(Array)
|
|
309
|
+
voice_numbers.length.should eql(1)
|
|
310
|
+
voice_numbers.each { |voice_number|
|
|
311
|
+
voice_number.should be_instance_of(Connfu::Provisioning::Phone)
|
|
312
|
+
voice_number.country.should eql(COUNTRY)
|
|
313
|
+
voice_number.phone_number.should eql(PHONE_NUMBER)
|
|
314
|
+
}
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
it "should process a phone number list with two numbers" do
|
|
318
|
+
stub_request(:get, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}/phones/?").
|
|
319
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
320
|
+
to_return(:status => 200, :body => "[{'country':'#{COUNTRY}','phone_number':'#{PHONE_NUMBER}'},{'country':'#{COUNTRY}','phone_number':'#{PHONE_NUMBER}'}]", :headers => {})
|
|
321
|
+
|
|
322
|
+
voice_numbers = @application.get_phones(VOICE_KEY)
|
|
323
|
+
voice_numbers.should be_an_instance_of(Array)
|
|
324
|
+
voice_numbers.length.should eql(2)
|
|
325
|
+
voice_numbers.each { |voice_number|
|
|
326
|
+
voice_number.should be_instance_of(Connfu::Provisioning::Phone)
|
|
327
|
+
voice_number.country.should eql(COUNTRY)
|
|
328
|
+
voice_number.phone_number.should eql(PHONE_NUMBER)
|
|
329
|
+
}
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
it "should process an empty phone number list" do
|
|
333
|
+
stub_request(:get, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}/phones/?").
|
|
334
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
335
|
+
to_return(:status => 200, :body => "[]", :headers => {})
|
|
336
|
+
|
|
337
|
+
voice_numbers = @application.get_phones(VOICE_KEY)
|
|
338
|
+
voice_numbers.should be_an_instance_of(Array)
|
|
339
|
+
voice_numbers.length.should eql(0)
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
it "should delete a phone number" do
|
|
343
|
+
stub_request(:delete, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}/phones/#{PHONE_NUMBER}?").
|
|
344
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
345
|
+
to_return(:status => 200, :body => "", :headers => {})
|
|
346
|
+
|
|
347
|
+
response = @application.delete_phone(VOICE_KEY, PHONE_NUMBER)
|
|
348
|
+
response.should eql("")
|
|
349
|
+
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
context "whitelist" do
|
|
356
|
+
it "should process a whitelist with one number" do
|
|
357
|
+
stub_request(:get, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}/whitelisted/?").
|
|
358
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
359
|
+
to_return(:status => 200, :body => '[{"name":"juan","phone":"972542279538"}]', :headers => {})
|
|
360
|
+
|
|
361
|
+
whitelist = @application.get_whitelist(VOICE_KEY)
|
|
362
|
+
whitelist.should be_an_instance_of(Connfu::Provisioning::Whitelist)
|
|
363
|
+
whitelist.users.should be_an_instance_of(Array)
|
|
364
|
+
whitelist.users.length.should eql(1)
|
|
365
|
+
whitelist.users.each { |user|
|
|
366
|
+
user.should be_instance_of(Connfu::Provisioning::WhitelistUser)
|
|
367
|
+
}
|
|
368
|
+
whitelist.users[0].name.should eql("juan")
|
|
369
|
+
whitelist.users[0].phone.should eql("972542279538")
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
it "should process a whitelist with more than one number" do
|
|
373
|
+
stub_request(:get, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}/whitelisted/?").
|
|
374
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
375
|
+
to_return(:status => 200, :body => '[{"name":"juan","phone":"972542279538"},{"name":"juandebravo","phone":"972542279531"}]', :headers => {})
|
|
376
|
+
|
|
377
|
+
whitelist = @application.get_whitelist(VOICE_KEY)
|
|
378
|
+
whitelist.should be_an_instance_of(Connfu::Provisioning::Whitelist)
|
|
379
|
+
whitelist.users.should be_an_instance_of(Array)
|
|
380
|
+
whitelist.users.length.should eql(2)
|
|
381
|
+
whitelist.each { |user|
|
|
382
|
+
user.should be_instance_of(Connfu::Provisioning::WhitelistUser)
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
it "should process a whitelist number" do
|
|
388
|
+
stub_request(:get, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}/whitelisted/#{PHONE_NUMBER}?").
|
|
389
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
390
|
+
to_return(:status => 200, :body => "{'name':'juan','phone':'#{PHONE_NUMBER}'}", :headers => {})
|
|
391
|
+
|
|
392
|
+
whitelist_number = @application.get_whitelist(VOICE_KEY, PHONE_NUMBER)
|
|
393
|
+
whitelist_number.should be_an_instance_of(Connfu::Provisioning::WhitelistUser)
|
|
394
|
+
whitelist_number.name.should eql("juan")
|
|
395
|
+
whitelist_number.phone.should eql(PHONE_NUMBER)
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
it "should delete a whitelist list" do
|
|
399
|
+
stub_request(:delete, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}/whitelisted/?").
|
|
400
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
401
|
+
to_return(:status => 200, :body => "", :headers => {})
|
|
402
|
+
|
|
403
|
+
response = @application.delete_whitelist(VOICE_KEY)
|
|
404
|
+
response.should eql("")
|
|
405
|
+
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
it "should delete a whitelist number" do
|
|
409
|
+
stub_request(:delete, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}/whitelisted/#{PHONE_NUMBER}?").
|
|
410
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
411
|
+
to_return(:status => 200, :body => "", :headers => {})
|
|
412
|
+
|
|
413
|
+
response = @application.delete_whitelist(VOICE_KEY, PHONE_NUMBER)
|
|
414
|
+
response.should eql("")
|
|
415
|
+
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
it "should create a whitelist number with 2 parameters (name, phone)" do
|
|
419
|
+
|
|
420
|
+
stub_request(:post, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}/whitelisted").
|
|
421
|
+
with(:body => "{\"name\":\"juan\",\"phone\":\"#{PHONE_NUMBER}\"}", :headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
422
|
+
to_return(:status => 200, :body => "", :headers => {})
|
|
423
|
+
|
|
424
|
+
response = @application.add_whitelist(VOICE_KEY, 'juan', PHONE_NUMBER)
|
|
425
|
+
response.should eql("")
|
|
426
|
+
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
it "should create a whitelist number with 1 parameter (WhitelistUser)" do
|
|
430
|
+
|
|
431
|
+
stub_request(:post, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}/whitelisted").
|
|
432
|
+
with(:body => "{\"name\":\"juan\",\"phone\":\"#{PHONE_NUMBER}\"}", :headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
433
|
+
to_return(:status => 200, :body => "", :headers => {})
|
|
434
|
+
|
|
435
|
+
response = @application.add_whitelist(VOICE_KEY, Connfu::Provisioning::WhitelistUser.new('juan', PHONE_NUMBER))
|
|
436
|
+
response.should eql("")
|
|
437
|
+
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
it "should update a whitelist number with 1 parameter (WhitelistUser)" do
|
|
441
|
+
|
|
442
|
+
stub_request(:put, "#{ENDPOINT}/channels/voice/#{VOICE_KEY}/whitelisted/#{PHONE_NUMBER}").
|
|
443
|
+
with(:body => "{\"name\":\"juanito\"}", :headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
444
|
+
to_return(:status => 200, :body => "", :headers => {})
|
|
445
|
+
|
|
446
|
+
response = @application.update_whitelist(VOICE_KEY, Connfu::Provisioning::WhitelistUser.new('juanito', PHONE_NUMBER))
|
|
447
|
+
response.should eql("")
|
|
448
|
+
|
|
449
|
+
end
|
|
450
|
+
end
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
context "rss" do
|
|
454
|
+
it "should create a RSS channel application" do
|
|
455
|
+
stub_request(:post, "#{ENDPOINT}/channels/rss").
|
|
456
|
+
with(:body => "{\"uid\":\"#{RSS_KEY}\",\"uri\":\"http://connfu.com/rss\"}", :headers => {'Accept'=>'application/json', 'Content-Type' => 'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
457
|
+
to_return(:status => 201, :body => "", :headers => {:location => "#{ENDPOINT}/channels/voice/#{RSS_KEY}"})
|
|
458
|
+
|
|
459
|
+
response = @application.create_rss_channel(RSS_KEY, "http://connfu.com/rss")
|
|
460
|
+
response.should eql("#{ENDPOINT}/channels/voice/#{RSS_KEY}")
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
it "should retrieve a RSS channel information when the channel exists" do
|
|
464
|
+
stub_request(:get, "#{ENDPOINT}/channels/rss/#{RSS_KEY}?").
|
|
465
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
466
|
+
to_return(:status => 200, :body => "{'created_at':'2011-07-17T20:57:01+03:00','uri':'http://connfu.com/rss','uid':#{RSS_KEY},'updated_at':'2011-07-17T20:57:01+03:00'}", :headers => {})
|
|
467
|
+
|
|
468
|
+
rss = @application.get_rss_channel(RSS_KEY)
|
|
469
|
+
rss.uid.should eql(RSS_KEY)
|
|
470
|
+
rss.uri.should eql("http://connfu.com/rss")
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
it "should retrieve all the RSS channels information when no name provided as argument" do
|
|
474
|
+
stub_request(:get, "#{ENDPOINT}/channels/rss/?").
|
|
475
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
476
|
+
to_return(:status => 200, :body => "[{'created_at':'2011-07-17T20:57:01+03:00','uri':'http://connfu.com/rss','uid':#{RSS_KEY}-0,'updated_at':'2011-07-17T20:57:01+03:00'}, {'created_at':'2011-07-17T20:57:01+03:00','uri':'http://connfu.com/rss','uid':#{RSS_KEY}-1,'updated_at':'2011-07-17T20:57:01+03:00'}]", :headers => {})
|
|
477
|
+
|
|
478
|
+
rss = @application.get_rss_channel
|
|
479
|
+
|
|
480
|
+
rss.should be_instance_of(Array)
|
|
481
|
+
rss.length.should eql(2)
|
|
482
|
+
rss.each_with_index { |channel, index|
|
|
483
|
+
channel.uid.should eql("#{RSS_KEY}-#{index}")
|
|
484
|
+
channel.uri.should eql("http://connfu.com/rss")
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
it "should delete a channel when the channel exists" do
|
|
490
|
+
stub_request(:delete, "#{ENDPOINT}/channels/rss/#{RSS_KEY}?").
|
|
491
|
+
with(:headers => {'Accept'=>'application/json', 'AUTH_TOKEN' => "#{API_KEY}"}).
|
|
492
|
+
to_return(:status => 200, :body => "", :headers => {})
|
|
493
|
+
|
|
494
|
+
response = @application.delete_rss_channel(RSS_KEY)
|
|
495
|
+
response.should eql("")
|
|
496
|
+
end
|
|
497
|
+
end
|
|
498
|
+
end
|
|
499
|
+
|
|
500
|
+
end
|