bandwidth-sdk 18.0.0 → 18.1.0

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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -4
  3. data/README.md +28 -1
  4. data/bandwidth.yml +944 -19
  5. data/coverage/.last_run.json +1 -1
  6. data/coverage/.resultset.json +784 -152
  7. data/coverage/index.html +21650 -14800
  8. data/docs/BrtcError.md +26 -0
  9. data/docs/BrtcErrorResponse.md +22 -0
  10. data/docs/BrtcErrorSource.md +24 -0
  11. data/docs/BrtcLink.md +22 -0
  12. data/docs/CreateCall.md +2 -2
  13. data/docs/CreateEndpointRequestBase.md +26 -0
  14. data/docs/CreateEndpointResponse.md +22 -0
  15. data/docs/CreateEndpointResponseData.md +32 -0
  16. data/docs/CreateWebRtcConnectionRequest.md +28 -0
  17. data/docs/Device.md +24 -0
  18. data/docs/DeviceStatusEnum.md +15 -0
  19. data/docs/Endpoint.md +30 -0
  20. data/docs/EndpointDirectionEnum.md +15 -0
  21. data/docs/EndpointEvent.md +34 -0
  22. data/docs/EndpointEventTypeEnum.md +15 -0
  23. data/docs/EndpointResponse.md +22 -0
  24. data/docs/EndpointStatusEnum.md +15 -0
  25. data/docs/EndpointTypeEnum.md +15 -0
  26. data/docs/Endpoints.md +28 -0
  27. data/docs/EndpointsApi.md +395 -0
  28. data/docs/InboundCallback.md +2 -2
  29. data/docs/ListEndpointsResponse.md +24 -0
  30. data/docs/LookupResult.md +1 -1
  31. data/docs/MachineDetectionConfiguration.md +1 -1
  32. data/docs/MessageRequest.md +1 -1
  33. data/docs/Page.md +24 -0
  34. data/docs/RbmActionBase.md +1 -1
  35. data/docs/RbmSuggestionResponse.md +1 -1
  36. data/docs/SipConnectionMetadata.md +24 -0
  37. data/docs/SipCredentials.md +20 -0
  38. data/docs/StatusCallback.md +1 -1
  39. data/docs/SyncLookupRequest.md +3 -1
  40. data/docs/UpdateCall.md +1 -1
  41. data/docs/WebhookSubscriptionError.md +22 -0
  42. data/docs/WebhookSubscriptionsListBody.md +1 -1
  43. data/lib/bandwidth-sdk/api/endpoints_api.rb +397 -0
  44. data/lib/bandwidth-sdk/configuration.rb +30 -0
  45. data/lib/bandwidth-sdk/models/brtc_error.rb +219 -0
  46. data/lib/bandwidth-sdk/models/brtc_error_response.rb +204 -0
  47. data/lib/bandwidth-sdk/models/brtc_error_source.rb +176 -0
  48. data/lib/bandwidth-sdk/models/brtc_link.rb +166 -0
  49. data/lib/bandwidth-sdk/models/create_call.rb +7 -7
  50. data/lib/bandwidth-sdk/models/create_endpoint_request_base.rb +250 -0
  51. data/lib/bandwidth-sdk/models/create_endpoint_response.rb +218 -0
  52. data/lib/bandwidth-sdk/models/create_endpoint_response_data.rb +356 -0
  53. data/lib/bandwidth-sdk/models/create_web_rtc_connection_request.rb +266 -0
  54. data/lib/bandwidth-sdk/models/device.rb +258 -0
  55. data/lib/bandwidth-sdk/models/device_status_enum.rb +40 -0
  56. data/lib/bandwidth-sdk/models/endpoint.rb +329 -0
  57. data/lib/bandwidth-sdk/models/endpoint_direction_enum.rb +41 -0
  58. data/lib/bandwidth-sdk/models/endpoint_event.rb +381 -0
  59. data/lib/bandwidth-sdk/models/endpoint_event_type_enum.rb +40 -0
  60. data/lib/bandwidth-sdk/models/endpoint_response.rb +218 -0
  61. data/lib/bandwidth-sdk/models/endpoint_status_enum.rb +40 -0
  62. data/lib/bandwidth-sdk/models/endpoint_type_enum.rb +39 -0
  63. data/lib/bandwidth-sdk/models/endpoints.rb +311 -0
  64. data/lib/bandwidth-sdk/models/inbound_callback.rb +2 -2
  65. data/lib/bandwidth-sdk/models/list_endpoints_response.rb +229 -0
  66. data/lib/bandwidth-sdk/models/lookup_result.rb +1 -1
  67. data/lib/bandwidth-sdk/models/machine_detection_configuration.rb +1 -1
  68. data/lib/bandwidth-sdk/models/message_request.rb +1 -1
  69. data/lib/bandwidth-sdk/models/page.rb +259 -0
  70. data/lib/bandwidth-sdk/models/sip_connection_metadata.rb +175 -0
  71. data/lib/bandwidth-sdk/models/sip_credentials.rb +156 -0
  72. data/lib/bandwidth-sdk/models/status_callback.rb +1 -1
  73. data/lib/bandwidth-sdk/models/sync_lookup_request.rb +35 -4
  74. data/lib/bandwidth-sdk/models/update_call.rb +6 -6
  75. data/lib/bandwidth-sdk/models/webhook_subscription_error.rb +165 -0
  76. data/lib/bandwidth-sdk/models/webhook_subscriptions_list_body.rb +1 -1
  77. data/lib/bandwidth-sdk/version.rb +1 -1
  78. data/lib/bandwidth-sdk.rb +24 -1
  79. data/spec/smoke/endpoints_api_spec.rb +148 -0
  80. data/spec/unit/api/endpoints_api_spec.rb +172 -0
  81. data/spec/unit/api/phone_number_lookup_api_spec.rb +2 -0
  82. metadata +104 -52
