bandwidth-sdk 9.0.0 → 9.1.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db76591055af337edfa263589d610ccaeb6548b790e8198c151c8aef12aae58a
|
4
|
+
data.tar.gz: '0149d372e10582225a5add12aa9f07b43ab52686431facea7968c011297ca97e'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07716df459d4e176ec1725d353f1c811db5fe8890bb413d84cc54a531d69db998add4aee95f6da55d113a62678a9d924c2278e6148a3fafeb0f04230c1561337
|
7
|
+
data.tar.gz: 21c7a1a53d35326b9319dc7836d93d71a7e252b0804ca2311053aaed6c85149e9ec5ac1f2bd2adfcf9439ae80259c22302f2b1f18c63d207d5b3b5260895bb46
|
data/README.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Bandwidth Ruby SDK
|
2
2
|
|
3
|
+
[](https://github.com/Bandwidth/ruby-sdk/actions/workflows/test.yml)
|
4
|
+
|
5
|
+
|
6
|
+
| **OS** | **Ruby** |
|
7
|
+
|:---:|:---:|
|
8
|
+
| Windows 2016 | 2.6, 2.7, 3.0 |
|
9
|
+
| Windows 2019 | 2.6, 2.7, 3.0 |
|
10
|
+
| Ubuntu 18.04 | 2.6, 2.7, 3.0 |
|
11
|
+
| Ubuntu 20.04 | 2.6, 2.7, 3.0 |
|
12
|
+
|
3
13
|
## Getting Started
|
4
14
|
|
5
15
|
### Installation
|
data/lib/bandwidth/api_helper.rb
CHANGED
@@ -144,6 +144,7 @@ module Bandwidth
|
|
144
144
|
# Parses JSON string.
|
145
145
|
# @param [String] A JSON string.
|
146
146
|
def self.json_deserialize(json)
|
147
|
+
return {} if json.nil? || json.empty?
|
147
148
|
JSON.parse(json)
|
148
149
|
rescue StandardError
|
149
150
|
raise TypeError, 'Server responded with invalid JSON.'
|
@@ -590,15 +590,9 @@ module Voice
|
|
590
590
|
)
|
591
591
|
_query_url = APIHelper.clean_url _query_builder
|
592
592
|
|
593
|
-
# Prepare headers.
|
594
|
-
_headers = {
|
595
|
-
'accept' => 'application/json'
|
596
|
-
}
|
597
|
-
|
598
593
|
# Prepare and execute HttpRequest.
|
599
594
|
_request = config.http_client.get(
|
600
|
-
_query_url
|
601
|
-
headers: _headers
|
595
|
+
_query_url
|
602
596
|
)
|
603
597
|
VoiceBasicAuth.apply(config, _request)
|
604
598
|
_response = execute_request(_request)
|
@@ -648,11 +642,8 @@ module Voice
|
|
648
642
|
validate_response(_response)
|
649
643
|
|
650
644
|
# Return appropriate response type.
|
651
|
-
decoded = APIHelper.json_deserialize(_response.raw_body) unless
|
652
|
-
_response.raw_body.nil? ||
|
653
|
-
_response.raw_body.to_s.strip.empty?
|
654
645
|
ApiResponse.new(
|
655
|
-
_response, data:
|
646
|
+
_response, data: _response.raw_body
|
656
647
|
)
|
657
648
|
end
|
658
649
|
|
@@ -3,6 +3,7 @@
|
|
3
3
|
# A simple integration test against Bandwidth's APIs
|
4
4
|
|
5
5
|
require 'test/unit'
|
6
|
+
require 'securerandom'
|
6
7
|
require_relative '../../lib/bandwidth.rb'
|
7
8
|
|
8
9
|
include Bandwidth
|
@@ -37,6 +38,17 @@ class IntegrationTest < Test::Unit::TestCase
|
|
37
38
|
phone_number_lookup_basic_auth_user_name: BW_USERNAME,
|
38
39
|
phone_number_lookup_basic_auth_password: BW_PASSWORD
|
39
40
|
)
|
41
|
+
|
42
|
+
@bandwidth_client_invalid_auth = Bandwidth::Client.new(
|
43
|
+
voice_basic_auth_user_name: "bad_username",
|
44
|
+
voice_basic_auth_password: "bad_password",
|
45
|
+
messaging_basic_auth_user_name: "bad_username",
|
46
|
+
messaging_basic_auth_password: "bad_password",
|
47
|
+
multi_factor_auth_basic_auth_user_name: "bad_username",
|
48
|
+
multi_factor_auth_basic_auth_password: "bad_password",
|
49
|
+
phone_number_lookup_basic_auth_user_name: "bad_username",
|
50
|
+
phone_number_lookup_basic_auth_password: "bad_password"
|
51
|
+
)
|
40
52
|
end
|
41
53
|
|
42
54
|
def test_create_message
|
@@ -66,18 +78,31 @@ class IntegrationTest < Test::Unit::TestCase
|
|
66
78
|
|
67
79
|
def test_upload_download_media
|
68
80
|
#define constants for upload media and download media
|
69
|
-
|
70
|
-
|
81
|
+
media_id = "text-media-id-" + SecureRandom.uuid
|
82
|
+
media = "Hello world"
|
71
83
|
|
72
84
|
#media upload
|
73
|
-
@bandwidth_client.messaging_client.client.upload_media(BW_ACCOUNT_ID,
|
85
|
+
@bandwidth_client.messaging_client.client.upload_media(BW_ACCOUNT_ID, media_id, media, :content_type => "application/octet-stream", :cache_control => "no-cache")
|
74
86
|
|
75
87
|
#media download
|
76
|
-
|
88
|
+
downloaded_media = @bandwidth_client.messaging_client.client.get_media(BW_ACCOUNT_ID, media_id).data
|
77
89
|
|
78
|
-
assert_equal(
|
90
|
+
assert_equal(downloaded_media, media, "Downloaded media file not equal to upload")
|
79
91
|
end
|
80
92
|
|
93
|
+
def test_get_message
|
94
|
+
# Send a successful request to the GET messages API
|
95
|
+
response = @bandwidth_client.messaging_client.client.get_messages(BW_ACCOUNT_ID, :message_id => "abc123")
|
96
|
+
assert_equal(response.status_code, 200, "API did not return a 200 OK")
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_get_message_invalid_auth
|
100
|
+
# Send an unsuccessful request to the GET messages API
|
101
|
+
assert_raise MessagingException do
|
102
|
+
response = @bandwidth_client_invalid_auth.messaging_client.client.get_messages(BW_ACCOUNT_ID)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
81
106
|
def test_create_call_and_get_call_state
|
82
107
|
body = CreateCallRequest.new
|
83
108
|
body.from = BW_NUMBER
|
@@ -88,6 +113,7 @@ class IntegrationTest < Test::Unit::TestCase
|
|
88
113
|
assert(response.data.call_id.length > 0, "call_id value not set")
|
89
114
|
|
90
115
|
#Get phone call information
|
116
|
+
sleep 1
|
91
117
|
response = @bandwidth_client.voice_client.client.get_call(BW_ACCOUNT_ID, response.data.call_id)
|
92
118
|
assert(response.data.state.length > 0, "state value not set")
|
93
119
|
end
|
@@ -515,7 +541,7 @@ class IntegrationTest < Test::Unit::TestCase
|
|
515
541
|
|
516
542
|
def test_mfa_verify
|
517
543
|
body = TwoFactorVerifyRequestSchema.new
|
518
|
-
body.to =
|
544
|
+
body.to = "+1000" + rand(1111111..9999999).to_s
|
519
545
|
body.application_id = BW_VOICE_APPLICATION_ID
|
520
546
|
body.scope = "scope"
|
521
547
|
body.code = "123456"
|
@@ -554,13 +580,14 @@ class IntegrationTest < Test::Unit::TestCase
|
|
554
580
|
|
555
581
|
def test_ring
|
556
582
|
ring = Bandwidth::Voice::Ring.new({
|
557
|
-
:duration => 5
|
583
|
+
:duration => 5,
|
584
|
+
:answer_call => false
|
558
585
|
})
|
559
586
|
|
560
587
|
response = Bandwidth::Voice::Response.new()
|
561
588
|
response.push(ring)
|
562
589
|
|
563
|
-
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Ring duration="5"/></Response>'
|
590
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Ring duration="5" answerCall="false"/></Response>'
|
564
591
|
actual = response.to_bxml()
|
565
592
|
assert_equal(expected, actual)
|
566
593
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bandwidth-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Bandwidth
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: '1.0'
|
34
34
|
- - "<="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 1.3
|
36
|
+
version: 1.9.3
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '1.0'
|
44
44
|
- - "<="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.3
|
46
|
+
version: 1.9.3
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: faraday_middleware
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,8 +140,9 @@ dependencies:
|
|
140
140
|
- - "~>"
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '1.0'
|
143
|
-
description:
|
144
|
-
|
143
|
+
description: The official client SDK for Bandwidht's Voice, Messaging, MFA, and WebRTC
|
144
|
+
APIs
|
145
|
+
email: dx@bandwidth.com
|
145
146
|
executables: []
|
146
147
|
extensions: []
|
147
148
|
extra_rdoc_files: []
|
@@ -283,7 +284,7 @@ files:
|
|
283
284
|
- test/http_response_catcher.rb
|
284
285
|
- test/integration/test_integration.rb
|
285
286
|
- test/test_helper.rb
|
286
|
-
homepage: https://
|
287
|
+
homepage: https://github.com/Bandwidth/ruby-sdk
|
287
288
|
licenses:
|
288
289
|
- MIT
|
289
290
|
metadata: {}
|
@@ -302,8 +303,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
302
303
|
- !ruby/object:Gem::Version
|
303
304
|
version: '0'
|
304
305
|
requirements: []
|
305
|
-
rubygems_version: 3.
|
306
|
+
rubygems_version: 3.3.7
|
306
307
|
signing_key:
|
307
308
|
specification_version: 4
|
308
|
-
summary:
|
309
|
+
summary: Bandwidth
|
309
310
|
test_files: []
|