didww-v3 1.3.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) 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 +53 -0
  5. data/Gemfile +20 -0
  6. data/README.md +7 -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/request_validator.rb +68 -0
  12. data/lib/didww/client.rb +61 -3
  13. data/lib/didww/complex_objects/base.rb +5 -1
  14. data/lib/didww/complex_objects/capacity_order_item.rb +1 -0
  15. data/lib/didww/complex_objects/cdr_export_filter.rb +1 -0
  16. data/lib/didww/complex_objects/configurations/base.rb +1 -0
  17. data/lib/didww/complex_objects/configurations/const.rb +1 -0
  18. data/lib/didww/complex_objects/configurations/h323_configuration.rb +1 -0
  19. data/lib/didww/complex_objects/configurations/iax2_configuration.rb +1 -0
  20. data/lib/didww/complex_objects/configurations/pstn_configuration.rb +1 -0
  21. data/lib/didww/complex_objects/configurations/sip_configuration.rb +1 -0
  22. data/lib/didww/complex_objects/configurations.rb +1 -0
  23. data/lib/didww/complex_objects/did_order_item.rb +14 -12
  24. data/lib/didww/encrypt.rb +101 -0
  25. data/lib/didww/jsonapi_middleware.rb +21 -0
  26. data/lib/didww/resources/address.rb +37 -0
  27. data/lib/didww/resources/address_verification.rb +56 -0
  28. data/lib/didww/resources/area.rb +12 -0
  29. data/lib/didww/resources/available_did.rb +1 -0
  30. data/lib/didww/resources/balance.rb +1 -0
  31. data/lib/didww/resources/base.rb +2 -1
  32. data/lib/didww/resources/capacity_pool.rb +1 -0
  33. data/lib/didww/resources/cdr_export.rb +12 -1
  34. data/lib/didww/resources/city.rb +5 -0
  35. data/lib/didww/resources/country.rb +1 -0
  36. data/lib/didww/resources/did.rb +3 -1
  37. data/lib/didww/resources/did_group.rb +1 -4
  38. data/lib/didww/resources/did_group_type.rb +1 -0
  39. data/lib/didww/resources/did_reservation.rb +1 -0
  40. data/lib/didww/resources/encrypted_file.rb +58 -0
  41. data/lib/didww/resources/identity.rb +78 -0
  42. data/lib/didww/resources/order.rb +9 -0
  43. data/lib/didww/resources/permanent_supporting_document.rb +15 -0
  44. data/lib/didww/resources/pop.rb +1 -0
  45. data/lib/didww/resources/proof.rb +19 -0
  46. data/lib/didww/resources/proof_type.rb +14 -0
  47. data/lib/didww/resources/public_key.rb +12 -0
  48. data/lib/didww/resources/qty_based_pricing.rb +1 -0
  49. data/lib/didww/resources/region.rb +1 -0
  50. data/lib/didww/resources/requirement.rb +61 -0
  51. data/lib/didww/resources/requirement_validation.rb +10 -0
  52. data/lib/didww/resources/shared_capacity_group.rb +1 -0
  53. data/lib/didww/resources/stock_keeping_unit.rb +1 -0
  54. data/lib/didww/resources/supporting_document_template.rb +14 -0
  55. data/lib/didww/resources/trunk/const.rb +1 -0
  56. data/lib/didww/resources/trunk.rb +1 -0
  57. data/lib/didww/resources/trunk_group.rb +1 -0
  58. data/lib/didww/version.rb +2 -1
  59. data/lib/didww.rb +5 -1
  60. metadata +32 -157
  61. data/.travis.yml +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f190a01670c1359b390201bc4cdd569f500ae20ed97ad5438f81903e55c442f
4
- data.tar.gz: fd332a3bc4bfe59ec7d12bfd60b706b2206bfdd2a77216a551405125231f1d1f
3
+ metadata.gz: 9d736e9893b21ef96ef76993d6bb3da3e47c1dbb760edcc6ea13d0cf86d5e847
4
+ data.tar.gz: 9d641935ce36af938ea6641b7488835535ef4a01f6464b5c90f667dafac953c3
5
5
  SHA512:
