bandwidth-sdk 0.1.0 → 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +27 -27
- data/README.md +115 -1
- data/lib/bandwidth.rb +39 -37
- data/lib/bandwidth/api_helper.rb +280 -280
- data/lib/bandwidth/client.rb +41 -32
- data/lib/bandwidth/configuration.rb +130 -111
- data/lib/bandwidth/exceptions/api_exception.rb +20 -20
- data/lib/bandwidth/http/api_response.rb +36 -36
- data/lib/bandwidth/http/auth/messaging_basic_auth.rb +22 -0
- data/lib/bandwidth/http/auth/voice_basic_auth.rb +22 -22
- data/lib/bandwidth/http/faraday_client.rb +64 -64
- data/lib/bandwidth/http/http_call_back.rb +24 -24
- data/lib/bandwidth/http/http_client.rb +104 -104
- data/lib/bandwidth/http/http_method_enum.rb +13 -13
- data/lib/bandwidth/http/http_request.rb +50 -50
- data/lib/bandwidth/http/http_response.rb +29 -29
- data/lib/bandwidth/messaging_lib/messaging.rb +23 -0
- data/lib/bandwidth/messaging_lib/messaging/client.rb +40 -0
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +406 -0
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +49 -0
- data/lib/bandwidth/messaging_lib/messaging/exceptions/generic_client_exception.rb +46 -0
- data/lib/bandwidth/messaging_lib/messaging/exceptions/path_client_exception.rb +49 -0
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +80 -0
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +125 -0
- data/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +44 -0
- data/lib/bandwidth/messaging_lib/messaging/models/field_error.rb +44 -0
- data/lib/bandwidth/messaging_lib/messaging/models/media.rb +123 -0
- data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +80 -0
- data/lib/bandwidth/messaging_lib/messaging/models/tag.rb +44 -0
- data/lib/bandwidth/models/base_model.rb +36 -36
- data/lib/bandwidth/voice_lib/bxml/bxml.rb +40 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/forward.rb +19 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +38 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/hangup.rb +15 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/pause.rb +16 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/phone_number.rb +19 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/play_audio.rb +18 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/redirect.rb +21 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +14 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/speak_sentence.rb +19 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/transfer.rb +38 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/xml_verb.rb +27 -0
- data/lib/bandwidth/voice_lib/voice.rb +27 -23
- data/lib/bandwidth/voice_lib/voice/client.rb +40 -36
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +184 -0
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +49 -49
- data/lib/bandwidth/voice_lib/voice/exceptions/bandwidth_exception.rb +51 -0
- data/lib/bandwidth/voice_lib/voice/exceptions/bandwidth_not_found_exception.rb +49 -0
- data/lib/bandwidth/voice_lib/voice/exceptions/bandwidth_rate_limit_error_exception.rb +56 -0
- data/lib/bandwidth/voice_lib/voice/models/answer_method_enum.rb +35 -35
- data/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +116 -116
- data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +125 -125
- data/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb +80 -80
- data/lib/bandwidth/voice_lib/voice/models/bandwidth_callback_message_voice.rb +98 -98
- data/lib/bandwidth/voice_lib/voice/models/disconnect_method_enum.rb +35 -35
- data/lib/bandwidth/voice_lib/voice/models/field_error.rb +44 -0
- data/lib/bandwidth/voice_lib/voice/models/redirect_method_enum.rb +35 -35
- data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +17 -17
- metadata +36 -47
- data/lib/bandwidth/voice_lib/voice/bxml/bxml.rb +0 -36
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/forward.rb +0 -19
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/gather.rb +0 -37
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/hangup.rb +0 -14
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/pause.rb +0 -15
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/phone_number.rb +0 -18
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/play_audio.rb +0 -17
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/redirect.rb +0 -20
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/send_dtmf.rb +0 -12
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/speak_sentence.rb +0 -18
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/transfer.rb +0 -37
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/xml_verb.rb +0 -26
- data/lib/bandwidth/voice_lib/voice/controllers/calls_controller.rb +0 -88
@@ -1,18 +0,0 @@
|
|
1
|
-
require_relative 'xml_verb'
|
2
|
-
|
3
|
-
module Bandwidth
|
4
|
-
module Voice
|
5
|
-
# The SpeakSentence verb is used to convert any text into speak for the caller
|
6
|
-
class SpeakSentence
|
7
|
-
include XmlVerb
|
8
|
-
|
9
|
-
def to_xml(xml)
|
10
|
-
xml.SpeakSentence(sentence, compact_hash({
|
11
|
-
'voice' => voice,
|
12
|
-
'locale' => locale,
|
13
|
-
'gender' => gender
|
14
|
-
}))
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require_relative 'xml_verb'
|
2
|
-
|
3
|
-
module Bandwidth
|
4
|
-
module Voice
|
5
|
-
# The Transfer verb is used to transfer the call to another number
|
6
|
-
class Transfer
|
7
|
-
include XmlVerb
|
8
|
-
|
9
|
-
def to_xml(xml)
|
10
|
-
xml.Transfer(compact_hash({
|
11
|
-
'transferCallerId' => transfer_caller_id,
|
12
|
-
'callTimeout' => call_timeout,
|
13
|
-
'tag' => tag,
|
14
|
-
'transferCompleteUrl' => transfer_complete_url,
|
15
|
-
'transferCompleteMethod' => transfer_complete_method,
|
16
|
-
'username' => username,
|
17
|
-
'password' => password,
|
18
|
-
'diversionTreatment' => diversion_treatment,
|
19
|
-
'diversionReason' => diversion_reason
|
20
|
-
})) do
|
21
|
-
def embedded_xml(xml, property, type)
|
22
|
-
if property
|
23
|
-
s = if property.is_a?(type)
|
24
|
-
then property
|
25
|
-
else type.new(property)
|
26
|
-
end
|
27
|
-
s.to_xml(xml)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
phone_numbers.each do |number|
|
31
|
-
embedded_xml(xml, number, PhoneNumber)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Bandwidth
|
2
|
-
module Voice
|
3
|
-
module XmlVerb
|
4
|
-
def initialize(data = nil)
|
5
|
-
@data = (data || {}).clone()
|
6
|
-
end
|
7
|
-
|
8
|
-
def method_missing(name, *args, &block)
|
9
|
-
if name[name.size - 1] == '='
|
10
|
-
@data[name[0..-2].to_sym] = args[0]
|
11
|
-
else
|
12
|
-
@data[name]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def compact_hash(hash)
|
17
|
-
hash.inject({}) do |new_hash, (k,v)|
|
18
|
-
if !v.nil?
|
19
|
-
new_hash[k] = v.class == Hash ? compact_hash(v) : v
|
20
|
-
end
|
21
|
-
new_hash
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
# bandwidth
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Bandwidth
|
7
|
-
module Voice
|
8
|
-
# CallsController
|
9
|
-
class CallsController < BaseController
|
10
|
-
def initialize(config, http_call_back: nil)
|
11
|
-
super(config, http_call_back: http_call_back)
|
12
|
-
end
|
13
|
-
|
14
|
-
# Creates a call request
|
15
|
-
# @param [String] account_id Required parameter: Example:
|
16
|
-
# @param [ApiCreateCallRequest] body Optional parameter: Example:
|
17
|
-
# @return [ApiCallResponse] response from the API call
|
18
|
-
def create_call(account_id,
|
19
|
-
body: nil)
|
20
|
-
# Prepare query url.
|
21
|
-
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
22
|
-
_query_builder << '/api/v2/accounts/{accountId}/calls'
|
23
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
24
|
-
_query_builder,
|
25
|
-
'accountId' => account_id
|
26
|
-
)
|
27
|
-
_query_url = APIHelper.clean_url _query_builder
|
28
|
-
|
29
|
-
# Prepare headers.
|
30
|
-
_headers = {
|
31
|
-
'accept' => 'application/json',
|
32
|
-
'content-type' => 'application/json; charset=utf-8'
|
33
|
-
}
|
34
|
-
|
35
|
-
# Prepare and execute HttpRequest.
|
36
|
-
_request = config.http_client.post(
|
37
|
-
_query_url,
|
38
|
-
headers: _headers,
|
39
|
-
parameters: body.to_json
|
40
|
-
)
|
41
|
-
VoiceBasicAuth.apply(config, _request)
|
42
|
-
_response = execute_request(_request)
|
43
|
-
validate_response(_response)
|
44
|
-
|
45
|
-
# Return appropriate response type.
|
46
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
47
|
-
ApiResponse.new(_response, data: ApiCallResponse.from_hash(decoded))
|
48
|
-
end
|
49
|
-
|
50
|
-
# Creates a call request
|
51
|
-
# @param [String] account_id Required parameter: Example:
|
52
|
-
# @param [String] call_id Required parameter: Example:
|
53
|
-
# @param [ApiModifyCallRequest] body Optional parameter: Example:
|
54
|
-
# @return [void] response from the API call
|
55
|
-
def modify_call(account_id,
|
56
|
-
call_id,
|
57
|
-
body: nil)
|
58
|
-
# Prepare query url.
|
59
|
-
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
60
|
-
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}'
|
61
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
62
|
-
_query_builder,
|
63
|
-
'accountId' => account_id,
|
64
|
-
'callId' => call_id
|
65
|
-
)
|
66
|
-
_query_url = APIHelper.clean_url _query_builder
|
67
|
-
|
68
|
-
# Prepare headers.
|
69
|
-
_headers = {
|
70
|
-
'content-type' => 'application/json; charset=utf-8'
|
71
|
-
}
|
72
|
-
|
73
|
-
# Prepare and execute HttpRequest.
|
74
|
-
_request = config.http_client.post(
|
75
|
-
_query_url,
|
76
|
-
headers: _headers,
|
77
|
-
parameters: body.to_json
|
78
|
-
)
|
79
|
-
VoiceBasicAuth.apply(config, _request)
|
80
|
-
_response = execute_request(_request)
|
81
|
-
validate_response(_response)
|
82
|
-
|
83
|
-
# Return appropriate response type.
|
84
|
-
ApiResponse.new(_response)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|