seven_api 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +7 -6
- data/.idea/inspectionProfiles/Project_Default.xml +5 -5
- data/.idea/ruby-client.iml +48 -13
- data/Gemfile +2 -2
- data/LICENSE +21 -21
- data/README.md +1 -1
- data/Rakefile +5 -5
- data/doc/SevenApi/Client.html +8 -8
- data/doc/SevenApi/Contacts/Action.html +0 -0
- data/doc/SevenApi/Contacts.html +0 -0
- data/doc/SevenApi/Endpoint.html +0 -0
- data/doc/SevenApi/Hooks/Action.html +0 -0
- data/doc/SevenApi/Hooks/EventType.html +0 -0
- data/doc/SevenApi/Hooks/RequestMethod.html +0 -0
- data/doc/SevenApi/Hooks/Validator.html +26 -26
- data/doc/SevenApi/Hooks.html +0 -0
- data/doc/SevenApi/Journal/Type.html +0 -0
- data/doc/SevenApi/Journal/Validator.html +18 -18
- data/doc/SevenApi/Journal.html +0 -0
- data/doc/SevenApi/Lookup/Type.html +0 -0
- data/doc/SevenApi/Lookup.html +0 -0
- data/doc/SevenApi/Resource.html +13 -13
- data/doc/SevenApi/Resources/Analytics.html +2 -2
- data/doc/SevenApi/Resources/Balance.html +2 -2
- data/doc/SevenApi/Resources/Contacts.html +6 -6
- data/doc/SevenApi/Resources/Hooks.html +10 -10
- data/doc/SevenApi/Resources/Journal.html +2 -2
- data/doc/SevenApi/Resources/Lookup.html +8 -8
- data/doc/SevenApi/Resources/Pricing.html +2 -2
- data/doc/SevenApi/Resources/Sms.html +2 -2
- data/doc/SevenApi/Resources/Status.html +2 -2
- data/doc/SevenApi/Resources/Subaccounts.html +18 -18
- data/doc/SevenApi/Resources/ValidateForVoice.html +2 -2
- data/doc/SevenApi/Resources/Voice.html +2 -2
- data/doc/SevenApi/Resources.html +0 -0
- data/doc/SevenApi/Sms/Type.html +0 -0
- data/doc/SevenApi/Sms.html +0 -0
- data/doc/SevenApi/Subaccounts/Action.html +0 -0
- data/doc/SevenApi/Subaccounts/Validator.html +29 -29
- data/doc/SevenApi/Subaccounts.html +0 -0
- data/doc/SevenApi/Util.html +39 -39
- data/doc/SevenApi.html +0 -0
- data/document.sh +3 -0
- data/lib/seven_api/client.rb +32 -32
- data/lib/seven_api/contacts.rb +5 -5
- data/lib/seven_api/endpoint.rb +0 -0
- data/lib/seven_api/hooks.rb +69 -68
- data/lib/seven_api/journal.rb +39 -39
- data/lib/seven_api/lookup.rb +12 -12
- data/lib/seven_api/numbers.rb +9 -9
- data/lib/seven_api/paginated.rb +10 -10
- data/lib/seven_api/rcs.rb +0 -0
- data/lib/seven_api/resource.rb +1 -2
- data/lib/seven_api/resources/analytics.rb +54 -54
- data/lib/seven_api/resources/balance.rb +19 -19
- data/lib/seven_api/resources/contacts.rb +56 -56
- data/lib/seven_api/resources/groups.rb +56 -56
- data/lib/seven_api/resources/hooks.rb +40 -40
- data/lib/seven_api/resources/journal.rb +20 -20
- data/lib/seven_api/resources/lookup.rb +63 -63
- data/lib/seven_api/resources/numbers.rb +70 -69
- data/lib/seven_api/resources/pricing.rb +20 -20
- data/lib/seven_api/resources/rcs.rb +3 -3
- data/lib/seven_api/resources/sms.rb +29 -20
- data/lib/seven_api/resources/status.rb +20 -20
- data/lib/seven_api/resources/subaccounts.rb +65 -65
- data/lib/seven_api/resources/validate_for_voice.rb +20 -20
- data/lib/seven_api/resources/voice.rb +29 -20
- data/lib/seven_api/sms.rb +9 -9
- data/lib/seven_api/subaccounts.rb +55 -55
- data/lib/seven_api/util.rb +68 -68
- data/lib/seven_api/version.rb +5 -5
- data/lib/seven_api.rb +6 -6
- data/release.sh +4 -4
- data/seven_api.gemspec +0 -0
- data/spec/EnvKeyStore.rb +14 -14
- data/spec/matchers.rb +22 -22
- data/spec/seven_api/analytics_spec.rb +49 -49
- data/spec/seven_api/balance_spec.rb +18 -18
- data/spec/seven_api/client_spec.rb +15 -15
- data/spec/seven_api/contacts_spec.rb +100 -100
- data/spec/seven_api/groups_spec.rb +74 -74
- data/spec/seven_api/hooks_spec.rb +108 -108
- data/spec/seven_api/instance_spec.rb +22 -22
- data/spec/seven_api/journal_spec.rb +86 -86
- data/spec/seven_api/lookup_spec.rb +197 -197
- data/spec/seven_api/numbers_spec.rb +135 -135
- data/spec/seven_api/pricing_spec.rb +76 -76
- data/spec/seven_api/rcs_spec.rb +0 -0
- data/spec/seven_api/sms_spec.rb +103 -103
- data/spec/seven_api/subaccounts_spec.rb +121 -121
- data/spec/seven_api/validate_for_voice_spec.rb +19 -19
- data/spec/seven_api/voice_spec.rb +51 -51
- data/spec/seven_api_spec.rb +9 -9
- metadata +4 -6
@@ -1,76 +1,76 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'seven_api/resources/pricing'
|
5
|
-
|
6
|
-
RSpec.describe SevenApi, '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(SevenApi::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 'seven_api/resources/pricing'
|
5
|
+
|
6
|
+
RSpec.describe SevenApi, '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(SevenApi::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
|
data/spec/seven_api/rcs_spec.rb
CHANGED
File without changes
|
data/spec/seven_api/sms_spec.rb
CHANGED
@@ -1,103 +1,103 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'seven_api/resources/sms'
|
5
|
-
|
6
|
-
RSpec.describe SevenApi, 'sms' do
|
7
|
-
$text = 'Your glasses are ready for pickup.'
|
8
|
-
|
9
|
-
def assert_response(response)
|
10
|
-
if response.is_a?(String)
|
11
|
-
id, name, number = response.split("\n")
|
12
|
-
else
|
13
|
-
id = response['ID']
|
14
|
-
name = response['Name']
|
15
|
-
number = response['Number']
|
16
|
-
end
|
17
|
-
|
18
|
-
expect(Integer(id)).to be_an_instance_of(Integer)
|
19
|
-
expect(name.to_f).to be_an_instance_of(Float) if id != ''
|
20
|
-
expect(number.to_f).to be_an_instance_of(Float)
|
21
|
-
end
|
22
|
-
|
23
|
-
def request(stub, extra_params = {})
|
24
|
-
params = {
|
25
|
-
from: 'seven',
|
26
|
-
text: $text,
|
27
|
-
to: '491716992343'
|
28
|
-
}.merge(extra_params)
|
29
|
-
|
30
|
-
helper = Helper.new(SevenApi::Resources::Sms)
|
31
|
-
helper.request(helper.resource.method(:retrieve), stub, params)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'sends a single sms and returns success code' do
|
35
|
-
expect(request(100)).to be_a(Integer)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'sends a single sms and returns detailed text response' do
|
39
|
-
stub = <<~TEXT
|
40
|
-
100
|
41
|
-
Verbucht: 0
|
42
|
-
Preis: 0.075
|
43
|
-
Guthaben: 4.575
|
44
|
-
Text: Your glasses are ready for pickup.
|
45
|
-
SMS-Typ: direct
|
46
|
-
Flash SMS: false
|
47
|
-
Encoding: gsm
|
48
|
-
GSM0338: true
|
49
|
-
Debug: true
|
50
|
-
TEXT
|
51
|
-
|
52
|
-
body = request(stub, { details: 1 })
|
53
|
-
|
54
|
-
expect(body).to be_a(String)
|
55
|
-
|
56
|
-
code, booked, cost, balance, text, type, flash, encoding, gsm0338, debug = body.split("\n")
|
57
|
-
|
58
|
-
expect(code).to be_a(String)
|
59
|
-
expect(booked.split(':').last.to_f).to be_a(Float)
|
60
|
-
expect(cost.split(':').last.to_f).to be_a(Float)
|
61
|
-
expect(balance.split(':').last.to_f).to be_a(Float)
|
62
|
-
expect(text.split(':').last.strip!).to eq($text)
|
63
|
-
expect(type.split(':').last.strip!).to eq('direct')
|
64
|
-
expect(flash.split(':').last.strip!).to eq('false')
|
65
|
-
expect(encoding.split(':').last.strip!).to eq('gsm')
|
66
|
-
expect(gsm0338.split(':').last.strip!).to eq('true')
|
67
|
-
expect(debug.split(':').last.strip!).to eq('true')
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'sends a single sms and returns json response' do
|
71
|
-
stub = {
|
72
|
-
success: '100',
|
73
|
-
total_price: 0,
|
74
|
-
balance: 4.5,
|
75
|
-
debug: 'true',
|
76
|
-
sms_type: 'direct',
|
77
|
-
messages: [{ id: nil,
|
78
|
-
sender: '491771783130',
|
79
|
-
recipient: '491771783130',
|
80
|
-
text: 'Your glasses are ready for pickup.',
|
81
|
-
encoding: 'gsm',
|
82
|
-
parts: 1,
|
83
|
-
price: 0,
|
84
|
-
success: true,
|
85
|
-
error: nil,
|
86
|
-
error_text: nil }]
|
87
|
-
}
|
88
|
-
|
89
|
-
body = request(stub, { json: 1 })
|
90
|
-
|
91
|
-
expect(body).to be_a(Hash)
|
92
|
-
|
93
|
-
expect(body[:success]).to be_a(String)
|
94
|
-
expect(body[:total_price]).to be_numeric
|
95
|
-
expect(body[:balance]).to be_a(Float)
|
96
|
-
expect(body[:debug]).to be_a(String)
|
97
|
-
expect(body[:sms_type]).to eq('direct')
|
98
|
-
expect(body[:messages]).to be_a(Array)
|
99
|
-
body[:messages].each do |message|
|
100
|
-
expect(message).to be_a(Hash)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'seven_api/resources/sms'
|
5
|
+
|
6
|
+
RSpec.describe SevenApi, 'sms' do
|
7
|
+
$text = 'Your glasses are ready for pickup.'
|
8
|
+
|
9
|
+
def assert_response(response)
|
10
|
+
if response.is_a?(String)
|
11
|
+
id, name, number = response.split("\n")
|
12
|
+
else
|
13
|
+
id = response['ID']
|
14
|
+
name = response['Name']
|
15
|
+
number = response['Number']
|
16
|
+
end
|
17
|
+
|
18
|
+
expect(Integer(id)).to be_an_instance_of(Integer)
|
19
|
+
expect(name.to_f).to be_an_instance_of(Float) if id != ''
|
20
|
+
expect(number.to_f).to be_an_instance_of(Float)
|
21
|
+
end
|
22
|
+
|
23
|
+
def request(stub, extra_params = {})
|
24
|
+
params = {
|
25
|
+
from: 'seven',
|
26
|
+
text: $text,
|
27
|
+
to: '491716992343'
|
28
|
+
}.merge(extra_params)
|
29
|
+
|
30
|
+
helper = Helper.new(SevenApi::Resources::Sms)
|
31
|
+
helper.request(helper.resource.method(:retrieve), stub, params)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'sends a single sms and returns success code' do
|
35
|
+
expect(request(100)).to be_a(Integer)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'sends a single sms and returns detailed text response' do
|
39
|
+
stub = <<~TEXT
|
40
|
+
100
|
41
|
+
Verbucht: 0
|
42
|
+
Preis: 0.075
|
43
|
+
Guthaben: 4.575
|
44
|
+
Text: Your glasses are ready for pickup.
|
45
|
+
SMS-Typ: direct
|
46
|
+
Flash SMS: false
|
47
|
+
Encoding: gsm
|
48
|
+
GSM0338: true
|
49
|
+
Debug: true
|
50
|
+
TEXT
|
51
|
+
|
52
|
+
body = request(stub, { details: 1 })
|
53
|
+
|
54
|
+
expect(body).to be_a(String)
|
55
|
+
|
56
|
+
code, booked, cost, balance, text, type, flash, encoding, gsm0338, debug = body.split("\n")
|
57
|
+
|
58
|
+
expect(code).to be_a(String)
|
59
|
+
expect(booked.split(':').last.to_f).to be_a(Float)
|
60
|
+
expect(cost.split(':').last.to_f).to be_a(Float)
|
61
|
+
expect(balance.split(':').last.to_f).to be_a(Float)
|
62
|
+
expect(text.split(':').last.strip!).to eq($text)
|
63
|
+
expect(type.split(':').last.strip!).to eq('direct')
|
64
|
+
expect(flash.split(':').last.strip!).to eq('false')
|
65
|
+
expect(encoding.split(':').last.strip!).to eq('gsm')
|
66
|
+
expect(gsm0338.split(':').last.strip!).to eq('true')
|
67
|
+
expect(debug.split(':').last.strip!).to eq('true')
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'sends a single sms and returns json response' do
|
71
|
+
stub = {
|
72
|
+
success: '100',
|
73
|
+
total_price: 0,
|
74
|
+
balance: 4.5,
|
75
|
+
debug: 'true',
|
76
|
+
sms_type: 'direct',
|
77
|
+
messages: [{ id: nil,
|
78
|
+
sender: '491771783130',
|
79
|
+
recipient: '491771783130',
|
80
|
+
text: 'Your glasses are ready for pickup.',
|
81
|
+
encoding: 'gsm',
|
82
|
+
parts: 1,
|
83
|
+
price: 0,
|
84
|
+
success: true,
|
85
|
+
error: nil,
|
86
|
+
error_text: nil }]
|
87
|
+
}
|
88
|
+
|
89
|
+
body = request(stub, { json: 1 })
|
90
|
+
|
91
|
+
expect(body).to be_a(Hash)
|
92
|
+
|
93
|
+
expect(body[:success]).to be_a(String)
|
94
|
+
expect(body[:total_price]).to be_numeric
|
95
|
+
expect(body[:balance]).to be_a(Float)
|
96
|
+
expect(body[:debug]).to be_a(String)
|
97
|
+
expect(body[:sms_type]).to eq('direct')
|
98
|
+
expect(body[:messages]).to be_a(Array)
|
99
|
+
body[:messages].each do |message|
|
100
|
+
expect(message).to be_a(Hash)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -1,121 +1,121 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'seven_api/resources/subaccounts'
|
5
|
-
|
6
|
-
dummy_subaccount = {
|
7
|
-
:auto_topup => {
|
8
|
-
:amount => 5,
|
9
|
-
:threshold => 1,
|
10
|
-
},
|
11
|
-
:balance => 36.8100,
|
12
|
-
:company => 'Company1',
|
13
|
-
:contact => {
|
14
|
-
:email => 'sms@acme-company1.com',
|
15
|
-
:name => 'John Doe',
|
16
|
-
},
|
17
|
-
:id => '1234567891',
|
18
|
-
:total_usage => 0.3000,
|
19
|
-
:username => nil,
|
20
|
-
}
|
21
|
-
|
22
|
-
RSpec.describe SevenApi, 'subaccounts' do
|
23
|
-
HELPER = Helper.new(SevenApi::Resources::Subaccounts)
|
24
|
-
|
25
|
-
def request(key, stub, extra_params = {})
|
26
|
-
HELPER.request(HELPER.resource.method(key), stub, extra_params)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'returns all subaccounts' do
|
30
|
-
res = request(:read, [
|
31
|
-
dummy_subaccount
|
32
|
-
])
|
33
|
-
|
34
|
-
expect(res).to be_a(Array)
|
35
|
-
|
36
|
-
res.each do |subaccount|
|
37
|
-
assert_subaccount(subaccount)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'creates a subaccount' do
|
42
|
-
res = request(:create, {
|
43
|
-
:error => nil,
|
44
|
-
:subaccount => dummy_subaccount,
|
45
|
-
:success => true,
|
46
|
-
})
|
47
|
-
|
48
|
-
expect(res).to be_a(Hash)
|
49
|
-
expect(res[:error]).to be_nil_or_lengthy_string
|
50
|
-
assert_subaccount(res[:subaccount])
|
51
|
-
expect(res[:success]).to be_boolean
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'deletes a subaccount' do
|
55
|
-
res = request(
|
56
|
-
:delete,
|
57
|
-
{
|
58
|
-
:error => nil,
|
59
|
-
:success => true,
|
60
|
-
},
|
61
|
-
{
|
62
|
-
:id => -1,
|
63
|
-
}
|
64
|
-
)
|
65
|
-
|
66
|
-
expect(res).to be_a(Hash)
|
67
|
-
expect(res[:error]).to be_nil_or_lengthy_string
|
68
|
-
expect(res[:success]).to be_boolean
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'transfers credits' do
|
72
|
-
res = request(
|
73
|
-
:transfer_credits,
|
74
|
-
{
|
75
|
-
:error => nil,
|
76
|
-
:success => true,
|
77
|
-
},
|
78
|
-
{
|
79
|
-
:amount => 0,
|
80
|
-
:id => -1,
|
81
|
-
}
|
82
|
-
)
|
83
|
-
|
84
|
-
expect(res).to be_a(Hash)
|
85
|
-
expect(res[:error]).to be_nil_or_lengthy_string
|
86
|
-
expect(res[:success]).to be_boolean
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'updats automatic charging of credits' do
|
90
|
-
res = request(
|
91
|
-
:update,
|
92
|
-
{
|
93
|
-
:error => nil,
|
94
|
-
:success => true,
|
95
|
-
},
|
96
|
-
{
|
97
|
-
:amount => 0,
|
98
|
-
:id => -1,
|
99
|
-
:threshold => -1,
|
100
|
-
}
|
101
|
-
)
|
102
|
-
|
103
|
-
expect(res).to be_a(Hash)
|
104
|
-
expect(res[:error]).to be_nil_or_lengthy_string
|
105
|
-
expect(res[:success]).to be_boolean
|
106
|
-
end
|
107
|
-
|
108
|
-
private
|
109
|
-
|
110
|
-
def assert_subaccount(subaccount)
|
111
|
-
expect(subaccount).to be_a(Hash)
|
112
|
-
expect(subaccount).to include(:auto_topup, :balance, :company, :contact, :id, :total_usage, :username,)
|
113
|
-
expect(subaccount[:auto_topup]).to be_a(Object)
|
114
|
-
expect(subaccount[:auto_topup]).to include(:amount, :threshold,)
|
115
|
-
expect(subaccount[:balance]).to be_a(Float)
|
116
|
-
expect(subaccount[:contact]).to be_a(Object)
|
117
|
-
expect(subaccount[:contact]).to include(:email, :name,)
|
118
|
-
expect(subaccount[:id]).to be_a(String)
|
119
|
-
expect(subaccount[:total_usage]).to be_a(Float)
|
120
|
-
end
|
121
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'seven_api/resources/subaccounts'
|
5
|
+
|
6
|
+
dummy_subaccount = {
|
7
|
+
:auto_topup => {
|
8
|
+
:amount => 5,
|
9
|
+
:threshold => 1,
|
10
|
+
},
|
11
|
+
:balance => 36.8100,
|
12
|
+
:company => 'Company1',
|
13
|
+
:contact => {
|
14
|
+
:email => 'sms@acme-company1.com',
|
15
|
+
:name => 'John Doe',
|
16
|
+
},
|
17
|
+
:id => '1234567891',
|
18
|
+
:total_usage => 0.3000,
|
19
|
+
:username => nil,
|
20
|
+
}
|
21
|
+
|
22
|
+
RSpec.describe SevenApi, 'subaccounts' do
|
23
|
+
HELPER = Helper.new(SevenApi::Resources::Subaccounts)
|
24
|
+
|
25
|
+
def request(key, stub, extra_params = {})
|
26
|
+
HELPER.request(HELPER.resource.method(key), stub, extra_params)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns all subaccounts' do
|
30
|
+
res = request(:read, [
|
31
|
+
dummy_subaccount
|
32
|
+
])
|
33
|
+
|
34
|
+
expect(res).to be_a(Array)
|
35
|
+
|
36
|
+
res.each do |subaccount|
|
37
|
+
assert_subaccount(subaccount)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'creates a subaccount' do
|
42
|
+
res = request(:create, {
|
43
|
+
:error => nil,
|
44
|
+
:subaccount => dummy_subaccount,
|
45
|
+
:success => true,
|
46
|
+
})
|
47
|
+
|
48
|
+
expect(res).to be_a(Hash)
|
49
|
+
expect(res[:error]).to be_nil_or_lengthy_string
|
50
|
+
assert_subaccount(res[:subaccount])
|
51
|
+
expect(res[:success]).to be_boolean
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'deletes a subaccount' do
|
55
|
+
res = request(
|
56
|
+
:delete,
|
57
|
+
{
|
58
|
+
:error => nil,
|
59
|
+
:success => true,
|
60
|
+
},
|
61
|
+
{
|
62
|
+
:id => -1,
|
63
|
+
}
|
64
|
+
)
|
65
|
+
|
66
|
+
expect(res).to be_a(Hash)
|
67
|
+
expect(res[:error]).to be_nil_or_lengthy_string
|
68
|
+
expect(res[:success]).to be_boolean
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'transfers credits' do
|
72
|
+
res = request(
|
73
|
+
:transfer_credits,
|
74
|
+
{
|
75
|
+
:error => nil,
|
76
|
+
:success => true,
|
77
|
+
},
|
78
|
+
{
|
79
|
+
:amount => 0,
|
80
|
+
:id => -1,
|
81
|
+
}
|
82
|
+
)
|
83
|
+
|
84
|
+
expect(res).to be_a(Hash)
|
85
|
+
expect(res[:error]).to be_nil_or_lengthy_string
|
86
|
+
expect(res[:success]).to be_boolean
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'updats automatic charging of credits' do
|
90
|
+
res = request(
|
91
|
+
:update,
|
92
|
+
{
|
93
|
+
:error => nil,
|
94
|
+
:success => true,
|
95
|
+
},
|
96
|
+
{
|
97
|
+
:amount => 0,
|
98
|
+
:id => -1,
|
99
|
+
:threshold => -1,
|
100
|
+
}
|
101
|
+
)
|
102
|
+
|
103
|
+
expect(res).to be_a(Hash)
|
104
|
+
expect(res[:error]).to be_nil_or_lengthy_string
|
105
|
+
expect(res[:success]).to be_boolean
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
|
110
|
+
def assert_subaccount(subaccount)
|
111
|
+
expect(subaccount).to be_a(Hash)
|
112
|
+
expect(subaccount).to include(:auto_topup, :balance, :company, :contact, :id, :total_usage, :username,)
|
113
|
+
expect(subaccount[:auto_topup]).to be_a(Object)
|
114
|
+
expect(subaccount[:auto_topup]).to include(:amount, :threshold,)
|
115
|
+
expect(subaccount[:balance]).to be_a(Float)
|
116
|
+
expect(subaccount[:contact]).to be_a(Object)
|
117
|
+
expect(subaccount[:contact]).to include(:email, :name,)
|
118
|
+
expect(subaccount[:id]).to be_a(String)
|
119
|
+
expect(subaccount[:total_usage]).to be_a(Float)
|
120
|
+
end
|
121
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'seven_api/resources/validate_for_voice'
|
5
|
-
|
6
|
-
RSpec.describe SevenApi, 'validate_for_voice' do
|
7
|
-
it 'returns caller id information' do
|
8
|
-
number = '491771783130'
|
9
|
-
callback_host = Helper::IS_HTTP ? `curl http://ipecho.net/plain` : '127.0.0.1'
|
10
|
-
callback = "#{callback_host}/callback.php"
|
11
|
-
stub = { success: true }
|
12
|
-
|
13
|
-
helper = Helper.new(SevenApi::Resources::ValidateForVoice)
|
14
|
-
body = helper.request(helper.resource.method(:retrieve), stub, { number: number, callback: callback })
|
15
|
-
|
16
|
-
expect(body).to be_a(Hash)
|
17
|
-
expect(body[:success]).to be_boolean
|
18
|
-
end
|
19
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'seven_api/resources/validate_for_voice'
|
5
|
+
|
6
|
+
RSpec.describe SevenApi, 'validate_for_voice' do
|
7
|
+
it 'returns caller id information' do
|
8
|
+
number = '491771783130'
|
9
|
+
callback_host = Helper::IS_HTTP ? `curl http://ipecho.net/plain` : '127.0.0.1'
|
10
|
+
callback = "#{callback_host}/callback.php"
|
11
|
+
stub = { success: true }
|
12
|
+
|
13
|
+
helper = Helper.new(SevenApi::Resources::ValidateForVoice)
|
14
|
+
body = helper.request(helper.resource.method(:retrieve), stub, { number: number, callback: callback })
|
15
|
+
|
16
|
+
expect(body).to be_a(Hash)
|
17
|
+
expect(body[:success]).to be_boolean
|
18
|
+
end
|
19
|
+
end
|