6
- metadata.gz: b5aacd2fc1d81c7ad726a46ceea8837f64ff1469b851b164b1d4a34ea131b8fff47eecba16e4b477b615029a39a911df22f985f2a185aa6d2b95a559114866d7
7
- data.tar.gz: 1665800d20ba7bca592b52cef5ad1aea3398fa7be9d045169cad71bf9b030f51f147c77ef1d373c582765a0c38ec3da318ae38e3dee9a822f4559ef815f64448
6
+ metadata.gz: b2cef4993cda70bd45a3a1efd960ab26d9ba603de9a10c246c537ccdbbb3506e923f1628643fabcefcc7be8ca1f9a6a93342b996e6233b9eadadc77818d766fe
7
+ data.tar.gz: de556881b793c412ea2fb486bacd00f89a3c07ad3902e755f5a4140e2eb0fda10f1b748ea719ce9968e87e476797bed8b28ce3b032f1e107ed457946235f303f
@@ -0,0 +1,27 @@
1
+ name: Tests
2
+ on:
3
+ pull_request:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ matrix:
13
+ ruby: [ '2.5', '2.6', '2.7' ]
14
+ rails: [ '~> 5.0', '~> 6.0' ]
15
+ name: Tests with Ruby ${{ matrix.ruby }} Activesupport ${{ matrix.rails }}
16
+ env:
17
+ RAILS_VERSION: ${{ matrix.rails }}
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - uses: actions/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ - name: Run tests
24
+ run: |
25
+ gem install bundler -v 2.2.7
26
+ bundle install
27
+ bundle exec rake
data/.rubocop.yml CHANGED
@@ -1,18 +1,18 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rake
4
+ - rubocop-rspec
5
+
1
6
  AllCops:
2
- TargetRubyVersion: 2.4
7
+ TargetRubyVersion: 2.5
3
8
  DisplayCopNames: true
4
9
  DisabledByDefault: true
5
10
 
6
11
  Exclude:
7
12
  - db/migrate/**/*
8
13
 
9
- Include:
10
- - "**/*.rake"
11
- - "**/Gemfile"
12
- - "**/Rakefile"
13
-
14
14
  ##################### Layout ##################################
15
- Layout/TrailingBlankLines:
15
+ Layout/TrailingEmptyLines:
16
16
  Enabled: true
17
17
 
18
18
  Layout/TrailingWhitespace:
@@ -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 ==`.
@@ -68,7 +71,7 @@ Performance/EndWith:
68
71
  Enabled: true
69
72
 
70
73
  # Use `strip` instead of `lstrip.rstrip`.
71
- Performance/LstripRstrip:
74
+ Style/Strip:
72
75
  Enabled: true
73
76
 
74
77
  # Use `Range#cover?` instead of `Range#include?`.
@@ -91,7 +94,7 @@ Performance/RedundantMerge:
91
94
  Enabled: true
92
95
 
93
96
  # Use `sort` instead of `sort_by { |x| x }`.
94
- Performance/RedundantSortBy:
97
+ Style/RedundantSortBy:
95
98
  Enabled: true
96
99
 
97
100
  # Use `start_with?` instead of a regex match anchored to the beginning of a
@@ -138,7 +141,7 @@ Lint/AssignmentInCondition:
138
141
  Enabled: true
139
142
 
140
143
  # Align block ends correctly.
141
- Lint/BlockAlignment:
144
+ Layout/BlockAlignment:
142
145
  Enabled: true
143
146
 
144
147
  # Default values in optional keyword arguments and optional ordinal arguments
@@ -147,7 +150,7 @@ Lint/CircularArgumentReference:
147
150
  Enabled: true
148
151
 
149
152
  # Checks for condition placed in a confusing position relative to the keyword.
150
- Lint/ConditionPosition:
153
+ Layout/ConditionPosition:
151
154
  Enabled: true
152
155
 
153
156
  # Check for debugger calls.
@@ -155,7 +158,7 @@ Lint/Debugger:
155
158
  Enabled: true
156
159
 
157
160
  # Align ends corresponding to defs correctly.
158
- Lint/DefEndAlignment:
161
+ Layout/DefEndAlignment:
159
162
  Enabled: true
160
163
 
161
164
  # Check for deprecated class method calls.
@@ -179,11 +182,11 @@ Lint/EmptyWhen:
179
182
  Enabled: true
180
183
 
181
184
  # Align ends correctly.
182
- Lint/EndAlignment:
185
+ Layout/EndAlignment:
183
186
  Enabled: true
184
187
 
185
188
  # END blocks should not be placed inside method definitions.
186
- Lint/EndInMethod:
189
+ Style/EndBlock:
187
190
  Enabled: true
188
191
 
189
192
  # Do not use return in an ensure block.
@@ -199,7 +202,7 @@ Lint/FormatParameterMismatch:
199
202
  Enabled: true
200
203
 
201
204
  # This cop checks for *rescue* blocks with no body.
