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,109 +1,109 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'securerandom'
|
5
|
-
require 'seven_api/hooks'
|
6
|
-
require 'seven_api/util'
|
7
|
-
require 'seven_api/resources/hooks'
|
8
|
-
|
9
|
-
RSpec.describe SevenApi, 'hooks' do
|
10
|
-
HOOK_ID = EnvKeyStore.new('HOOK_ID')
|
11
|
-
|
12
|
-
def alter_action_stub
|
13
|
-
{
|
14
|
-
:code => nil,
|
15
|
-
:success => true
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
def request(fn, stub, extra_params = {})
|
20
|
-
helper = Helper.new(SevenApi::Resources::Hooks)
|
21
|
-
|
22
|
-
res = helper.request(helper.resource.method(fn), stub, extra_params)
|
23
|
-
|
24
|
-
expect(res).to be_a(Hash)
|
25
|
-
|
26
|
-
stub_keys = stub.keys
|
27
|
-
|
28
|
-
res.each do |k, v|
|
29
|
-
expect(stub_keys).to include(k)
|
30
|
-
expect(v.class).to match(stub[:"#{k}"].class)
|
31
|
-
end
|
32
|
-
|
33
|
-
res
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'returns all hooks' do
|
37
|
-
res = request(:read, {
|
38
|
-
:code => nil,
|
39
|
-
:hooks => [
|
40
|
-
{
|
41
|
-
:created => "2020-11-04 23:04:15",
|
42
|
-
:event_type => "sms_mo",
|
43
|
-
:id => "30",
|
44
|
-
:request_method => "GET",
|
45
|
-
:target_url => "http://my.tld/testHook"
|
46
|
-
}
|
47
|
-
],
|
48
|
-
:success => true
|
49
|
-
})
|
50
|
-
|
51
|
-
expect(res).to include(:code, :hooks, :success)
|
52
|
-
expect(res[:code]).to eq(nil)
|
53
|
-
expect(res[:hooks]).to be_a(Array)
|
54
|
-
expect(res[:success]).to be_boolean
|
55
|
-
|
56
|
-
res[:hooks].each do |hook|
|
57
|
-
expect(hook).to include(:created, :event_type, :id, :request_method, :target_url)
|
58
|
-
|
59
|
-
expect(SevenApi::Util::is_valid_datetime?(hook[:created])).to be
|
60
|
-
expect(hook[:created]).to match(/^\d\d\d\d-(0?[1-9]|1[0-2])-(0?[1-9]|[12][0-9]|3[01]) (1[0-9]|2[0-3]|0[0-9]):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9])$/)
|
61
|
-
expect(SevenApi::Hooks::Validator::event_type?(hook[:event_type])).to be
|
62
|
-
expect(SevenApi::Util::is_positive_integer?(hook[:id])).to be
|
63
|
-
expect(SevenApi::Hooks::Validator::request_method?(hook[:request_method])).to be
|
64
|
-
expect(SevenApi::Hooks::Validator::target_url?(hook[:target_url])).to be
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
=begin
|
69
|
-
it 'subscribes' do
|
70
|
-
helper = Helper.new(Seven::Resources::Hooks)
|
71
|
-
stub = alter_action_stub.merge({ :id => rand(1...1000000) })
|
72
|
-
|
73
|
-
res = request(helper.resource.method(:subscribe), stub, {
|
74
|
-
:event_type => Seven::Hooks::EventType::NEW_INBOUND_SMS,
|
75
|
-
:request_method => Seven::Hooks::RequestMethod::GET,
|
76
|
-
:target_url => "http://ruby.tld/#{SecureRandom.uuid}"
|
77
|
-
})
|
78
|
-
|
79
|
-
expect(Seven::Util::is_positive_integer?(res[:id])).to be
|
80
|
-
expect(res[:id]).to be_a(Integer)
|
81
|
-
expect(stub[:id]).to match(res[:id]) unless Helper::IS_HTTP
|
82
|
-
|
83
|
-
assert_alter_response(res)
|
84
|
-
|
85
|
-
puts "Subscribed ID: #{Helper::IS_HTTP ? res[:id] : stub[:id]}"
|
86
|
-
|
87
|
-
HOOK_ID.set(res[:id])
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'unsubscribes' do
|
91
|
-
helper = Helper.new(Seven::Resources::Hooks)
|
92
|
-
id = HOOK_ID.get
|
93
|
-
res = request(helper.resource.method(:unubscribe), alter_action_stub, { :id => id })
|
94
|
-
|
95
|
-
assert_alter_response(res)
|
96
|
-
|
97
|
-
expect(res[:success]).to be_boolean
|
98
|
-
|
99
|
-
puts "Unsubscribed ID #{id}: #{res[:success]}"
|
100
|
-
|
101
|
-
res[:success]
|
102
|
-
end
|
103
|
-
=end
|
104
|
-
|
105
|
-
def assert_alter_response(res)
|
106
|
-
expect(res[:code]).to match(nil)
|
107
|
-
expect(res[:success]).to be_boolean
|
108
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'securerandom'
|
5
|
+
require 'seven_api/hooks'
|
6
|
+
require 'seven_api/util'
|
7
|
+
require 'seven_api/resources/hooks'
|
8
|
+
|
9
|
+
RSpec.describe SevenApi, 'hooks' do
|
10
|
+
HOOK_ID = EnvKeyStore.new('HOOK_ID')
|
11
|
+
|
12
|
+
def alter_action_stub
|
13
|
+
{
|
14
|
+
:code => nil,
|
15
|
+
:success => true
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def request(fn, stub, extra_params = {})
|
20
|
+
helper = Helper.new(SevenApi::Resources::Hooks)
|
21
|
+
|
22
|
+
res = helper.request(helper.resource.method(fn), stub, extra_params)
|
23
|
+
|
24
|
+
expect(res).to be_a(Hash)
|
25
|
+
|
26
|
+
stub_keys = stub.keys
|
27
|
+
|
28
|
+
res.each do |k, v|
|
29
|
+
expect(stub_keys).to include(k)
|
30
|
+
expect(v.class).to match(stub[:"#{k}"].class)
|
31
|
+
end
|
32
|
+
|
33
|
+
res
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'returns all hooks' do
|
37
|
+
res = request(:read, {
|
38
|
+
:code => nil,
|
39
|
+
:hooks => [
|
40
|
+
{
|
41
|
+
:created => "2020-11-04 23:04:15",
|
42
|
+
:event_type => "sms_mo",
|
43
|
+
:id => "30",
|
44
|
+
:request_method => "GET",
|
45
|
+
:target_url => "http://my.tld/testHook"
|
46
|
+
}
|
47
|
+
],
|
48
|
+
:success => true
|
49
|
+
})
|
50
|
+
|
51
|
+
expect(res).to include(:code, :hooks, :success)
|
52
|
+
expect(res[:code]).to eq(nil)
|
53
|
+
expect(res[:hooks]).to be_a(Array)
|
54
|
+
expect(res[:success]).to be_boolean
|
55
|
+
|
56
|
+
res[:hooks].each do |hook|
|
57
|
+
expect(hook).to include(:created, :event_type, :id, :request_method, :target_url)
|
58
|
+
|
59
|
+
expect(SevenApi::Util::is_valid_datetime?(hook[:created])).to be
|
60
|
+
expect(hook[:created]).to match(/^\d\d\d\d-(0?[1-9]|1[0-2])-(0?[1-9]|[12][0-9]|3[01]) (1[0-9]|2[0-3]|0[0-9]):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9])$/)
|
61
|
+
expect(SevenApi::Hooks::Validator::event_type?(hook[:event_type])).to be
|
62
|
+
expect(SevenApi::Util::is_positive_integer?(hook[:id])).to be
|
63
|
+
expect(SevenApi::Hooks::Validator::request_method?(hook[:request_method])).to be
|
64
|
+
expect(SevenApi::Hooks::Validator::target_url?(hook[:target_url])).to be
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
=begin
|
69
|
+
it 'subscribes' do
|
70
|
+
helper = Helper.new(Seven::Resources::Hooks)
|
71
|
+
stub = alter_action_stub.merge({ :id => rand(1...1000000) })
|
72
|
+
|
73
|
+
res = request(helper.resource.method(:subscribe), stub, {
|
74
|
+
:event_type => Seven::Hooks::EventType::NEW_INBOUND_SMS,
|
75
|
+
:request_method => Seven::Hooks::RequestMethod::GET,
|
76
|
+
:target_url => "http://ruby.tld/#{SecureRandom.uuid}"
|
77
|
+
})
|
78
|
+
|
79
|
+
expect(Seven::Util::is_positive_integer?(res[:id])).to be
|
80
|
+
expect(res[:id]).to be_a(Integer)
|
81
|
+
expect(stub[:id]).to match(res[:id]) unless Helper::IS_HTTP
|
82
|
+
|
83
|
+
assert_alter_response(res)
|
84
|
+
|
85
|
+
puts "Subscribed ID: #{Helper::IS_HTTP ? res[:id] : stub[:id]}"
|
86
|
+
|
87
|
+
HOOK_ID.set(res[:id])
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'unsubscribes' do
|
91
|
+
helper = Helper.new(Seven::Resources::Hooks)
|
92
|
+
id = HOOK_ID.get
|
93
|
+
res = request(helper.resource.method(:unubscribe), alter_action_stub, { :id => id })
|
94
|
+
|
95
|
+
assert_alter_response(res)
|
96
|
+
|
97
|
+
expect(res[:success]).to be_boolean
|
98
|
+
|
99
|
+
puts "Unsubscribed ID #{id}: #{res[:success]}"
|
100
|
+
|
101
|
+
res[:success]
|
102
|
+
end
|
103
|
+
=end
|
104
|
+
|
105
|
+
def assert_alter_response(res)
|
106
|
+
expect(res[:code]).to match(nil)
|
107
|
+
expect(res[:success]).to be_boolean
|
108
|
+
end
|
109
109
|
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#noinspection RubyResolve
|
4
|
-
require 'spec_helper'
|
5
|
-
require 'seven_api/resource'
|
6
|
-
|
7
|
-
#noinspection RubyResolve
|
8
|
-
RSpec.describe SevenApi, 'instance' do
|
9
|
-
helper = Helper.new(SevenApi::Resource)
|
10
|
-
|
11
|
-
it 'checks api key' do
|
12
|
-
expect(helper.resource.api_key).to be_lengthy_string
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'checks sentWith' do
|
16
|
-
expect(helper.resource.sent_with).to be_lengthy_string
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'fails authentication' do
|
20
|
-
expect { SevenApi::Resource.new('') }.to raise_error(RuntimeError)
|
21
|
-
end
|
22
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#noinspection RubyResolve
|
4
|
+
require 'spec_helper'
|
5
|
+
require 'seven_api/resource'
|
6
|
+
|
7
|
+
#noinspection RubyResolve
|
8
|
+
RSpec.describe SevenApi, 'instance' do
|
9
|
+
helper = Helper.new(SevenApi::Resource)
|
10
|
+
|
11
|
+
it 'checks api key' do
|
12
|
+
expect(helper.resource.api_key).to be_lengthy_string
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'checks sentWith' do
|
16
|
+
expect(helper.resource.sent_with).to be_lengthy_string
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'fails authentication' do
|
20
|
+
expect { SevenApi::Resource.new('') }.to raise_error(RuntimeError)
|
21
|
+
end
|
22
|
+
end
|
@@ -1,86 +1,86 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'seven_api/journal'
|
5
|
-
require 'seven_api/resources/journal'
|
6
|
-
require 'seven_api/sms'
|
7
|
-
|
8
|
-
RSpec.describe SevenApi, 'journal' do
|
9
|
-
def valid_timestamp?(str)
|
10
|
-
str.match(/[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]) (2[0-3]|[01][\d]):[0-5][\d]/)
|
11
|
-
end
|
12
|
-
|
13
|
-
def request(type)
|
14
|
-
stub = [{
|
15
|
-
:from => "SMS",
|
16
|
-
:id => "123456789",
|
17
|
-
:price => "1.2",
|
18
|
-
:text => "Hey my friend!",
|
19
|
-
:timestamp => "2020-10-14 14:25:04",
|
20
|
-
:to => "49170123456789",
|
21
|
-
}]
|
22
|
-
|
23
|
-
helper = Helper.new(SevenApi::Resources::Journal)
|
24
|
-
res = helper.request(helper.resource.method(:retrieve), stub, { type: type })
|
25
|
-
|
26
|
-
expect(res).to be_a(Array)
|
27
|
-
|
28
|
-
res.each do |journal|
|
29
|
-
expect(journal).to be_a(Hash)
|
30
|
-
expect(journal[:from]).to be_lengthy_string
|
31
|
-
expect(journal[:id]).to be_numeric
|
32
|
-
expect(SevenApi::Util::valid_float?(journal[:price])).to be_truthy
|
33
|
-
expect(journal[:text]).to be_lengthy_string
|
34
|
-
expect(valid_timestamp?(journal[:timestamp])).to be_truthy
|
35
|
-
expect(journal[:to]).to be_lengthy_string
|
36
|
-
end
|
37
|
-
|
38
|
-
res
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'returns all inbound messages' do
|
42
|
-
request(SevenApi::Journal::Type::INBOUND)
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'returns all outbound messages' do
|
46
|
-
request(SevenApi::Journal::Type::OUTBOUND).each do |journal|
|
47
|
-
journal.merge!({
|
48
|
-
:connection => "http",
|
49
|
-
:dlr => "DELIVERED",
|
50
|
-
:dlr_timestamp => "2020-10-04 09:26:10.000",
|
51
|
-
:foreign_id => "MyForeignId",
|
52
|
-
:label => "MyCustomLabel",
|
53
|
-
:latency => "5.1060",
|
54
|
-
:mccmnc => "26207",
|
55
|
-
:type => "direct",
|
56
|
-
})
|
57
|
-
expect(journal[:connection]).to be_lengthy_string
|
58
|
-
expect(journal[:dlr]).to be_nil_or_lengthy_string
|
59
|
-
expect(valid_timestamp?(journal[:dlr_timestamp])).to be_truthy
|
60
|
-
expect(journal[:foreign_id]).to be_nil_or_lengthy_string
|
61
|
-
expect(journal[:label]).to be_nil_or_lengthy_string
|
62
|
-
expect(journal[:latency]).to be_nil_or_lengthy_string
|
63
|
-
expect(journal[:mccmnc]).to be_nil_or_lengthy_string
|
64
|
-
expect(SevenApi::Util::in_module_constants?(journal[:type], SevenApi::Sms::Type)).to be_truthy
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'returns all voice messages' do
|
69
|
-
request(SevenApi::Journal::Type::VOICE).each do |journal|
|
70
|
-
journal.merge!({
|
71
|
-
:duration => "2",
|
72
|
-
:error => "",
|
73
|
-
:status => "completed",
|
74
|
-
:xml => false,
|
75
|
-
})
|
76
|
-
expect(journal[:duration]).to be_numeric
|
77
|
-
expect(journal[:error]).to be_nil_or_lengthy_string
|
78
|
-
expect(journal[:status]).to be_lengthy_string
|
79
|
-
expect(journal[:xml]).to be_boolean
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'returns all reply messages' do
|
84
|
-
request(SevenApi::Journal::Type::REPLIES)
|
85
|
-
end
|
86
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'seven_api/journal'
|
5
|
+
require 'seven_api/resources/journal'
|
6
|
+
require 'seven_api/sms'
|
7
|
+
|
8
|
+
RSpec.describe SevenApi, 'journal' do
|
9
|
+
def valid_timestamp?(str)
|
10
|
+
str.match(/[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]) (2[0-3]|[01][\d]):[0-5][\d]/)
|
11
|
+
end
|
12
|
+
|
13
|
+
def request(type)
|
14
|
+
stub = [{
|
15
|
+
:from => "SMS",
|
16
|
+
:id => "123456789",
|
17
|
+
:price => "1.2",
|
18
|
+
:text => "Hey my friend!",
|
19
|
+
:timestamp => "2020-10-14 14:25:04",
|
20
|
+
:to => "49170123456789",
|
21
|
+
}]
|
22
|
+
|
23
|
+
helper = Helper.new(SevenApi::Resources::Journal)
|
24
|
+
res = helper.request(helper.resource.method(:retrieve), stub, { type: type })
|
25
|
+
|
26
|
+
expect(res).to be_a(Array)
|
27
|
+
|
28
|
+
res.each do |journal|
|
29
|
+
expect(journal).to be_a(Hash)
|
30
|
+
expect(journal[:from]).to be_lengthy_string
|
31
|
+
expect(journal[:id]).to be_numeric
|
32
|
+
expect(SevenApi::Util::valid_float?(journal[:price])).to be_truthy
|
33
|
+
expect(journal[:text]).to be_lengthy_string
|
34
|
+
expect(valid_timestamp?(journal[:timestamp])).to be_truthy
|
35
|
+
expect(journal[:to]).to be_lengthy_string
|
36
|
+
end
|
37
|
+
|
38
|
+
res
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns all inbound messages' do
|
42
|
+
request(SevenApi::Journal::Type::INBOUND)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'returns all outbound messages' do
|
46
|
+
request(SevenApi::Journal::Type::OUTBOUND).each do |journal|
|
47
|
+
journal.merge!({
|
48
|
+
:connection => "http",
|
49
|
+
:dlr => "DELIVERED",
|
50
|
+
:dlr_timestamp => "2020-10-04 09:26:10.000",
|
51
|
+
:foreign_id => "MyForeignId",
|
52
|
+
:label => "MyCustomLabel",
|
53
|
+
:latency => "5.1060",
|
54
|
+
:mccmnc => "26207",
|
55
|
+
:type => "direct",
|
56
|
+
})
|
57
|
+
expect(journal[:connection]).to be_lengthy_string
|
58
|
+
expect(journal[:dlr]).to be_nil_or_lengthy_string
|
59
|
+
expect(valid_timestamp?(journal[:dlr_timestamp])).to be_truthy
|
60
|
+
expect(journal[:foreign_id]).to be_nil_or_lengthy_string
|
61
|
+
expect(journal[:label]).to be_nil_or_lengthy_string
|
62
|
+
expect(journal[:latency]).to be_nil_or_lengthy_string
|
63
|
+
expect(journal[:mccmnc]).to be_nil_or_lengthy_string
|
64
|
+
expect(SevenApi::Util::in_module_constants?(journal[:type], SevenApi::Sms::Type)).to be_truthy
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'returns all voice messages' do
|
69
|
+
request(SevenApi::Journal::Type::VOICE).each do |journal|
|
70
|
+
journal.merge!({
|
71
|
+
:duration => "2",
|
72
|
+
:error => "",
|
73
|
+
:status => "completed",
|
74
|
+
:xml => false,
|
75
|
+
})
|
76
|
+
expect(journal[:duration]).to be_numeric
|
77
|
+
expect(journal[:error]).to be_nil_or_lengthy_string
|
78
|
+
expect(journal[:status]).to be_lengthy_string
|
79
|
+
expect(journal[:xml]).to be_boolean
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'returns all reply messages' do
|
84
|
+
request(SevenApi::Journal::Type::REPLIES)
|
85
|
+
end
|
86
|
+
end
|