didww-v3 1.2.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/tests.yml +27 -0
  3. data/.rubocop.yml +22 -19
  4. data/CHANGELOG.md +75 -0
  5. data/Gemfile +20 -0
  6. data/README.md +8 -1
  7. data/Rakefile +6 -1
  8. data/bin/console +1 -0
  9. data/didww-v3.gemspec +3 -18
  10. data/lib/didww/{middleware.rb → base_middleware.rb} +5 -4
  11. data/lib/didww/callback/const.rb +14 -0
  12. data/lib/didww/callback/request_validator.rb +77 -0
  13. data/lib/didww/client.rb +101 -26
  14. data/lib/didww/complex_objects/base.rb +6 -4
  15. data/lib/didww/complex_objects/capacity_order_item.rb +17 -0
  16. data/lib/didww/complex_objects/configurations/base.rb +143 -2
  17. data/lib/didww/complex_objects/configurations/h323_configuration.rb +1 -0
  18. data/lib/didww/complex_objects/configurations/iax2_configuration.rb +1 -0
  19. data/lib/didww/complex_objects/configurations/pstn_configuration.rb +1 -0
  20. data/lib/didww/complex_objects/configurations/sip_configuration.rb +34 -3
  21. data/lib/didww/complex_objects/configurations.rb +1 -0
  22. data/lib/didww/complex_objects/did_order_item.rb +14 -7
  23. data/lib/didww/complex_objects/export_filters.rb +26 -0
  24. data/lib/didww/encrypt.rb +101 -0
  25. data/lib/didww/jsonapi_middleware.rb +21 -0
  26. data/lib/didww/resource/address.rb +37 -0
  27. data/lib/didww/resource/address_verification.rb +56 -0
  28. data/lib/didww/resource/area.rb +12 -0
  29. data/lib/didww/{resources → resource}/available_did.rb +1 -0
  30. data/lib/didww/{resources → resource}/balance.rb +1 -0
  31. data/lib/didww/{resources → resource}/base.rb +2 -2
  32. data/lib/didww/resource/capacity_pool.rb +47 -0
  33. data/lib/didww/resource/city.rb +14 -0
  34. data/lib/didww/{resources → resource}/country.rb +1 -0
  35. data/lib/didww/{resources → resource}/did.rb +11 -3
  36. data/lib/didww/{resources → resource}/did_group.rb +13 -21
  37. data/lib/didww/{resources → resource}/did_group_type.rb +1 -0
  38. data/lib/didww/{resources → resource}/did_reservation.rb +1 -0
  39. data/lib/didww/resource/encrypted_file.rb +58 -0
  40. data/lib/didww/{resources/cdr_export.rb → resource/export.rb} +24 -5
  41. data/lib/didww/resource/identity.rb +78 -0
  42. data/lib/didww/{resources → resource}/order.rb +21 -12
  43. data/lib/didww/resource/permanent_supporting_document.rb +15 -0
  44. data/lib/didww/{resources → resource}/pop.rb +1 -0
  45. data/lib/didww/resource/proof.rb +19 -0
  46. data/lib/didww/resource/proof_type.rb +14 -0
  47. data/lib/didww/resource/public_key.rb +12 -0
  48. data/lib/didww/resource/qty_based_pricing.rb +20 -0
  49. data/lib/didww/{resources → resource}/region.rb +1 -0
  50. data/lib/didww/resource/requirement.rb +61 -0
  51. data/lib/didww/resource/requirement_validation.rb +10 -0
  52. data/lib/didww/resource/shared_capacity_group.rb +27 -0
  53. data/lib/didww/{resources → resource}/stock_keeping_unit.rb +1 -0
  54. data/lib/didww/resource/supporting_document_template.rb +14 -0
  55. data/lib/didww/{resources/trunk.rb → resource/voice_in_trunk.rb} +40 -4
  56. data/lib/didww/{resources/trunk_group.rb → resource/voice_in_trunk_group.rb} +3 -2
  57. data/lib/didww/resource/voice_out_trunk.rb +75 -0
  58. data/lib/didww/resource/voice_out_trunk_regenerate_credential.rb +11 -0
  59. data/lib/didww/types/ip_addresses.rb +23 -0
  60. data/lib/didww/types/strings.rb +21 -0
  61. data/lib/didww/types.rb +12 -0
  62. data/lib/didww/version.rb +2 -1
  63. data/lib/didww.rb +6 -1
  64. metadata +59 -176
  65. data/.travis.yml +0 -5
  66. data/lib/didww/complex_objects/cdr_export_filter.rb +0 -23
  67. data/lib/didww/complex_objects/configurations/const.rb +0 -149
  68. data/lib/didww/resources/city.rb +0 -9
  69. data/lib/didww/resources/trunk/const.rb +0 -46
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'json_api_client/schema'
2
3
 
