tropo-provisioning 0.0.23 → 0.0.24
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/Gemfile.lock +19 -18
- data/README.rdoc +1 -1
- data/lib/tropo-provisioning/tropo_client.rb +19 -20
- data/lib/tropo-provisioning/tropo_provisioning.rb +106 -106
- data/lib/tropo-provisioning/version.rb +2 -2
- data/spec/spec_helper.rb +2 -0
- data/spec/tropo-provisioning_spec.rb +433 -415
- metadata +65 -18
@@ -5,568 +5,576 @@ FakeWeb.allow_net_connect = false
|
|
5
5
|
|
6
6
|
describe "TropoProvisioning" do
|
7
7
|
let(:applications) do
|
8
|
-
[ { "region" => "I-US",
|
9
|
-
"city" => "iNum US",
|
10
|
-
"number" => "883510001812716",
|
11
|
-
"href" => "http://api.tropo.com/v1/applications/108000/addresses/number/883510001812716",
|
12
|
-
"prefix" => "008",
|
13
|
-
"type" => "number" },
|
14
|
-
{ "number" => "9991436301",
|
15
|
-
"href" => "http://api.tropo.com/v1/applications/108000/addresses/pin/9991436300",
|
8
|
+
[ { "region" => "I-US",
|
9
|
+
"city" => "iNum US",
|
10
|
+
"number" => "883510001812716",
|
11
|
+
"href" => "http://api.tropo.com/v1/applications/108000/addresses/number/883510001812716",
|
12
|
+
"prefix" => "008",
|
13
|
+
"type" => "number" },
|
14
|
+
{ "number" => "9991436301",
|
15
|
+
"href" => "http://api.tropo.com/v1/applications/108000/addresses/pin/9991436300",
|
16
16
|
"type" => "pin" },
|
17
|
-
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
|
18
|
-
"nickname" => "",
|
19
|
-
"username" => "xyz123",
|
17
|
+
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
|
18
|
+
"nickname" => "",
|
19
|
+
"username" => "xyz123",
|
20
20
|
"type" => "jabber" },
|
21
|
-
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
|
22
|
-
"nickname" => "",
|
23
|
-
"username" => "9991436300",
|
21
|
+
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
|
22
|
+
"nickname" => "",
|
23
|
+
"username" => "9991436300",
|
24
24
|
"type" => "pin" },
|
25
|
-
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/token/a1b2c3d4",
|
26
|
-
"nickname" => "",
|
27
|
-
"username" => "a1b2c3d4",
|
25
|
+
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/token/a1b2c3d4",
|
26
|
+
"nickname" => "",
|
27
|
+
"username" => "a1b2c3d4",
|
28
28
|
"type" => "token" } ]
|
29
29
|
end
|
30
30
|
|
31
31
|
before(:all) do
|
32
|
-
@addresses = [ { "region" => "I-US",
|
33
|
-
"city" => "iNum US",
|
34
|
-
"number" => "883510001812716",
|
35
|
-
"href" => "http://api.tropo.com/v1/applications/108000/addresses/number/883510001812716",
|
36
|
-
"prefix" => "008",
|
37
|
-
"type" => "number" },
|
38
|
-
{ "number" => "9991436301",
|
39
|
-
"href" => "http://api.tropo.com/v1/applications/108000/addresses/pin/9991436300",
|
32
|
+
@addresses = [ { "region" => "I-US",
|
33
|
+
"city" => "iNum US",
|
34
|
+
"number" => "883510001812716",
|
35
|
+
"href" => "http://api.tropo.com/v1/applications/108000/addresses/number/883510001812716",
|
36
|
+
"prefix" => "008",
|
37
|
+
"type" => "number" },
|
38
|
+
{ "number" => "9991436301",
|
39
|
+
"href" => "http://api.tropo.com/v1/applications/108000/addresses/pin/9991436300",
|
40
40
|
"type" => "pin" },
|
41
|
-
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
|
42
|
-
"nickname" => "",
|
43
|
-
"username" => "xyz123",
|
41
|
+
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
|
42
|
+
"nickname" => "",
|
43
|
+
"username" => "xyz123",
|
44
44
|
"type" => "jabber" },
|
45
|
-
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
|
46
|
-
"nickname" => "",
|
47
|
-
"username" => "9991436300",
|
45
|
+
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
|
46
|
+
"nickname" => "",
|
47
|
+
"username" => "9991436300",
|
48
48
|
"type" => "pin" },
|
49
|
-
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/token/a1b2c3d4",
|
50
|
-
"nickname" => "",
|
51
|
-
"username" => "a1b2c3d4",
|
49
|
+
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/token/a1b2c3d4",
|
50
|
+
"nickname" => "",
|
51
|
+
"username" => "a1b2c3d4",
|
52
52
|
"type" => "token" } ]
|
53
|
-
|
54
|
-
|
53
|
+
|
54
|
+
|
55
55
|
@new_user = { 'user_id' => "12345", 'href' => "http://api.tropo.com/v1/users/12345", 'confirmation_key' => '1234' }
|
56
56
|
@new_user_json = ActiveSupport::JSON.encode({ 'user_id' => "12345", 'href' => "http://api.tropo.com/v1/users/12345", 'confirmationKey' => '1234' })
|
57
|
-
@existing_user = { "city" => "Orlando",
|
58
|
-
"address" => "1234 Anywhere St",
|
59
|
-
"href" => "https://api-smsified-eng.voxeo.net/v1/users/12345",
|
60
|
-
"lastName" => "User",
|
61
|
-
"address2" => "Unit 1337",
|
62
|
-
"joinDate" => "2010-05-17T18:26:07.217+0000",
|
63
|
-
"country" => "USA",
|
64
|
-
"username" => "foo",
|
65
|
-
"phoneNumber" => "4075551212",
|
66
|
-
"id" => "12345",
|
67
|
-
"postalCode" => "32801",
|
68
|
-
"jobTitle" => "Technical Writer",
|
69
|
-
"firstName" => "Tropo",
|
70
|
-
"organization" => "Voxeo",
|
71
|
-
"status" => "active",
|
57
|
+
@existing_user = { "city" => "Orlando",
|
58
|
+
"address" => "1234 Anywhere St",
|
59
|
+
"href" => "https://api-smsified-eng.voxeo.net/v1/users/12345",
|
60
|
+
"lastName" => "User",
|
61
|
+
"address2" => "Unit 1337",
|
62
|
+
"joinDate" => "2010-05-17T18:26:07.217+0000",
|
63
|
+
"country" => "USA",
|
64
|
+
"username" => "foo",
|
65
|
+
"phoneNumber" => "4075551212",
|
66
|
+
"id" => "12345",
|
67
|
+
"postalCode" => "32801",
|
68
|
+
"jobTitle" => "Technical Writer",
|
69
|
+
"firstName" => "Tropo",
|
70
|
+
"organization" => "Voxeo",
|
71
|
+
"status" => "active",
|
72
72
|
"email" => "support@tropo.com"}
|
73
73
|
|
74
|
-
|
74
|
+
|
75
75
|
@list_account = { 'account_id' => "12345", 'href' => "http://api-eng.voxeo.net:8080/v1/users/12345" }
|
76
|
-
|
77
|
-
@payment_method = { "rechargeAmount" => "0.00",
|
78
|
-
"paymentType" => "https://api-smsified-eng.voxeo.net/v1/types/payment/1",
|
79
|
-
"accountNumber" => "5555",
|
80
|
-
"paymentTypeName" => "visa",
|
76
|
+
|
77
|
+
@payment_method = { "rechargeAmount" => "0.00",
|
78
|
+
"paymentType" => "https://api-smsified-eng.voxeo.net/v1/types/payment/1",
|
79
|
+
"accountNumber" => "5555",
|
80
|
+
"paymentTypeName" => "visa",
|
81
81
|
"rechargeThreshold" => "0.00",
|
82
82
|
"id" => "1" }
|
83
|
-
|
84
|
-
@payment_methods = [ { "name" => "visa",
|
85
|
-
"href" => "https://api-smsified-eng.voxeo.net/v1/types/payment/1",
|
86
|
-
"id" => "1" },
|
87
|
-
{ "name" => "mastercard",
|
88
|
-
"href" => "https://api-smsified-eng.voxeo.net/v1/types/payment/2",
|
89
|
-
"id" => "2" },
|
90
|
-
{ "name" => "amex",
|
91
|
-
"href" => "https://api-smsified-eng.voxeo.net/v1/types/payment/3",
|
83
|
+
|
84
|
+
@payment_methods = [ { "name" => "visa",
|
85
|
+
"href" => "https://api-smsified-eng.voxeo.net/v1/types/payment/1",
|
86
|
+
"id" => "1" },
|
87
|
+
{ "name" => "mastercard",
|
88
|
+
"href" => "https://api-smsified-eng.voxeo.net/v1/types/payment/2",
|
89
|
+
"id" => "2" },
|
90
|
+
{ "name" => "amex",
|
91
|
+
"href" => "https://api-smsified-eng.voxeo.net/v1/types/payment/3",
|
92
92
|
"id" => "3" }]
|
93
93
|
|
94
|
-
@features = [ { "name" => "International Outbound SMS",
|
95
|
-
"href" => "https://api-smsified-eng.voxeo.net/v1/features/9",
|
96
|
-
"id" => "9",
|
97
|
-
"description" => "International Outbound SMS" },
|
98
|
-
{ "name" => "Test Outbound SMS",
|
99
|
-
"href" => "https://api-smsified-eng.voxeo.net/v1/features/7",
|
100
|
-
"id" => "7",
|
101
|
-
"description" => "Test Outbound SMS" },
|
102
|
-
{ "name" => "Domestic Outbound SMS",
|
103
|
-
"href" => "https://api-smsified-eng.voxeo.net/v1/features/8",
|
104
|
-
"id" => "8",
|
94
|
+
@features = [ { "name" => "International Outbound SMS",
|
95
|
+
"href" => "https://api-smsified-eng.voxeo.net/v1/features/9",
|
96
|
+
"id" => "9",
|
97
|
+
"description" => "International Outbound SMS" },
|
98
|
+
{ "name" => "Test Outbound SMS",
|
99
|
+
"href" => "https://api-smsified-eng.voxeo.net/v1/features/7",
|
100
|
+
"id" => "7",
|
101
|
+
"description" => "Test Outbound SMS" },
|
102
|
+
{ "name" => "Domestic Outbound SMS",
|
103
|
+
"href" => "https://api-smsified-eng.voxeo.net/v1/features/8",
|
104
|
+
"id" => "8",
|
105
105
|
"description" => "Domestic Outbound SMS" } ]
|
106
|
-
|
107
|
-
@user_features = [ { "feature" => "https://api-smsified-eng.voxeo.net/v1/features/7",
|
108
|
-
"href" => "https://api-smsified-eng.voxeo.net/v1/users/12345/features/7",
|
106
|
+
|
107
|
+
@user_features = [ { "feature" => "https://api-smsified-eng.voxeo.net/v1/features/7",
|
108
|
+
"href" => "https://api-smsified-eng.voxeo.net/v1/users/12345/features/7",
|
109
109
|
"featureName" => "Test Outbound SMS" } ]
|
110
|
-
|
110
|
+
|
111
111
|
@feature = { 'href' => 'http://api-smsified-eng.voxeo.net/v1/users/12345/features/8' }
|
112
|
-
|
112
|
+
|
113
113
|
@feature_delete_message = { "message" => "disabled feature https://api-smsified-eng.voxeo.net/v1/features/8 for user https://api-smsified-eng.voxeo.net/v1/users/12345" }
|
114
|
-
|
114
|
+
|
115
115
|
@payment_info_message = { "href" => "http://api-smsified-eng.voxeo.net/v1/users/12345/payment/method" }
|
116
|
-
|
116
|
+
|
117
117
|
@bad_account_creds = { "account-accesstoken-get-response" =>
|
118
|
-
{ "accessToken" => "",
|
119
|
-
"statusMessage" => "Invalid login.",
|
118
|
+
{ "accessToken" => "",
|
119
|
+
"statusMessage" => "Invalid login.",
|
120
120
|
"statusCode" => 403 } }
|
121
|
-
|
122
|
-
@search_accounts = [ { "href" => "http://api-smsified-eng.voxeo.net/v1/users/53209",
|
123
|
-
"marketingOptIn" => true,
|
124
|
-
"lastName" => "Empty LastName",
|
125
|
-
"joinDate" => "2010-11-15T21:13:23.837+0000",
|
126
|
-
"username" => "foobar5331",
|
127
|
-
"id" => "53209",
|
128
|
-
"phoneNumber" => "Empty Phone",
|
129
|
-
"firstName" => "Empty FirstName",
|
130
|
-
"status" => "active",
|
131
|
-
"email" => "jsgoecke@voxeo.com"},
|
132
|
-
{ "href" => "http://api-smsified-eng.voxeo.net/v1/users/53211",
|
133
|
-
"marketingOptIn" => true,
|
134
|
-
"lastName" => "Empty LastName",
|
135
|
-
"joinDate" => "2010-11-15T21:17:24.473+0000",
|
136
|
-
"username" => "foobar1197",
|
137
|
-
"id" => "53211",
|
138
|
-
"phoneNumber" => "Empty Phone",
|
139
|
-
"firstName" => "Empty FirstName",
|
140
|
-
"status" => "active",
|
121
|
+
|
122
|
+
@search_accounts = [ { "href" => "http://api-smsified-eng.voxeo.net/v1/users/53209",
|
123
|
+
"marketingOptIn" => true,
|
124
|
+
"lastName" => "Empty LastName",
|
125
|
+
"joinDate" => "2010-11-15T21:13:23.837+0000",
|
126
|
+
"username" => "foobar5331",
|
127
|
+
"id" => "53209",
|
128
|
+
"phoneNumber" => "Empty Phone",
|
129
|
+
"firstName" => "Empty FirstName",
|
130
|
+
"status" => "active",
|
131
|
+
"email" => "jsgoecke@voxeo.com"},
|
132
|
+
{ "href" => "http://api-smsified-eng.voxeo.net/v1/users/53211",
|
133
|
+
"marketingOptIn" => true,
|
134
|
+
"lastName" => "Empty LastName",
|
135
|
+
"joinDate" => "2010-11-15T21:17:24.473+0000",
|
136
|
+
"username" => "foobar1197",
|
137
|
+
"id" => "53211",
|
138
|
+
"phoneNumber" => "Empty Phone",
|
139
|
+
"firstName" => "Empty FirstName",
|
140
|
+
"status" => "active",
|
141
141
|
"email" => "jsgoecke@voxeo.com" } ]
|
142
|
-
|
143
|
-
@partitions = [{ "name" => "staging", "href" => "https://api-smsified-eng.voxeo.net/v1/partitions/staging" },
|
144
|
-
{ "name" => "production", "href" => "https://api-smsified-eng.voxeo.net/v1/partitions/production" }]
|
142
|
+
|
143
|
+
@partitions = [{ "name" => "staging", "href" => "https://api-smsified-eng.voxeo.net/v1/partitions/staging" },
|
144
|
+
{ "name" => "production", "href" => "https://api-smsified-eng.voxeo.net/v1/partitions/production" }]
|
145
145
|
|
146
146
|
@platforms = [{ "name" => "sms", "href" => "https://api-smsified-eng.voxeo.net/v1/platforms/sms", "description" => "SMSified Interface" }]
|
147
147
|
|
148
148
|
@balance = { "pendingUsageAmount" => "0.00", "pendingRechargeAmount" => "0.00", "balance" => "3.00" }
|
149
|
-
|
149
|
+
|
150
150
|
@whitelist = [{ "href" => "https://api-smsified-eng.voxeo.net/v1/partitions/staging/platforms/sms/whitelist/14075551212", "value"=>"14075551212" }]
|
151
|
-
|
151
|
+
|
152
152
|
@countries = [{ "name"=>"Zimbabwe", "href"=>"http://api-smsified-eng.voxeo.net/v1/countries/426", "code"=>"ZW", "id" => "426" },
|
153
153
|
{ "name"=>"United States", "href"=>"http://api-smsified-eng.voxeo.net/v1/countries/36", "code"=>"US", "states"=>"http://api-smsified-eng.voxeo.net/v1/countries/36/states", "id" => "36" }]
|
154
|
-
|
154
|
+
|
155
155
|
@states = [{ "name"=>"Wisconsin", "href"=>"http://api-smsified-eng.voxeo.net/v1/countries/36/states/49", "code"=>"WI", "id" => "49" },
|
156
156
|
{ "name"=>"Wyoming", "href"=>"http://api-smsified-eng.voxeo.net/v1/countries/36/states/50", "code"=>"WY", "id"=>"50" }]
|
157
|
-
|
157
|
+
|
158
158
|
@recurrence = { 'rechargeAmount' => 13.50, 'rechargeThreshold' => 10.00 }
|
159
159
|
@recurrence_updated = { 'href' => 'http://api-smsified-eng.voxeo.net/v1/users/1234/payment/recurrence' }
|
160
|
-
|
160
|
+
|
161
161
|
# Register our resources
|
162
|
-
|
162
|
+
|
163
163
|
# Applications with a bad uname/passwd
|
164
|
-
FakeWeb.register_uri(:get,
|
165
|
-
%r|http://bad:password@api.tropo.com/v1/applications|,
|
164
|
+
FakeWeb.register_uri(:get,
|
165
|
+
%r|http://bad:password@api.tropo.com/v1/applications|,
|
166
166
|
:status => ["401", "Unauthorized"])
|
167
167
|
|
168
|
+
# Alternate Base URI
|
169
|
+
FakeWeb.register_uri(:get,
|
170
|
+
"http://foo:bar@testserver.com/rest/v1/users/foo",
|
171
|
+
:body => '{}',
|
172
|
+
:content_type => "application/json",
|
173
|
+
:status => ["200", "OK"])
|
174
|
+
|
175
|
+
|
168
176
|
# A specific application
|
169
|
-
FakeWeb.register_uri(:get,
|
170
|
-
"http://foo:bar@api.tropo.com/v1/applications/108000",
|
177
|
+
FakeWeb.register_uri(:get,
|
178
|
+
"http://foo:bar@api.tropo.com/v1/applications/108000",
|
171
179
|
:body => ActiveSupport::JSON.encode(applications[0]),
|
172
180
|
:content_type => "application/json")
|
173
|
-
|
181
|
+
|
174
182
|
# Applications
|
175
|
-
FakeWeb.register_uri(:get,
|
176
|
-
%r|https://foo:bar@api.tropo.com/v1/applications|,
|
177
|
-
:body => ActiveSupport::JSON.encode(applications),
|
183
|
+
FakeWeb.register_uri(:get,
|
184
|
+
%r|https://foo:bar@api.tropo.com/v1/applications|,
|
185
|
+
:body => ActiveSupport::JSON.encode(applications),
|
178
186
|
:content_type => "application/json")
|
179
|
-
|
180
|
-
# Create an application
|
181
|
-
FakeWeb.register_uri(:post,
|
182
|
-
%r|https://foo:bar@api.tropo.com/v1/applications|,
|
187
|
+
|
188
|
+
# Create an application
|
189
|
+
FakeWeb.register_uri(:post,
|
190
|
+
%r|https://foo:bar@api.tropo.com/v1/applications|,
|
183
191
|
:body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108016" }),
|
184
192
|
:status => ["200", "OK"])
|
185
|
-
|
193
|
+
|
186
194
|
# Update a specific application
|
187
|
-
FakeWeb.register_uri(:put,
|
188
|
-
%r|https://foo:bar@api.tropo.com/v1/applications/108000|,
|
195
|
+
FakeWeb.register_uri(:put,
|
196
|
+
%r|https://foo:bar@api.tropo.com/v1/applications/108000|,
|
189
197
|
:body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108016" }),
|
190
198
|
:status => ["200", "OK"])
|
191
|
-
|
199
|
+
|
192
200
|
# Addresses
|
193
|
-
FakeWeb.register_uri(:get,
|
194
|
-
"http://foo:bar@api.tropo.com/v1/applications/108000/addresses",
|
195
|
-
:body => ActiveSupport::JSON.encode(@addresses),
|
201
|
+
FakeWeb.register_uri(:get,
|
202
|
+
"http://foo:bar@api.tropo.com/v1/applications/108000/addresses",
|
203
|
+
:body => ActiveSupport::JSON.encode(@addresses),
|
196
204
|
:content_type => "application/json")
|
197
|
-
|
205
|
+
|
198
206
|
# Get a specific address
|
199
|
-
FakeWeb.register_uri(:get,
|
200
|
-
"https://foo:bar@api.tropo.com/v1/applications/108000/addresses/number/883510001812716",
|
207
|
+
FakeWeb.register_uri(:get,
|
208
|
+
"https://foo:bar@api.tropo.com/v1/applications/108000/addresses/number/883510001812716",
|
201
209
|
:body => ActiveSupport::JSON.encode(@addresses[0]),
|
202
210
|
:content_type => "application/json")
|
203
211
|
|
204
212
|
# Get a address that is an IM/username
|
205
|
-
FakeWeb.register_uri(:get,
|
206
|
-
"https://foo:bar@api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
|
207
|
-
:body => ActiveSupport::JSON.encode(@addresses[2]),
|
213
|
+
FakeWeb.register_uri(:get,
|
214
|
+
"https://foo:bar@api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
|
215
|
+
:body => ActiveSupport::JSON.encode(@addresses[2]),
|
208
216
|
:content_type => "application/json")
|
209
217
|
|
210
218
|
# Get a address that is a token
|
211
|
-
FakeWeb.register_uri(:get,
|
212
|
-
"https://foo:bar@api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
|
213
|
-
:body => ActiveSupport::JSON.encode(@addresses[2]),
|
219
|
+
FakeWeb.register_uri(:get,
|
220
|
+
"https://foo:bar@api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
|
221
|
+
:body => ActiveSupport::JSON.encode(@addresses[2]),
|
214
222
|
:content_type => "application/json")
|
215
|
-
|
223
|
+
|
216
224
|
# Get a address that is a Pin
|
217
|
-
FakeWeb.register_uri(:post,
|
218
|
-
"http://foo:bar@api.tropo.com/v1/applications/108000/addresses",
|
225
|
+
FakeWeb.register_uri(:post,
|
226
|
+
"http://foo:bar@api.tropo.com/v1/applications/108000/addresses",
|
219
227
|
:body => ActiveSupport::JSON.encode(@addresses[2]),
|
220
228
|
:content_type => "application/json")
|
221
|
-
|
229
|
+
|
222
230
|
# Get a address that is a token
|
223
|
-
FakeWeb.register_uri(:get,
|
231
|
+
FakeWeb.register_uri(:get,
|
224
232
|
"https://foo:bar@api.tropo.com/v1/applications/108000/addresses/token/a1b2c3d4",
|
225
|
-
:body => ActiveSupport::JSON.encode(@addresses[4]),
|
233
|
+
:body => ActiveSupport::JSON.encode(@addresses[4]),
|
226
234
|
:content_type => "application/json")
|
227
|
-
|
235
|
+
|
228
236
|
# Get a address that is a number
|
229
|
-
FakeWeb.register_uri(:post,
|
230
|
-
"https://foo:bar@api.tropo.com/v1/applications/108000/addresses",
|
231
|
-
:body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108000/addresses/number/7202551912" }),
|
237
|
+
FakeWeb.register_uri(:post,
|
238
|
+
"https://foo:bar@api.tropo.com/v1/applications/108000/addresses",
|
239
|
+
:body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108000/addresses/number/7202551912" }),
|
232
240
|
:content_type => "application/json")
|
233
|
-
|
234
|
-
# Create a address that is an IM account
|
235
|
-
FakeWeb.register_uri(:post,
|
236
|
-
"https://foo:bar@api.tropo.com/v1/applications/108001/addresses",
|
237
|
-
:body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108001/addresses/jabber/xyz123@bot.im" }),
|
241
|
+
|
242
|
+
# Create a address that is an IM account
|
243
|
+
FakeWeb.register_uri(:post,
|
244
|
+
"https://foo:bar@api.tropo.com/v1/applications/108001/addresses",
|
245
|
+
:body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108001/addresses/jabber/xyz123@bot.im" }),
|
238
246
|
:content_type => "application/json")
|
239
|
-
|
240
|
-
# Create a address that is a Token
|
241
|
-
FakeWeb.register_uri(:post,
|
242
|
-
"https://foo:bar@api.tropo.com/v1/applications/108002/addresses",
|
243
|
-
:body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108002/addresses/token/12345679f90bac47a05b178c37d3c68aaf38d5bdbc5aba0c7abb12345d8a9fd13f1234c1234567dbe2c6f63b" }),
|
247
|
+
|
248
|
+
# Create a address that is a Token
|
249
|
+
FakeWeb.register_uri(:post,
|
250
|
+
"https://foo:bar@api.tropo.com/v1/applications/108002/addresses",
|
251
|
+
:body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108002/addresses/token/12345679f90bac47a05b178c37d3c68aaf38d5bdbc5aba0c7abb12345d8a9fd13f1234c1234567dbe2c6f63b" }),
|
244
252
|
:content_type => "application/json")
|
245
|
-
|
246
|
-
# Delete an application
|
247
|
-
FakeWeb.register_uri(:delete,
|
248
|
-
"https://foo:bar@api.tropo.com/v1/applications/108000",
|
249
|
-
:body => ActiveSupport::JSON.encode({ 'message' => 'delete successful' }),
|
253
|
+
|
254
|
+
# Delete an application
|
255
|
+
FakeWeb.register_uri(:delete,
|
256
|
+
"https://foo:bar@api.tropo.com/v1/applications/108000",
|
257
|
+
:body => ActiveSupport::JSON.encode({ 'message' => 'delete successful' }),
|
250
258
|
:content_type => "application/json",
|
251
259
|
:status => ["200", "OK"])
|
252
260
|
|
253
261
|
# Exchanges
|
254
|
-
FakeWeb.register_uri(:get,
|
255
|
-
"https://foo:bar@api.tropo.com/v1/exchanges",
|
256
|
-
:body => exchanges,
|
262
|
+
FakeWeb.register_uri(:get,
|
263
|
+
"https://foo:bar@api.tropo.com/v1/exchanges",
|
264
|
+
:body => exchanges,
|
257
265
|
:status => ["200", "OK"],
|
258
266
|
:content_type => "application/json")
|
259
267
|
|
260
268
|
# Delete a address
|
261
|
-
FakeWeb.register_uri(:delete,
|
262
|
-
"https://foo:bar@api.tropo.com/v1/applications/108000/addresses/number/883510001812716",
|
263
|
-
:body => ActiveSupport::JSON.encode({ 'message' => 'delete successful' }),
|
269
|
+
FakeWeb.register_uri(:delete,
|
270
|
+
"https://foo:bar@api.tropo.com/v1/applications/108000/addresses/number/883510001812716",
|
271
|
+
:body => ActiveSupport::JSON.encode({ 'message' => 'delete successful' }),
|
264
272
|
:content_type => "application/json",
|
265
273
|
:status => ["200", "OK"])
|
266
|
-
|
274
|
+
|
267
275
|
# Add a specific address
|
268
|
-
FakeWeb.register_uri(:post,
|
269
|
-
"https://foo:bar@api.tropo.com/v1/applications/108002/addresses/number/883510001812716",
|
270
|
-
:body => ActiveSupport::JSON.encode({ 'message' => 'delete successful' }),
|
276
|
+
FakeWeb.register_uri(:post,
|
277
|
+
"https://foo:bar@api.tropo.com/v1/applications/108002/addresses/number/883510001812716",
|
278
|
+
:body => ActiveSupport::JSON.encode({ 'message' => 'delete successful' }),
|
271
279
|
:content_type => "application/json",
|
272
280
|
:status => ["200", "OK"])
|
273
|
-
|
281
|
+
|
274
282
|
# Create a new user
|
275
|
-
FakeWeb.register_uri(:post,
|
276
|
-
"https://foo:bar@api.tropo.com/v1/users",
|
277
|
-
:body => @new_user_json,
|
283
|
+
FakeWeb.register_uri(:post,
|
284
|
+
"https://foo:bar@api.tropo.com/v1/users",
|
285
|
+
:body => @new_user_json,
|
278
286
|
:content_type => "application/json",
|
279
287
|
:status => ["200", "OK"])
|
280
288
|
|
281
|
-
# Get a specific user by user_id
|
282
|
-
FakeWeb.register_uri(:get,
|
289
|
+
# Get a specific user by user_id
|
290
|
+
FakeWeb.register_uri(:get,
|
283
291
|
"https://foo:bar@api.tropo.com/v1/users/12345",
|
284
|
-
:body => ActiveSupport::JSON.encode(@existing_user),
|
292
|
+
:body => ActiveSupport::JSON.encode(@existing_user),
|
285
293
|
:content_type => "application/json",
|
286
294
|
:status => ["200", "OK"])
|
287
|
-
|
288
|
-
# Get a specific user by user_id
|
289
|
-
FakeWeb.register_uri(:get,
|
295
|
+
|
296
|
+
# Get a specific user by user_id
|
297
|
+
FakeWeb.register_uri(:get,
|
290
298
|
"https://foo:bar@api.tropo.com/v1/users/98765",
|
291
|
-
:body => nil,
|
299
|
+
:body => nil,
|
292
300
|
:content_type => "application/json",
|
293
301
|
:status => ["404", "Got an error here!"])
|
294
|
-
|
302
|
+
|
295
303
|
# Get a specific user by username
|
296
|
-
FakeWeb.register_uri(:get,
|
304
|
+
FakeWeb.register_uri(:get,
|
297
305
|
"https://foo:bar@api.tropo.com/v1/users/foo",
|
298
|
-
:body => ActiveSupport::JSON.encode(@existing_user),
|
306
|
+
:body => ActiveSupport::JSON.encode(@existing_user),
|
299
307
|
:content_type => "application/json",
|
300
308
|
:status => ["200", "OK"])
|
301
309
|
|
302
310
|
# Get a specific user by username with HTTPS/SSL
|
303
|
-
FakeWeb.register_uri(:get,
|
311
|
+
FakeWeb.register_uri(:get,
|
304
312
|
"https://foo:bar@api.tropo.com/v1/users/foo",
|
305
|
-
:body => ActiveSupport::JSON.encode(@existing_user),
|
313
|
+
:body => ActiveSupport::JSON.encode(@existing_user),
|
306
314
|
:content_type => "application/json",
|
307
315
|
:status => ["200", "OK"])
|
308
|
-
|
316
|
+
|
309
317
|
# Invalid credentials
|
310
|
-
FakeWeb.register_uri(:get,
|
318
|
+
FakeWeb.register_uri(:get,
|
311
319
|
"https://bad:password@api.tropo.com/v1/users/bad",
|
312
320
|
:content_type => "application/json",
|
313
321
|
:status => ["401", "Unauthorized"])
|
314
|
-
|
322
|
+
|
315
323
|
# Confirm an account account
|
316
|
-
FakeWeb.register_uri(:post,
|
317
|
-
"https://foo:bar@api.tropo.com/v1/users/12345/confirmations",
|
318
|
-
:body => ActiveSupport::JSON.encode({"message" => "successfully confirmed user 12345" }),
|
324
|
+
FakeWeb.register_uri(:post,
|
325
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/confirmations",
|
326
|
+
:body => ActiveSupport::JSON.encode({"message" => "successfully confirmed user 12345" }),
|
319
327
|
:content_type => "application/json",
|
320
328
|
:status => ["200", "OK"])
|
321
|
-
|
329
|
+
|
322
330
|
# Return the payment method configured for a user
|
323
|
-
FakeWeb.register_uri(:get,
|
324
|
-
"https://foo:bar@api.tropo.com/v1/users/12345/payment/method",
|
325
|
-
:body => ActiveSupport::JSON.encode(@payment_method),
|
331
|
+
FakeWeb.register_uri(:get,
|
332
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/payment/method",
|
333
|
+
:body => ActiveSupport::JSON.encode(@payment_method),
|
326
334
|
:content_type => "application/json",
|
327
|
-
:status => ["200", "OK"])
|
335
|
+
:status => ["200", "OK"])
|
328
336
|
|
329
337
|
# Return payment types
|
330
|
-
FakeWeb.register_uri(:get,
|
331
|
-
"https://foo:bar@api.tropo.com/v1/types/payment",
|
332
|
-
:body => ActiveSupport::JSON.encode(@payment_methods),
|
338
|
+
FakeWeb.register_uri(:get,
|
339
|
+
"https://foo:bar@api.tropo.com/v1/types/payment",
|
340
|
+
:body => ActiveSupport::JSON.encode(@payment_methods),
|
333
341
|
:content_type => "application/json",
|
334
342
|
:status => ["200", "OK"])
|
335
|
-
|
343
|
+
|
336
344
|
# Return features
|
337
|
-
FakeWeb.register_uri(:get,
|
338
|
-
"https://foo:bar@api.tropo.com/v1/features",
|
339
|
-
:body => ActiveSupport::JSON.encode(@features),
|
345
|
+
FakeWeb.register_uri(:get,
|
346
|
+
"https://foo:bar@api.tropo.com/v1/features",
|
347
|
+
:body => ActiveSupport::JSON.encode(@features),
|
340
348
|
:content_type => "application/json",
|
341
|
-
:status => ["200", "OK"])
|
349
|
+
:status => ["200", "OK"])
|
342
350
|
|
343
351
|
# Return features for a user
|
344
|
-
FakeWeb.register_uri(:get,
|
345
|
-
"https://foo:bar@api.tropo.com/v1/users/12345/features",
|
346
|
-
:body => ActiveSupport::JSON.encode(@user_features),
|
352
|
+
FakeWeb.register_uri(:get,
|
353
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/features",
|
354
|
+
:body => ActiveSupport::JSON.encode(@user_features),
|
347
355
|
:content_type => "application/json",
|
348
356
|
:status => ["200", "OK"])
|
349
357
|
|
350
358
|
# Add a feature to a user
|
351
|
-
FakeWeb.register_uri(:post,
|
352
|
-
"https://foo:bar@api.tropo.com/v1/users/12345/features",
|
353
|
-
:body => ActiveSupport::JSON.encode(@feature),
|
359
|
+
FakeWeb.register_uri(:post,
|
360
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/features",
|
361
|
+
:body => ActiveSupport::JSON.encode(@feature),
|
354
362
|
:content_type => "application/json",
|
355
363
|
:status => ["200", "OK"])
|
356
|
-
|
364
|
+
|
357
365
|
# Add a feature to a user
|
358
|
-
FakeWeb.register_uri(:delete,
|
359
|
-
"https://foo:bar@api.tropo.com/v1/users/12345/features/8",
|
360
|
-
:body => ActiveSupport::JSON.encode(@feature_delete_message),
|
366
|
+
FakeWeb.register_uri(:delete,
|
367
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/features/8",
|
368
|
+
:body => ActiveSupport::JSON.encode(@feature_delete_message),
|
361
369
|
:content_type => "application/json",
|
362
370
|
:status => ["200", "OK"])
|
363
|
-
|
371
|
+
|
364
372
|
# Add payment info to a user
|
365
|
-
FakeWeb.register_uri(:put,
|
366
|
-
"https://foo:bar@api.tropo.com/v1/users/12345/payment/method",
|
373
|
+
FakeWeb.register_uri(:put,
|
374
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/payment/method",
|
367
375
|
:body => ActiveSupport::JSON.encode(@payment_info_message),
|
368
376
|
:content_type => "application/json",
|
369
377
|
:status => ["200", "OK"])
|
370
378
|
|
371
|
-
|
379
|
+
|
372
380
|
# List an account, with bad credentials
|
373
|
-
FakeWeb.register_uri(:get,
|
374
|
-
"https://evolution.voxeo.com/api/account/accesstoken/get.jsp?username=foobar7474&password=fooeyfooey",
|
375
|
-
:body => ActiveSupport::JSON.encode(@bad_account_creds),
|
381
|
+
FakeWeb.register_uri(:get,
|
382
|
+
"https://evolution.voxeo.com/api/account/accesstoken/get.jsp?username=foobar7474&password=fooeyfooey",
|
383
|
+
:body => ActiveSupport::JSON.encode(@bad_account_creds),
|
376
384
|
:content_type => "application/json",
|
377
385
|
:status => ["403", "Invalid Login."])
|
378
|
-
|
386
|
+
|
379
387
|
# Get our search terms
|
380
|
-
FakeWeb.register_uri(:get,
|
381
|
-
"https://foo:bar@api.tropo.com/v1/users/?username=foobar",
|
382
|
-
:body => ActiveSupport::JSON.encode(@search_accounts),
|
388
|
+
FakeWeb.register_uri(:get,
|
389
|
+
"https://foo:bar@api.tropo.com/v1/users/?username=foobar",
|
390
|
+
:body => ActiveSupport::JSON.encode(@search_accounts),
|
383
391
|
:content_type => "application/json",
|
384
392
|
:status => ["200", "OK"])
|
385
|
-
|
393
|
+
|
386
394
|
# Payment resource
|
387
|
-
FakeWeb.register_uri(:post,
|
388
|
-
"https://foo:bar@api.tropo.com/v1/users/1234/payments",
|
389
|
-
:body => ActiveSupport::JSON.encode({ :message => "successfully posted payment for the amount 1.000000" }),
|
395
|
+
FakeWeb.register_uri(:post,
|
396
|
+
"https://foo:bar@api.tropo.com/v1/users/1234/payments",
|
397
|
+
:body => ActiveSupport::JSON.encode({ :message => "successfully posted payment for the amount 1.000000" }),
|
390
398
|
:content_type => "application/json",
|
391
|
-
:status => ["200", "OK"])
|
392
|
-
|
399
|
+
:status => ["200", "OK"])
|
400
|
+
|
393
401
|
# Modify a user
|
394
|
-
FakeWeb.register_uri(:put,
|
395
|
-
"https://foo:bar@api.tropo.com/v1/users/12345",
|
396
|
-
:body => ActiveSupport::JSON.encode({ :href => "http://api-smsified-eng.voxeo.net/v1/users/12345" }),
|
402
|
+
FakeWeb.register_uri(:put,
|
403
|
+
"https://foo:bar@api.tropo.com/v1/users/12345",
|
404
|
+
:body => ActiveSupport::JSON.encode({ :href => "http://api-smsified-eng.voxeo.net/v1/users/12345" }),
|
397
405
|
:content_type => "application/json",
|
398
406
|
:status => ["200", "OK"])
|
399
|
-
|
407
|
+
|
400
408
|
# List available partitions
|
401
|
-
FakeWeb.register_uri(:get,
|
402
|
-
"https://foo:bar@api.tropo.com/v1/partitions",
|
403
|
-
:body => ActiveSupport::JSON.encode(@partitions),
|
409
|
+
FakeWeb.register_uri(:get,
|
410
|
+
"https://foo:bar@api.tropo.com/v1/partitions",
|
411
|
+
:body => ActiveSupport::JSON.encode(@partitions),
|
404
412
|
:content_type => "application/json",
|
405
413
|
:status => ["200", "OK"])
|
406
|
-
|
414
|
+
|
407
415
|
# List available platforms
|
408
|
-
FakeWeb.register_uri(:get,
|
409
|
-
"https://foo:bar@api.tropo.com/v1/partitions/staging/platforms",
|
410
|
-
:body => ActiveSupport::JSON.encode(@platforms),
|
416
|
+
FakeWeb.register_uri(:get,
|
417
|
+
"https://foo:bar@api.tropo.com/v1/partitions/staging/platforms",
|
418
|
+
:body => ActiveSupport::JSON.encode(@platforms),
|
411
419
|
:content_type => "application/json",
|
412
420
|
:status => ["200", "OK"])
|
413
|
-
|
421
|
+
|
414
422
|
# List balance
|
415
|
-
FakeWeb.register_uri(:get,
|
416
|
-
"https://foo:bar@api.tropo.com/v1/users/12345/usage",
|
417
|
-
:body => ActiveSupport::JSON.encode(@balance),
|
423
|
+
FakeWeb.register_uri(:get,
|
424
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/usage",
|
425
|
+
:body => ActiveSupport::JSON.encode(@balance),
|
418
426
|
:content_type => "application/json",
|
419
427
|
:status => ["200", "OK"])
|
420
|
-
|
428
|
+
|
421
429
|
# Whitelist
|
422
|
-
FakeWeb.register_uri(:get,
|
423
|
-
"https://foo:bar@api.tropo.com/v1/users/12345/partitions/production/platforms/sms/whitelist",
|
424
|
-
:body => ActiveSupport::JSON.encode(@whitelist),
|
430
|
+
FakeWeb.register_uri(:get,
|
431
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/partitions/production/platforms/sms/whitelist",
|
432
|
+
:body => ActiveSupport::JSON.encode(@whitelist),
|
425
433
|
:content_type => "application/json",
|
426
434
|
:status => ["200", "OK"])
|
427
435
|
# Whitelist
|
428
|
-
FakeWeb.register_uri(:get,
|
429
|
-
"https://foo:bar@api.tropo.com/v1/users/partitions/production/platforms/sms/whitelist",
|
430
|
-
:body => ActiveSupport::JSON.encode(@whitelist),
|
436
|
+
FakeWeb.register_uri(:get,
|
437
|
+
"https://foo:bar@api.tropo.com/v1/users/partitions/production/platforms/sms/whitelist",
|
438
|
+
:body => ActiveSupport::JSON.encode(@whitelist),
|
431
439
|
:content_type => "application/json",
|
432
440
|
:status => ["200", "OK"])
|
433
|
-
|
441
|
+
|
434
442
|
# Whitelist create
|
435
|
-
FakeWeb.register_uri(:post,
|
436
|
-
"https://foo:bar@api.tropo.com/v1/users/12345/partitions/production/platforms/sms/whitelist",
|
437
|
-
:body => ActiveSupport::JSON.encode(@whitelist),
|
443
|
+
FakeWeb.register_uri(:post,
|
444
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/partitions/production/platforms/sms/whitelist",
|
445
|
+
:body => ActiveSupport::JSON.encode(@whitelist),
|
438
446
|
:content_type => "application/json",
|
439
447
|
:status => ["200", "OK"])
|
440
448
|
# Whitelist delete
|
441
|
-
FakeWeb.register_uri(:delete,
|
442
|
-
"https://foo:bar@api.tropo.com/v1/users/12345/partitions/production/platforms/sms/whitelist/14155551212",
|
443
|
-
:body => ActiveSupport::JSON.encode(@whitelist),
|
449
|
+
FakeWeb.register_uri(:delete,
|
450
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/partitions/production/platforms/sms/whitelist/14155551212",
|
451
|
+
:body => ActiveSupport::JSON.encode(@whitelist),
|
444
452
|
:content_type => "application/json",
|
445
453
|
:status => ["200", "OK"])
|
446
|
-
|
454
|
+
|
447
455
|
# Countries
|
448
|
-
FakeWeb.register_uri(:get,
|
449
|
-
"https://foo:bar@api.tropo.com/v1/countries",
|
450
|
-
:body => ActiveSupport::JSON.encode(@countries),
|
456
|
+
FakeWeb.register_uri(:get,
|
457
|
+
"https://foo:bar@api.tropo.com/v1/countries",
|
458
|
+
:body => ActiveSupport::JSON.encode(@countries),
|
451
459
|
:content_type => "application/json",
|
452
460
|
:status => ["200", "OK"])
|
453
461
|
|
454
462
|
# States
|
455
|
-
FakeWeb.register_uri(:get,
|
456
|
-
"https://foo:bar@api.tropo.com/v1/countries/36/states",
|
457
|
-
:body => ActiveSupport::JSON.encode(@states),
|
463
|
+
FakeWeb.register_uri(:get,
|
464
|
+
"https://foo:bar@api.tropo.com/v1/countries/36/states",
|
465
|
+
:body => ActiveSupport::JSON.encode(@states),
|
458
466
|
:content_type => "application/json",
|
459
467
|
:status => ["200", "OK"])
|
460
|
-
|
468
|
+
|
461
469
|
# Recurrency get
|
462
|
-
FakeWeb.register_uri(:get,
|
463
|
-
"https://foo:bar@api.tropo.com/v1/users/1234/payment/recurrence",
|
464
|
-
:body => ActiveSupport::JSON.encode(@recurrence),
|
470
|
+
FakeWeb.register_uri(:get,
|
471
|
+
"https://foo:bar@api.tropo.com/v1/users/1234/payment/recurrence",
|
472
|
+
:body => ActiveSupport::JSON.encode(@recurrence),
|
465
473
|
:content_type => "application/json",
|
466
474
|
:status => ["200", "OK"])
|
467
|
-
|
475
|
+
|
468
476
|
# Recurrency update
|
469
|
-
FakeWeb.register_uri(:put,
|
470
|
-
"https://foo:bar@api.tropo.com/v1/users/1234/payment/recurrence",
|
471
|
-
:body => ActiveSupport::JSON.encode(@recurrence_updated),
|
477
|
+
FakeWeb.register_uri(:put,
|
478
|
+
"https://foo:bar@api.tropo.com/v1/users/1234/payment/recurrence",
|
479
|
+
:body => ActiveSupport::JSON.encode(@recurrence_updated),
|
472
480
|
:content_type => "application/json",
|
473
481
|
:status => ["200", "OK"])
|
474
|
-
|
482
|
+
|
475
483
|
@invitation_created = { 'href' => "http://api-smsified-eng.voxeo.net/v1/invitations/ABC457" }
|
476
484
|
@deleted_invitation = { 'message' => "deleted invitation at uri http://api-smsified-eng.voxeo.net/v1/invitations/ABC457" }
|
477
485
|
@invitations = [ { 'code' => "ABC456", 'count' => 100, 'credit' => "10.00", 'href' => "http://api-smsified-eng.voxeo.net/v1/invitations/ABC456" },
|
478
486
|
{ 'code' => "ABC457", 'count' => 100, 'credit' => "10.00", 'href' => "http://api-smsified-eng.voxeo.net/v1/invitations/ABC457" }]
|
479
487
|
|
480
488
|
# List invitations
|
481
|
-
FakeWeb.register_uri(:get,
|
482
|
-
"https://foo:bar@api.tropo.com/v1/invitations",
|
483
|
-
:body => ActiveSupport::JSON.encode(@invitations),
|
489
|
+
FakeWeb.register_uri(:get,
|
490
|
+
"https://foo:bar@api.tropo.com/v1/invitations",
|
491
|
+
:body => ActiveSupport::JSON.encode(@invitations),
|
484
492
|
:content_type => "application/json",
|
485
493
|
:status => ["200", "OK"])
|
486
494
|
|
487
495
|
# Get an invitation
|
488
|
-
FakeWeb.register_uri(:get,
|
489
|
-
"https://foo:bar@api.tropo.com/v1/invitations/ABC457",
|
490
|
-
:body => ActiveSupport::JSON.encode(@invitations[1]),
|
496
|
+
FakeWeb.register_uri(:get,
|
497
|
+
"https://foo:bar@api.tropo.com/v1/invitations/ABC457",
|
498
|
+
:body => ActiveSupport::JSON.encode(@invitations[1]),
|
491
499
|
:content_type => "application/json",
|
492
500
|
:status => ["200", "OK"])
|
493
501
|
|
494
502
|
# Update an invitation
|
495
|
-
FakeWeb.register_uri(:put,
|
496
|
-
"https://foo:bar@api.tropo.com/v1/invitations/ABC457",
|
497
|
-
:body => ActiveSupport::JSON.encode(@invitation_created),
|
503
|
+
FakeWeb.register_uri(:put,
|
504
|
+
"https://foo:bar@api.tropo.com/v1/invitations/ABC457",
|
505
|
+
:body => ActiveSupport::JSON.encode(@invitation_created),
|
498
506
|
:content_type => "application/json",
|
499
507
|
:status => ["200", "OK"])
|
500
|
-
|
508
|
+
|
501
509
|
# Update an invitation
|
502
|
-
FakeWeb.register_uri(:put,
|
503
|
-
"https://foo:bar@api.tropo.com/v1/users/15909/invitations/ABC457",
|
504
|
-
:body => ActiveSupport::JSON.encode(@invitation_created),
|
510
|
+
FakeWeb.register_uri(:put,
|
511
|
+
"https://foo:bar@api.tropo.com/v1/users/15909/invitations/ABC457",
|
512
|
+
:body => ActiveSupport::JSON.encode(@invitation_created),
|
505
513
|
:content_type => "application/json",
|
506
514
|
:status => ["200", "OK"])
|
507
|
-
|
515
|
+
|
508
516
|
# Delete an invitation
|
509
|
-
FakeWeb.register_uri(:delete,
|
510
|
-
"https://foo:bar@api.tropo.com/v1/invitations/ABC457",
|
511
|
-
:body => ActiveSupport::JSON.encode(@deleted_invitation),
|
517
|
+
FakeWeb.register_uri(:delete,
|
518
|
+
"https://foo:bar@api.tropo.com/v1/invitations/ABC457",
|
519
|
+
:body => ActiveSupport::JSON.encode(@deleted_invitation),
|
512
520
|
:content_type => "application/json",
|
513
521
|
:status => ["200", "OK"])
|
514
|
-
|
522
|
+
|
515
523
|
# Delete an invitation
|
516
|
-
FakeWeb.register_uri(:delete,
|
517
|
-
"https://foo:bar@api.tropo.com/v1/users/15909/invitations/ABC457",
|
518
|
-
:body => ActiveSupport::JSON.encode(@deleted_invitation),
|
524
|
+
FakeWeb.register_uri(:delete,
|
525
|
+
"https://foo:bar@api.tropo.com/v1/users/15909/invitations/ABC457",
|
526
|
+
:body => ActiveSupport::JSON.encode(@deleted_invitation),
|
519
527
|
:content_type => "application/json",
|
520
528
|
:status => ["200", "OK"])
|
521
|
-
|
529
|
+
|
522
530
|
# Create invitation
|
523
|
-
FakeWeb.register_uri(:post,
|
524
|
-
"https://foo:bar@api.tropo.com/v1/invitations",
|
525
|
-
:body => ActiveSupport::JSON.encode(@invitation_created),
|
531
|
+
FakeWeb.register_uri(:post,
|
532
|
+
"https://foo:bar@api.tropo.com/v1/invitations",
|
533
|
+
:body => ActiveSupport::JSON.encode(@invitation_created),
|
526
534
|
:content_type => "application/json",
|
527
535
|
:status => ["200", "OK"])
|
528
536
|
|
529
537
|
# Create invitation
|
530
|
-
FakeWeb.register_uri(:post,
|
531
|
-
"https://foo:bar@api.tropo.com/v1/users/15909/invitations",
|
532
|
-
:body => ActiveSupport::JSON.encode(@invitation_created),
|
538
|
+
FakeWeb.register_uri(:post,
|
539
|
+
"https://foo:bar@api.tropo.com/v1/users/15909/invitations",
|
540
|
+
:body => ActiveSupport::JSON.encode(@invitation_created),
|
533
541
|
:content_type => "application/json",
|
534
542
|
:status => ["200", "OK"])
|
535
|
-
|
543
|
+
|
536
544
|
# List invitation for a user
|
537
|
-
FakeWeb.register_uri(:get,
|
538
|
-
"https://foo:bar@api.tropo.com/v1/users/15909/invitations",
|
539
|
-
:body => ActiveSupport::JSON.encode([@invitation_created]),
|
545
|
+
FakeWeb.register_uri(:get,
|
546
|
+
"https://foo:bar@api.tropo.com/v1/users/15909/invitations",
|
547
|
+
:body => ActiveSupport::JSON.encode([@invitation_created]),
|
540
548
|
:content_type => "application/json",
|
541
549
|
:status => ["200", "OK"])
|
542
|
-
|
550
|
+
|
543
551
|
# List invitation for a user via SSL
|
544
|
-
FakeWeb.register_uri(:get,
|
545
|
-
"https://foo:bar@api.tropo.com/v1/invitations",
|
546
|
-
:body => ActiveSupport::JSON.encode(@invitations),
|
552
|
+
FakeWeb.register_uri(:get,
|
553
|
+
"https://foo:bar@api.tropo.com/v1/invitations",
|
554
|
+
:body => ActiveSupport::JSON.encode(@invitations),
|
547
555
|
:content_type => "application/json",
|
548
556
|
:status => ["200", "OK"])
|
549
|
-
|
557
|
+
|
550
558
|
# List invitation for a user
|
551
|
-
FakeWeb.register_uri(:get,
|
552
|
-
"https://foo:bar@api.tropo.com/v1/users/15909/invitations/ABC457",
|
553
|
-
:body => ActiveSupport::JSON.encode(@invitations[1]),
|
559
|
+
FakeWeb.register_uri(:get,
|
560
|
+
"https://foo:bar@api.tropo.com/v1/users/15909/invitations/ABC457",
|
561
|
+
:body => ActiveSupport::JSON.encode(@invitations[1]),
|
554
562
|
:content_type => "application/json",
|
555
563
|
:status => ["200", "OK"])
|
556
|
-
|
564
|
+
|
557
565
|
@username_check = { 'available' => false, 'href' => "http://api.smsified.com/v1/usernames/jsgoecke", 'valid' => true }
|
558
566
|
# List invitation for a user
|
559
|
-
FakeWeb.register_uri(:get,
|
560
|
-
"https://foo:bar@api.tropo.com/v1/usernames/12345",
|
561
|
-
:body => ActiveSupport::JSON.encode(@username_check),
|
567
|
+
FakeWeb.register_uri(:get,
|
568
|
+
"https://foo:bar@api.tropo.com/v1/usernames/12345",
|
569
|
+
:body => ActiveSupport::JSON.encode(@username_check),
|
562
570
|
:content_type => "application/json",
|
563
571
|
:status => ["200", "OK"])
|
564
572
|
end
|
565
|
-
|
566
|
-
let(:tropo_provisioning) do
|
573
|
+
|
574
|
+
let(:tropo_provisioning) do
|
567
575
|
TropoProvisioning.new('foo', 'bar')
|
568
576
|
end
|
569
|
-
|
577
|
+
|
570
578
|
let(:exchanges) do
|
571
579
|
'[
|
572
580
|
{
|
@@ -619,11 +627,11 @@ describe "TropoProvisioning" do
|
|
619
627
|
}
|
620
628
|
]'
|
621
629
|
end
|
622
|
-
|
630
|
+
|
623
631
|
it "should create a TropoProvisioning object" do
|
624
632
|
tropo_provisioning.instance_of?(TropoProvisioning).should == true
|
625
633
|
end
|
626
|
-
|
634
|
+
|
627
635
|
describe 'authentication' do
|
628
636
|
it "should get an unathorized back if there is an invalid username or password" do
|
629
637
|
begin
|
@@ -632,12 +640,22 @@ describe "TropoProvisioning" do
|
|
632
640
|
e.to_s.should == '401: Unauthorized - '
|
633
641
|
end
|
634
642
|
end
|
635
|
-
|
643
|
+
|
636
644
|
it 'should have the user data on the object if a successful login' do
|
637
645
|
provisioning = TropoProvisioning.new('foo', 'bar')
|
638
646
|
provisioning.user_data['username'].should == 'foo'
|
639
647
|
end
|
640
|
-
|
648
|
+
|
649
|
+
it 'should take a base_url' do
|
650
|
+
provisioning = TropoProvisioning.new('foo', 'bar', :base_uri => "http://testserver.com/rest/v1")
|
651
|
+
provisioning.base_uri.should == "http://testserver.com/rest/v1/"
|
652
|
+
end
|
653
|
+
|
654
|
+
it 'should sanatize a dirty base_url' do
|
655
|
+
provisioning = TropoProvisioning.new('foo', 'bar', :base_uri => "http://testserver.com/rest/v1//////")
|
656
|
+
provisioning.base_uri.should == "http://testserver.com/rest/v1/"
|
657
|
+
end
|
658
|
+
|
641
659
|
it "should not provide a token for an existing account if wrong credentials" do
|
642
660
|
pending('Need to work on tests for the new account')
|
643
661
|
begin
|
@@ -646,14 +664,14 @@ describe "TropoProvisioning" do
|
|
646
664
|
e.to_s.should == "403 - Invalid Login."
|
647
665
|
end
|
648
666
|
end
|
649
|
-
|
667
|
+
|
650
668
|
it "should provide a token for an existing account" do
|
651
669
|
pending('Need to work on tests for the new account')
|
652
670
|
result = tropo_provisioning.account("foobar7474", 'fooey')
|
653
671
|
result.should == @list_account
|
654
672
|
end
|
655
673
|
end
|
656
|
-
|
674
|
+
|
657
675
|
describe 'applications' do
|
658
676
|
it "should get a list of applications" do
|
659
677
|
_applications = []
|
@@ -661,12 +679,12 @@ describe "TropoProvisioning" do
|
|
661
679
|
|
662
680
|
tropo_provisioning.applications.should == _applications
|
663
681
|
end
|
664
|
-
|
682
|
+
|
665
683
|
it "should get a specific application" do
|
666
684
|
response = tropo_provisioning.application '108000'
|
667
685
|
response['href'].should == applications[0]['href']
|
668
686
|
end
|
669
|
-
|
687
|
+
|
670
688
|
it "should raise ArgumentErrors if appropriate arguments are not specified" do
|
671
689
|
begin
|
672
690
|
tropo_provisioning.create_application({ :foo => 'bar' })
|
@@ -674,7 +692,7 @@ describe "TropoProvisioning" do
|
|
674
692
|
e.to_s.should == ':name is a required parameter'
|
675
693
|
end
|
676
694
|
end
|
677
|
-
|
695
|
+
|
678
696
|
it "should raise ArgumentErrors if appropriate values are not passed" do
|
679
697
|
begin
|
680
698
|
tropo_provisioning.create_application({ :name => 'foobar',
|
@@ -684,7 +702,7 @@ describe "TropoProvisioning" do
|
|
684
702
|
rescue => e
|
685
703
|
e.to_s.should == ":platform must be 'scripting' or 'webapi'"
|
686
704
|
end
|
687
|
-
|
705
|
+
|
688
706
|
begin
|
689
707
|
tropo_provisioning.create_application({ :name => 'foobar',
|
690
708
|
:partition => 'foobar',
|
@@ -694,7 +712,7 @@ describe "TropoProvisioning" do
|
|
694
712
|
e.to_s.should == ":partition must be 'staging' or 'production'"
|
695
713
|
end
|
696
714
|
end
|
697
|
-
|
715
|
+
|
698
716
|
it "should receive an href back when we create a new application receiving an href back" do
|
699
717
|
# With camelCase
|
700
718
|
result = tropo_provisioning.create_application({ :name => 'foobar',
|
@@ -703,7 +721,7 @@ describe "TropoProvisioning" do
|
|
703
721
|
:messagingUrl => 'http://foobar' })
|
704
722
|
result.href.should == "http://api.tropo.com/v1/applications/108016"
|
705
723
|
result.application_id.should == '108016'
|
706
|
-
|
724
|
+
|
707
725
|
# With underscores
|
708
726
|
result = tropo_provisioning.create_application({ :name => 'foobar',
|
709
727
|
:partition => 'production',
|
@@ -712,7 +730,7 @@ describe "TropoProvisioning" do
|
|
712
730
|
result.href.should == "http://api.tropo.com/v1/applications/108016"
|
713
731
|
result.application_id.should == '108016'
|
714
732
|
end
|
715
|
-
|
733
|
+
|
716
734
|
it "should receive an href back when we update an application receiving an href back" do
|
717
735
|
# With camelCase
|
718
736
|
result = tropo_provisioning.update_application('108000', { :name => 'foobar',
|
@@ -720,7 +738,7 @@ describe "TropoProvisioning" do
|
|
720
738
|
:platform => 'scripting',
|
721
739
|
:messagingUrl => 'http://foobar' })
|
722
740
|
result.href.should == "http://api.tropo.com/v1/applications/108016"
|
723
|
-
|
741
|
+
|
724
742
|
# With underscore
|
725
743
|
result = tropo_provisioning.update_application('108000', { :name => 'foobar',
|
726
744
|
:partition => 'production',
|
@@ -728,42 +746,42 @@ describe "TropoProvisioning" do
|
|
728
746
|
:messaging_url => 'http://foobar' })
|
729
747
|
result.href.should == "http://api.tropo.com/v1/applications/108016"
|
730
748
|
end
|
731
|
-
|
749
|
+
|
732
750
|
it "should delete an application" do
|
733
751
|
result = tropo_provisioning.delete_application('108000')
|
734
752
|
result.message.should == 'delete successful'
|
735
753
|
end
|
736
754
|
end
|
737
|
-
|
755
|
+
|
738
756
|
describe 'addresses' do
|
739
757
|
it "should list all of the addresses available for an application" do
|
740
758
|
result = tropo_provisioning.addresses('108000')
|
741
759
|
result.should == @addresses
|
742
760
|
end
|
743
|
-
|
761
|
+
|
744
762
|
it "should list a single address when requested with a number for numbers" do
|
745
763
|
result = tropo_provisioning.address('108000', '883510001812716')
|
746
764
|
result.should == @addresses[0]
|
747
765
|
end
|
748
|
-
|
766
|
+
|
749
767
|
it "should list a single address of the appropriate type when requested" do
|
750
768
|
# First a number
|
751
769
|
result = tropo_provisioning.address('108000', '883510001812716')
|
752
770
|
result.should == @addresses[0]
|
753
|
-
|
771
|
+
|
754
772
|
# Then an IM username
|
755
773
|
result = tropo_provisioning.address('108000', 'xyz123')
|
756
774
|
result.should == @addresses[2]
|
757
|
-
|
775
|
+
|
758
776
|
# Then a pin
|
759
777
|
result = tropo_provisioning.address('108000', '9991436300')
|
760
778
|
result.should == @addresses[3]
|
761
|
-
|
779
|
+
|
762
780
|
# Then a token
|
763
781
|
result = tropo_provisioning.address('108000', 'a1b2c3d4')
|
764
782
|
result.should == @addresses[4]
|
765
783
|
end
|
766
|
-
|
784
|
+
|
767
785
|
it "should generate an error of the addition of the address does not have a required field" do
|
768
786
|
# Add a address without a type
|
769
787
|
begin
|
@@ -771,35 +789,35 @@ describe "TropoProvisioning" do
|
|
771
789
|
rescue => e
|
772
790
|
e.to_s.should == ":type is a required parameter"
|
773
791
|
end
|
774
|
-
|
792
|
+
|
775
793
|
# Add a number without a prefix
|
776
794
|
begin
|
777
795
|
tropo_provisioning.create_address('108000', { :type => 'number' })
|
778
796
|
rescue => e
|
779
797
|
e.to_s.should == ":prefix required to add a number address"
|
780
798
|
end
|
781
|
-
|
799
|
+
|
782
800
|
# Add a jabber without a username
|
783
801
|
begin
|
784
802
|
tropo_provisioning.create_address('108000', { :type => 'jabber' })
|
785
803
|
rescue => e
|
786
804
|
e.to_s.should == ":username is a required parameter"
|
787
805
|
end
|
788
|
-
|
806
|
+
|
789
807
|
# Add an aim without a password
|
790
808
|
begin
|
791
809
|
tropo_provisioning.create_address('108000', { :type => 'aim', :username => 'joeblow@aim.com' })
|
792
810
|
rescue => e
|
793
811
|
e.to_s.should == ":password is a required parameter"
|
794
812
|
end
|
795
|
-
|
813
|
+
|
796
814
|
# Add a token without a channel
|
797
815
|
begin
|
798
816
|
tropo_provisioning.create_address('108000', { :type => 'token' })
|
799
817
|
rescue => e
|
800
818
|
e.to_s.should == ":channel is a required parameter"
|
801
819
|
end
|
802
|
-
|
820
|
+
|
803
821
|
# Add a token with an invalid channel type
|
804
822
|
begin
|
805
823
|
tropo_provisioning.create_address('108000', { :type => 'token', :channel => 'BBC' })
|
@@ -807,28 +825,28 @@ describe "TropoProvisioning" do
|
|
807
825
|
e.to_s.should == ":channel must be voice or messaging"
|
808
826
|
end
|
809
827
|
end
|
810
|
-
|
811
|
-
it "should add appropriate number address" do
|
828
|
+
|
829
|
+
it "should add appropriate number address" do
|
812
830
|
# Add a address based on a prefix
|
813
831
|
result = tropo_provisioning.create_address('108000', { :type => 'number', :prefix => '1303' })
|
814
832
|
result[:href].should == "http://api.tropo.com/v1/applications/108000/addresses/number/7202551912"
|
815
833
|
result[:address].should == '7202551912'
|
816
834
|
end
|
817
|
-
|
818
|
-
it "should add appropriate jabber address" do
|
835
|
+
|
836
|
+
it "should add appropriate jabber address" do
|
819
837
|
# Add a jabber account
|
820
838
|
result = tropo_provisioning.create_address('108001', { :type => 'jabber', :username => 'xyz123@bot.im' })
|
821
839
|
result[:href].should == "http://api.tropo.com/v1/applications/108001/addresses/jabber/xyz123@bot.im"
|
822
|
-
result[:address].should == 'xyz123@bot.im'
|
840
|
+
result[:address].should == 'xyz123@bot.im'
|
823
841
|
end
|
824
842
|
|
825
|
-
it "should add appropriate token address" do
|
843
|
+
it "should add appropriate token address" do
|
826
844
|
# Add a token
|
827
845
|
result = tropo_provisioning.create_address('108002', { :type => 'token', :channel => 'voice' })
|
828
846
|
result[:href].should == "http://api.tropo.com/v1/applications/108002/addresses/token/12345679f90bac47a05b178c37d3c68aaf38d5bdbc5aba0c7abb12345d8a9fd13f1234c1234567dbe2c6f63b"
|
829
847
|
result[:address].should == '12345679f90bac47a05b178c37d3c68aaf38d5bdbc5aba0c7abb12345d8a9fd13f1234c1234567dbe2c6f63b'
|
830
848
|
end
|
831
|
-
|
849
|
+
|
832
850
|
it "should delete a address" do
|
833
851
|
result = tropo_provisioning.delete_address('108000', '883510001812716')
|
834
852
|
result[:message].should == "delete successful"
|
@@ -858,7 +876,7 @@ describe "TropoProvisioning" do
|
|
858
876
|
results = tropo_provisioning.move_address({ :from => '108000', :to => '108002', :address => '883510001812716'})
|
859
877
|
results.should == { 'message' => 'delete successful' }
|
860
878
|
end
|
861
|
-
|
879
|
+
|
862
880
|
it "should return accounts with associated addresses" do
|
863
881
|
pending()
|
864
882
|
result = tropo_provisioning.account_with_addresses('108000')
|
@@ -868,14 +886,14 @@ describe "TropoProvisioning" do
|
|
868
886
|
result.should == nil
|
869
887
|
end
|
870
888
|
end
|
871
|
-
|
889
|
+
|
872
890
|
describe 'exchanges' do
|
873
891
|
it "should obtain a list of available exchanges" do
|
874
892
|
results = tropo_provisioning.exchanges
|
875
893
|
results.should == ActiveSupport::JSON.decode(exchanges)
|
876
894
|
end
|
877
895
|
end
|
878
|
-
|
896
|
+
|
879
897
|
describe 'user' do
|
880
898
|
it "should raise argument errors on create_user if required params not passed" do
|
881
899
|
begin
|
@@ -883,35 +901,35 @@ describe "TropoProvisioning" do
|
|
883
901
|
rescue => e
|
884
902
|
e.to_s.should == ':username is a required parameter'
|
885
903
|
end
|
886
|
-
|
904
|
+
|
887
905
|
begin
|
888
906
|
tropo_provisioning.create_user({ :username => "foobar7474" })
|
889
907
|
rescue => e
|
890
908
|
e.to_s.should == ':password is a required parameter'
|
891
909
|
end
|
892
|
-
|
910
|
+
|
893
911
|
begin
|
894
|
-
tropo_provisioning.create_user({ :username => "foobar7474", :password => 'fooey' })
|
912
|
+
tropo_provisioning.create_user({ :username => "foobar7474", :password => 'fooey', :first_name=> "blah",:last_name=>"blah" })
|
895
913
|
rescue => e
|
896
914
|
e.to_s.should == ':email is a required parameter'
|
897
915
|
end
|
898
916
|
end
|
899
|
-
|
917
|
+
|
900
918
|
it "should create a new user" do
|
901
|
-
result = tropo_provisioning.create_user({ :username => "foobar7474", :password => 'fooey', :email => 'jsgoecke@voxeo.com' })
|
919
|
+
result = tropo_provisioning.create_user({ :username => "foobar7474", :password => 'fooey', :email => 'jsgoecke@voxeo.com',:first_name=> "jason", :last_name=> "blah" })
|
902
920
|
result.should == @new_user
|
903
921
|
end
|
904
|
-
|
922
|
+
|
905
923
|
it "should confirm a user" do
|
906
924
|
result = tropo_provisioning.confirm_user('12345', '1234', '127.0.0.1')
|
907
925
|
result.message.should == "successfully confirmed user 12345"
|
908
926
|
end
|
909
|
-
|
927
|
+
|
910
928
|
it "should obtain details about a user" do
|
911
929
|
result = tropo_provisioning.user('12345')
|
912
930
|
result.should == @existing_user
|
913
931
|
end
|
914
|
-
|
932
|
+
|
915
933
|
it 'should return a list of search terms that we search for' do
|
916
934
|
result = tropo_provisioning.search_users('username=foobar')
|
917
935
|
result.should == @search_accounts
|
@@ -927,46 +945,46 @@ describe "TropoProvisioning" do
|
|
927
945
|
result.href.should == 'http://api-smsified-eng.voxeo.net/v1/users/12345'
|
928
946
|
tropo_provisioning.user_data['password'].should == 'foobar'
|
929
947
|
end
|
930
|
-
|
948
|
+
|
931
949
|
it 'should see if a username is available' do
|
932
950
|
tropo_provisioning.username_exists?('12345').should == @username_check
|
933
951
|
end
|
934
952
|
end
|
935
|
-
|
953
|
+
|
936
954
|
describe 'features' do
|
937
955
|
it "should return a list of available features" do
|
938
956
|
result = tropo_provisioning.features
|
939
957
|
result.should == @features
|
940
958
|
end
|
941
|
-
|
959
|
+
|
942
960
|
it "should return a list of features configured for a user" do
|
943
961
|
result = tropo_provisioning.user_features('12345')
|
944
962
|
result.should == @user_features
|
945
963
|
end
|
946
|
-
|
964
|
+
|
947
965
|
it "should add a feature to a user" do
|
948
966
|
result = tropo_provisioning.user_enable_feature('12345', 'http://api-smsified-eng.voxeo.net/v1/features/8')
|
949
967
|
result.should == @feature
|
950
968
|
end
|
951
|
-
|
969
|
+
|
952
970
|
it "should disable a feature for a user" do
|
953
971
|
result = tropo_provisioning.user_disable_feature('12345', '8')
|
954
972
|
result.should == @feature_delete_message
|
955
973
|
end
|
956
974
|
end
|
957
|
-
|
975
|
+
|
958
976
|
describe 'platforms and partitions' do
|
959
977
|
it 'should list the available partitions' do
|
960
978
|
result = tropo_provisioning.partitions
|
961
979
|
result[0]['name'].should == 'staging'
|
962
980
|
end
|
963
|
-
|
981
|
+
|
964
982
|
it 'should return a list of available platforms under a partition' do
|
965
983
|
result = tropo_provisioning.platforms('staging')
|
966
984
|
result[0].name.should == 'sms'
|
967
985
|
end
|
968
986
|
end
|
969
|
-
|
987
|
+
|
970
988
|
describe 'payments' do
|
971
989
|
it "should add a payment method to a user" do
|
972
990
|
result = tropo_provisioning.add_payment_info('12345', { :account_number => '1234567890',
|
@@ -985,7 +1003,7 @@ describe "TropoProvisioning" do
|
|
985
1003
|
:phone_number => '4155551212' })
|
986
1004
|
result.should == @payment_info_message
|
987
1005
|
end
|
988
|
-
|
1006
|
+
|
989
1007
|
it "should add a payment method to a user in camelCase" do
|
990
1008
|
result = tropo_provisioning.add_payment_info('12345', { :accountNumber => '1234567890',
|
991
1009
|
:paymentType => 'https://api-smsified-eng.voxeo.net/v1/types/payment/1',
|
@@ -1002,7 +1020,7 @@ describe "TropoProvisioning" do
|
|
1002
1020
|
:email => 'j@doe.com',
|
1003
1021
|
:phoneNumber => '4155551212' })
|
1004
1022
|
|
1005
|
-
result.should == @payment_info_message
|
1023
|
+
result.should == @payment_info_message
|
1006
1024
|
end
|
1007
1025
|
|
1008
1026
|
it 'should add a payment method to a user keys as strings' do
|
@@ -1024,7 +1042,7 @@ describe "TropoProvisioning" do
|
|
1024
1042
|
|
1025
1043
|
result.should == @payment_info_message
|
1026
1044
|
end
|
1027
|
-
|
1045
|
+
|
1028
1046
|
it 'should add a payment method to a user in camelCase and keys as strings' do
|
1029
1047
|
result = tropo_provisioning.add_payment_info('12345', { 'accountNumber' => '1234567890',
|
1030
1048
|
'paymentType' => 'https://api-smsified-eng.voxeo.net/v1/types/payment/1',
|
@@ -1043,17 +1061,17 @@ describe "TropoProvisioning" do
|
|
1043
1061
|
|
1044
1062
|
result.should == @payment_info_message
|
1045
1063
|
end
|
1046
|
-
|
1064
|
+
|
1047
1065
|
it 'should return the balance' do
|
1048
1066
|
result = tropo_provisioning.balance('12345')
|
1049
1067
|
result['balance'].should == "3.00"
|
1050
1068
|
end
|
1051
|
-
|
1069
|
+
|
1052
1070
|
it 'should make a payment' do
|
1053
1071
|
result = tropo_provisioning.make_payment('1234', 1.0)
|
1054
1072
|
result.message.should == "successfully posted payment for the amount 1.000000"
|
1055
1073
|
end
|
1056
|
-
|
1074
|
+
|
1057
1075
|
it "should get the payment method for a user" do
|
1058
1076
|
result = tropo_provisioning.user_payment_method('12345')
|
1059
1077
|
result.should == @payment_method
|
@@ -1063,7 +1081,7 @@ describe "TropoProvisioning" do
|
|
1063
1081
|
result = tropo_provisioning.available_payment_types
|
1064
1082
|
result.should == @payment_methods
|
1065
1083
|
end
|
1066
|
-
|
1084
|
+
|
1067
1085
|
it 'should raise an error if a float is not passed in amount for make_payment' do
|
1068
1086
|
begin
|
1069
1087
|
tropo_provisioning.make_payment('1234', { :foo => 'bar' })
|
@@ -1071,37 +1089,37 @@ describe "TropoProvisioning" do
|
|
1071
1089
|
e.to_s.should == "amount must be of type Float"
|
1072
1090
|
end
|
1073
1091
|
end
|
1074
|
-
|
1092
|
+
|
1075
1093
|
it 'should update the recurring payment details' do
|
1076
1094
|
result = tropo_provisioning.update_recurrence('1234', { :recharge_amount => 13.50, :threshold_percentage => 10 })
|
1077
1095
|
result.should == @recurrence_updated
|
1078
1096
|
end
|
1079
|
-
|
1097
|
+
|
1080
1098
|
it 'should get the existing recurrent payment details' do
|
1081
1099
|
tropo_provisioning.get_recurrence('1234').should == @recurrence
|
1082
1100
|
end
|
1083
1101
|
end
|
1084
|
-
|
1102
|
+
|
1085
1103
|
describe 'whitelists' do
|
1086
1104
|
it 'should get the whitelist for a user account' do
|
1087
1105
|
result = tropo_provisioning.whitelist('12345')
|
1088
1106
|
result.should == @whitelist
|
1089
|
-
|
1107
|
+
|
1090
1108
|
result = tropo_provisioning.whitelist
|
1091
1109
|
result.should == @whitelist
|
1092
1110
|
end
|
1093
|
-
|
1111
|
+
|
1094
1112
|
it 'should add to a whitelist' do
|
1095
1113
|
result = tropo_provisioning.add_whitelist({ :user_id => '12345', :value => '14155551212' })
|
1096
1114
|
result.should == @whitelist
|
1097
1115
|
end
|
1098
|
-
|
1116
|
+
|
1099
1117
|
it 'should remove from a whitelist' do
|
1100
1118
|
result = tropo_provisioning.delete_whitelist({ :user_id => '12345', :value => '14155551212' })
|
1101
1119
|
result.should == @whitelist
|
1102
1120
|
end
|
1103
1121
|
end
|
1104
|
-
|
1122
|
+
|
1105
1123
|
describe 'custome error' do
|
1106
1124
|
it 'should raise a custom error with an http_status code on the error object' do
|
1107
1125
|
begin
|
@@ -1112,75 +1130,75 @@ describe "TropoProvisioning" do
|
|
1112
1130
|
end
|
1113
1131
|
end
|
1114
1132
|
end
|
1115
|
-
|
1133
|
+
|
1116
1134
|
describe 'geography' do
|
1117
1135
|
it 'should return a list of countries' do
|
1118
1136
|
tropo_provisioning.countries.should == @countries
|
1119
1137
|
end
|
1120
|
-
|
1138
|
+
|
1121
1139
|
it 'should have the id added for the country' do
|
1122
1140
|
result = tropo_provisioning.countries[1][:id].should == '36'
|
1123
1141
|
end
|
1124
|
-
|
1142
|
+
|
1125
1143
|
it 'should return a list of states' do
|
1126
1144
|
tropo_provisioning.states('36').should == @states
|
1127
1145
|
end
|
1128
|
-
|
1146
|
+
|
1129
1147
|
it 'should have the id added for the state' do
|
1130
1148
|
tropo_provisioning.states('36')[1]['id'].should == '50'
|
1131
1149
|
end
|
1132
1150
|
end
|
1133
|
-
|
1151
|
+
|
1134
1152
|
describe 'invitations' do
|
1135
1153
|
it 'should return a list of inivitations' do
|
1136
1154
|
tropo_provisioning.invitations.should == @invitations
|
1137
1155
|
end
|
1138
|
-
|
1156
|
+
|
1139
1157
|
it 'should return an invitation' do
|
1140
1158
|
tropo_provisioning.invitation('ABC457').should == @invitations[1]
|
1141
1159
|
end
|
1142
|
-
|
1160
|
+
|
1143
1161
|
it 'should create an invitation' do
|
1144
1162
|
tropo_provisioning.create_invitation({ :code => 'ABC457',
|
1145
1163
|
:count => 100,
|
1146
1164
|
:credit => 10 }).should == @invitation_created
|
1147
1165
|
end
|
1148
|
-
|
1166
|
+
|
1149
1167
|
it 'should create an invitationfor a specific user' do
|
1150
1168
|
tropo_provisioning.create_invitation('15909',
|
1151
1169
|
{ :code => 'ABC457',
|
1152
1170
|
:count => 100,
|
1153
1171
|
:credit => 10 }).should == @invitation_created
|
1154
1172
|
end
|
1155
|
-
|
1173
|
+
|
1156
1174
|
it 'should update an invitation' do
|
1157
1175
|
tropo_provisioning.update_invitation('ABC457', :count => 200).should == @invitation_created
|
1158
1176
|
end
|
1159
|
-
|
1177
|
+
|
1160
1178
|
it 'should update an invitation for a specific user' do
|
1161
1179
|
tropo_provisioning.update_invitation('ABC457', '15909', :count => 200).should == @invitation_created
|
1162
1180
|
end
|
1163
|
-
|
1181
|
+
|
1164
1182
|
it 'should delete an invitation' do
|
1165
1183
|
tropo_provisioning.delete_invitation('ABC457').should == @deleted_invitation
|
1166
1184
|
end
|
1167
|
-
|
1185
|
+
|
1168
1186
|
it 'should delete a specific user invitation' do
|
1169
1187
|
tropo_provisioning.delete_invitation('ABC457', '15909').should == @deleted_invitation
|
1170
1188
|
end
|
1171
|
-
|
1189
|
+
|
1172
1190
|
it 'should fetch the invitations for a user' do
|
1173
1191
|
tropo_provisioning.user_invitations('15909').should == [@invitation_created]
|
1174
1192
|
end
|
1175
|
-
|
1193
|
+
|
1176
1194
|
it 'should list a specific invitation for a user' do
|
1177
1195
|
tropo_provisioning.invitation('ABC457', '15909').should == @invitations[1]
|
1178
1196
|
end
|
1179
1197
|
end
|
1180
|
-
|
1198
|
+
|
1181
1199
|
describe "HTTPS/SSL support" do
|
1182
1200
|
it 'should fetch invitations via HTTPS/SSL' do
|
1183
1201
|
tropo_provisioning.invitations.should == @invitations
|
1184
1202
|
end
|
1185
1203
|
end
|
1186
|
-
end
|
1204
|
+
end
|