Skip to content

Commit 1e6ff4b

Browse files
authored
DX-2648 Add enqueuedTime to SDK (#56)
* DX-2648 Add enqueuedTime to SDK * add test for `enqueued_time` * add test for create call response and add accessor
1 parent af13607 commit 1e6ff4b

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

lib/bandwidth/voice_lib/voice/models/call_state.rb

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ class CallState < BaseModel
6262
# @return [DateTime]
6363
attr_accessor :start_time
6464

65+
# @return [DateTime]
66+
attr_accessor :enqueued_time
67+
6568
# The current state of the call. Current possible values are 'initiated',
6669
# 'answered' and 'disconnected'. Additional states may be added in the
6770
# future, so your application must be tolerant of unknown values.
@@ -124,6 +127,7 @@ def self.names
124127
@_hash['identity'] = 'identity'
125128
@_hash['stir_shaken'] = 'stirShaken'
126129
@_hash['start_time'] = 'startTime'
130+
@_hash['enqueued_time'] = 'enqueuedTime'
127131
@_hash['answer_time'] = 'answerTime'
128132
@_hash['end_time'] = 'endTime'
129133
@_hash['disconnect_cause'] = 'disconnectCause'
@@ -147,6 +151,7 @@ def optionals
147151
identity
148152
stir_shaken
149153
start_time
154+
enqueued_time
150155
answer_time
151156
end_time
152157
disconnect_cause
@@ -180,6 +185,7 @@ def initialize(call_id = nil,
180185
identity = nil,
181186
stir_shaken = nil,
182187
start_time = nil,
188+
enqueued_time = nil,
183189
answer_time = nil,
184190
end_time = nil,
185191
disconnect_cause = nil,
@@ -197,6 +203,7 @@ def initialize(call_id = nil,
197203
@identity = identity unless identity == SKIP
198204
@stir_shaken = stir_shaken unless stir_shaken == SKIP
199205
@start_time = start_time unless start_time == SKIP
206+
@enqueued_time = enqueued_time unless enqueued_time == SKIP
200207
@answer_time = answer_time unless answer_time == SKIP
201208
@end_time = end_time unless end_time == SKIP
202209
@disconnect_cause = disconnect_cause unless disconnect_cause == SKIP
@@ -221,17 +228,22 @@ def self.from_hash(hash)
221228
identity = hash.key?('identity') ? hash['identity'] : SKIP
222229
stir_shaken = hash.key?('stirShaken') ? hash['stirShaken'] : SKIP
223230
start_time = if hash.key?('startTime')
224-
(DateTimeHelper.from_rfc3339(hash['startTime']) if hash['startTime'])
231+
(DateTimeHelper.from_rfc3339(hash['startTime']) if hash['startTime'])
225232
else
226233
SKIP
227234
end
235+
enqueued_time = if hash.key?('enqueuedTime')
236+
(DateTimeHelper.from_rfc3339(hash['enqueuedTime']) if hash['enqueuedTime'])
237+
else
238+
SKIP
239+
end
228240
answer_time = if hash.key?('answerTime')
229241
(DateTimeHelper.from_rfc3339(hash['answerTime']) if hash['answerTime'])
230242
else
231243
SKIP
232244
end
233245
end_time = if hash.key?('endTime')
234-
(DateTimeHelper.from_rfc3339(hash['endTime']) if hash['endTime'])
246+
(DateTimeHelper.from_rfc3339(hash['endTime']) if hash['endTime'])
235247
else
236248
SKIP
237249
end
@@ -257,6 +269,7 @@ def self.from_hash(hash)
257269
identity,
258270
stir_shaken,
259271
start_time,
272+
enqueued_time,
260273
answer_time,
261274
end_time,
262275
disconnect_cause,
@@ -269,6 +282,10 @@ def to_start_time
269282
DateTimeHelper.to_rfc3339(start_time)
270283
end
271284

285+
def to_enqueued_time
286+
DateTimeHelper.to_rfc3339(enqueued_time)
287+
end
288+
272289
def to_answer_time
273290
DateTimeHelper.to_rfc3339(answer_time)
274291
end

lib/bandwidth/voice_lib/voice/models/create_call_response.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CreateCallResponse < BaseModel
3232

3333
# TODO: Write general description for this method
3434
# @return [DateTime]
35-
attr_accessor :start_time
35+
attr_accessor :enqueued_time
3636

3737
# TODO: Write general description for this method
3838
# @return [String]
@@ -101,7 +101,7 @@ def self.names
101101
@_hash['application_id'] = 'applicationId'
102102
@_hash['to'] = 'to'
103103
@_hash['from'] = 'from'
104-
@_hash['start_time'] = 'startTime'
104+
@_hash['enqueued_time'] = 'enqueuedTime '
105105
@_hash['call_url'] = 'callUrl'
106106
@_hash['call_timeout'] = 'callTimeout'
107107
@_hash['callback_timeout'] = 'callbackTimeout'
@@ -123,7 +123,7 @@ def self.names
123123
# An array for optional fields
124124
def optionals
125125
%w[
126-
start_time
126+
enqueued_time
127127
call_timeout
128128
callback_timeout
129129
answer_fallback_url
@@ -163,7 +163,7 @@ def initialize(account_id = nil,
163163
answer_url = nil,
164164
answer_method = nil,
165165
disconnect_method = nil,
166-
start_time = nil,
166+
enqueued_time = nil,
167167
call_timeout = nil,
168168
callback_timeout = nil,
169169
answer_fallback_url = nil,
@@ -180,7 +180,7 @@ def initialize(account_id = nil,
180180
@application_id = application_id unless application_id == SKIP
181181
@to = to unless to == SKIP
182182
@from = from unless from == SKIP
183-
@start_time = start_time unless start_time == SKIP
183+
@enqueued_time = enqueued_time unless enqueued_time == SKIP
184184
@call_url = call_url unless call_url == SKIP
185185
@call_timeout = call_timeout unless call_timeout == SKIP
186186
@callback_timeout = callback_timeout unless callback_timeout == SKIP
@@ -213,8 +213,8 @@ def self.from_hash(hash)
213213
answer_method = hash.key?('answerMethod') ? hash['answerMethod'] : SKIP
214214
disconnect_method =
215215
hash.key?('disconnectMethod') ? hash['disconnectMethod'] : SKIP
216-
start_time = if hash.key?('startTime')
217-
(DateTimeHelper.from_rfc3339(hash['startTime']) if hash['startTime'])
216+
enqueued_time = if hash.key?('enqueuedTime')
217+
(DateTimeHelper.from_rfc3339(hash['enqueuedTime']) if hash['enqueuedTime'])
218218
else
219219
SKIP
220220
end
@@ -245,7 +245,7 @@ def self.from_hash(hash)
245245
answer_url,
246246
answer_method,
247247
disconnect_method,
248-
start_time,
248+
enqueued_time,
249249
call_timeout,
250250
callback_timeout,
251251
answer_fallback_url,
@@ -259,8 +259,8 @@ def self.from_hash(hash)
259259
priority)
260260
end
261261

262-
def to_start_time
263-
DateTimeHelper.to_rfc3339(start_time)
262+
def to_enqueued_time
263+
DateTimeHelper.to_rfc3339(enqueued_time)
264264
end
265265
end
266266
end

test/integration/test_integration.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,15 @@ def test_create_call_and_get_call_state
111111
body.answer_url = BASE_CALLBACK_URL
112112
response = @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, body)
113113
assert(response.data.call_id.length > 0, "call_id value not set")
114+
assert_not_nil(response.data.enqueued_time, "enqueued time is nil")
115+
assert(response.data.enqueued_time.is_a?(DateTime), "enqueued time is not a DateTime object")
114116

115117
#Get phone call information
116118
sleep 1
117119
response = @bandwidth_client.voice_client.client.get_call(BW_ACCOUNT_ID, response.data.call_id)
118120
assert(response.data.state.length > 0, "state value not set")
121+
assert_not_nil(response.data.enqueued_time, "enqueued time is nil")
122+
assert(response.data.enqueued_time.is_a?(DateTime), "enqueued time is not a DateTime object")
119123
end
120124

121125
def test_create_call_with_amd_and_get_call_state

0 commit comments

Comments
 (0)