@@ -39,7 +39,7 @@ module Bandwidth
39
39
  # Basic auth password.
40
40
  attr_accessor :fallback_password
41
41
 
42
- # A custom string that will be sent with this and all future callbacks unless overwritten by a future `tag` attribute or [`<Tag>`](/docs/voice/bxml/tag) verb, or cleared. May be cleared by setting `tag=\"\"`. Max length 256 characters. Not allowed if `state` is `completed`.
42
+ # A custom string that will be sent with this and all future callbacks unless overwritten by a future `tag` attribute or [`<Tag>`](/docs/voice/bxml/tag) verb, or cleared. May be cleared by setting `tag=\"\"`. Max length 4096 characters. Not allowed if `state` is `completed`.
43
43
  attr_accessor :tag
44
44
 
45
45
  class EnumAttributeValidator
@@ -206,8 +206,8 @@ module Bandwidth
206
206
  invalid_properties.push('invalid value for "fallback_password", the character length must be smaller than or equal to 1024.')
207
207
  end
208
208
 
209
- if !@tag.nil? && @tag.to_s.length > 256
210
- invalid_properties.push('invalid value for "tag", the character length must be smaller than or equal to 256.')
209
+ if !@tag.nil? && @tag.to_s.length > 4096
210
+ invalid_properties.push('invalid value for "tag", the character length must be smaller than or equal to 4096.')
211
211
  end
212
212
 
213
213
  invalid_properties
@@ -221,7 +221,7 @@ module Bandwidth
221
221
  return false if !@password.nil? && @password.to_s.length > 1024
222
222
  return false if !@fallback_username.nil? && @fallback_username.to_s.length > 1024
223
223
  return false if !@fallback_password.nil? && @fallback_password.to_s.length > 1024
224
- return false if !@tag.nil? && @tag.to_s.length > 256
224
+ return false if !@tag.nil? && @tag.to_s.length > 4096
225
225
  true
226
226
  end
227
227
 
@@ -268,8 +268,8 @@ module Bandwidth
268
268
  # Custom attribute writer method with validation
269
269
  # @param [Object] tag Value to be assigned
270
270
  def tag=(tag)
271
- if !tag.nil? && tag.to_s.length > 256
272
- fail ArgumentError, 'invalid value for "tag", the character length must be smaller than or equal to 256.'
271
+ if !tag.nil? && tag.to_s.length > 4096
272
+ fail ArgumentError, 'invalid value for "tag", the character length must be smaller than or equal to 4096.'
273
273
  end
274
274
 
275
275
  @tag = tag