3
4
  module DIDWW
@@ -11,7 +12,7 @@ module DIDWW
11
12
  end
12
13
 
13
14
  def property(name, options = {})
14
- property = schema.add(name, options)
15
+ schema.add(name, options)
15
16
  define_method(name.to_sym) { self[name] }
16
17
  define_method("#{name}=".to_sym) { |val| self[name] = val }
17
18
  end
@@ -44,7 +45,10 @@ module DIDWW
44
45
 
45
46
  # Returns a ComplexObject class if given JSON API type matches any
46
47
  def class_for_type(type)
47
- "#{parent.name}::#{type.classify}".safe_constantize
48
+ # activesupport 6 has breaking change - parent* methods renamed to module_parent*.
49
+ # see https://github.com/rails/rails/pull/34051
50
+ name = respond_to?(:module_parent_name) ? module_parent_name : parent_name
51
+ "#{name}::#{type.classify}".safe_constantize
48
52
  end
49
53
  end
50
54
 
@@ -84,5 +88,3 @@ module DIDWW
84
88
  end
85
89
  end
86
90
  end
87
-
88
- JsonApiClient::Schema.register complex_object: DIDWW::ComplexObject::Base
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ module DIDWW
3
+ module ComplexObject
4
+ class CapacityOrderItem < Base
5
+ # passed at order creation
6
+ property :qty, type: :int
7
+ property :capacity_pool_id, type: :string
8
+
9
+ # returned
10
+ property :nrc, type: :decimal
11
+ property :mrc, type: :decimal
12
+ property :propated_mrc, type: :boolean
13
+ property :billed_from, type: :string
14
+ property :billed_to, type: :string
15
+ end
16
+ end
17
+ end
@@ -1,10 +1,151 @@
1
- require 'didww/complex_objects/configurations/const'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module DIDWW
4
4
  module ComplexObject
5
5
  module Configuration
6
6
  class Base < ComplexObject::Base
