Skip to content

Commit

Permalink
SWI-2821 Improve BXML Library (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoegel authored Jul 19, 2023
1 parent 446c463 commit 0ddacd4
Show file tree
Hide file tree
Showing 35 changed files with 35 additions and 97 deletions.
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/bxml.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class Bxml
include Bandwidth::Bxml::Root

class Bxml < Bandwidth::Bxml::Root
# Initializer
# @param nested_verbs [Array<Verb>] XML element children. Defaults to an empty array.
def initialize(nested_verbs = [])
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/nestable_verb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

module Bandwidth
module Bxml
module NestableVerb
include Bandwidth::Bxml::Verb

class NestableVerb < Bandwidth::Bxml::Verb
# Initializer
# @param tag [String] Name of the XML element.
# @param content [String] XML element content. Defaults to nil.
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/response.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class Response
include Bandwidth::Bxml::Root

class Response < Bandwidth::Bxml::Root
# Initializer
# @param nested_verbs [Array<Verb>] XML element children. Defaults to an empty array.
def initialize(nested_verbs = [])
Expand Down
2 changes: 1 addition & 1 deletion lib/bandwidth-sdk/models/bxml/root.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Bxml
SPEAK_SENTENCE_REGEX = /<SpeakSentence.*?>(.*?)<\/SpeakSentence>/
SSML_REGEX = /&lt;([a-zA-Z\/\/].*?)&gt;/

module Root
class Root
# Initializer
# @param tag [String] Name of the XML element.
# @param nested_verbs [Array<Verb>] XML element children. Defaults to an empty array.
Expand Down
2 changes: 1 addition & 1 deletion lib/bandwidth-sdk/models/bxml/verb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Bandwidth
module Bxml
module Verb
class Verb
# Initializer
# @param tag [String] Name of the XML element.
# @param content [String] XML element content. Defaults to nil.
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/bridge.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class Bridge
include Bandwidth::Bxml::Verb

class Bridge < Bandwidth::Bxml::Verb
# Initializer
# @param target_call [String] The callId of the call to be bridged.
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/conference.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class Conference
include Bandwidth::Bxml::Verb

class Conference < Bandwidth::Bxml::Verb
# Initializer
# @param name [String] The name of the conference. Can contain up to 100 characters of letters, numbers, and the symbols -, _, and .
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/custom_param.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class CustomParam
include Bandwidth::Bxml::Verb

class CustomParam < Bandwidth::Bxml::Verb
# Initializer
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
def initialize(attributes = {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/forward.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class Forward
include Bandwidth::Bxml::Verb

class Forward < Bandwidth::Bxml::Verb
# Initializer
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
def initialize(attributes = {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/gather.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class Gather
include Bandwidth::Bxml::NestableVerb

class Gather < Bandwidth::Bxml::NestableVerb
# Initializer
# @param audio_verbs [Array] XML element children. Defaults to an empty array. Valid nested audio verbs are: SpeakSentence, PlayAudio.
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/hangup.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class Hangup
include Bandwidth::Bxml::Verb

class Hangup < Bandwidth::Bxml::Verb
# Initializer
def initialize
super('Hangup', nil, {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/pause.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class Pause
include Bandwidth::Bxml::Verb

class Pause < Bandwidth::Bxml::Verb
# Initializer
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
def initialize(attributes = {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/pause_recording.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class PauseRecording
include Bandwidth::Bxml::Verb

class PauseRecording < Bandwidth::Bxml::Verb
# Initializer
def initialize
super('PauseRecording', nil, {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/phone_number.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class PhoneNumber
include Bandwidth::Bxml::Verb

class PhoneNumber < Bandwidth::Bxml::Verb
# Initializer
# @param number [String] A phone number to transfer the call to. Value must be in E.164 format (e.g. +15555555555).
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/play_audio.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class PlayAudio
include Bandwidth::Bxml::Verb

class PlayAudio < Bandwidth::Bxml::Verb
# Initializer
# @param audio_uri [String] The URL of the audio file to play. May be a relative URL.
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/record.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class Record
include Bandwidth::Bxml::Verb

class Record < Bandwidth::Bxml::Verb
# Initializer
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
def initialize(attributes = {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/redirect.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class Redirect
include Bandwidth::Bxml::Verb

class Redirect < Bandwidth::Bxml::Verb
# Initializer
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
def initialize(attributes = {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/resume_recording.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class ResumeRecording
include Bandwidth::Bxml::Verb

class ResumeRecording < Bandwidth::Bxml::Verb
# Initializer
def initialize
super('ResumeRecording', nil, {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/ring.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class Ring
include Bandwidth::Bxml::Verb

class Ring < Bandwidth::Bxml::Verb
# Initializer
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
def initialize(attributes = {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/send_dtmf.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class SendDtmf
include Bandwidth::Bxml::Verb

class SendDtmf < Bandwidth::Bxml::Verb
# Initializer
# @param digits [String] String containing the DTMF characters to be sent in a call. Allows a maximum of 50 characters. The digits will be sent one-by-one with a marginal delay.
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/sip_uri.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class SipUri
include Bandwidth::Bxml::Verb

class SipUri < Bandwidth::Bxml::Verb
# Initializer
# @param uri [String] A SIP URI to transfer the call to (e.g. sip:[email protected])
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/speak_sentence.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class SpeakSentence
include Bandwidth::Bxml::Verb

class SpeakSentence < Bandwidth::Bxml::Verb
# Initializer
# @param text [String] The text to speak. Cannot be blank. Can be a mixture of plain text and SSML tags.
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/start_gather.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class StartGather
include Bandwidth::Bxml::Verb

class StartGather < Bandwidth::Bxml::Verb
# Initializer
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
def initialize(attributes = {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/start_recording.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class StartRecording
include Bandwidth::Bxml::Verb

class StartRecording < Bandwidth::Bxml::Verb
# Initializer
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
def initialize(attributes = {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/start_stream.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class StartStream
include Bandwidth::Bxml::NestableVerb

class StartStream < Bandwidth::Bxml::NestableVerb
# Initializer
# @param stream_params [Array] XML element children. Defaults to an empty array. Valid nested stream params are: StreamParam. You may specify up to 12 <StreamParam/> elements nested within a <StartStream> tag.
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/start_transcription.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class StartTranscription
include Bandwidth::Bxml::NestableVerb

class StartTranscription < Bandwidth::Bxml::NestableVerb
# Initializer
# @param custom_params [Array] XML element children. Defaults to an empty array. Valid nested custom params are: CustomParam. You may specify up to 12 <CustomParam/> elements nested within a <StartTranscription> tag.
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/stop_gather.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class StopGather
include Bandwidth::Bxml::Verb

class StopGather < Bandwidth::Bxml::Verb
# Initializer
def initialize
super('StopGather', nil, {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/stop_recording.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class StopRecording
include Bandwidth::Bxml::Verb

class StopRecording < Bandwidth::Bxml::Verb
# Initializer
def initialize
super('StopRecording', nil, {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/stop_stream.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class StopStream
include Bandwidth::Bxml::Verb

class StopStream < Bandwidth::Bxml::Verb
# Initializer
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
def initialize(attributes = {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/stop_transcription.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class StopTranscription
include Bandwidth::Bxml::Verb

class StopTranscription < Bandwidth::Bxml::Verb
# Initializer
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
def initialize(attributes = {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/stream_param.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class StreamParam
include Bandwidth::Bxml::Verb

class StreamParam < Bandwidth::Bxml::Verb
# Initializer
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
def initialize(attributes = {})
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/tag.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class Tag
include Bandwidth::Bxml::Verb

class Tag < Bandwidth::Bxml::Verb
# Initializer
# @param content [String] Custom tag value. Defaults to nil.
def initialize(content = nil)
Expand Down
4 changes: 1 addition & 3 deletions lib/bandwidth-sdk/models/bxml/verbs/transfer.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Bandwidth
module Bxml
class Transfer
include Bandwidth::Bxml::NestableVerb

class Transfer < Bandwidth::Bxml::NestableVerb
# Initializer
# @param transfer_to [Array] XML element children. Defaults to an empty array. Valid nested transfer verbs are: PhoneNumber, SipUri.
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
Expand Down
2 changes: 1 addition & 1 deletion spec/models/bxml/nestable_verb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Unit tests for Bandwidth::Bxml::NestableVerb
describe 'Bandwidth::Bxml::NestableVerb' do
let(:instance) { Class.new.include(Bandwidth::Bxml::NestableVerb).new('Test') }
let(:instance) { Bandwidth::Bxml::NestableVerb.new('Test') }

describe 'test an instance of NestableVerb' do
it 'validates instance of NestableVerb' do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/bxml/verb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Unit tests for Bandwidth::Bxml::Verb
describe 'Bandwidth::Bxml::Verb' do
let(:instance) { Class.new.include(Bandwidth::Bxml::Verb).new('Test') }
let(:instance) { Bandwidth::Bxml::Verb.new('Test') }

describe 'test an instance of Verb' do
it 'validates instance of Verb' do
Expand Down

0 comments on commit 0ddacd4

Please sign in to comment.