202
- Lint/HandleExceptions:
205
+ Lint/SuppressedException:
203
206
  Enabled: true
204
207
 
205
208
  # Checks for adjacent string literals on the same line, which could better be
@@ -255,7 +258,7 @@ Lint/ShadowingOuterLocalVariable:
255
258
  Enabled: false
256
259
 
257
260
  # Checks for Object#to_s usage in string interpolation.
258
- Lint/StringConversionInInterpolation:
261
+ Lint/RedundantStringCoercion:
259
262
  Enabled: false
260
263
 
261
264
  # Do not use prefix `_` for a variable that is used.
@@ -269,11 +272,11 @@ Lint/UnifiedInteger:
269
272
  # Checks for rubocop:disable comments that can be removed.
270
273
  # Note: this cop is not disabled when disabling all cops.
271
274
  # It must be explicitly disabled.
272
- Lint/UnneededDisable:
275
+ Lint/RedundantCopDisableDirective:
273
276
  Enabled: false
274
277
 
275
278
  # This cop checks for unneeded usages of splat expansion
276
- Lint/UnneededSplatExpansion:
279
+ Lint/RedundantSplatExpansion:
277
280
  Enabled: false
278
281
 
279
282
  # Unreachable code.
@@ -297,7 +300,7 @@ Lint/UselessAssignment:
297
300
  Enabled: false
298
301
 
299
302
  # Checks for comparison of something with itself.
300
- Lint/UselessComparison:
303
+ Lint/BinaryOperatorWithIdenticalOperands:
301
304
  Enabled: false
302
305
 
303
306
  # Checks for useless `else` in `begin..end` without `rescue`.