7
- include CONST
7
+ RX_DTMF_FORMATS = {
8
+ 1 => 'RFC 2833',
9
+ 2 => 'SIP INFO application/dtmf-relay OR application/dtmf',
10
+ 3 => 'RFC 2833 OR SIP INFO'
11
+ }.freeze
12
+
13
+ TX_DTMF_FORMATS = {
14
+ 0 => 'Disable sending',
15
+ 1 => 'RFC 2833',
16
+ 2 => 'SIP INFO application/dtmf-relay',
17
+ 4 => 'SIP INFO application/dtmf'
18
+ }.freeze
19
+
20
+ SST_REFRESH_METHODS = {
21
+ 1 => 'Invite',
22
+ 2 => 'Update',
23
+ 3 => 'Update fallback Invite'
24
+ }.freeze
25
+
26
+ TRANSPORT_PROTOCOLS = {
27
+ 1 => 'UDP',
28
+ 2 => 'TCP',
29
+ 3 => 'TLS'
30
+ }.freeze
31
+
32
+ REROUTING_DISCONNECT_CODES = {
33
+ 56 => '400 | Bad Request',
34
+ 57 => '401 | Unauthorized',
35
+ 58 => '402 | Payment Required',
36
+ 59 => '403 | Forbidden',
37
+ 60 => '404 | Not Found',
38
+ 64 => '408 | Request Timeout',
39
+ 65 => '409 | Conflict',
40
+ 66 => '410 | Gone',
41
+ 67 => '412 | Conditional Request Failed',
42
+ 68 => '413 | Request Entity Too Large',
43
+ 69 => '414 | Request-URI Too Long',
44
+ 70 => '415 | Unsupported Media Type',
45
+ 71 => '416 | Unsupported URI Scheme',
46
+ 72 => '417 | Unknown Resource-Priority',
47
+ 73 => '420 | Bad Extension',
48
+ 74 => '421 | Extension Required',
49
+ 75 => '422 | Session Interval Too Small',
50
+ 76 => '423 | Interval Too Brief',
51
+ 77 => '424 | Bad Location Information',
52
+ 78 => '428 | Use Identity Header',
53
+ 79 => '429 | Provide Referrer Identity',
54
+ 80 => '433 | Anonymity Disallowed',
55
+ 81 => '436 | Bad Identity-Info',
56
+ 82 => '437 | Unsupported Certificate',
57
+ 83 => '438 | Invalid Identity Header',
58
+ 84 => '480 | Temporarily Unavailable',
59
+ 86 => '482 | Loop Detected',
60
+ 87 => '483 | Too Many Hops',
61
+ 88 => '484 | Address Incomplete',
62
+ 89 => '485 | Ambiguous',
63
+ 90 => '486 | Busy Here',
64
+ 91 => '487 | Request Terminated',
65
+ 92 => '488 | Not Acceptable Here',
66
+ 96 => '494 | Security Agreement Required',
67
+ 97 => '500 | Server Internal Error',
68
+ 98 => '501 | Not Implemented',
69
+ 99 => '502 | Bad Gateway',
70
+ 100 => '503 | Service Unavailable',
71
+ 101 => '504 | Server Time-out',
72
+ 102 => '505 | Version Not Supported',
73
+ 103 => '513 | Message Too Large',
74
+ 104 => '580 | Precondition Failure',
75
+ 105 => '600 | Busy Everywhere',
76
+ 106 => '603 | Decline',
77
+ 107 => '604 | Does Not Exist Anywhere',
78
+ 108 => '606 | Not Acceptable',
79
+ 1505 => 'Ringing timeout'
80
+ }.freeze
81
+
82
+ CODECS = {
83
+ 6 => 'telephone-event',
84
+ 7 => 'G723',
85
+ 8 => 'G729',
86
+ 9 => 'PCMU',
87
+ 10 => 'PCMA',
88
+ 12 => 'speex',
89
+ 13 => 'GSM',
90
+ 14 => 'G726-32',
91
+ 15 => 'G721',
92
+ 16 => 'G726-24',
93
+ 17 => 'G726-40',
94
+ 18 => 'G726-16',
95
+ 19 => 'L16'
96
+ }.freeze
97
+
98
+ DEFAULT_REROUTING_DISCONNECT_CODE_IDS = [
99
+ 56,
100
+ 58,
101
+ 59,
102
+ 60,
103
+ 64,
104
+ 65,
105
+ 66,
106
+ 67,
107
+ 68,
108
+ 69,
109
+ 70,
110
+ 71,
111
+ 72,
112
+ 73,
113
+ 74,
114
+ 75,
115
+ 76,
116
+ 77,
117
+ 78,
118
+ 79,
119
+ 80,
120
+ 81,
121
+ 82,
122
+ 83,
123
+ 84,
124
+ 86,
125
+ 87,
126
+ 88,
127
+ 89,
128
+ 90,
129
+ 91,
130
+ 92,
131
+ 96,
132
+ 97,
133
+ 98,
134
+ 99,
135
+ 101,
136
+ 102,
137
+ 103,
138
+ 104,
139
+ 105,
140
+ 106,
141
+ 107,
142
+ 108,
143
+ 1505
144
+ ].freeze
145
+
146
+ DEFAULT_CODEC_IDS = [9, 10, 8, 7, 6].freeze
147
+
148
+ DID_PLACEHOLDER = '{DID}'
8
149
  end