@@ -0,0 +1,165 @@
1
+ =begin
2
+ #Bandwidth
3
+
4
+ #Bandwidth's Communication APIs
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: letstalk@bandwidth.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.17.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Bandwidth
17
+ class WebhookSubscriptionError < ApiModelBase
18
+ attr_accessor :code
19
+
20
+ attr_accessor :description
21
+
22
+ attr_accessor :telephone_numbers
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'code' => :'code',
28
+ :'description' => :'description',
29
+ :'telephone_numbers' => :'telephoneNumbers'
30
+ }
31
+ end
32
+
33
+ # Returns attribute mapping this model knows about
34
+ def self.acceptable_attribute_map
35
+ attribute_map
36
+ end
37
+
38
+ # Returns all the JSON keys this model knows about
39
+ def self.acceptable_attributes
40
+ acceptable_attribute_map.values
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.openapi_types
45
+ {
46
+ :'code' => :'Integer',
47
+ :'description' => :'String',
48
+ :'telephone_numbers' => :'Array<TelephoneNumber>'
49
+ }
50
+ end
51
+
52
+ # List of attributes with nullable: true
53
+ def self.openapi_nullable
54
+ Set.new([
55
+ ])
56
+ end
57
+
58
+ # Initializes the object
59
+ # @param [Hash] attributes Model attributes in the form of hash
60
+ def initialize(attributes = {})
61
+ if (!attributes.is_a?(Hash))
62
+ fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::WebhookSubscriptionError` initialize method'
63
+ end
64
+
65
+ # check to see if the attribute exists and convert string to symbol for hash key
66
+ acceptable_attribute_map = self.class.acceptable_attribute_map
67
+ attributes = attributes.each_with_object({}) { |(k, v), h|
68
+ if (!acceptable_attribute_map.key?(k.to_sym))
69
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::WebhookSubscriptionError`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
70
+ end
71
+ h[k.to_sym] = v
72
+ }
73
+
74
+ if attributes.key?(:'code')
75
+ self.code = attributes[:'code']
76
+ end
77
+
78
+ if attributes.key?(:'description')
79
+ self.description = attributes[:'description']
80
+ end
81
+
82
+ if attributes.key?(:'telephone_numbers')
83
+ if (value = attributes[:'telephone_numbers']).is_a?(Array)
84
+ self.telephone_numbers = value
85
+ end
86
+ end
87
+ end
88
+
89
+ # Show invalid properties with the reasons. Usually used together with valid?
90
+ # @return Array for valid properties with the reasons
91
+ def list_invalid_properties
92
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
93
+ invalid_properties = Array.new
94
+ invalid_properties
95
+ end
96
+
97
+ # Check to see if the all the properties in the model are valid
98
+ # @return true if the model is valid
99
+ def valid?
100
+ warn '[DEPRECATED] the `valid?` method is obsolete'
101
+ true
102
+ end
103
+
104
+ # Checks equality by comparing each attribute.
105
+ # @param [Object] Object to be compared
106
+ def ==(o)
107
+ return true if self.equal?(o)
108
+ self.class == o.class &&
109
+ code == o.code &&
110
+ description == o.description &&
111
+ telephone_numbers == o.telephone_numbers
112
+ end
113
+
114
+ # @see the `==` method
115
+ # @param [Object] Object to be compared
116
+ def eql?(o)
117
+ self == o
118
+ end
119
+
120
+ # Calculates hash code according to all attributes.
121
+ # @return [Integer] Hash code
122
+ def hash
123
+ [code, description, telephone_numbers].hash
124
+ end
125
+
126
+ # Builds the object from hash
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ # @return [Object] Returns the model itself
129
+ def self.build_from_hash(attributes)
130
+ return nil unless attributes.is_a?(Hash)
131
+ attributes = attributes.transform_keys(&:to_sym)
132
+ transformed_hash = {}
133
+ openapi_types.each_pair do |key, type|
134
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
135
+ transformed_hash["#{key}"] = nil
136
+ elsif type =~ /\AArray<(.*)>/i
137
+ # check to ensure the input is an array given that the attribute
138
+ # is documented as an array but the input is not
139
+ if attributes[attribute_map[key]].is_a?(Array)
140
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
141
+ end
142
+ elsif !attributes[attribute_map[key]].nil?
143
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
144
+ end
145
+ end
146
+ new(transformed_hash)
147
+ end
148
+
149
+ # Returns the object in the form of hash
150
+ # @return [Hash] Returns the object in the form of hash
151
+ def to_hash
152
+ hash = {}
153
+ self.class.attribute_map.each_pair do |attr, param|
154
+ value = self.send(attr)
155
+ if value.nil?
156
+ is_nullable = self.class.openapi_nullable.include?(attr)
157
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
158
+ end
159
+
160
+ hash[param] = _to_hash(value)
161
+ end
162
+ hash
163
+ end
164
+ end
165
+ end
@@ -45,7 +45,7 @@ module Bandwidth
45
45
  def self.openapi_types
46
46
  {
47
47
  :'links' => :'LinksObject',
48
- :'errors' => :'Array<Error>',
48
+ :'errors' => :'Array<WebhookSubscriptionError>',
49
49
  :'data' => :'Array<WebhookSubscription>'
50
50
  }
51
51
  end
@@ -11,5 +11,5 @@ Generator version: 7.17.0
11
11
  =end
12
12
 
13
13
  module Bandwidth
14
- VERSION = '18.0.0'
14
+ VERSION = '18.1.0'
15
15
  end