data/CHANGELOG.md ADDED
@@ -0,0 +1,53 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [2.0.0] - 2021-10-26
8
+ ### Breaking Changes
9
+ - upgrade `json_api_client` version to `1.18.0` [#9](https://github.com/didww/didww-v3-ruby/pull/9)
10
+ Handling of 4XX responses was changed - it now raises JsonApiClient::Errors::ClientError with `detail` as error message instead of adding it into base errors.
11
+ - /v3/dids in request and response attributes pending_removal being removed in favor of billing_cycles_count.
12
+ - /v3/did_groups restriction message removed in favor of requirements relationship.
13
+
14
+ ### Changes
15
+ - 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)
16
+ - use rubocop 1.9.X version [#7](https://github.com/didww/didww-v3-ruby/pull/7)
17
+ - add bundle-audit [#7](https://github.com/didww/didww-v3-ruby/pull/7)
18
+ - /v3/orders request attribute items of type DID Order Item Attributes can have billing_cycles_count.
19
+ - /v3/dids added address_verification relationship.
20
+ - callbacks attributes added to /v3/orders, /v3/cdr_exports.
21
+ - /v3/proof_types read endpoints being added.
22
+ - /v3/supporting_document_templates read endpoints being added.
23
+ - /v3/requirements read endpoints being added.
24
+ - /v3/identities read, write, and delete endpoints being added.
25
+ - /v3/addresses read, write, and delete endpoints being added.
26
+ - /v3/encrypted_files read, write, and delete endpoints being added.
27
+ - /v3/proofs write, delete endpoint being added.
28
+ - /v3/permanent_supporting_documents write, delete endpoint being added.
29
+ - /v3/address_verifications read and write endpoints being added.
30
+ - /v3/requirement_validations write endpoint being added.
31
+
32
+ ### Bugfixes
33
+ - fix order purchase when activesupport 6.X.X is used.
34
+
35
+ ## [1.3.0] - 2018-09-03
36
+ ### Changes
37
+ - Add Capacity Pool and Shared Capacity Group resources
38
+ - Add Capacity Pool and Shared Capacity Group relationships to DID
39
+ - Add Quantity based pricings and Capacity type Order Item
40
+
41
+ ## [1.2.0] - 2018-04-25
42
+ ### Changes
43
+ - add number selection feature
44
+
45
+ ## [1.1.0] - 2018-03-05
46
+ ### Changes
47
+ - add Pop resource
48
+ - Remove old trunk.preferred_server property
49
+ - Add max_transfers and max_30x_redirects to sip_configurations
50
+ - Added custom user-agent header
51
+
52
+ ## [1.0.0] - 2017-12-05
53
+ - initial release
data/Gemfile CHANGED
@@ -1,6 +1,26 @@
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}" }
4
5
 
5
6
  # Specify your gem's dependencies in didww-v3.gemspec
6
7
  gemspec
8
+
9
+ if ENV['RAILS_VERSION']
10
+ gem 'activesupport', ENV['RAILS_VERSION'], require: false
11
+ end
12
+
13
+ gem 'rake', '~> 12.0'
14
+ gem 'rspec', '~> 3.0'
15
+ gem 'pry'
16
+ gem 'byebug'
17
+ gem 'awesome_print'
18
+ gem 'http_logger'
19
+ gem 'rubocop', '~> 1.9'
20
+ gem 'rubocop-performance'
21
+ gem 'rubocop-rake'
22
+ gem 'rubocop-rspec'
23
+ gem 'simplecov'
24
+ gem 'smart_rspec'
25
+ gem 'webmock'
26
+ gem 'bundler-audit'
data/README.md CHANGED
@@ -1,14 +1,20 @@
1
1
  Ruby client for DIDWW API v3.
2
2
 
3
+ ![Tests](https://github.com/didww/didww-v3-ruby/workflows/Tests/badge.svg)
4
+
3
5
  About DIDWW API v3
4
6
  -----
5
7
 
6
- The DIDWW API provides a simple yet powerful interface that allows you to fully integrate your own applications with DIDWW services. An extensive set of actions may be performed using this API, such as ordering and configuring phone numbers, setting capacity, creating SIP trunks and retrieving CDRs and other operational data. As such, this interface is the ideal tool for building alternative dashboards, developing mobile applications and automating front and back-end applications.
8
+ The DIDWW API provides a simple yet powerful interface that allows you to fully integrate your own applications with DIDWW services. An extensive set of actions may be performed using this API, such as ordering and configuring phone numbers, setting capacity, creating SIP trunks and retrieving CDRs and other operational data.
7
9
 
8
10
  The DIDWW API v3 is a fully compliant implementation of the [JSON API specification](http://jsonapi.org/format/).
9
11
 
10
12
  Read more https://doc.didww.com/api
11
13
 
14
+ Gem Versions **2.X.X** are intended to use with DIDWW API 3 version [2021-04-19](https://doc.didww.com/api3/2021-04-19/index.html).
15
+
16
+ Gem Versions **1.X.X** are intended to use with DIDWW API 3 version [2017-09-18](https://doc.didww.com/api3/2017-09-18/index.html).
17
+
12
18
  ## Installation
13
19
 
14
20
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -1,6 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  require 'bundler/gem_tasks'
2
3
  require 'rspec/core/rake_task'
4
+ require 'bundler/audit/task'
5
+ require 'rubocop/rake_task'
3
6
 
4
7
  RSpec::Core::RakeTask.new(:spec)
8
+ Bundler::Audit::Task.new
9
+ RuboCop::RakeTask.new
5
10
 
6
- task default: :spec
11
+ task default: ['bundle:audit', :rubocop, :spec]
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)
@@ -21,26 +22,10 @@ Gem::Specification.new do |spec|
21
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
23
  spec.require_paths = ['lib']
23
24
 
24
- spec.add_development_dependency 'bundler', '~> 1.16'
25
- spec.add_development_dependency 'rake', '~> 10.0'
26
- spec.add_development_dependency 'rspec', '~> 3.0'
27
-
28
- # development
29
- spec.add_development_dependency 'pry'
30
- spec.add_development_dependency 'byebug'
31
- spec.add_development_dependency 'awesome_print'
32
- spec.add_development_dependency 'http_logger'
33
- spec.add_development_dependency 'rubocop'
34
-
35
- # test
36
- spec.add_development_dependency 'simplecov'
37
- spec.add_development_dependency 'smart_rspec'
38
- spec.add_development_dependency 'webmock'
39
-
40
25
  spec.add_dependency 'activesupport'
41
26
  spec.add_dependency 'faraday'
42
- spec.add_dependency 'json_api_client'
27
+ spec.add_dependency 'json_api_client', '1.18.0'
43
28
  spec.add_dependency 'http'
44
29
  spec.add_dependency 'down'
45
-
30
+ spec.add_dependency 'openssl-oaep'
46
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,68 @@
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]
41
+ # @return [String] generated signature in URL safe format.
42
+ def valid_signature(url, payload)
43
+ normalized_url = normalize_url(url)
44
+ data = normalized_url + payload.sort.join
45
+ OpenSSL::HMAC.hexdigest(DIGEST_ALGO, @api_key, data)
46
+ end
47
+
48
+ # @return [String] normalized URL.
49
+ def normalize_url(url)
50
+ parsed_url = URI ensure_protocol_url(url)
51
+ url = "#{parsed_url.scheme || 'http'}://"
52
+ url += "#{parsed_url.userinfo}@" if parsed_url.userinfo
53
+ url += "#{parsed_url.host}:#{parsed_url.port || parsed_url.default_port}#{parsed_url.path}"
54
+ url += "?#{parsed_url.query}" if parsed_url.query
55
+ url += "##{parsed_url.fragment}" if parsed_url.fragment
56
+ url
57
+ end
58
+
59
+ def ensure_protocol_url(url)
60
+ if url[%r{\A[a-zA-Z]+://}i]
61
+ url
62
+ else
63
+ 'http://' + url
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
data/lib/didww/client.rb CHANGED
@@ -1,4 +1,6 @@
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
6
  require 'didww/resources/base'
@@ -11,7 +13,7 @@ module DIDWW
11
13
  }.freeze
12
14
  DEFAULT_MODE = :sandbox
13
15
 
14
- mattr_accessor :api_key, :api_mode, :http_verbose
16
+ mattr_accessor :api_key, :api_mode, :http_verbose, :api_version
15
17
 
16
18
  class << self
17
19
  def configure
@@ -29,8 +31,20 @@ module DIDWW
29
31
  @@api_key
30
32
  end
31
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
+
32
46
  def api_base_url
33
- BASE_URLS[api_mode]
47
+ ENV['DIDWW_API_URL'].presence || BASE_URLS[api_mode]
34
48
  end
35
49
 
36
50
  def balance
@@ -97,6 +111,38 @@ module DIDWW
97
111
  Resource::DidReservation
98
112
  end
99
113
 
114
+ def requirements
115
+ Resource::Requirement
116
+ end
117
+
118
+ def identities
119
+ Resource::Identity
120
+ end
121
+
122
+ def proofs
123
+ Resource::Proof
124
+ end
125
+
126
+ def addresses
127
+ Resource::Address
128
+ end
129
+
130
+ def permanent_supporting_documents
131
+ Resource::PermanentSupportingDocument
132
+ end
133
+
134
+ def encrypted_file
135
+ Resource::EncryptedFile
136
+ end
137
+
138
+ def address_verifications
139
+ Resource::AddressVerification
140
+ end
141
+
142
+ def requirement_validation
143
+ Resource::RequirementValidation
144
+ end
145
+
100
146
  def api_mode=(arg)
101
147
  unless BASE_URLS.keys.include?(arg)
102
148
  raise ArgumentError.new("Mode should be in #{BASE_URLS.keys} (given '#{arg}').")
@@ -114,7 +160,7 @@ module DIDWW
114
160
  DIDWW::Resource::Base.site = api_base_url
115
161
  DIDWW::Resource::Base.connection do |connection|
116
162
  connection.use Faraday::Response::Logger if http_verbose?
117
- connection.use DIDWW::Middleware
163
+ connection.use DIDWW::JsonapiMiddleware
118
164
  end
119
165
  JsonApiClient::Paginating::Paginator.page_param = 'number'
120
166
  JsonApiClient::Paginating::Paginator.per_page_param = 'size'
@@ -139,6 +185,18 @@ module DIDWW
139
185
  require 'didww/resources/trunk'
140
186
  require 'didww/resources/available_did'
141
187
  require 'didww/resources/did_reservation'
188
+ require 'didww/resources/requirement'
189
+ require 'didww/resources/proof_type'
190
+ require 'didww/resources/supporting_document_template'
191
+ require 'didww/resources/identity'
192
+ require 'didww/resources/proof'
193
+ require 'didww/resources/address'
194
+ require 'didww/resources/permanent_supporting_document'
195
+ require 'didww/resources/encrypted_file'
196
+ require 'didww/resources/address_verification'
197
+ require 'didww/resources/requirement_validation'
198
+ require 'didww/resources/public_key'
199
+ require 'didww/resources/area'
142
200
  end
143
201
 
144
202
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'json_api_client/schema'
2
3
 
3
4
  module DIDWW
@@ -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
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module DIDWW
2
3
  module ComplexObject
3
4
  class CapacityOrderItem < Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'json_api_client/schema'
2
3
 
3
4
  module DIDWW
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'didww/complex_objects/configurations/const'
2
3
 
3
4
  module DIDWW
@@ -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
@@ -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
  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,21 +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 :nrc, type: :decimal
14
- property :mrc, type: :decimal
15
- property :propated_mrc, type: :boolean
16
- property :billed_from, type: :string
17
- property :billed_to, type: :string
18
- 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
19
21
  end
20
22
  end
21
23
  end