9
150
  end
10
151
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module DIDWW
2
3
  module ComplexObject
3
4
  module Configuration
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module DIDWW
2
3
  module ComplexObject
3
4
  module Configuration
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module DIDWW
2
3
  module ComplexObject
3
4
  module Configuration
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module DIDWW
2
3
  module ComplexObject
3
4
  module Configuration
@@ -147,7 +148,7 @@ module DIDWW
147
148
  property :transport_protocol_id, type: :integer
148
149
  # Type: Integer
149
150
  # 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
+ # Description: The transport layer that will be responsible for the actual transmission of SIP requests and responses. See TRANSPORT_PROTOCOLS for available values.
151
152
 
152
153
  property :max_transfers, type: :integer
153
154
  # Nullable: No
@@ -157,6 +158,36 @@ module DIDWW
157
158
  # Nullable: No
158
159
  # Description: Max count of 301/302 redirects
159
160
 
161
+ property :media_encryption_mode, type: :string
162
+ # Type: String
163
+ # Nullable: No
164
+ # Description: The Media encryption mode for RTP traffic. See MEDIA_ENCRYPTION_MODES for available values.
165
+
166
+ property :stir_shaken_mode, type: :string
167
+ # Type: String
168
+ # Nullable: No
169
+ # Description: The STIR/SHAKEN mode for sending identity via SIP. See STIR_SHAKEN_MODES for available values.
170
+
171
+ property :allowed_rtp_ips, type: :ip_addresses
172
+ # Type: Array of strings
173
+ # Nullable: Yes
174
+ # Description: Allowed IP addresses for RTP connection.
175
+
176
+ MEDIA_ENCRYPTION_MODES = [
177
+ 'disabled',
178
+ 'srtp_sdes',
179
+ 'srtp_dtls',
180
+ 'zrtp'
181
+ ].freeze
182
+
183
+ STIR_SHAKEN_MODES = [
184
+ 'disabled',
185
+ 'original',
186
+ 'pai',
187
+ 'original_pai',
188
+ 'verstat'
189
+ ].freeze
190
+
160
191
  DEFAULTS = {
161
192
  username: DID_PLACEHOLDER,
162
193
  port: '5060',
@@ -176,7 +207,7 @@ module DIDWW
176
207
  transport_protocol_id: 1
177
208
  }.freeze
178
209
 
179
- RECOMMENDED = DEFAULTS.merge({
210
+ RECOMMENDED = DEFAULTS.merge(
180
211
  #-- Authentication
181
212
  auth_user: '',
182
213
  auth_password: '',
@@ -190,7 +221,7 @@ module DIDWW
190
221
  #-- Advanced Signalling Settings
191
222
  sst_enabled: false,
192
223
  sst_session_expires: '',
193
- }).freeze
224
+ ).freeze
194
225
 
195
226
  def sst_refresh_method
196
227
  SST_REFRESH_METHODS[sst_refresh_method_id]
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'didww/complex_objects/configurations/base'
2
3
  require 'didww/complex_objects/configurations/sip_configuration'
3
4
  require 'didww/complex_objects/configurations/iax2_configuration'
@@ -1,16 +1,23 @@
1
+ # frozen_string_literal: true
1
2
  module DIDWW
2
3
  module ComplexObject
3
4
  class DidOrderItem < Base
4
5
  # passed at order creation
5
- property :qty, type: :int
6
- property :available_did_id, type: :string
7
- property :did_reservation_id, type: :string
8
- property :sku_id, type: :string
6
+ property :qty, type: :int
7
+ property :available_did_id, type: :string
8
+ property :did_reservation_id, type: :string
9
+ property :sku_id, type: :string
10
+ property :billing_cycles_count, type: :string
9
11
 
