sms77 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -4
  3. data/.idea/.gitignore +8 -0
  4. data/.idea/inspectionProfiles/Project_Default.xml +6 -0
  5. data/.idea/modules.xml +8 -0
  6. data/.idea/ruby-client.iml +18 -0
  7. data/.idea/vcs.xml +6 -0
  8. data/Gemfile +2 -2
  9. data/LICENSE +20 -20
  10. data/README.md +41 -35
  11. data/Rakefile +5 -5
  12. data/doc/Sms77/Client.html +230 -0
  13. data/doc/Sms77/Contacts/Action.html +131 -0
  14. data/doc/Sms77/Contacts.html +126 -0
  15. data/doc/Sms77/Endpoint.html +187 -0
  16. data/doc/Sms77/Hooks/Action.html +131 -0
  17. data/doc/Sms77/Hooks/EventType.html +146 -0
  18. data/doc/Sms77/Hooks/RequestMethod.html +131 -0
  19. data/doc/Sms77/Hooks/Validator.html +598 -0
  20. data/doc/Sms77/Hooks.html +126 -0
  21. data/doc/Sms77/Journal/Type.html +136 -0
  22. data/doc/Sms77/Journal/Validator.html +394 -0
  23. data/doc/Sms77/Journal.html +126 -0
  24. data/doc/Sms77/Lookup/Type.html +136 -0
  25. data/doc/Sms77/Lookup.html +126 -0
  26. data/doc/Sms77/Resource.html +870 -0
  27. data/doc/Sms77/Resources/Analytics.html +263 -0
  28. data/doc/Sms77/Resources/Balance.html +246 -0
  29. data/doc/Sms77/Resources/Contacts.html +449 -0
  30. data/doc/Sms77/Resources/Hooks.html +457 -0
  31. data/doc/Sms77/Resources/Journal.html +261 -0
  32. data/doc/Sms77/Resources/Lookup.html +540 -0
  33. data/doc/Sms77/Resources/Pricing.html +263 -0
  34. data/doc/Sms77/Resources/Sms.html +261 -0
  35. data/doc/Sms77/Resources/Status.html +261 -0
  36. data/doc/Sms77/Resources/Subaccounts.html +651 -0
  37. data/doc/Sms77/Resources/ValidateForVoice.html +261 -0
  38. data/doc/Sms77/Resources/Voice.html +261 -0
  39. data/doc/Sms77/Resources.html +128 -0
  40. data/doc/Sms77/Sms/Type.html +126 -0
  41. data/doc/Sms77/Sms.html +126 -0
  42. data/doc/Sms77/Subaccounts/Action.html +141 -0
  43. data/doc/Sms77/Subaccounts/Validator.html +490 -0
  44. data/doc/Sms77/Subaccounts.html +126 -0
  45. data/doc/Sms77/Util.html +1033 -0
  46. data/doc/Sms77.html +146 -0
  47. data/doc/_index.html +444 -0
  48. data/doc/class_list.html +51 -0
  49. data/doc/css/common.css +1 -0
  50. data/doc/css/full_list.css +58 -0
  51. data/doc/css/style.css +497 -0
  52. data/doc/file.README.html +112 -0
  53. data/doc/file_list.html +56 -0
  54. data/doc/frames.html +17 -0
  55. data/doc/index.html +112 -0
  56. data/doc/js/app.js +314 -0
  57. data/doc/js/full_list.js +216 -0
  58. data/doc/js/jquery.js +4 -0
  59. data/doc/method_list.html +563 -0
  60. data/doc/top-level-namespace.html +110 -0
  61. data/lib/sms77/client.rb +30 -29
  62. data/lib/sms77/contacts.rb +10 -9
  63. data/lib/sms77/endpoint.rb +17 -15
  64. data/lib/sms77/hooks.rb +67 -64
  65. data/lib/sms77/journal.rb +39 -38
  66. data/lib/sms77/lookup.rb +11 -10
  67. data/lib/sms77/resource.rb +94 -93
  68. data/lib/sms77/resources/analytics.rb +21 -16
  69. data/lib/sms77/resources/balance.rb +19 -15
  70. data/lib/sms77/resources/contacts.rb +38 -25
  71. data/lib/sms77/resources/hooks.rb +40 -29
  72. data/lib/sms77/resources/journal.rb +20 -15
  73. data/lib/sms77/resources/lookup.rb +47 -29
  74. data/lib/sms77/resources/pricing.rb +20 -15
  75. data/lib/sms77/resources/sms.rb +20 -15
  76. data/lib/sms77/resources/status.rb +20 -15
  77. data/lib/sms77/resources/subaccounts.rb +66 -0
  78. data/lib/sms77/resources/validate_for_voice.rb +20 -15
  79. data/lib/sms77/resources/voice.rb +20 -15
  80. data/lib/sms77/sms.rb +9 -8
  81. data/lib/sms77/subaccounts.rb +55 -0
  82. data/lib/sms77/util.rb +68 -67
  83. data/lib/sms77/version.rb +5 -5
  84. data/lib/sms77.rb +6 -6
  85. data/release.sh +4 -7
  86. data/sms77.gemspec +21 -21
  87. data/spec/EnvKeyStore.rb +14 -14
  88. data/spec/matchers.rb +22 -22
  89. data/spec/sms77/balance_spec.rb +12 -12
  90. data/spec/sms77/client_spec.rb +15 -15
  91. data/spec/sms77/contacts_spec.rb +129 -116
  92. data/spec/sms77/hooks_spec.rb +108 -105
  93. data/spec/sms77/instance_spec.rb +22 -20
  94. data/spec/sms77/journal_spec.rb +86 -86
  95. data/spec/sms77/lookup_spec.rb +179 -179
  96. data/spec/sms77/pricing_spec.rb +76 -76
  97. data/spec/sms77/sms_spec.rb +103 -103
  98. data/spec/sms77/subaccounts_spec.rb +121 -0
  99. data/spec/sms77/validate_for_voice_spec.rb +19 -19
  100. data/spec/sms77/voice_spec.rb +51 -51
  101. data/spec/sms77_spec.rb +9 -7
  102. data/spec/spec_helper.rb +53 -53
  103. metadata +75 -17