data/lib/bandwidth-sdk.rb CHANGED
@@ -26,6 +26,10 @@ require 'bandwidth-sdk/models/async_lookup_request'
26
26
  require 'bandwidth-sdk/models/blocked_webhook'
27
27
  require 'bandwidth-sdk/models/bridge_complete_callback'
28
28
  require 'bandwidth-sdk/models/bridge_target_complete_callback'
29
+ require 'bandwidth-sdk/models/brtc_error'
30
+ require 'bandwidth-sdk/models/brtc_error_response'
31
+ require 'bandwidth-sdk/models/brtc_error_source'
32
+ require 'bandwidth-sdk/models/brtc_link'
29
33
  require 'bandwidth-sdk/models/business_entity_type_enum'
30
34
  require 'bandwidth-sdk/models/business_registration_type_enum'
31
35
  require 'bandwidth-sdk/models/call_direction_enum'
@@ -57,15 +61,28 @@ require 'bandwidth-sdk/models/create_async_bulk_lookup_response'
57
61
  require 'bandwidth-sdk/models/create_async_bulk_lookup_response_data'
58
62
  require 'bandwidth-sdk/models/create_call'
59
63
  require 'bandwidth-sdk/models/create_call_response'
64
+ require 'bandwidth-sdk/models/create_endpoint_request_base'
65
+ require 'bandwidth-sdk/models/create_endpoint_response'
66
+ require 'bandwidth-sdk/models/create_endpoint_response_data'
60
67
  require 'bandwidth-sdk/models/create_message_request_error'
61
68
  require 'bandwidth-sdk/models/create_multi_channel_message_response'
62
69
  require 'bandwidth-sdk/models/create_sync_lookup_response'
63
70
  require 'bandwidth-sdk/models/create_sync_lookup_response_data'
71
+ require 'bandwidth-sdk/models/create_web_rtc_connection_request'
64
72
  require 'bandwidth-sdk/models/deactivation_event_enum'
73
+ require 'bandwidth-sdk/models/device'
74
+ require 'bandwidth-sdk/models/device_status_enum'
65
75
  require 'bandwidth-sdk/models/disconnect_callback'
66
76
  require 'bandwidth-sdk/models/diversion'
67
77
  require 'bandwidth-sdk/models/dtmf_callback'
68
- require 'bandwidth-sdk/models/error'
78
+ require 'bandwidth-sdk/models/endpoint'
79
+ require 'bandwidth-sdk/models/endpoint_direction_enum'
80
+ require 'bandwidth-sdk/models/endpoint_event'
81
+ require 'bandwidth-sdk/models/endpoint_event_type_enum'
82
+ require 'bandwidth-sdk/models/endpoint_response'
83
+ require 'bandwidth-sdk/models/endpoint_status_enum'
84
+ require 'bandwidth-sdk/models/endpoint_type_enum'
85
+ require 'bandwidth-sdk/models/endpoints'
69
86
  require 'bandwidth-sdk/models/error_object'
70
87
  require 'bandwidth-sdk/models/error_source'
71
88
  require 'bandwidth-sdk/models/failure_webhook'
@@ -84,6 +101,7 @@ require 'bandwidth-sdk/models/line_type_enum'
84
101
  require 'bandwidth-sdk/models/link'
85
102
  require 'bandwidth-sdk/models/link_schema'
86
103
  require 'bandwidth-sdk/models/links_object'
104
+ require 'bandwidth-sdk/models/list_endpoints_response'
87
105
  require 'bandwidth-sdk/models/list_message_direction_enum'
88
106
  require 'bandwidth-sdk/models/list_message_item'
89
107
  require 'bandwidth-sdk/models/lookup_error_response'
@@ -127,6 +145,7 @@ require 'bandwidth-sdk/models/multi_channel_message_content'
127
145
  require 'bandwidth-sdk/models/multi_channel_message_request'
128
146
  require 'bandwidth-sdk/models/multi_channel_message_response_data'
129
147
  require 'bandwidth-sdk/models/opt_in_workflow'
148
+ require 'bandwidth-sdk/models/page'
130
149
  require 'bandwidth-sdk/models/page_info'
131
150
  require 'bandwidth-sdk/models/priority_enum'
132
151
  require 'bandwidth-sdk/models/product_type_enum'
@@ -155,6 +174,8 @@ require 'bandwidth-sdk/models/recording_transcription_metadata'
155
174
  require 'bandwidth-sdk/models/recording_transcriptions'
156
175
  require 'bandwidth-sdk/models/redirect_callback'
157
176
  require 'bandwidth-sdk/models/redirect_method_enum'
177
+ require 'bandwidth-sdk/models/sip_connection_metadata'
178
+ require 'bandwidth-sdk/models/sip_credentials'
158
179
  require 'bandwidth-sdk/models/sms_message_content'
