didww-v3 1.3.1 → 4.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 +5 -1
  3. data/.rubocop.yml +3 -0
  4. data/CHANGELOG.md +51 -2
  5. data/Gemfile +2 -1
  6. data/README.md +10 -1
  7. data/Rakefile +1 -0
  8. data/bin/console +1 -0
  9. data/didww-v3.gemspec +3 -1
  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 +98 -39
  14. data/lib/didww/complex_objects/base.rb +2 -3
  15. data/lib/didww/complex_objects/capacity_order_item.rb +1 -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 +15 -12
  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 +2 -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/{resources → resource}/capacity_pool.rb +1 -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 +5 -3
  36. data/lib/didww/{resources → resource}/did_group.rb +13 -25
  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/resource/nanpa_prefix.rb +18 -0
  43. data/lib/didww/{resources → resource}/order.rb +20 -12
  44. data/lib/didww/resource/permanent_supporting_document.rb +15 -0
  45. data/lib/didww/{resources → resource}/pop.rb +1 -0
  46. data/lib/didww/resource/proof.rb +19 -0
  47. data/lib/didww/resource/proof_type.rb +14 -0
  48. data/lib/didww/resource/public_key.rb +12 -0
  49. data/lib/didww/{resources → resource}/qty_based_pricing.rb +1 -0
  50. data/lib/didww/{resources → resource}/region.rb +1 -0
  51. data/lib/didww/resource/requirement.rb +61 -0
  52. data/lib/didww/resource/requirement_validation.rb +10 -0
  53. data/lib/didww/{resources → resource}/shared_capacity_group.rb +1 -0
  54. data/lib/didww/{resources → resource}/stock_keeping_unit.rb +1 -0
  55. data/lib/didww/resource/supporting_document_template.rb +14 -0
  56. data/lib/didww/{resources/trunk.rb → resource/voice_in_trunk.rb} +40 -4
  57. data/lib/didww/{resources/trunk_group.rb → resource/voice_in_trunk_group.rb} +3 -2
  58. data/lib/didww/resource/voice_out_trunk.rb +75 -0
  59. data/lib/didww/resource/voice_out_trunk_regenerate_credential.rb +11 -0
  60. data/lib/didww/types/ip_addresses.rb +23 -0
  61. data/lib/didww/types/strings.rb +21 -0
  62. data/lib/didww/types.rb +12 -0
  63. data/lib/didww/version.rb +2 -1
  64. data/lib/didww.rb +6 -1
  65. metadata +63 -28
  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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67435ef42f0af2a8862a0951069af3d7a4ce4b3afedfeef02c89203fef215645
4
- data.tar.gz: f5bcb5ea9069ef3b10a1ac6c9b714d315e3b0f55d80fc132e22e21cc076a24ac
3
+ metadata.gz: 6784812fdd19810c53a47401d9f05205e894172a663b6bd5bf47c0d99a08e755
4
+ data.tar.gz: 8ca18f71683357e40a91faf5166da6fbc6d793b5568484fcb5e01114b7b9d99d
5
5
  SHA512:
6
- metadata.gz: 843ef3ddb29b72b09a7ef3b586169fe2f481463a0de49a8361642ff20c31973dee901f0c0d4f21bfa0c6aff60df2243e0e9e2e22b1e123168775bea200ecd6f0
7
- data.tar.gz: 842db8a8747dcfe7aa79fb363d45022d31a407ef2321e2599b770b7294c9eba890b4f1858a35735f77512d639a58948db44d25afddc69cfcad50f26f581820ec
6
+ metadata.gz: 2e1e8cd571ccd0e2bab57590b3712c24d06bdf22eea640258c8993271f6c92e84956245eaf86ce8b1c9720afef7d1d5f0d963c4c7be9bb36a62e45c23121067d
7
+ data.tar.gz: 6ab5993b537757b5f9a5a7004436dac9ce257cb37322d6e5759609867702f2694db47ba861efd20d308cf54395521c535ed0d22086b2bff9fd309ff61b248b5d
@@ -1,5 +1,9 @@
1
1
  name: Tests