10
12
  # returned
11
- property :setup_price, type: :decimal
12
- property :monthly_price, type: :decimal
13
- property :did_group_id, type: :string
13
+ property :setup_price, type: :decimal
14
+ property :monthly_price, type: :decimal
15
+ property :nrc, type: :decimal
16
+ property :mrc, type: :decimal
17
+ property :propated_mrc, type: :boolean
18
+ property :billed_from, type: :string
19
+ property :billed_to, type: :string
20
+ property :did_group_id, type: :string
14
21
  end
15
22
  end
16
23
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ require 'json_api_client/schema'
3
+
4
+ module DIDWW
5
+ module ComplexObject
6
+ class ExportFilters < Base
7
+ # Type casting for JsonApiClient parser/setters
8
+ def self.cast_single_object(hash)
9
+ new(hash)
10
+ end
11
+
12
+ property :year, type: :integer
13
+ property :month, type: :integer
14
+ property :day, type: :integer # only for CDR Out
15
+ property :did_number, type: :string # only for CDR in
16
+ property :voice_out_trunk_id, type: :string # only for CDR Out
17
+
18
+ def as_json(*)
19
+ result = attributes.as_json.with_indifferent_access
20
+ result[:'voice_out_trunk.id'] = result.delete(:voice_out_trunk_id) if result.key?(:voice_out_trunk_id)
21
+ result
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+ require 'openssl'
3
+ require 'openssl/oaep'
4
+ require 'net/http'
5
+
6
+ module DIDWW
7
+ # Allows to encrypt file on Ruby-side before uploading to `/v3/encrypted_files`.
8
+ # @example
9
+ # file_content_1 = File.read('file_to_send_1.jpg', mode: 'rb')
10
+ # file_content_2 = File.read('file_to_send_1.pdf', mode: 'rb')
11
+ # enc = DIDWW::Encrypt.new
12
+ # enc_data_1 = enc.encrypt(file_content_1)
13
+ # enc_data_2 = enc.encrypt(file_content_2)
14
+ # enc_io_1 = Faraday::UploadIO.new(StringIO.new(enc_data_1), 'application/octet-stream')
15
+ # enc_io_2 = Faraday::UploadIO.new(StringIO.new(enc_data_2), 'application/octet-stream')
16
+ # DIDWW::Resource::EncryptedFile.upload(
17
+ # encryption_fingerprint: enc.encryption_fingerprint,
18
+ # items: [
19
+ # { file: enc_io_1, description: 'file_to_send_1.jpg' },
20
+ # { file: enc_io_2, description: 'file_to_send_2.pdf' }
21
+ # ]
22
+ # ) # => Array if IDs
23
+ #
24
+ class Encrypt
25
+ AES_ALGO = [256, :CBC]
26
+ AES_KEY_LEN = 32
27
+ AES_IV_LEN = 16
28
+ LABEL = ''
29
+ SEPARATOR = ':::'
30
+
31
+ class << self
32
+ # @param binary [String]
33
+ # @return [String]
34
+ def encrypt(binary)
35
+ new.encrypt(binary)
36
+ end
37
+ end
38
+
39
+ attr_reader :public_keys, :encryption_fingerprint
40
+
41
+ def initialize
42
+ reset!
43
+ end
44
+
45
+ # @param binary [String] binary content of a file.
46
+ # @return [String] binary content of an encrypted file.
47
+ def encrypt(binary)
48
+ aes_key, aes_iv, encrypted_aes = encrypt_aes(binary)
49
+ aes_credentials = aes_key + aes_iv
50
+ encrypted_rsa_a = encrypt_rsa_oaep(public_keys[0], aes_credentials)
51
+ encrypted_rsa_b = encrypt_rsa_oaep(public_keys[1], aes_credentials)
52
+ encrypted_rsa_a + encrypted_rsa_b + encrypted_aes
53
+ end
54
+
55
+ # Resets public keys and fingerprint.
56
+ def reset!
57
+ @public_keys = fetch_public_keys
58
+ @encryption_fingerprint = calculate_fingerprint
59
+ end
60
+
61
+ private
62
+
63
+ # @return [Array(String,String)] public keys.
64
+ def fetch_public_keys
65
+ DIDWW::Resource::PublicKey.find.map(&:key)
66
+ end
67
+
68
+ def calculate_fingerprint
69
+ public_keys.map { |pub_key| fingerprint_for(pub_key) }.join(SEPARATOR)
70
+ end
71
+
72
+ # @param public_key [String] PEM public key.
73
+ # @return [String] hexstring digest SHA1 for public key binary.
74
+ def fingerprint_for(public_key)
75
+ public_key += "\n" unless public_key[-1] == "\n"
76
+ public_key_base64 = public_key.split("\n")[1..-2].join
77
+ public_key_bin = Base64.decode64(public_key_base64)
78
+ OpenSSL::Digest::SHA1.hexdigest(public_key_bin)
79
+ end
80
+
81
+ # @param public_key [String]
82
+ # @param text [String]
83
+ def encrypt_rsa_oaep(public_key, text)
84
+ rsa = OpenSSL::PKey::RSA.new(public_key)
85
+ rsa.public_encrypt_oaep(text, LABEL, OpenSSL::Digest::SHA256)
86
+ end
87
+
88
+ # @param binary [String]
89
+ # @return [Array(String,String,String)] binaries key, vector, encrypted data.
90
+ def encrypt_aes(binary)
91
+ key = SecureRandom.random_bytes(AES_KEY_LEN)
92
+ iv = SecureRandom.random_bytes(AES_IV_LEN)
93
+ cipher = OpenSSL::Cipher::AES.new(*AES_ALGO)
94
+ cipher.encrypt
95
+ cipher.key = key
96
+ cipher.iv = iv
97
+ encrypted = cipher.update(binary) + cipher.final
98
+ [key, iv, encrypted]
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ module DIDWW
3
+ # :nodoc:
4
+ class JsonapiMiddleware < Faraday::Middleware
5
+ def call(request_env)
6
+ headers = {}
7
+ headers['Content-Type'] = 'application/vnd.api+json'
8
+ headers['Api-Key'] = DIDWW::Client.api_key
9
+ headers['User-Agent'] = "didww-v3 Ruby gem v#{VERSION}"
10
+ headers['x-didww-api-version'] = DIDWW::Client.api_version unless DIDWW::Client.api_version.blank?
11
+
12
+ request_env[:request_headers].merge!(headers)
13
+ request_env.url.host = URI(DIDWW::Client.api_base_url).host
14
+
15
+ @app.call(request_env).on_complete do |response_env|
16
+ # do something with the response
17
+ # response_env[:response_headers].merge!(...)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+ module DIDWW
3
+ module Resource
4
+ class Address < Base
5
+
6
+ has_one :identity, class_name: 'Identity'
7
+ has_one :country, class_name: 'Country'
8
+ has_many :proofs, class_name: 'Proof'
9
+ has_many :city, class_name: 'City'
10
+ has_many :area, class_name: 'Area'
11
+
12
+ property :city_name, type: :string
13
+ # Type: String
14
+ # Description:
15
+
16
+ property :postal_code, type: :string
17
+ # Type: String
18
+ # Description:
19
+
20
+ property :address, type: :string
21
+ # Type: String
22
+ # Description:
23
+
24
+ property :description, type: :string
25
+ # Type: String
26
+ # Description:
27
+
28
+ property :created_at, type: :date
29
+ # Type: Date
30
+ # Description:
31
+
32
+ property :verified, type: :boolean
33
+ # Type: Boolean
34
+ # Description:
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+ module DIDWW
3
+ module Resource
4
+ class AddressVerification < Base
5
+ STATUS_PENDING = 'Pending'
6
+ STATUS_APPROVED = 'Approved'
7
+ STATUS_REJECTED = 'Rejected'
8
+ STATUSES = [
9
+ STATUS_PENDING,
10
+ STATUS_APPROVED,
11
+ STATUS_REJECTED
12
+ ].freeze
13
+
14
+ has_one :address, class_name: 'Address'
15
+ has_many :dids, class_name: 'Did'
16
+ has_many :onetime_files, class_name: 'EncryptedFile'
17
+
18
+ property :service_description, type: :string
19
+ # Type: String
20
+ # Description:
21
+
22
+ property :status, type: :string
23
+ # Type: String
24
+ # Description:
25
+
26
+ property :reject_reasons, type: :string
27
+ # Type: String
28
+ # Description:
29
+
30
+ property :created_at, type: :date
31
+ # Type: Date
32
+ # Description:
33
+
34
+ property :callback_url, type: :string
35
+ # Type: String
36
+ # Description: valid URI for callbacks
37
+
38
+ property :callback_method, type: :string
39
+ # Type: String
40
+ # Description: GET or POST
41
+
42
+ def pending?
43
+ status == STATUS_PENDING
44
+ end
45
+
46
+ def approved?
47
+ status == STATUS_APPROVED
48
+ end
49
+
50
+ def rejected?
51
+ status == STATUS_REJECTED
52
+ end
53
+
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ module DIDWW
3
+ module Resource
4
+ class Area < Base
5
+ has_one :country, class_name: 'Country'
6
+
7
+ property :name, type: :string
8
+ # Type: String
9
+ # Description: Regulatory Area name
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module DIDWW
2
3
  module Resource