159
180
  require 'bandwidth-sdk/models/standalone_card_orientation_enum'
160
181
  require 'bandwidth-sdk/models/status_callback'
@@ -191,6 +212,7 @@ require 'bandwidth-sdk/models/voice_api_error'
191
212
  require 'bandwidth-sdk/models/voice_code_response'
192
213
  require 'bandwidth-sdk/models/webhook_subscription'
193
214
  require 'bandwidth-sdk/models/webhook_subscription_basic_authentication'
215
+ require 'bandwidth-sdk/models/webhook_subscription_error'
194
216
  require 'bandwidth-sdk/models/webhook_subscription_request_schema'
195
217
  require 'bandwidth-sdk/models/webhook_subscription_type_enum'
196
218
  require 'bandwidth-sdk/models/webhook_subscriptions_list_body'
@@ -233,6 +255,7 @@ require 'bandwidth-sdk/models/bxml/verbs/transfer'
233
255
  # APIs
234
256
  require 'bandwidth-sdk/api/calls_api'
235
257
  require 'bandwidth-sdk/api/conferences_api'
258
+ require 'bandwidth-sdk/api/endpoints_api'
236
259
  require 'bandwidth-sdk/api/mfa_api'
237
260
  require 'bandwidth-sdk/api/media_api'
238
261
  require 'bandwidth-sdk/api/messages_api'