@@ -1,179 +1,179 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'sms77/endpoint'
5
- require 'sms77/lookup'
6
- require 'sms77/resources/lookup'
7
- require 'json'
8
-
9
- RSpec.describe Sms77, 'lookup' do
10
- def request(type, stub, extra_args = {})
11
- helper = Helper.new(Sms77::Resources::Lookup)
12
- helper.request(
13
- helper.resource.method(type),
14
- stub,
15
- { number: '+491771783130' }.merge(extra_args))
16
- end
17
-
18
- it 'misses number to lookup' do
19
- stub = {
20
- carrier: nil,
21
- country_code: false,
22
- country_iso: nil,
23
- country_name: nil,
24
- international: '+',
25
- international_formatted: '',
26
- national: '',
27
- network_type: nil,
28
- success: false
29
- }
30
-
31
- res = request(Sms77::Lookup::Type::FORMAT, stub, { number: '' })
32
-
33
- expect(res).to be_a(Hash)
34
- expect(res[:success]).to match(false)
35
- end
36
-
37
- it 'returns number formatting details as json' do
38
- stub = {
39
- carrier: 'Eplus',
40
- country_code: '49',
41
- country_iso: 'DE',
42
- country_name: 'Germany',
43
- international: '+491771783130',
44
- international_formatted: '+49 177 1783130',
45
- national: '0177 1783130',
46
- network_type: 'mobile',
47
- success: true
48
- }
49
-
50
- body = request(Sms77::Lookup::Type::FORMAT, stub)
51
-
52
- expect(body).to be_a(Hash)
53
- expect(body[:carrier]).to be_a(String)
54
- expect(body[:country_code]).to be_a(String)
55
- expect(body[:country_iso]).to be_a(String)
56
- expect(body[:country_name]).to be_a(String)
57
- expect(body[:international]).to be_a(String)
58
- expect(body[:international_formatted]).to be_a(String)
59
- expect(body[:national]).to be_a(String)
60
- expect(body[:network_type]).to be_a(String)
61
- expect(body[:success]).to be_boolean
62
- end
63
-
64
- it 'returns CNAM details as json' do
65
- stub = {
66
- code: '100',
67
- name: 'GERMANY',
68
- number: '+491771783130',
69
- success: 'true'
70
- }
71
- body = request(Sms77::Lookup::Type::CNAM, stub)
72
-
73
- expect(body).to be_a(Hash)
74
- expect(body[:code]).to be_a(String)
75
- expect(body[:name]).to be_a(String)
76
- expect(body[:number]).to be_a(String)
77
- expect(body[:success]).to be_a(String)
78
- end
79
-
80
- it 'returns MNP details as text' do
81
- body = request(Sms77::Lookup::Type::MNP, 'eplus')
82
-
83
- expect(body).to be_a(String)
84
- end
85
-
86
- it 'returns MNP details as json' do
87
- stub = {
88
- code: 100,
89
- mnp: {
90
- country: 'DE',
91
- international_formatted: '+49 177 1783130',
92
- isPorted: false,
93
- mccmnc: '26203',
94
- national_format: '0177 1783130',
95
- network: "Telef\u00f3nica Germany GmbH & Co. oHG (O2)",
96
- number: '+491771783130'
97
- },
98
- price: 0.005,
99
- success: true
100
- }
101
- body = request(Sms77::Lookup::Type::MNP, stub, { json: 1 })
102
-
103
- expect(body).to be_a(Hash)
104
- expect(body[:code]).to be_a(Integer)
105
- expect(body[:price]).to be_a(Float)
106
- expect(body[:mnp]).to be_a(Hash)
107
- expect(body[:mnp][:country]).to be_a(String)
108
- expect(body[:mnp][:international_formatted]).to be_a(String)
109
- expect(body[:mnp][:isPorted]).to be_boolean
110
- expect(body[:mnp][:mccmnc]).to be_a(String)
111
- expect(body[:mnp][:national_format]).to be_a(String)
112
- expect(body[:mnp][:network]).to be_a(String)
113
- expect(body[:mnp][:number]).to be_a(String)
114
- expect(body[:success]).to be_boolean
115
- end
116
-
117
- it 'returns HLR details as json' do
118
- stub = {
119
- country_code: 'DE',
120
- country_name: 'Germany',
121
- country_prefix: '49',
122
- current_carrier: {
123
- country: 'DE',
124
- name: "Telef\u00f3nica Germany GmbH & Co. oHG (O2)",
125
- network_code: '26203',
126
- network_type: 'mobile'
127
- },
128
- international_format_number: '491771783130',
129
- international_formatted: '+49 177 1783130',
130
- lookup_outcome: true,
131
- lookup_outcome_message: 'success',
132
- national_format_number: '0177 1783130',
133
- original_carrier: {
134
- country: 'DE',
135
- name: "Telef\u00f3nica Germany GmbH & Co. oHG (O2)",
136
- network_code: '26203',
137
- network_type: 'mobile'
138
- },
139
- status: true,
140
- status_message: 'success',
141
- gsm_code: '0',
142
- gsm_message: 'No error',
143
- ported: 'assumed_not_ported',
144
- reachable: 'reachable',
145
- roaming: 'not_roaming',
146
- valid_number: 'valid'
147
- }
148
-
149
- body = request(Sms77::Lookup::Type::HLR, stub)
150
-
151
- expect(body).to be_a(Hash)
152
- expect(body[:country_code]).to be_a(String)
153
- expect(body[:country_name]).to be_a(String)
154
- expect(body[:country_prefix]).to be_a(String)
155
- assert_carrier(body[:current_carrier])
156
- expect(body[:international_format_number]).to be_a(String)
157
- expect(body[:international_formatted]).to be_a(String)
158
- expect(body[:lookup_outcome]).to be_boolean
159
- expect(body[:lookup_outcome_message]).to be_a(String)
160
- expect(body[:national_format_number]).to be_a(String)
161
- assert_carrier(body[:original_carrier])
162
- expect(body[:status]).to be_boolean
163
- expect(body[:status_message]).to be_a(String)
164
- expect(body[:gsm_code]).to be_a(String)
165
- expect(body[:gsm_message]).to be_a(String)
166
- expect(body[:ported]).to be_a(String)
167
- expect(body[:reachable]).to be_a(String)
168
- expect(body[:roaming]).to be_a(String)
169
- expect(body[:valid_number]).to be_a(String)
170
- end
171
-
172
- def assert_carrier(hash)
173
- expect(hash).to be_a(Hash)
174
- expect(hash[:country]).to be_a(String)
175
- expect(hash[:name]).to be_a(String)
176
- expect(hash[:network_code]).to be_a(String)
177
- expect(hash[:network_type]).to be_a(String)
178
- end
179
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'sms77/endpoint'
5
+ require 'sms77/lookup'
6
+ require 'sms77/resources/lookup'
7
+ require 'json'
8
+
9
+ RSpec.describe Sms77, 'lookup' do
10
+ def request(type, stub, extra_args = {})
11
+ helper = Helper.new(Sms77::Resources::Lookup)
12
+ helper.request(
13
+ helper.resource.method(type),
14
+ stub,
15
+ { number: '+491771783130' }.merge(extra_args))
16
+ end
17
+
18
+ it 'misses number to lookup' do
19
+ stub = {
20
+ carrier: nil,
21
+ country_code: false,
22
+ country_iso: nil,
23
+ country_name: nil,
24
+ international: '+',
25
+ international_formatted: '',
26
+ national: '',
27
+ network_type: nil,
28
+ success: false
29
+ }
30
+
31
+ res = request(Sms77::Lookup::Type::FORMAT, stub, { number: '' })
32
+
33
+ expect(res).to be_a(Hash)
34
+ expect(res[:success]).to match(false)
35
+ end
36
+
37
+ it 'returns number formatting details as json' do
38
+ stub = {
39
+ carrier: 'Eplus',
40
+ country_code: '49',
41
+ country_iso: 'DE',
42
+ country_name: 'Germany',
43
+ international: '+491771783130',
44
+ international_formatted: '+49 177 1783130',
45
+ national: '0177 1783130',
46
+ network_type: 'mobile',
47
+ success: true
48
+ }
49
+
50
+ body = request(Sms77::Lookup::Type::FORMAT, stub)
51
+
52
+ expect(body).to be_a(Hash)
53
+ expect(body[:carrier]).to be_a(String)
54
+ expect(body[:country_code]).to be_a(String)
55
+ expect(body[:country_iso]).to be_a(String)
56
+ expect(body[:country_name]).to be_a(String)
57
+ expect(body[:international]).to be_a(String)
58
+ expect(body[:international_formatted]).to be_a(String)
59
+ expect(body[:national]).to be_a(String)
60
+ expect(body[:network_type]).to be_a(String)
61
+ expect(body[:success]).to be_boolean
62
+ end
63
+
64
+ it 'returns CNAM details as json' do
65
+ stub = {
66
+ code: '100',
67
+ name: 'GERMANY',
68
+ number: '+491771783130',
69
+ success: 'true'
70
+ }
71
+ body = request(Sms77::Lookup::Type::CNAM, stub)
72
+
73
+ expect(body).to be_a(Hash)
74
+ expect(body[:code]).to be_a(String)
75
+ expect(body[:name]).to be_a(String)
76
+ expect(body[:number]).to be_a(String)
77
+ expect(body[:success]).to be_a(String)
78
+ end
79
+
80
+ it 'returns MNP details as text' do
81
+ body = request(Sms77::Lookup::Type::MNP, 'eplus')
82
+
83
+ expect(body).to be_a(String)
84
+ end
85
+
86
+ it 'returns MNP details as json' do
87
+ stub = {
88
+ code: 100,
89
+ mnp: {
90
+ country: 'DE',
91
+ international_formatted: '+49 177 1783130',
92
+ isPorted: false,
93
+ mccmnc: '26203',
94
+ national_format: '0177 1783130',
95
+ network: "Telef\u00f3nica Germany GmbH & Co. oHG (O2)",
96
+ number: '+491771783130'
97
+ },
98
+ price: 0.005,
99
+ success: true
100
+ }
101
+ body = request(Sms77::Lookup::Type::MNP, stub, { json: 1 })
102
+
103
+ expect(body).to be_a(Hash)
104
+ expect(body[:code]).to be_a(Integer)
105
+ expect(body[:price]).to be_a(Float)
106
+ expect(body[:mnp]).to be_a(Hash)
107
+ expect(body[:mnp][:country]).to be_a(String)
108
+ expect(body[:mnp][:international_formatted]).to be_a(String)
109
+ expect(body[:mnp][:isPorted]).to be_boolean
110
+ expect(body[:mnp][:mccmnc]).to be_a(String)
111
+ expect(body[:mnp][:national_format]).to be_a(String)
112
+ expect(body[:mnp][:network]).to be_a(String)
113
+ expect(body[:mnp][:number]).to be_a(String)
114
+ expect(body[:success]).to be_boolean
115
+ end
116
+
117
+ it 'returns HLR details as json' do
118
+ stub = {
119
+ country_code: 'DE',
120
+ country_name: 'Germany',
121
+ country_prefix: '49',
122
+ current_carrier: {
123
+ country: 'DE',
124
+ name: "Telef\u00f3nica Germany GmbH & Co. oHG (O2)",
125
+ network_code: '26203',
126
+ network_type: 'mobile'
127
+ },
128
+ international_format_number: '491771783130',
129
+ international_formatted: '+49 177 1783130',
130
+ lookup_outcome: true,
131
+ lookup_outcome_message: 'success',
132
+ national_format_number: '0177 1783130',
133
+ original_carrier: {
134
+ country: 'DE',
135
+ name: "Telef\u00f3nica Germany GmbH & Co. oHG (O2)",
136
+ network_code: '26203',
137
+ network_type: 'mobile'
138
+ },
139
+ status: true,
140
+ status_message: 'success',
141
+ gsm_code: '0',
142
+ gsm_message: 'No error',
143
+ ported: 'assumed_not_ported',
144
+ reachable: 'reachable',
145
+ roaming: 'not_roaming',
146
+ valid_number: 'valid'
147
+ }
148
+
149
+ body = request(Sms77::Lookup::Type::HLR, stub)
150
+
151
+ expect(body).to be_a(Hash)
152
+ expect(body[:country_code]).to be_a(String)
153
+ expect(body[:country_name]).to be_a(String)
154
+ expect(body[:country_prefix]).to be_a(String)
155
+ assert_carrier(body[:current_carrier])
156
+ expect(body[:international_format_number]).to be_a(String)
157
+ expect(body[:international_formatted]).to be_a(String)
158
+ expect(body[:lookup_outcome]).to be_boolean
159
+ expect(body[:lookup_outcome_message]).to be_a(String)
160
+ expect(body[:national_format_number]).to be_a(String)
161
+ assert_carrier(body[:original_carrier])
162
+ expect(body[:status]).to be_boolean
163
+ expect(body[:status_message]).to be_a(String)
164
+ expect(body[:gsm_code]).to be_a(String)
165
+ expect(body[:gsm_message]).to be_a(String)
166
+ expect(body[:ported]).to be_a(String)
167
+ expect(body[:reachable]).to be_a(String)
168
+ expect(body[:roaming]).to be_a(String)
169
+ expect(body[:valid_number]).to be_a(String)
170
+ end
171
+
172
+ def assert_carrier(hash)
173
+ expect(hash).to be_a(Hash)
174
+ expect(hash[:country]).to be_a(String)
175
+ expect(hash[:name]).to be_a(String)
176
+ expect(hash[:network_code]).to be_a(String)
177
+ expect(hash[:network_type]).to be_a(String)
178
+ end
179
+ end
@@ -1,76 +1,76 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'sms77/resources/pricing'
5
-
6
- RSpec.describe Sms77, 'pricing' do
7
- it 'returns all countries pricing as json' do
8
- stub = {
9
- countCountries: 1,
10
- countNetworks: 4,
11
- countries: [
12
- {
13
- countryCode: 'AT',
14
- countryName: 'Austria',
15
- countryPrefix: '43',
16
- networks: [
17
- {
18
- comment: '',
19
- features: [],
20
- mcc: '232',
21
- mncs: ['02'],
22
- networkName: 'A1 Telekom Austria',
23
- price: 0.075
24
- },
25
- {
26
- comment: '',
27
- features: %w[alpha Numeric dlr sc],
28
- mcc: '232',
29
- mncs: ['01'],
30
- networkName: 'A1 Telekom Austria (A1.net)',
31
- price: 0.075
32
- }
33
- ]
34
- }
35
- ]
36
- }
37
-
38
- helper = Helper.new(Sms77::Resources::Pricing)
39
- res = helper.request(helper.resource.method(:retrieve), stub)
40
- countries = res[:countries]
41
-
42
- expect(res).to be_a(Hash)
43
- expect(res[:countCountries]).to be_a(Integer)
44
- expect(res[:countNetworks]).to be_a(Integer)
45
- expect(countries).to be_a(Array)
46
-
47
- countries.each do |country|
48
- networks = country[:networks]
49
-
50
- expect(country).to be_a(Hash)
51
- expect(country[:countryCode]).to be_a(String)
52
- expect(country[:countryName]).to be_a(String)
53
- expect(country[:countryPrefix]).to be_a(String)
54
- expect(networks).to be_a(Array)
55
-
56
- networks.each do |network|
57
- mncs = network[:mncs]
58
- features = network[:features]
59
-
60
- expect(network).to be_a(Hash)
61
- expect(network[:mcc]).to be_a(String)
62
- expect(mncs).to be_a(Array)
63
- mncs.each do |mnc|
64
- expect(mnc).to be_a(String)
65
- end
66
- expect(network[:networkName]).to be_a(String)
67
- expect(network[:price]).to be_a(Float)
68
- expect(features).to be_a(Array)
69
- features.each do |feature|
70
- expect(feature).to be_a(String)
71
- end
72
- expect(network[:comment]).to be_a(String)
73
- end
74
- end
75
- end
76
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'sms77/resources/pricing'
5
+
6
+ RSpec.describe Sms77, 'pricing' do
7
+ it 'returns all countries pricing as json' do
8
+ stub = {
9
+ countCountries: 1,
10
+ countNetworks: 4,
11
+ countries: [
12
+ {
13
+ countryCode: 'AT',
14
+ countryName: 'Austria',
15
+ countryPrefix: '43',
16
+ networks: [
17
+ {
18
+ comment: '',
19
+ features: [],
20
+ mcc: '232',
21
+ mncs: ['02'],
22
+ networkName: 'A1 Telekom Austria',
23
+ price: 0.075
24
+ },
25
+ {
26
+ comment: '',
27
+ features: %w[alpha Numeric dlr sc],
28
+ mcc: '232',
29
+ mncs: ['01'],
30
+ networkName: 'A1 Telekom Austria (A1.net)',
31
+ price: 0.075
32
+ }
33
+ ]
34
+ }
35
+ ]
36
+ }
37
+
38
+ helper = Helper.new(Sms77::Resources::Pricing)
39
+ res = helper.request(helper.resource.method(:retrieve), stub)
40
+ countries = res[:countries]
41
+
42
+ expect(res).to be_a(Hash)
43
+ expect(res[:countCountries]).to be_a(Integer)
44
+ expect(res[:countNetworks]).to be_a(Integer)
45
+ expect(countries).to be_a(Array)
46
+
47
+ countries.each do |country|
48
+ networks = country[:networks]
49
+
50
+ expect(country).to be_a(Hash)
51
+ expect(country[:countryCode]).to be_a(String)
52
+ expect(country[:countryName]).to be_a(String)
53
+ expect(country[:countryPrefix]).to be_a(String)
54
+ expect(networks).to be_a(Array)
55
+
56
+ networks.each do |network|
57
+ mncs = network[:mncs]
58
+ features = network[:features]
59
+
60
+ expect(network).to be_a(Hash)
61
+ expect(network[:mcc]).to be_a(String)
62
+ expect(mncs).to be_a(Array)
63
+ mncs.each do |mnc|
64
+ expect(mnc).to be_a(String)
65
+ end
66
+ expect(network[:networkName]).to be_a(String)
67
+ expect(network[:price]).to be_a(Float)
68
+ expect(features).to be_a(Array)
69
+ features.each do |feature|
70
+ expect(feature).to be_a(String)
71
+ end
72
+ expect(network[:comment]).to be_a(String)
73
+ end
74
+ end
75
+ end
76
+ end