2
- on: [ 'pull_request' ]
2
+ on:
3
+ pull_request:
4
+ push:
5
+ branches:
6
+ - master
3
7
 
4
8
  jobs:
5
9
  test:
data/.rubocop.yml CHANGED
@@ -52,6 +52,9 @@ Style/StringLiterals:
52
52
  Style/StringLiteralsInInterpolation:
53
53
  Enabled: true
54
54
 
55
+ Style/FrozenStringLiteralComment:
56
+ Enabled: true
57
+
55
58
  ##################### Performance ############################
56
59
 
57
60
  # Use `casecmp` rather than `downcase ==`.
data/CHANGELOG.md CHANGED
@@ -4,15 +4,64 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [1.3.1] - 2021-10-26
7
+ ## [Unreleased]
8
+ ### Breaking Changes
9
+ - /v3/did_groups removed `local_prefix` attribute
10
+ ### Added
11
+ - /v3/nanpa_prefixes endpoints being added.
12
+
13
+ ### Changes
14
+ - /v3/orders endpoints being updated. Added nanpa_prefix_id attribute for DID order item.
15
+
16
+ ## [3.0.0]
17
+ ### Breaking Changes
18
+ - /v3/trunks being moved to /v3/voice_in_trunks.
19
+ - /v3/trunk_groups being moved to /v3/voice_in_trunk_groups.
20
+ - /v3/cdr_exports being moved to /v3/exports. Endpoint now allows generating both inbound and outbound CDRs export.
21
+ - /v3/exports result file will be CSV archived in GZIP.
22
+ - Callbacks payload for exports being changed: value of type attribute is changed to exports.
23
+ - /v3/exports export_type required attribute being added to request and response with possible values: cdr_in, cdr_out.
24
+ - /v3/exports filters attribute being removed from response.
25
+ - /v3/did_groups filter features allowed values to be changed to sms_in, sms_out, voice_in, voice_out, t38.
26
+ - /v3/did_groups response value of features attribute to be changed to sms_in, sms_out, voice_in, voice_out, t38.
27
+ - /v3/available_dids filter did_group.features allowed values being changed to sms_in, sms_out, voice_in, voice_out, t38.
28
+ - /v3/dids rename trunk_group relationship to voice_in_trunk_group with type voice_in_trunk_groups.
29
+ - /v3/dids rename trunks relationship to voice_in_trunks with type voice_in_trunks.
30
+
31
+ ### Changes
32
+ - /v3/voice_out_trunks endpoints being added.
33
+ - /v3/voice_out_trunk_regenerate_credentials endpoint being added.
34
+ - /v3/voice_in_trunks SIP configuration additional attributes being added to request and response: media_encryption_mode, stir_shaken_mode, allowed_rtp_ips.
35
+ - /v3/dids filter add filter did_group.features with allowed values: sms_in, sms_out, voice_in, voice_out, t38.
36
+ - Callbacks allow receiving events about /v3/voice_out_trunks status change.
37
+
38
+ ## [2.0.0] - 2021-10-26
39
+ ### Breaking Changes
40
+ - upgrade `json_api_client` version to `1.18.0` [#9](https://github.com/didww/didww-v3-ruby/pull/9)
41
+ Handling of 4XX responses was changed - it now raises JsonApiClient::Errors::ClientError with `detail` as error message instead of adding it into base errors.
42
+ - /v3/dids in request and response attributes pending_removal being removed in favor of billing_cycles_count.
43
+ - /v3/did_groups restriction message removed in favor of requirements relationship.
44
+
8
45
  ### Changes
9
46
  - replace travis with github actions [#7](https://github.com/didww/didww-v3-ruby/pull/7) [#9](https://github.com/didww/didww-v3-ruby/pull/9)
10
47
  - use rubocop 1.9.X version [#7](https://github.com/didww/didww-v3-ruby/pull/7)
11
48
  - add bundle-audit [#7](https://github.com/didww/didww-v3-ruby/pull/7)
49
+ - /v3/orders request attribute items of type DID Order Item Attributes can have billing_cycles_count.
50
+ - /v3/dids added address_verification relationship.
51
+ - callbacks attributes added to /v3/orders, /v3/cdr_exports.
52
+ - /v3/proof_types read endpoints being added.
53
+ - /v3/supporting_document_templates read endpoints being added.
54
+ - /v3/requirements read endpoints being added.
55
+ - /v3/identities read, write, and delete endpoints being added.
56
+ - /v3/addresses read, write, and delete endpoints being added.
57
+ - /v3/encrypted_files read, write, and delete endpoints being added.
58
+ - /v3/proofs write, delete endpoint being added.
59
+ - /v3/permanent_supporting_documents write, delete endpoint being added.
60
+ - /v3/address_verifications read and write endpoints being added.
61
+ - /v3/requirement_validations write endpoint being added.
12
62
 
13
63
  ### Bugfixes
14
64
  - fix order purchase when activesupport 6.X.X is used.
15
- - fix BigDecimal 2 support for ruby 2.7+.
16
65
 
17
66
  ## [1.3.0] - 2018-09-03
18
67
  ### Changes
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
@@ -15,7 +16,7 @@ gem 'pry'
15
16
  gem 'byebug'
16
17
  gem 'awesome_print'
17
18
  gem 'http_logger'
18
- gem 'rubocop', '~> 1.9'
19
+ gem 'rubocop', '~> 1.28.2'
19
20
  gem 'rubocop-performance'
20
21
  gem 'rubocop-rake'
21
22
  gem 'rubocop-rspec'
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  Ruby client for DIDWW API v3.
2
2
 
3
- [![Build Status](https://github.com/didww/didww-v3-ruby/workflows/tests/badge.svg?branch=master)](https://github.com/didww/didww-v3-ruby/actions)
3
+ ![Tests](https://github.com/didww/didww-v3-ruby/workflows/Tests/badge.svg)
4
+ [![Gem Version](https://badge.fury.io/rb/didww-v3.svg)](https://badge.fury.io/rb/didww-v3)
4
5
 
5
6
  About DIDWW API v3
6
7
  -----
@@ -11,6 +12,14 @@ The DIDWW API v3 is a fully compliant implementation of the [JSON API specificat
11
12
 
12
13
  Read more https://doc.didww.com/api
13
14
 
15
+ Gem Versions **4.X.X** and branch [master](https://github.com/didww/didww-v3-ruby) are intended to use with DIDWW API 3 version [2022-05-10](https://doc.didww.com/api3/2022-05-10/index.html).
16
+
17
+ Gem Versions **3.X.X** and branch [release-3](https://github.com/didww/didww-v3-ruby/tree/release-3) are intended to use with DIDWW API 3 version [2021-12-15](https://doc.didww.com/api3/2021-12-15/index.html).
18
+
19
+ Gem Versions **2.X.X** and branch [release-2](https://github.com/didww/didww-v3-ruby/tree/release-2) are intended to use with DIDWW API 3 version [2021-04-19](https://doc.didww.com/api3/2021-04-19/index.html).
20
+
21
+ Gem Versions **1.X.X** and branch [release-1](https://github.com/didww/didww-v3-ruby/tree/release-1) are intended to use with DIDWW API 3 version [2017-09-18](https://doc.didww.com/api3/2017-09-18/index.html).
22
+
14
23
  ## Installation
15
24
 
16
25
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'bundler/gem_tasks'
2
3
  require 'rspec/core/rake_task'
3
4
  require 'bundler/audit/task'
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'didww'
data/didww-v3.gemspec CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -23,7 +24,8 @@ Gem::Specification.new do |spec|
23
24
 
24
25
  spec.add_dependency 'activesupport'
25
26
  spec.add_dependency 'faraday'
26
- spec.add_dependency 'json_api_client', '1.5.3'
27
+ spec.add_dependency 'json_api_client', '1.18.0'
27
28
  spec.add_dependency 'http'
28
29
  spec.add_dependency 'down'
30
+ spec.add_dependency 'openssl-oaep'
29
31
  end
@@ -1,11 +1,12 @@
1
+ # frozen_string_literal: true
1
2
  module DIDWW
2
3
  # :nodoc:
3
- class Middleware < Faraday::Middleware
4
+ class BaseMiddleware < Faraday::Middleware
4
5
  def call(request_env)
5
6
  headers = {}
6
- headers['Content-Type'] = 'application/vnd.api+json'
7
- headers['Api-Key'] = DIDWW::Client.api_key
8
- headers['User-Agent'] = "didww-v3 Ruby gem v#{VERSION}"
7
+ headers['Api-Key'] = DIDWW::Client.api_key
8
+ headers['User-Agent'] = "didww-v3 Ruby gem v#{VERSION}"
9
+ headers['x-didww-api-version'] = DIDWW::Client.api_version unless DIDWW::Client.api_version.blank?
9
10
 
10
11
  request_env[:request_headers].merge!(headers)
11
12
  request_env.url.host = URI(DIDWW::Client.api_base_url).host
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DIDWW
4
+ module Callback
5
+ module CONST
6
+ CALLBACK_METHOD_POST = 'POST'
7
+ CALLBACK_METHOD_GET = 'GET'
8
+ CALLBACK_METHODS = [
9
+ CALLBACK_METHOD_GET,
10
+ CALLBACK_METHOD_POST
11
+ ].freeze
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+ require 'openssl'
3
+
4
+ module DIDWW
5
+ module Callback
6
+ # @example
7
+ # validator = DIDWW::Callback::RequestValidator.new(api_key)
8
+ # uri = request.original_url
9
+ # if request.post?
10
+ # # Collect all parameters passed from DIDWW.
11
+ # params = env['rack.request.form_hash']
12
+ # else
13
+ # params = env['rack.request.query_hash']
14
+ # end
15
+ #
16
+ # signature = env['HTTP_X_DIDWW_SIGNATURE']
17
+ # validator.validate(uri, params, signature) #=> true if the request is from DIDWW
18
+ # # or with rails
19
+ class RequestValidator
20
+ DIGEST_ALGO = 'SHA1'
21
+ HEADER = 'X-DIDWW-Signature'
22
+
23
+ def initialize(api_key)
24
+ @api_key = api_key
25
+ end
26
+
27
+ # @param url [String]
28
+ # @param payload [Hash]
29
+ # @param signature [String]
30
+ # @return [Boolean] whether signature valid or not.
31
+ def validate(url, payload, signature)
32
+ return false if signature.blank?
33
+
34
+ signature == valid_signature(url, payload)
35
+ end
36
+
37
+ private
38
+
39
+ # @param url [String]
40
+ # @param payload [Hash,Array]
41
+ # @return [String] generated signature in URL safe format.
42
+ def valid_signature(url, payload)
43
+ data = normalize_url(url) + normalize_payload(payload)
44
+ OpenSSL::HMAC.hexdigest(DIGEST_ALGO, @api_key, data)
45
+ end
46
+
47
+ # @param payload [Hash,Array]
48
+ # @return [String] normalized payload.
49
+ def normalize_payload(payload)
50
+ if payload.is_a?(Hash)
51
+ payload.sort.join
52
+ else
53
+ payload.map { |item| item.sort.join }.join
54
+ end
55
+ end
56
+
57
+ # @return [String] normalized URL.
58
+ def normalize_url(url)
59
+ parsed_url = URI ensure_protocol_url(url)
60
+ url = "#{parsed_url.scheme || 'http'}://"
61
+ url += "#{parsed_url.userinfo}@" if parsed_url.userinfo
62
+ url += "#{parsed_url.host}:#{parsed_url.port || parsed_url.default_port}#{parsed_url.path}"
63
+ url += "?#{parsed_url.query}" if parsed_url.query
64
+ url += "##{parsed_url.fragment}" if parsed_url.fragment
65
+ url
66
+ end
67
+
68
+ def ensure_protocol_url(url)
69
+ if url[%r{\A[a-zA-Z]+://}i]
70
+ url
71
+ else
72
+ 'http://' + url
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
data/lib/didww/client.rb CHANGED
@@ -1,27 +1,19 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_support/core_ext/module/attribute_accessors'
3
+ require 'active_support/core_ext/object/blank'
2
4
  require 'json_api_client'
3
5
 
4
- require 'didww/resources/base'
5
-
6
- # Fixes BigDecimal 2 support for ruby 2.7+ without introducing json_api_client breaking changes.
7
- # https://github.com/JsonApiClient/json_api_client/commit/ac372b8bab3b71bb0aa5c4dcc6ced1d9c3fe8d14
8
- class JsonApiClient::Schema::Types::FixedDecimal
9
- def self.cast(value, _)
10
- BigDecimal(value)
11
- end
12
- end
13
-
14
- JsonApiClient::Schema.register decimal: JsonApiClient::Schema::Types::FixedDecimal
6
+ require 'didww/resource/base'
15
7
 
16
8
  module DIDWW
17
9
  module Client
18
10
  BASE_URLS = {
19
11
  sandbox: 'https://sandbox-api.didww.com/v3/' .freeze,
20
- production: 'https://api.didww.com/v3/' .freeze
12
+ production: 'https://sandbox-api.didww.com/v3/' .freeze
21
13
  }.freeze
22
14
  DEFAULT_MODE = :sandbox
23
15
 
24
- mattr_accessor :api_key, :api_mode, :http_verbose
16
+ mattr_accessor :api_key, :api_mode, :http_verbose, :api_version
25
17
 
26
18
  class << self
27
19
  def configure
@@ -39,8 +31,20 @@ module DIDWW
39
31
  @@api_key
40
32
  end
41
33
 
34
+ def api_version
35
+ @@api_version
36
+ end
37
+
38
+ def with_api_version(api_version)
39
+ old_api_version = self.api_version
40
+ self.api_version = api_version
41
+ yield
42
+ ensure
43
+ self.api_version = old_api_version
44
+ end
45
+
42
46
  def api_base_url
43
- BASE_URLS[api_mode]
47
+ ENV['DIDWW_API_URL'].presence || BASE_URLS[api_mode]
44
48
  end
45
49
 
46
50
  def balance
@@ -51,8 +55,8 @@ module DIDWW
51
55
  Resource::CapacityPool
52
56
  end
53
57
 
54
- def cdr_exports
55
- Resource::CdrExport
58
+ def exports
59
+ Resource::Export
56
60
  end
57
61
 
58
62
  def shared_capacity_groups
@@ -91,12 +95,16 @@ module DIDWW
91
95
  Resource::Region
92
96
  end
93
97
 
94
- def trunk_groups
95
- Resource::TrunkGroup
98
+ def voice_in_trunk_groups
99
+ Resource::VoiceInTrunkGroup
100
+ end
101
+
102
+ def voice_in_trunks
103
+ Resource::VoiceInTrunk
96
104
  end
97
105
 
98
- def trunks
99
- Resource::Trunk
106
+ def voice_out_trunks
107
+ Resource::VoiceOutTrunk
100
108
  end
101
109
 
102
110
  def available_dids
@@ -107,6 +115,38 @@ module DIDWW
107
115
  Resource::DidReservation
108
116
  end
109
117
 
118
+ def requirements
119
+ Resource::Requirement
120
+ end
121
+
122
+ def identities
123
+ Resource::Identity
124
+ end
125
+
126
+ def proofs
127
+ Resource::Proof
128
+ end
129
+
130
+ def addresses
131
+ Resource::Address
132
+ end
133
+
134
+ def permanent_supporting_documents
135
+ Resource::PermanentSupportingDocument
136
+ end
137
+
138
+ def encrypted_file
139
+ Resource::EncryptedFile
140
+ end
141
+
142
+ def address_verifications
143
+ Resource::AddressVerification
144
+ end
145
+
146
+ def requirement_validation
147
+ Resource::RequirementValidation
148
+ end
149
+
110
150
  def api_mode=(arg)
111
151
  unless BASE_URLS.keys.include?(arg)
112
152
  raise ArgumentError.new("Mode should be in #{BASE_URLS.keys} (given '#{arg}').")
@@ -114,6 +154,10 @@ module DIDWW
114
154
  @@api_mode = arg
115
155
  end
116
156
 
157
+ def nanpa_prefixes
158
+ Resource::NanpaPrefix
159
+ end
160
+
117
161
  private
118
162
 
119
163
  def http_verbose?
@@ -124,31 +168,46 @@ module DIDWW
124
168
  DIDWW::Resource::Base.site = api_base_url
125
169
  DIDWW::Resource::Base.connection do |connection|
126
170
  connection.use Faraday::Response::Logger if http_verbose?
127
- connection.use DIDWW::Middleware
171
+ connection.use DIDWW::JsonapiMiddleware
128
172
  end
129
173
  JsonApiClient::Paginating::Paginator.page_param = 'number'
130
174
  JsonApiClient::Paginating::Paginator.per_page_param = 'size'
131
175
  end
132
176
 
133
177
  def require_didww_resources
134
- require 'didww/resources/balance'
135
- require 'didww/resources/capacity_pool'
136
- require 'didww/resources/cdr_export'
137
- require 'didww/resources/shared_capacity_group'
138
- require 'didww/resources/city'
139
- require 'didww/resources/country'
140
- require 'didww/resources/did_group_type'
141
- require 'didww/resources/did_group'
142
- require 'didww/resources/did'
143
- require 'didww/resources/order'
144
- require 'didww/resources/pop'
145
- require 'didww/resources/qty_based_pricing'
146
- require 'didww/resources/region'
147
- require 'didww/resources/stock_keeping_unit'
148
- require 'didww/resources/trunk_group'
149
- require 'didww/resources/trunk'
150
- require 'didww/resources/available_did'
151
- require 'didww/resources/did_reservation'
178
+ require 'didww/resource/balance'
179
+ require 'didww/resource/capacity_pool'
180
+ require 'didww/resource/export'
181
+ require 'didww/resource/shared_capacity_group'
182
+ require 'didww/resource/city'
183
+ require 'didww/resource/country'
184
+ require 'didww/resource/did_group_type'
185
+ require 'didww/resource/did_group'
186
+ require 'didww/resource/did'
187
+ require 'didww/resource/order'
188
+ require 'didww/resource/pop'
189
+ require 'didww/resource/qty_based_pricing'
190
+ require 'didww/resource/region'
191
+ require 'didww/resource/stock_keeping_unit'
192
+ require 'didww/resource/voice_in_trunk_group'
193
+ require 'didww/resource/voice_in_trunk'
194
+ require 'didww/resource/available_did'
195
+ require 'didww/resource/did_reservation'
196
+ require 'didww/resource/requirement'
197
+ require 'didww/resource/proof_type'
198
+ require 'didww/resource/supporting_document_template'
199
+ require 'didww/resource/identity'
200
+ require 'didww/resource/proof'
201
+ require 'didww/resource/address'
202
+ require 'didww/resource/permanent_supporting_document'
203
+ require 'didww/resource/encrypted_file'
204
+ require 'didww/resource/address_verification'
205
+ require 'didww/resource/requirement_validation'
206
+ require 'didww/resource/public_key'
207
+ require 'didww/resource/area'
208
+ require 'didww/resource/voice_out_trunk'
209
+ require 'didww/resource/voice_out_trunk_regenerate_credential'
210
+ require 'didww/resource/nanpa_prefix'
152
211
  end
153
212
 
154
213
  end
@@ -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
@@ -87,5 +88,3 @@ module DIDWW
87
88
  end
88
89
  end
89
90
  end
90
-
91
- JsonApiClient::Schema.register complex_object: DIDWW::ComplexObject::Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module DIDWW
2
3
  module ComplexObject
3
4
  class CapacityOrderItem < Base
@@ -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