@@ -0,0 +1,148 @@
1
+ # Integration Tests for Bandwidth::EndpointsApi
2
+ describe 'EndpointsApi Integration Tests' do
3
+ before(:all) do
4
+ config = Bandwidth::Configuration.new
5
+ config.configure do |config|
6
+ config.client_id = BW_CLIENT_ID
7
+ config.client_secret = BW_CLIENT_SECRET
8
+ end
9
+ client = Bandwidth::ApiClient.new(config)
10
+ @endpoints_api_instance = Bandwidth::EndpointsApi.new(client)
11
+
12
+ unauthorized_config = Bandwidth::Configuration.new
13
+ unauthorized_config.configure do |config|
14
+ config.username = UNAUTHORIZED_USERNAME
15
+ config.password = UNAUTHORIZED_PASSWORD
16
+ end
17
+ unauthorized_client = Bandwidth::ApiClient.new(unauthorized_config)
18
+ @unauthorized_api_instance = Bandwidth::EndpointsApi.new(unauthorized_client)
19
+
20
+ $endpoint_id = ''
21
+ end
22
+
23
+ # Create Endpoint
24
+ describe 'create_endpoint' do
25
+ it 'creates a WebRTC endpoint' do
26
+ create_endpoint_body = Bandwidth::CreateWebRtcConnectionRequest.new(
27
+ type: Bandwidth::EndpointTypeEnum::WEBRTC,
28
+ direction: Bandwidth::EndpointDirectionEnum::BIDIRECTIONAL,
29
+ event_callback_url: BASE_CALLBACK_URL + '/endpoint/callback',
30
+ event_fallback_url: BASE_CALLBACK_URL + '/endpoint/fallback',
31
+ tag: 'ruby-sdk-test-endpoint'
32
+ )
33
+
34
+ data, status_code = @endpoints_api_instance.create_endpoint_with_http_info(BW_ACCOUNT_ID, create_endpoint_body)
35
+
36
+ expect(status_code).to eq(201)
37
+ expect(data).to be_instance_of(Bandwidth::CreateEndpointResponse)
38
+ expect(data.links).to be_instance_of(Array)
39
+ expect(data.errors).to be_instance_of(Array)
40
+ expect(data.data).to be_instance_of(Bandwidth::CreateEndpointResponseData)
41
+ expect(data.data.endpoint_id).to be_instance_of(String)
42
+ expect(data.data.type).to eq(Bandwidth::EndpointTypeEnum::WEBRTC)
43
+ expect(data.data.status).to be_one_of(Bandwidth::EndpointStatusEnum.all_vars)
44
+ expect(data.data.token).to be_instance_of(String)
45
+ expect(data.data.creation_timestamp).to be_instance_of(Time)
46
+ expect(data.data.expiration_timestamp).to be_instance_of(Time)
47
+ expect(data.data.tag).to eq('ruby-sdk-test-endpoint')
48
+ expect(data.data.devices).to be_instance_of(Array)
49
+
50
+ $endpoint_id = data.data.endpoint_id
51
+ end
52
+ end
53
+
54
+ # List Endpoints
55
+ describe 'list_endpoints' do
56
+ it 'gets a list of endpoints' do
57
+ data, status_code = @endpoints_api_instance.list_endpoints_with_http_info(
58
+ BW_ACCOUNT_ID,
59
+ type: Bandwidth::EndpointTypeEnum::WEBRTC,
60
+ limit: 10
61
+ )
62
+
63
+ expect(status_code).to eq(200)
64
+ expect(data).to be_instance_of(Bandwidth::ListEndpointsResponse)
65
+ expect(data.links).to be_instance_of(Array)
66
+ expect(data.errors).to be_instance_of(Array)
67
+ expect(data.data).to be_instance_of(Array)
68
+ expect(data.data.length).to be > 0
69
+
70
+ tagged_endpoint = data.data.find { |ep| ep.endpoint_id == $endpoint_id }
71
+ expect(tagged_endpoint).not_to be_nil
72
+ expect(tagged_endpoint.tag).to eq('ruby-sdk-test-endpoint')
73
+ end
74
+ end
75
+
76
+ # Get Endpoint
77
+ describe 'get_endpoint' do
78
+ it 'gets a specific endpoint' do
79
+ data, status_code = @endpoints_api_instance.get_endpoint_with_http_info(BW_ACCOUNT_ID, $endpoint_id)
80
+
81
+ expect(status_code).to eq(200)
82
+ expect(data).to be_instance_of(Bandwidth::EndpointResponse)
83
+ expect(data.links).to be_instance_of(Array)
84
+ expect(data.errors).to be_instance_of(Array)
85
+ expect(data.data).to be_instance_of(Bandwidth::Endpoint)
86
+ expect(data.data.endpoint_id).to eq($endpoint_id)
87
+ expect(data.data.type).to eq(Bandwidth::EndpointTypeEnum::WEBRTC)
88
+ expect(data.data.status).to be_one_of(Bandwidth::EndpointStatusEnum.all_vars)
89
+ expect(data.data.creation_timestamp).to be_instance_of(Time)
90
+ expect(data.data.expiration_timestamp).to be_instance_of(Time)
91
+ expect(data.data.tag).to eq('ruby-sdk-test-endpoint')
92
+ expect(data.data.devices).to be_instance_of(Array)
93
+ end
94
+ end
95
+
96
+ # Delete Endpoint
97
+ describe 'delete_endpoint' do
98
+ it 'deletes an endpoint' do
99
+ _data, status_code = @endpoints_api_instance.delete_endpoint_with_http_info(BW_ACCOUNT_ID, $endpoint_id)
100
+
101
+ expect(status_code).to eq(204)
102
+ end
103
+ end
104
+
105
+ # HTTP 4XX Errors
106
+ describe 'http error' do
107
+ it 'causes a 401 error on create' do
108
+ create_endpoint_body = Bandwidth::CreateWebRtcConnectionRequest.new(
109
+ type: Bandwidth::EndpointTypeEnum::WEBRTC,
110
+ direction: Bandwidth::EndpointDirectionEnum::BIDIRECTIONAL
111
+ )
112
+
113
+ expect {
114
+ @unauthorized_api_instance.create_endpoint_with_http_info(BW_ACCOUNT_ID, create_endpoint_body)
115
+ }.to raise_error { |e|
116
+ expect(e).to be_instance_of(Bandwidth::ApiError)
117
+ expect(e.code).to eq(401)
118
+ }
119
+ end
120
+
121
+ it 'causes a 401 error on list' do
122
+ expect {
123
+ @unauthorized_api_instance.list_endpoints_with_http_info(BW_ACCOUNT_ID)
124
+ }.to raise_error { |e|
125
+ expect(e).to be_instance_of(Bandwidth::ApiError)
126
+ expect(e.code).to eq(401)
127
+ }
128
+ end
129
+
130
+ it 'causes a 404 error on get' do
131
+ expect {
132
+ @endpoints_api_instance.get_endpoint_with_http_info(BW_ACCOUNT_ID, 'does-not-exist')
133
+ }.to raise_error { |e|
134
+ expect(e).to be_instance_of(Bandwidth::ApiError)
135
+ expect(e.code).to eq(404)
136
+ }
137
+ end
138
+
139
+ it 'causes a 404 error on delete' do
140
+ expect {
141
+ @endpoints_api_instance.delete_endpoint_with_http_info(BW_ACCOUNT_ID, 'does-not-exist')
142
+ }.to raise_error { |e|
143
+ expect(e).to be_instance_of(Bandwidth::ApiError)
144
+ expect(e.code).to eq(404)
145
+ }
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,172 @@
1
+ # Unit tests for Bandwidth::EndpointsApi
2
+ describe 'EndpointsApi' do
3
+ let(:endpoint_id) { 'ep-abc123' }
4
+
5
+ before(:all) do
6
+ Bandwidth.configure do |config|
7
+ config.debugging = true
8
+ config.username = BW_USERNAME
9
+ config.password = BW_PASSWORD
10
+ config.ignore_operation_servers = true
11
+ config.host = '127.0.0.1:4010'
12
+ end
13
+ @endpoints_api_instance = Bandwidth::EndpointsApi.new
14
+ end
15
+
16
+ describe 'test an instance of EndpointsApi' do
17
+ it 'should create an instance of EndpointsApi' do
18
+ expect(@endpoints_api_instance).to be_instance_of(Bandwidth::EndpointsApi)
19
+ end
20
+ end
21
+
22
+ # Create Endpoint
23
+ describe '#create_endpoint' do
24
+ it 'creates a WebRTC endpoint' do
25
+ create_endpoint_body = Bandwidth::CreateWebRtcConnectionRequest.new(
26
+ type: Bandwidth::EndpointTypeEnum::WEBRTC,
27
+ direction: Bandwidth::EndpointDirectionEnum::BIDIRECTIONAL,
28
+ event_callback_url: 'https://myServer.com/bandwidth/webhooks/endpoint',
29
+ event_fallback_url: 'https://myFallbackServer.com/bandwidth/webhooks/endpoint',
30
+ tag: 'test-endpoint',
31
+ connection_metadata: { 'key1' => 'value1', 'key2' => 'value2' }
32
+ )
33
+
34
+ data, status_code = @endpoints_api_instance.create_endpoint_with_http_info(BW_ACCOUNT_ID, create_endpoint_body)
35
+
36
+ expect(status_code).to eq(201)
37
+ expect(data).to be_instance_of(Bandwidth::CreateEndpointResponse)
38
+ expect(data.links).to be_instance_of(Array)
39
+ expect(data.data).to be_instance_of(Bandwidth::CreateEndpointResponseData)
40
+ expect(data.data.endpoint_id).to be_instance_of(String)
41
+ expect(data.data.type).to be_one_of(Bandwidth::EndpointTypeEnum.all_vars)
42
+ expect(data.data.status).to be_one_of(Bandwidth::EndpointStatusEnum.all_vars)
43
+ expect(data.data.creation_timestamp).to be_instance_of(Time)
44
+ expect(data.data.expiration_timestamp).to be_instance_of(Time)
45
+ expect(data.data.token).to be_instance_of(String)
46
+ expect(data.data.tag).to be_instance_of(String)
47
+ expect(data.data.devices).to be_instance_of(Array)
48
+ expect(data.errors).to be_instance_of(Array)
49
+ end
50
+
51
+ it 'causes an ArgumentError for a missing account_id' do
52
+ expect {
53
+ @endpoints_api_instance.create_endpoint(nil, {})
54
+ }.to raise_error(ArgumentError)
55
+ end
56
+
57
+ it 'causes an ArgumentError for a missing body' do
58
+ expect {
59
+ @endpoints_api_instance.create_endpoint(BW_ACCOUNT_ID, nil)
60
+ }.to raise_error(ArgumentError)
61
+ end
62
+ end
63
+
64
+ # List Endpoints
65
+ describe '#list_endpoints' do
66
+ it 'gets a list of endpoints' do
67
+ data, status_code = @endpoints_api_instance.list_endpoints_with_http_info(BW_ACCOUNT_ID)
68
+
69
+ expect(status_code).to eq(200)
70
+ expect(data).to be_instance_of(Bandwidth::ListEndpointsResponse)
71
+ expect(data.links).to be_instance_of(Array)
72
+ expect(data.page).to be_instance_of(Bandwidth::Page)
73
+ expect(data.data).to be_instance_of(Array)
74
+ expect(data.data[0]).to be_instance_of(Bandwidth::Endpoints)
75
+ expect(data.data[0].endpoint_id).to be_instance_of(String)
76
+ expect(data.data[0].type).to be_one_of(Bandwidth::EndpointTypeEnum.all_vars)
77
+ expect(data.data[0].status).to be_one_of(Bandwidth::EndpointStatusEnum.all_vars)
78
+ expect(data.data[0].creation_timestamp).to be_instance_of(Time)
79
+ expect(data.data[0].expiration_timestamp).to be_instance_of(Time)
80
+ expect(data.data[0].tag).to be_instance_of(String)
81
+ expect(data.errors).to be_instance_of(Array)
82
+ end
83
+
84
+ it 'causes an ArgumentError for a missing account_id' do
85
+ expect {
86
+ @endpoints_api_instance.list_endpoints(nil)
87
+ }.to raise_error(ArgumentError)
88
+ end
89
+ end
90
+
91
+ # Get Endpoint
92
+ describe '#get_endpoint' do
93
+ it 'gets an endpoint' do
94
+ data, status_code = @endpoints_api_instance.get_endpoint_with_http_info(BW_ACCOUNT_ID, endpoint_id)
95
+
96
+ expect(status_code).to eq(200)
97
+ expect(data).to be_instance_of(Bandwidth::EndpointResponse)
98
+ expect(data.links).to be_instance_of(Array)
99
+ expect(data.data).to be_instance_of(Bandwidth::Endpoint)
100
+ expect(data.data.endpoint_id).to be_instance_of(String)
101
+ expect(data.data.type).to be_one_of(Bandwidth::EndpointTypeEnum.all_vars)
102
+ expect(data.data.status).to be_one_of(Bandwidth::EndpointStatusEnum.all_vars)
103
+ expect(data.data.creation_timestamp).to be_instance_of(Time)
104
+ expect(data.data.expiration_timestamp).to be_instance_of(Time)
105
+ expect(data.data.tag).to be_instance_of(String)
106
+ expect(data.data.devices).to be_instance_of(Array)
107
+ expect(data.errors).to be_instance_of(Array)
108
+ end
109
+
110
+ it 'causes an ArgumentError for a missing account_id' do
111
+ expect {
112
+ @endpoints_api_instance.get_endpoint(nil, '')
113
+ }.to raise_error(ArgumentError)
114
+ end
115
+
116
+ it 'causes an ArgumentError for a missing endpoint_id' do
117
+ expect {
118
+ @endpoints_api_instance.get_endpoint(BW_ACCOUNT_ID, nil)
119
+ }.to raise_error(ArgumentError)
120
+ end
121
+ end
122
+
123
+ # Update Endpoint BXML
124
+ describe '#update_endpoint_bxml' do
125
+ it 'updates an endpoint using bxml' do
126
+ update_bxml = "<?xml version='1.0' encoding='UTF-8'?><Bxml><SpeakSentence>Hello</SpeakSentence></Bxml>"
127
+
128
+ _data, status_code = @endpoints_api_instance.update_endpoint_bxml_with_http_info(BW_ACCOUNT_ID, endpoint_id, update_bxml)
129
+
130
+ expect(status_code).to eq(204)
131
+ end
132
+
133
+ it 'causes an ArgumentError for a missing account_id' do
134
+ expect {
135
+ @endpoints_api_instance.update_endpoint_bxml(nil, '', {})
136
+ }.to raise_error(ArgumentError)
137
+ end
138
+
139
+ it 'causes an ArgumentError for a missing endpoint_id' do
140
+ expect {
141
+ @endpoints_api_instance.update_endpoint_bxml(BW_ACCOUNT_ID, nil, {})
142
+ }.to raise_error(ArgumentError)
143
+ end
144
+
145
+ it 'causes an ArgumentError for a missing body' do
146
+ expect {
147
+ @endpoints_api_instance.update_endpoint_bxml(BW_ACCOUNT_ID, '', nil)
148
+ }.to raise_error(ArgumentError)
149
+ end
150
+ end
151
+
152
+ # Delete Endpoint
153
+ describe '#delete_endpoint' do
154
+ it 'deletes an endpoint' do
155
+ _data, status_code = @endpoints_api_instance.delete_endpoint_with_http_info(BW_ACCOUNT_ID, endpoint_id)
156
+
157
+ expect(status_code).to eq(204)
158
+ end
159
+
160
+ it 'causes an ArgumentError for a missing account_id' do
161
+ expect {
162
+ @endpoints_api_instance.delete_endpoint(nil, '')
163
+ }.to raise_error(ArgumentError)
164
+ end
165
+
166
+ it 'causes an ArgumentError for a missing endpoint_id' do
167
+ expect {
168
+ @endpoints_api_instance.delete_endpoint(BW_ACCOUNT_ID, nil)
169
+ }.to raise_error(ArgumentError)
170
+ end
171
+ end
172
+ end
@@ -2,6 +2,7 @@
2
2
  describe 'PhoneNumberLookupApi' do
3
3
  let(:phone_numbers) { [BW_NUMBER, USER_NUMBER] }
4
4
  let(:request_id) { '123e4567-e89b-12d3-a456-426614174000' }
5
+ let(:rcs_agent) { 'TestAgent' }
5
6
 
6
7
  before(:all) do
7
8
  Bandwidth.configure do |config|
@@ -46,6 +47,7 @@ describe 'PhoneNumberLookupApi' do
46
47
  it 'should work' do
47
48
  request = Bandwidth::SyncLookupRequest.new(
48
49
  phone_numbers: phone_numbers,
50
+ rcs_agent: rcs_agent,
49
51
  )
50
52
 
51
53
  data, status_code = @api_instance.create_sync_lookup_with_http_info(BW_ACCOUNT_ID, request)