3
4
  class AvailableDid < Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module DIDWW
2
3
  module Resource
3
4
  class Balance < Base
@@ -1,5 +1,5 @@
1
- require 'didww/middleware'
2
- require 'didww/complex_objects/base'
1
+ # frozen_string_literal: true
2
+ require 'didww/jsonapi_middleware'
3
3
 
4
4
  module DIDWW
5
5
  module Resource
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+ module DIDWW
3
+ module Resource
4
+ class CapacityPool < Base
5
+ has_many :countries, class: 'Country'
6
+ has_many :shared_capacity_groups, class: 'SharedCapacityGroup'
7
+ has_many :qty_based_pricings, class: 'QtyBasedPricing'
8
+
9
+ property :name, type: :string
10
+ # Type: String
11
+ # Description: Capacity pool name
12
+
13
+ property :renew_date, type: :string
14
+ # Type: String
15
+ # Description: Next monthly renew date in format 'YYYY-MM-DD'
16
+
17
+ property :total_channels_count, type: :integer
18
+ # Type: Integer
19
+ # Description: Channels count owned by customer in this pool
20
+
21
+ property :assigned_channels_count, type: :integer
22
+ # Type: Integer
23
+ # Description: Channels used by at least one service in this pool
24
+
25
+ property :minimum_limit, type: :integer
26
+ # Type: Integer
27
+ # Description: A minimum amount of channels in this pool. Customer cannot remove unassigned channels below this level.
28
+
29
+ property :minimum_qty_per_order, type: :integer
30
+ # Type: Integer
31
+ # Description: A minimum amount of new channels to add to this pool in one order.
32
+
33
+ property :setup_price, type: :decimal
34
+ # Type: String
35
+ # Description: Non-recurring price per channel
36
+
37
+ property :monthly_price, type: :decimal
38
+ # Type: String
39
+ # Description: Monthly recurring price per channel
40
+
41
+ property :metered_rate, type: :decimal
42
+ # Type: String
43
+ # Description: Metered rate per minute
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+ module DIDWW
3
+ module Resource
4
+ class City < Base
5
+ has_one :country, class_name: 'Country'
6
+ has_one :region, class_name: 'Region'
7
+ has_one :area, class_name: 'Area'
8
+
9
+ property :name, type: :string
10
+ # Type: String
11
+ # Description: City name
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module DIDWW
2
3
  module Resource
3
4
  class Country < Base