ruby-transmitsms 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +49 -0
- data/LICENSE +22 -0
- data/README.md +62 -0
- data/Rakefile +7 -0
- data/fixtures/vcr_cassettes/account_api_get_balance.yml +49 -0
- data/fixtures/vcr_cassettes/email_sms_api_add_email.yml +49 -0
- data/fixtures/vcr_cassettes/email_sms_api_delete_email.yml +49 -0
- data/fixtures/vcr_cassettes/keywords_api_add_keyword.yml +49 -0
- data/fixtures/vcr_cassettes/keywords_api_edit_keyword.yml +49 -0
- data/fixtures/vcr_cassettes/keywords_api_get_keywords.yml +50 -0
- data/fixtures/vcr_cassettes/lists_api_add_list.yml +49 -0
- data/fixtures/vcr_cassettes/lists_api_add_to_list.yml +50 -0
- data/fixtures/vcr_cassettes/lists_api_delete_from_list.yml +49 -0
- data/fixtures/vcr_cassettes/lists_api_edit_list_member.yml +50 -0
- data/fixtures/vcr_cassettes/lists_api_get_list.yml +60 -0
- data/fixtures/vcr_cassettes/lists_api_get_lists.yml +61 -0
- data/fixtures/vcr_cassettes/lists_api_optout_list_member.yml +49 -0
- data/fixtures/vcr_cassettes/lists_api_remove_list.yml +49 -0
- data/fixtures/vcr_cassettes/numbers_api_get_number.yml +49 -0
- data/fixtures/vcr_cassettes/numbers_api_get_numbers.yml +49 -0
- data/fixtures/vcr_cassettes/numbers_api_lease_number.yml +50 -0
- data/fixtures/vcr_cassettes/resellers_api_add_client.yml +49 -0
- data/fixtures/vcr_cassettes/resellers_api_edit_client.yml +40 -0
- data/fixtures/vcr_cassettes/resellers_api_get_client.yml +50 -0
- data/fixtures/vcr_cassettes/resellers_api_get_clients.yml +59 -0
- data/fixtures/vcr_cassettes/resellers_api_get_transaction.yml +51 -0
- data/fixtures/vcr_cassettes/resellers_api_get_transactions.yml +61 -0
- data/fixtures/vcr_cassettes/sms_api_test_cancel_sms.yml +50 -0
- data/fixtures/vcr_cassettes/sms_api_test_format_number.yml +49 -0
- data/fixtures/vcr_cassettes/sms_api_test_format_number_fail_in_missing_msisdn.yml +50 -0
- data/fixtures/vcr_cassettes/sms_api_test_get_message_log.yml +50 -0
- data/fixtures/vcr_cassettes/sms_api_test_get_sms_info.yml +49 -0
- data/fixtures/vcr_cassettes/sms_api_test_get_sms_info_fail_for_not_existing_message_id.yml +50 -0
- data/fixtures/vcr_cassettes/sms_api_test_get_sms_responses.yml +53 -0
- data/fixtures/vcr_cassettes/sms_api_test_get_sms_sent.yml +50 -0
- data/fixtures/vcr_cassettes/sms_api_test_get_user_sms_responses.yml +49 -0
- data/fixtures/vcr_cassettes/sms_api_test_message_reply.yml +49 -0
- data/fixtures/vcr_cassettes/sms_api_test_send.yml +49 -0
- data/fixtures/vcr_cassettes/sms_api_test_send_missing_to_and_list_id.yml +50 -0
- data/fixtures/vcr_cassettes/sms_api_test_send_with_list_id.yml +50 -0
- data/geminstall.sh +1 -0
- data/lib/account_api.rb +80 -0
- data/lib/email_api.rb +137 -0
- data/lib/keywords_api.rb +224 -0
- data/lib/lists_api.rb +523 -0
- data/lib/monkey.rb +90 -0
- data/lib/numbers_api.rb +188 -0
- data/lib/resellers_api.rb +379 -0
- data/lib/ruby-transmitsms.rb +16 -0
- data/lib/sms_api.rb +550 -0
- data/lib/swagger.rb +84 -0
- data/lib/swagger/configuration.rb +22 -0
- data/lib/swagger/request.rb +212 -0
- data/lib/swagger/response.rb +70 -0
- data/lib/swagger/version.rb +4 -0
- data/ruby-transmitsms.gemspec +33 -0
- data/runtest.sh +8 -0
- data/setup.sh +1 -0
- data/spec/.resellers_api_spec.rb.swp +0 -0
- data/spec/account_api_spec.rb +30 -0
- data/spec/email_sms_api_spec.rb +40 -0
- data/spec/keywords_api_spec.rb +56 -0
- data/spec/lists_api_spec.rb +117 -0
- data/spec/numbers_api_spec.rb +53 -0
- data/spec/resellers_api_spec.rb +85 -0
- data/spec/sms_api_spec.rb +174 -0
- data/spec/spec.opts +4 -0
- metadata +219 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
require "ruby-transmitsms"
|
4
|
+
require "test/unit"
|
5
|
+
require "vcr"
|
6
|
+
|
7
|
+
VCR.configure do |c|
|
8
|
+
c.cassette_library_dir = "fixtures/vcr_cassettes"
|
9
|
+
c.hook_into :webmock
|
10
|
+
end
|
11
|
+
|
12
|
+
class EmailApiTest < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup()
|
15
|
+
@api = EmailApi.new("15ad266c538fb36c4d90f01055aef494", "moose")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_add_email()
|
19
|
+
VCR.use_cassette("email_sms_api_add_email") do
|
20
|
+
response = @api.add_email("test@email.com")
|
21
|
+
|
22
|
+
assert response.code == 200
|
23
|
+
assert response.body["success"] == true
|
24
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
25
|
+
assert response.body["error"]["description"] == "OK"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_delete_email()
|
30
|
+
VCR.use_cassette("email_sms_api_delete_email") do
|
31
|
+
response = @api.delete_email("test@email.com")
|
32
|
+
|
33
|
+
assert response.code == 200
|
34
|
+
assert response.body["success"] == true
|
35
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
36
|
+
assert response.body["error"]["description"] == "OK"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
require "ruby-transmitsms"
|
4
|
+
require "test/unit"
|
5
|
+
require "vcr"
|
6
|
+
|
7
|
+
VCR.configure do |c|
|
8
|
+
c.cassette_library_dir = "fixtures/vcr_cassettes"
|
9
|
+
c.hook_into :webmock
|
10
|
+
end
|
11
|
+
|
12
|
+
class KeywordsApiTest < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup()
|
15
|
+
@api = KeywordsApi.new("15ad266c538fb36c4d90f01055aef494", "moose")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_add_keyword()
|
19
|
+
VCR.use_cassette("keywords_api_add_keyword") do
|
20
|
+
response = @api.add_keyword("NEWS", 61422222222)
|
21
|
+
|
22
|
+
assert response.code == 200
|
23
|
+
assert response.body["keyword"] == "NEWS"
|
24
|
+
assert response.body["number"] == 61422222222
|
25
|
+
assert response.body["status"] == "open"
|
26
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
27
|
+
assert response.body["error"]["description"] == "OK"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_edit_keyword()
|
32
|
+
VCR.use_cassette("keywords_api_edit_keyword") do
|
33
|
+
response = @api.edit_keyword("NEWS", 61422222222)
|
34
|
+
|
35
|
+
assert response.code == 200
|
36
|
+
assert response.body["keyword"] == "NEWS"
|
37
|
+
assert response.body["number"] == 61422222222
|
38
|
+
assert response.body["status"] == "open"
|
39
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
40
|
+
assert response.body["error"]["description"] == "OK"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_get_keyword()
|
45
|
+
VCR.use_cassette("keywords_api_get_keywords") do
|
46
|
+
response = @api.get_keywords(61422222222)
|
47
|
+
|
48
|
+
assert response.code == 200
|
49
|
+
assert response.body["keywords_total"] == 6
|
50
|
+
assert response.body["keywords"].length == 6
|
51
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
52
|
+
assert response.body["error"]["description"] == "OK"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
require "ruby-transmitsms"
|
4
|
+
require "test/unit"
|
5
|
+
require "vcr"
|
6
|
+
|
7
|
+
VCR.configure do |c|
|
8
|
+
c.cassette_library_dir = "fixtures/vcr_cassettes"
|
9
|
+
c.hook_into :webmock
|
10
|
+
end
|
11
|
+
|
12
|
+
class ListsApiTest < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup()
|
15
|
+
@api = ListsApi.new("15ad266c538fb36c4d90f01055aef494", "moose")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_get_list()
|
19
|
+
VCR.use_cassette("lists_api_get_list") do
|
20
|
+
response = @api.get_list(55314)
|
21
|
+
|
22
|
+
assert response.code == 200
|
23
|
+
assert response.body["id"] == 55314
|
24
|
+
assert response.body["members_total"] == 1075
|
25
|
+
assert response.body["members_active"] == 1075
|
26
|
+
assert response.body["members"].length > 0
|
27
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
28
|
+
assert response.body["error"]["description"] == "OK"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_get_lists()
|
33
|
+
VCR.use_cassette("lists_api_get_lists") do
|
34
|
+
response = @api.get_lists()
|
35
|
+
|
36
|
+
assert response.code == 200
|
37
|
+
assert response.body["lists_total"] == 12
|
38
|
+
assert response.body["lists"].length > 0
|
39
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
40
|
+
assert response.body["error"]["description"] == "OK"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_add_list()
|
45
|
+
VCR.use_cassette("lists_api_add_list") do
|
46
|
+
response = @api.add_list("my_list")
|
47
|
+
|
48
|
+
assert response.code == 200
|
49
|
+
assert response.body["id"] == 55320
|
50
|
+
assert response.body["name"] == "my_list"
|
51
|
+
assert response.body["members_active"] == 0
|
52
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
53
|
+
assert response.body["error"]["description"] == "OK"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_add_to_list()
|
58
|
+
VCR.use_cassette("lists_api_add_to_list") do
|
59
|
+
response = @api.add_to_list(55314, 61491570158)
|
60
|
+
|
61
|
+
assert response.code == 200
|
62
|
+
assert response.body["list_id"] == 55314
|
63
|
+
assert response.body["msisdn"] == 61491570158
|
64
|
+
assert response.body["status"] == "active"
|
65
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
66
|
+
assert response.body["error"]["description"] == "OK"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_delete_from_list()
|
71
|
+
VCR.use_cassette("lists_api_delete_from_list") do
|
72
|
+
response = @api.delete_from_list(55314, 61491570158)
|
73
|
+
|
74
|
+
assert response.code == 200
|
75
|
+
assert response.body["list_ids"][0] == 55314
|
76
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
77
|
+
assert response.body["error"]["description"] == "OK"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_remove_list()
|
82
|
+
VCR.use_cassette("lists_api_remove_list") do
|
83
|
+
response = @api.remove_list(55329)
|
84
|
+
|
85
|
+
assert response.code == 200
|
86
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
87
|
+
assert response.body["error"]["description"] == "OK"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_optout_list_member()
|
92
|
+
VCR.use_cassette("lists_api_optout_list_member") do
|
93
|
+
response = @api.optout_list_member(55314, 61400233560)
|
94
|
+
|
95
|
+
assert response.code == 200
|
96
|
+
assert response.body["list_ids"][0] == 55314
|
97
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
98
|
+
assert response.body["error"]["description"] == "OK"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_edit_list_member()
|
103
|
+
VCR.use_cassette("lists_api_edit_list_member") do
|
104
|
+
response = @api.edit_list_member(55314, 61400124714)
|
105
|
+
|
106
|
+
assert response.code == 200
|
107
|
+
assert response.body["list_id"] == 55314
|
108
|
+
assert response.body["msisdn"] == 61400124714
|
109
|
+
assert response.body["first_name"] == "Hugh"
|
110
|
+
assert response.body["last_name"] == "Heller"
|
111
|
+
assert response.body["status"] == "active"
|
112
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
113
|
+
assert response.body["error"]["description"] == "OK"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
require "ruby-transmitsms"
|
4
|
+
require "test/unit"
|
5
|
+
require "vcr"
|
6
|
+
|
7
|
+
VCR.configure do |c|
|
8
|
+
c.cassette_library_dir = "fixtures/vcr_cassettes"
|
9
|
+
c.hook_into :webmock
|
10
|
+
end
|
11
|
+
|
12
|
+
class NumbersApiTest < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup()
|
15
|
+
@api = NumbersApi.new("15ad266c538fb36c4d90f01055aef494", "moose")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_get_number()
|
19
|
+
VCR.use_cassette("numbers_api_get_number") do
|
20
|
+
response = @api.get_number("+61422222222")
|
21
|
+
|
22
|
+
assert response.code == 200
|
23
|
+
assert response.body["number"] == 61422222222
|
24
|
+
assert response.body["auto_renew"] == true
|
25
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
26
|
+
assert response.body["error"]["description"] == "OK"
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_get_numbers()
|
32
|
+
VCR.use_cassette("numbers_api_get_numbers") do
|
33
|
+
response = @api.get_numbers("+61422222222")
|
34
|
+
|
35
|
+
assert response.code == 200
|
36
|
+
assert response.body["numbers"].length > 0
|
37
|
+
assert response.body["numbers_total"] == 4
|
38
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
39
|
+
assert response.body["error"]["description"] == "OK"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_lease_number()
|
44
|
+
VCR.use_cassette("numbers_api_lease_number") do
|
45
|
+
response = @api.lease_number("0422222213")
|
46
|
+
|
47
|
+
assert response.code == 400
|
48
|
+
assert response.body["error"]["code"] == "FIELD_INVALID"
|
49
|
+
assert response.body["error"]["description"] == "This number is not available for lease."
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
require "ruby-transmitsms"
|
4
|
+
require "test/unit"
|
5
|
+
require "vcr"
|
6
|
+
|
7
|
+
VCR.configure do |c|
|
8
|
+
c.cassette_library_dir = "fixtures/vcr_cassettes"
|
9
|
+
c.hook_into :webmock
|
10
|
+
end
|
11
|
+
|
12
|
+
class ResellersApiTest < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup()
|
15
|
+
@api = ResellersApi.new("15ad266c538fb36c4d90f01055aef494", "moose")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_get_client()
|
19
|
+
VCR.use_cassette("resellers_api_get_client") do
|
20
|
+
response = @api.get_client(2024)
|
21
|
+
|
22
|
+
assert_equal 200, response.code
|
23
|
+
assert_equal 2024, response.body["id"]
|
24
|
+
assert_equal "wefwefwef", response.body["name"]
|
25
|
+
assert_equal "SUCCESS", response.body["error"]["code"]
|
26
|
+
assert_equal "OK", response.body["error"]["description"]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_get_clients()
|
31
|
+
VCR.use_cassette("resellers_api_get_clients") do
|
32
|
+
response = @api.get_clients()
|
33
|
+
|
34
|
+
assert_equal 200, response.code
|
35
|
+
assert_equal 15, response.body["clients_total"]
|
36
|
+
assert_equal 10, response.body["clients"].length
|
37
|
+
assert_equal "SUCCESS", response.body["error"]["code"]
|
38
|
+
assert_equal "OK", response.body["error"]["description"]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_add_client()
|
43
|
+
# Needs to revisit why getting 400???
|
44
|
+
VCR.use_cassette("resellers_api_add_client") do
|
45
|
+
response = @api.add_client("my_client_test_13", nil, "my@clienttest13.com", "my_password", "+61491570156")
|
46
|
+
|
47
|
+
assert_equal 400, response.code
|
48
|
+
assert_equal "KEY_EXISTS", response.body["error"]["code"]
|
49
|
+
assert_equal "User already exists", response.body["error"]["description"]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_edit_client()
|
54
|
+
# Needs to revisit why getting 411??
|
55
|
+
VCR.use_cassette("resellers_api_edit_client") do
|
56
|
+
response = @api.edit_client(2024)
|
57
|
+
|
58
|
+
assert_equal 411, response.code
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_get_transactions()
|
63
|
+
VCR.use_cassette("resellers_api_get_transactions") do
|
64
|
+
response = @api.get_transactions(2026)
|
65
|
+
|
66
|
+
assert_equal 200, response.code
|
67
|
+
assert_equal 6, response.body["transactions_total"]
|
68
|
+
assert_equal "SUCCESS", response.body["error"]["code"]
|
69
|
+
assert_equal "OK", response.body["error"]["description"]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_get_transaction()
|
74
|
+
VCR.use_cassette("resellers_api_get_transaction") do
|
75
|
+
response = @api.get_transaction(17389227)
|
76
|
+
|
77
|
+
assert_equal 200, response.code
|
78
|
+
assert_equal 17389227, response.body["id"]
|
79
|
+
assert_equal 2026, response.body["user_id"]
|
80
|
+
assert_equal "SUCCESS", response.body["error"]["code"]
|
81
|
+
assert_equal "OK", response.body["error"]["description"]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
require "ruby-transmitsms"
|
4
|
+
require "test/unit"
|
5
|
+
require "vcr"
|
6
|
+
|
7
|
+
VCR.configure do |c|
|
8
|
+
c.cassette_library_dir = "fixtures/vcr_cassettes"
|
9
|
+
c.hook_into :webmock
|
10
|
+
end
|
11
|
+
|
12
|
+
class SmsApiTest < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup()
|
15
|
+
@api = SmsApi.new("15ad266c538fb36c4d90f01055aef494", "moose")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_send()
|
19
|
+
VCR.use_cassette("sms_api_test_send") do
|
20
|
+
# Call method to test
|
21
|
+
response = @api.send("Testing API to field", "61422222222")
|
22
|
+
|
23
|
+
# Assert result
|
24
|
+
assert response.code == 200
|
25
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
26
|
+
assert response.body["error"]["description"] == "OK"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_message_reply()
|
31
|
+
VCR.use_cassette("sms_api_test_message_reply") do
|
32
|
+
# Call method to test
|
33
|
+
response = @api.message_reply("Testing API to field", "61422222222", "61412345678")
|
34
|
+
|
35
|
+
# Assert result
|
36
|
+
assert response.code == 200
|
37
|
+
assert response.body["result"] == "SYSTEM: Message response handled\n"
|
38
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
39
|
+
assert response.body["error"]["description"] == "OK"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_get_message_log()
|
44
|
+
VCR.use_cassette("sms_api_test_get_message_log") do
|
45
|
+
# Call method to test
|
46
|
+
response = @api.get_message_log("50694", "61422222222")
|
47
|
+
|
48
|
+
# Assert result
|
49
|
+
assert response.code == 200
|
50
|
+
assert response.body["message_id"] == 50694
|
51
|
+
assert response.body["caller_id"] == 61422345678
|
52
|
+
assert response.body["mobile"] == 61422222222
|
53
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
54
|
+
assert response.body["error"]["description"] == "OK"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_send_with_list_id()
|
59
|
+
VCR.use_cassette("sms_api_test_send_with_list_id") do
|
60
|
+
# Call method to test
|
61
|
+
response = @api.send("Testing API with list_id field", nil, nil, nil, 55314)
|
62
|
+
|
63
|
+
# Assert result
|
64
|
+
assert response.code == 200
|
65
|
+
assert response.body["list"]["id"] == 55314
|
66
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
67
|
+
assert response.body["error"]["description"] == "OK"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_send_missing_to_and_list_id()
|
72
|
+
VCR.use_cassette("sms_api_test_send_missing_to_and_list_id") do
|
73
|
+
response = @api.send("Test error sending")
|
74
|
+
|
75
|
+
assert response.code == 400
|
76
|
+
assert response.body["error"]["code"] == "FIELD_INVALID"
|
77
|
+
assert response.body["error"]["description"] == "You must provide either 'list_id' or 'to'"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_format_number()
|
82
|
+
VCR.use_cassette("sms_api_test_format_number") do
|
83
|
+
response = @api.format_number("0455667889", "AU")
|
84
|
+
|
85
|
+
assert response.code == 200
|
86
|
+
assert response.body["number"]["countrycode"] == 61
|
87
|
+
assert response.body["number"]["nationalnumber"] == 455667889
|
88
|
+
assert response.body["number"]["national_leading_zeroes"] == 455667889
|
89
|
+
assert response.body["number"]["rawinput"] == nil
|
90
|
+
assert response.body["number"]["international"] == 61455667889
|
91
|
+
assert response.body["number"]["type"] == 1
|
92
|
+
assert response.body["number"]["isValid"] == true
|
93
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
94
|
+
assert response.body["error"]["description"] == "OK"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_format_number_fail_in_missing_msisdn()
|
99
|
+
VCR.use_cassette("sms_api_test_format_number_fail_in_missing_msisdn") do
|
100
|
+
response = @api.format_number("", "AU")
|
101
|
+
|
102
|
+
assert response.code == 400
|
103
|
+
assert response.body["error"]["code"] == "FIELD_EMPTY"
|
104
|
+
assert response.body["error"]["description"] == "Required field 'msisdn' is empty"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_get_sms_info()
|
109
|
+
VCR.use_cassette("sms_api_test_get_sms_info") do
|
110
|
+
response = @api.get_sms(27746)
|
111
|
+
|
112
|
+
assert response.code == 200
|
113
|
+
assert response.body["message_id"] == 27746
|
114
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
115
|
+
assert response.body["error"]["description"] == "OK"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_get_sms_info_fail_for_not_existing_message_id()
|
120
|
+
VCR.use_cassette("sms_api_test_get_sms_info_fail_for_not_existing_message_id") do
|
121
|
+
response = @api.get_sms(1)
|
122
|
+
|
123
|
+
assert response.code == 400
|
124
|
+
assert response.body["error"]["code"] == "NOT_FOUND"
|
125
|
+
assert response.body["error"]["description"] == "Message with this ID does not exist"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_get_sms_responses()
|
130
|
+
VCR.use_cassette("sms_api_test_get_sms_responses") do
|
131
|
+
response = @api.get_sms_responses(27746)
|
132
|
+
|
133
|
+
assert response.code == 200
|
134
|
+
assert response.body["total"] == 2
|
135
|
+
assert response.body["responses"].length > 0
|
136
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
137
|
+
assert response.body["error"]["description"] == "OK"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_get_user_sms_responses()
|
142
|
+
VCR.use_cassette("sms_api_test_get_user_sms_responses") do
|
143
|
+
response = @api.get_user_sms_responses("2015-09-13 00:00:00", "2015-04-20 23:59:59")
|
144
|
+
|
145
|
+
puts response.body
|
146
|
+
assert response.code == 200
|
147
|
+
assert response.body["total"] == 1
|
148
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
149
|
+
assert response.body["error"]["description"] == "OK"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_get_sms_sent()
|
154
|
+
VCR.use_cassette("sms_api_test_get_sms_sent") do
|
155
|
+
response = @api.get_sms_sent(27746)
|
156
|
+
|
157
|
+
assert response.code == 200
|
158
|
+
assert response.body["total"] == 2
|
159
|
+
assert response.body["recipients"].length > 0
|
160
|
+
assert response.body["error"]["code"] == "SUCCESS"
|
161
|
+
assert response.body["error"]["description"] == "OK"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_cancel_sms()
|
166
|
+
VCR.use_cassette("sms_api_test_cancel_sms") do
|
167
|
+
response = @api.cancel_sms(27741)
|
168
|
+
|
169
|
+
assert response.code == 400
|
170
|
+
assert response.body["error"]["code"] == "ALREADY_SENT"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|