didww-v3 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +313 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +57 -0
- data/Rakefile +6 -0
- data/bin/console +19 -0
- data/bin/setup +8 -0
- data/didww-v3.gemspec +46 -0
- data/lib/didww.rb +3 -0
- data/lib/didww/client.rb +120 -0
- data/lib/didww/complex_objects/base.rb +89 -0
- data/lib/didww/complex_objects/cdr_export_filter.rb +23 -0
- data/lib/didww/complex_objects/configurations.rb +11 -0
- data/lib/didww/complex_objects/configurations/base.rb +11 -0
- data/lib/didww/complex_objects/configurations/const.rb +149 -0
- data/lib/didww/complex_objects/configurations/h323_configuration.rb +35 -0
- data/lib/didww/complex_objects/configurations/iax2_configuration.rb +45 -0
- data/lib/didww/complex_objects/configurations/pstn_configuration.rb +16 -0
- data/lib/didww/complex_objects/configurations/sip_configuration.rb +203 -0
- data/lib/didww/complex_objects/did_order_item.rb +14 -0
- data/lib/didww/middleware.rb +18 -0
- data/lib/didww/resources/balance.rb +20 -0
- data/lib/didww/resources/base.rb +29 -0
- data/lib/didww/resources/cdr_export.rb +47 -0
- data/lib/didww/resources/city.rb +9 -0
- data/lib/didww/resources/country.rb +17 -0
- data/lib/didww/resources/did.rb +49 -0
- data/lib/didww/resources/did_group.rb +66 -0
- data/lib/didww/resources/did_group_type.rb +9 -0
- data/lib/didww/resources/order.rb +67 -0
- data/lib/didww/resources/region.rb +9 -0
- data/lib/didww/resources/stock_keeping_unit.rb +19 -0
- data/lib/didww/resources/trunk.rb +70 -0
- data/lib/didww/resources/trunk/const.rb +61 -0
- data/lib/didww/resources/trunk_group.rb +23 -0
- data/lib/didww/version.rb +3 -0
- metadata +307 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
module DIDWW
|
2
|
+
module ComplexObject
|
3
|
+
module Configuration
|
4
|
+
class H323Configuration < Base
|
5
|
+
property :dst, type: :string
|
6
|
+
# Type: String
|
7
|
+
# Nullable: No
|
8
|
+
# Description: Phone number
|
9
|
+
|
10
|
+
property :host, type: :string
|
11
|
+
# Type: String
|
12
|
+
# Nullable: No
|
13
|
+
# Description: Destination server
|
14
|
+
|
15
|
+
property :port, type: :string
|
16
|
+
# Type: String
|
17
|
+
# Nullable: No
|
18
|
+
# Description: Destination port
|
19
|
+
|
20
|
+
property :codec_ids, type: :array
|
21
|
+
# TODO array type
|
22
|
+
# Type: Array
|
23
|
+
# Nullable: No
|
24
|
+
# Description:
|
25
|
+
|
26
|
+
DEFAULTS = {
|
27
|
+
codec_ids: DEFAULT_CODEC_IDS,
|
28
|
+
dst: DID_PLACEHOLDER,
|
29
|
+
}.freeze
|
30
|
+
|
31
|
+
RECOMMENDED = {}.freeze
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module DIDWW
|
2
|
+
module ComplexObject
|
3
|
+
module Configuration
|
4
|
+
class Iax2Configuration < Base
|
5
|
+
property :dst, type: :string
|
6
|
+
# Type: String
|
7
|
+
# Nullable: No
|
8
|
+
# Description: Phone number
|
9
|
+
|
10
|
+
property :host, type: :string
|
11
|
+
# Type: String
|
12
|
+
# Nullable: No
|
13
|
+
# Description: Destination server
|
14
|
+
|
15
|
+
property :port, type: :string
|
16
|
+
# Type: String
|
17
|
+
# Nullable: No
|
18
|
+
# Description: Destination port
|
19
|
+
|
20
|
+
property :auth_user, type: :string
|
21
|
+
# Type: String
|
22
|
+
# Nullable: No
|
23
|
+
# Description: Optional authorization user
|
24
|
+
|
25
|
+
property :auth_password, type: :string
|
26
|
+
# Type: String
|
27
|
+
# Nullable: No
|
28
|
+
# Description: Optional authorization password
|
29
|
+
|
30
|
+
property :codec_ids, type: :array
|
31
|
+
# TODO array type
|
32
|
+
# Type: Array
|
33
|
+
# Nullable: No
|
34
|
+
# Description:
|
35
|
+
|
36
|
+
DEFAULTS = {
|
37
|
+
codec_ids: DEFAULT_CODEC_IDS,
|
38
|
+
dst: DID_PLACEHOLDER,
|
39
|
+
}.freeze
|
40
|
+
|
41
|
+
RECOMMENDED = {}.freeze
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module DIDWW
|
2
|
+
module ComplexObject
|
3
|
+
module Configuration
|
4
|
+
class PstnConfiguration < Base
|
5
|
+
property :dst, type: :string
|
6
|
+
# Type: String
|
7
|
+
# Nullable: No
|
8
|
+
# Description: Phone number
|
9
|
+
|
10
|
+
DEFAULTS = {}.freeze
|
11
|
+
|
12
|
+
RECOMMENDED = {}.freeze
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
module DIDWW
|
2
|
+
module ComplexObject
|
3
|
+
module Configuration
|
4
|
+
class SipConfiguration < Base
|
5
|
+
property :username, type: :string
|
6
|
+
# Type: String
|
7
|
+
# Nullable: No
|
8
|
+
# Description: User part of R-URI in INVITE request.You also may use "{DID}" pattern which will be replaced by called DID number in E164 format. For example, you can set Username to "+{DID}"; if you wish to have it in +E164 format
|
9
|
+
|
10
|
+
property :host, type: :string
|
11
|
+
# Type: String
|
12
|
+
# Nullable: No
|
13
|
+
# Description: Host part of R-URI in INVITE request
|
14
|
+
|
15
|
+
property :auth_user, type: :string
|
16
|
+
# Type: String
|
17
|
+
# Nullable: No
|
18
|
+
# Description: Optional authorization user for the SIP server
|
19
|
+
|
20
|
+
property :auth_password, type: :string
|
21
|
+
# Type: String
|
22
|
+
# Nullable: No
|
23
|
+
# Description: Optional authorization password for the SIP server
|
24
|
+
|
25
|
+
property :auth_from_user, type: :string
|
26
|
+
# Type: String
|
27
|
+
# Nullable: No
|
28
|
+
# Description: Specify user in a "from" field instead of CallerID (overrides CallerID). Some equipment require "from"; to be equivalent to "Auth user";
|
29
|
+
|
30
|
+
property :auth_from_domain, type: :string
|
31
|
+
# Type: String
|
32
|
+
# Nullable: No
|
33
|
+
# Description: Sets default "from" domain in SIP messages. Some equipment may require specific "From" Domain
|
34
|
+
|
35
|
+
property :sst_refresh_method_id, type: :integer
|
36
|
+
# Type: Integer
|
37
|
+
# Nullable: No
|
38
|
+
# Description: SIP method which will be used for session update.
|
39
|
+
# See RFC 4028 for more details.
|
40
|
+
# Possible values:
|
41
|
+
# 1 - Invite
|
42
|
+
# 2 - Update
|
43
|
+
# 3 - Update fallback Invite
|
44
|
+
|
45
|
+
property :sip_timer_b, type: :integer
|
46
|
+
# Type: Integer
|
47
|
+
# Nullable: No
|
48
|
+
# Description: INVITE transaction timeout (Default 8000ms). See RFC 3261 Section 17.1.1.2 for more details
|
49
|
+
|
50
|
+
property :dns_srv_failover_timer, type: :integer
|
51
|
+
# Type: Integer
|
52
|
+
# Nullable: No
|
53
|
+
# Description: Invite transaction timeout for each of gateways with DNS SRV rerouting (Default 2000ms)
|
54
|
+
|
55
|
+
property :rtp_ping, type: :boolean
|
56
|
+
# Type: Boolean
|
57
|
+
# Nullable: No
|
58
|
+
# Description: Use RTP PING when connecting a call. After establishing the call, DIDWW will send empty RTP packet "RTP PING". It is neccessary if both parties operate in Symmetric RTP / Comedia mode and expect the other party to start sending RTP first.
|
59
|
+
|
60
|
+
property :rtp_timeout, type: :integer
|
61
|
+
# Type: Integer
|
62
|
+
# Nullable: No
|
63
|
+
# Description: Disconnect call if the RTP packets do not arrive within the specified time
|
64
|
+
|
65
|
+
property :sst_min_timer, type: :integer
|
66
|
+
# Type: Integer
|
67
|
+
# Nullable: No
|
68
|
+
# Description: Minimal SIP Session timer value (Default 600 seconds). See RFC 4028 for more details
|
69
|
+
|
70
|
+
property :sst_max_timer, type: :integer
|
71
|
+
# Type: Integer
|
72
|
+
# Nullable: No
|
73
|
+
# Description: Maximal SIP Session timer value (Default 900 seconds). See RFC 4028 for more details
|
74
|
+
|
75
|
+
property :sst_session_expires, type: :integer
|
76
|
+
# Type: Integer
|
77
|
+
# Nullable: No
|
78
|
+
# Description: Session-Expires header value. Optional, should be in range sst_min_timer ... sst_max_timer.
|
79
|
+
# See RFC 4028 for more details
|
80
|
+
|
81
|
+
property :port, type: :integer
|
82
|
+
# Type: Integer
|
83
|
+
# Nullable: No
|
84
|
+
# Description: Port part of R-URI in INVITE request (is not mandatory).If port is null, SRV record will be resolved (or A record if SRV is unavailable)
|
85
|
+
|
86
|
+
property :rx_dtmf_format_id, type: :integer
|
87
|
+
# Type: Integer
|
88
|
+
# Nullable: No
|
89
|
+
# Description: The method id for receiving DTMF signals from customer equipment
|
90
|
+
# Possible values:
|
91
|
+
# 1 - RFC 2833
|
92
|
+
# 2 - SIP INFO application/dtmf-relay OR application/dtmf
|
93
|
+
# 3 - RFC 2833 OR SIP INFO
|
94
|
+
|
95
|
+
property :tx_dtmf_format_id, type: :integer
|
96
|
+
# Type: Integer
|
97
|
+
# Nullable: No
|
98
|
+
# Description: The method of sending DTMF signals to customer equipment
|
99
|
+
# Possible values:
|
100
|
+
# 1 - Disable sending
|
101
|
+
# 2 - RFC 2833
|
102
|
+
# 3 - SIP INFO application/dtmf-relay
|
103
|
+
# 4 - SIP INFO application/dtmf
|
104
|
+
|
105
|
+
property :force_symmetric_rtp, type: :boolean
|
106
|
+
# Type: Boolean
|
107
|
+
# Nullable: No
|
108
|
+
# Description: Forced to work in Symmetric RTP / COMEDIA mode
|
109
|
+
|
110
|
+
property :symmetric_rtp_ignore_rtcp, type: :boolean
|
111
|
+
# Type: Boolean
|
112
|
+
# Nullable: No
|
113
|
+
# Description: Avoid switching RTP session based on RTCP packet while working in Symmetric RTP / COMEDIA. Only RTP packets will be considered
|
114
|
+
|
115
|
+
property :sst_enabled, type: :boolean
|
116
|
+
# Type: Boolean
|
117
|
+
# Nullable: No
|
118
|
+
# Description: Enable SIP Session timers customization. SIP session timers are used to make sure that a session (dialog) is still alive, even though there may have been a long time since the last in-dialog message. If the other end is not responding, the dialog will be hung up automatically. SIP session timers need to be supported by all end points for it to work. It's a SIP extension, standardized by the IETF. See RFC 4028 for more details
|
119
|
+
|
120
|
+
property :sst_accept_501, type: :boolean
|
121
|
+
# Type: Boolean
|
122
|
+
# Nullable: No
|
123
|
+
# Description: Do not drop the call after receiving SIP 501 response for non-critical messages
|
124
|
+
|
125
|
+
property :auth_enabled, type: :boolean
|
126
|
+
# Type: Boolean
|
127
|
+
# Nullable: No
|
128
|
+
# Description: Enable authorization for the SIP server
|
129
|
+
|
130
|
+
property :resolve_ruri, type: :boolean
|
131
|
+
# Type: Boolean
|
132
|
+
# Nullable: No
|
133
|
+
# Description: Replace host part of the R-URI by resolved IP address
|
134
|
+
|
135
|
+
property :rerouting_disconnect_code_ids, type: :array
|
136
|
+
# TODO array type
|
137
|
+
# Type: Array
|
138
|
+
# Nullable: No
|
139
|
+
# Description: Rerouting disconnect codes
|
140
|
+
|
141
|
+
property :codec_ids, type: :array
|
142
|
+
# TODO array type
|
143
|
+
# Type: Array
|
144
|
+
# Nullable: No
|
145
|
+
# Description: Codecs
|
146
|
+
|
147
|
+
property :transport_protocol_id, type: :integer
|
148
|
+
# Type: Integer
|
149
|
+
# Nullable: No
|
150
|
+
# Description: The transport layer that will be responsible for the actual transmission of SIP requests and responses (1 - UDP, 2 - TCP)
|
151
|
+
|
152
|
+
DEFAULTS = {
|
153
|
+
username: DID_PLACEHOLDER,
|
154
|
+
port: '5060',
|
155
|
+
tx_dtmf_format_id: 1,
|
156
|
+
sst_min_timer: 600,
|
157
|
+
sst_max_timer: 900,
|
158
|
+
sst_refresh_method_id: 1,
|
159
|
+
sst_accept_501: true,
|
160
|
+
sip_timer_b: 8000,
|
161
|
+
dns_srv_failover_timer: 2000,
|
162
|
+
rtp_timeout: 30,
|
163
|
+
auth_enabled: false,
|
164
|
+
codec_ids: DEFAULT_CODEC_IDS,
|
165
|
+
rerouting_disconnect_code_ids: DEFAULT_REROUTING_DISCONNECT_CODE_IDS,
|
166
|
+
transport_protocol_id: 1
|
167
|
+
}.freeze
|
168
|
+
|
169
|
+
RECOMMENDED = DEFAULTS.merge({
|
170
|
+
#-- Authentication
|
171
|
+
auth_user: '',
|
172
|
+
auth_password: '',
|
173
|
+
auth_from_user: '',
|
174
|
+
auth_from_domain: '',
|
175
|
+
#-- Media & DTMF
|
176
|
+
rx_dtmf_format_id: 1,
|
177
|
+
rtp_ping: false,
|
178
|
+
force_symmetric_rtp: false,
|
179
|
+
symmetric_rtp_ignore_rtcp: false,
|
180
|
+
#-- Advanced Signalling Settings
|
181
|
+
sst_enabled: false,
|
182
|
+
sst_session_expires: '',
|
183
|
+
}).freeze
|
184
|
+
|
185
|
+
def sst_refresh_method
|
186
|
+
SST_REFRESH_METHODS[sst_refresh_method_id]
|
187
|
+
end
|
188
|
+
|
189
|
+
def rx_dtmf_format
|
190
|
+
RX_DTMF_FORMATS[rx_dtmf_format_id]
|
191
|
+
end
|
192
|
+
|
193
|
+
def tx_dtmf_format
|
194
|
+
TX_DTMF_FORMATS[tx_dtmf_format_id]
|
195
|
+
end
|
196
|
+
|
197
|
+
def transport_protocol
|
198
|
+
TRANSPORT_PROTOCOLS[transport_protocol_id]
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DIDWW
|
2
|
+
module ComplexObject
|
3
|
+
class DidOrderItem < Base
|
4
|
+
# passed at order creation
|
5
|
+
property :qty, type: :int
|
6
|
+
property :sku_id, type: :string
|
7
|
+
|
8
|
+
# returned
|
9
|
+
property :setup_price, type: :decimal
|
10
|
+
property :monthly_price, type: :decimal
|
11
|
+
property :did_group_id, type: :string
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module DIDWW
|
2
|
+
# :nodoc:
|
3
|
+
class Middleware < Faraday::Middleware
|
4
|
+
def call(request_env)
|
5
|
+
headers = {}
|
6
|
+
headers['Content-Type'] = 'application/vnd.api+json'
|
7
|
+
headers['Api-Key'] = DIDWW::Client.api_key
|
8
|
+
|
9
|
+
request_env[:request_headers].merge!(headers)
|
10
|
+
request_env.url.host = URI(DIDWW::Client.api_base_url).host
|
11
|
+
|
12
|
+
@app.call(request_env).on_complete do |response_env|
|
13
|
+
# do something with the response
|
14
|
+
# response_env[:response_headers].merge!(...)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module DIDWW
|
2
|
+
module Resource
|
3
|
+
class Balance < Base
|
4
|
+
def self.table_name
|
5
|
+
'balance'
|
6
|
+
end
|
7
|
+
property :balance, type: :decimal
|
8
|
+
# Type: String
|
9
|
+
# Description: Prepaid balance
|
10
|
+
|
11
|
+
property :credit, type: :decimal
|
12
|
+
# Type: String
|
13
|
+
# Description: Available credit
|
14
|
+
|
15
|
+
property :total_balance, type: :decimal
|
16
|
+
# Type: String
|
17
|
+
# Description: The net balance (balance + credit)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'didww/middleware'
|
2
|
+
require 'didww/complex_objects/base'
|
3
|
+
|
4
|
+
module DIDWW
|
5
|
+
module Resource
|
6
|
+
class Base < JsonApiClient::Resource
|
7
|
+
def as_json_api(*args)
|
8
|
+
serialize_complex_attributes(super(*args))
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def serialize_complex_attributes(hash)
|
14
|
+
# Replace complex objects with their json_api representation
|
15
|
+
attributes = hash[:attributes]
|
16
|
+
hash[:attributes] = Hash[attributes.map do |k, v|
|
17
|
+
if v.respond_to?(:as_json_api)
|
18
|
+
[k, v.as_json_api]
|
19
|
+
elsif v.is_a?(Array)
|
20
|
+
[k, v.map { |i| i.respond_to?(:as_json_api) ? i.as_json_api : i }]
|
21
|
+
else
|
22
|
+
[k, v]
|
23
|
+
end
|
24
|
+
end].with_indifferent_access
|
25
|
+
return hash
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
require 'didww/complex_objects/cdr_export_filter'
|
3
|
+
require 'down/http'
|
4
|
+
|
5
|
+
module DIDWW
|
6
|
+
module Resource
|
7
|
+
class CdrExport < Base
|
8
|
+
extend Forwardable
|
9
|
+
|
10
|
+
property :filters, type: :cdr_export_filter
|
11
|
+
# Type: CDR Export Filters Object
|
12
|
+
# Nullable: No
|
13
|
+
# Description: Filters
|
14
|
+
|
15
|
+
property :status, type: :string
|
16
|
+
# Type: String
|
17
|
+
# Nullable: false
|
18
|
+
# Description: status can be "Pending", "Processing" or "Completed"
|
19
|
+
|
20
|
+
property :created_at, type: :time
|
21
|
+
# Type: DateTime
|
22
|
+
# Nullable: false
|
23
|
+
# Description: timestamp when export request was created
|
24
|
+
|
25
|
+
property :url, type: :string
|
26
|
+
# Type: String
|
27
|
+
# Nullable: true
|
28
|
+
# Description: url of csv file for downloading. available only when status is "Completed"
|
29
|
+
|
30
|
+
def_delegators :filters, :year, :month, :did_number, :year=, :month=, :did_number=
|
31
|
+
|
32
|
+
def initialize(params = {})
|
33
|
+
super params.reverse_merge(filters: {})
|
34
|
+
end
|
35
|
+
|
36
|
+
def csv
|
37
|
+
return unless url.present?
|
38
|
+
Down::Http.new(headers: { 'Api-Key' => DIDWW::Client.api_key }).open(url)
|
39
|
+
end
|
40
|
+
|
41
|
+
def complete?
|
42
|
+
status == 'Completed'
|
43
|
+
end
|
44
|
+
alias_method :completed?, :complete?
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|