didww-v3 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/tests.yml +27 -0
- data/.rubocop.yml +22 -19
- data/CHANGELOG.md +53 -0
- data/Gemfile +20 -0
- data/README.md +7 -1
- data/Rakefile +6 -1
- data/bin/console +1 -0
- data/didww-v3.gemspec +3 -18
- data/lib/didww/{middleware.rb → base_middleware.rb} +5 -3
- data/lib/didww/callback/request_validator.rb +68 -0
- data/lib/didww/client.rb +91 -7
- data/lib/didww/complex_objects/base.rb +9 -6
- data/lib/didww/complex_objects/capacity_order_item.rb +17 -0
- data/lib/didww/complex_objects/cdr_export_filter.rb +1 -0
- data/lib/didww/complex_objects/configurations/base.rb +1 -0
- data/lib/didww/complex_objects/configurations/const.rb +1 -0
- data/lib/didww/complex_objects/configurations/h323_configuration.rb +1 -0
- data/lib/didww/complex_objects/configurations/iax2_configuration.rb +1 -0
- data/lib/didww/complex_objects/configurations/pstn_configuration.rb +1 -0
- data/lib/didww/complex_objects/configurations/sip_configuration.rb +11 -0
- data/lib/didww/complex_objects/configurations.rb +1 -0
- data/lib/didww/complex_objects/did_order_item.rb +14 -5
- data/lib/didww/encrypt.rb +101 -0
- data/lib/didww/jsonapi_middleware.rb +21 -0
- data/lib/didww/resources/address.rb +37 -0
- data/lib/didww/resources/address_verification.rb +56 -0
- data/lib/didww/resources/area.rb +12 -0
- data/lib/didww/resources/available_did.rb +13 -0
- data/lib/didww/resources/balance.rb +1 -0
- data/lib/didww/resources/base.rb +2 -1
- data/lib/didww/resources/capacity_pool.rb +47 -0
- data/lib/didww/resources/cdr_export.rb +12 -1
- data/lib/didww/resources/city.rb +5 -0
- data/lib/didww/resources/country.rb +1 -0
- data/lib/didww/resources/did.rb +9 -1
- data/lib/didww/resources/did_group.rb +5 -4
- data/lib/didww/resources/did_group_type.rb +1 -0
- data/lib/didww/resources/did_reservation.rb +17 -0
- data/lib/didww/resources/encrypted_file.rb +58 -0
- data/lib/didww/resources/identity.rb +78 -0
- data/lib/didww/resources/order.rb +10 -0
- data/lib/didww/resources/permanent_supporting_document.rb +15 -0
- data/lib/didww/resources/pop.rb +10 -0
- data/lib/didww/resources/proof.rb +19 -0
- data/lib/didww/resources/proof_type.rb +14 -0
- data/lib/didww/resources/public_key.rb +12 -0
- data/lib/didww/resources/qty_based_pricing.rb +20 -0
- data/lib/didww/resources/region.rb +1 -0
- data/lib/didww/resources/requirement.rb +61 -0
- data/lib/didww/resources/requirement_validation.rb +10 -0
- data/lib/didww/resources/shared_capacity_group.rb +27 -0
- data/lib/didww/resources/stock_keeping_unit.rb +1 -0
- data/lib/didww/resources/supporting_document_template.rb +14 -0
- data/lib/didww/resources/trunk/const.rb +1 -15
- data/lib/didww/resources/trunk.rb +2 -4
- data/lib/didww/resources/trunk_group.rb +1 -0
- data/lib/didww/version.rb +2 -1
- data/lib/didww.rb +5 -1
- metadata +39 -157
- data/.travis.yml +0 -5
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module DIDWW
|
2
3
|
module ComplexObject
|
3
4
|
module Configuration
|
@@ -149,6 +150,14 @@ module DIDWW
|
|
149
150
|
# Nullable: No
|
150
151
|
# Description: The transport layer that will be responsible for the actual transmission of SIP requests and responses (1 - UDP, 2 - TCP)
|
151
152
|
|
153
|
+
property :max_transfers, type: :integer
|
154
|
+
# Nullable: No
|
155
|
+
# Description: Max count of the REFER requests
|
156
|
+
|
157
|
+
property :max_30x_redirects, type: :integer
|
158
|
+
# Nullable: No
|
159
|
+
# Description: Max count of 301/302 redirects
|
160
|
+
|
152
161
|
DEFAULTS = {
|
153
162
|
username: DID_PLACEHOLDER,
|
154
163
|
port: '5060',
|
@@ -161,6 +170,8 @@ module DIDWW
|
|
161
170
|
dns_srv_failover_timer: 2000,
|
162
171
|
rtp_timeout: 30,
|
163
172
|
auth_enabled: false,
|
173
|
+
max_transfers: 0,
|
174
|
+
max_30x_redirects: 0,
|
164
175
|
codec_ids: DEFAULT_CODEC_IDS,
|
165
176
|
rerouting_disconnect_code_ids: DEFAULT_REROUTING_DISCONNECT_CODE_IDS,
|
166
177
|
transport_protocol_id: 1
|
@@ -1,14 +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,
|
6
|
-
property :
|
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
|
7
11
|
|
8
12
|
# returned
|
9
|
-
property :setup_price,
|
10
|
-
property :monthly_price,
|
11
|
-
property :
|
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
|
12
21
|
end
|
13
22
|
end
|
14
23
|
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,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module DIDWW
|
3
|
+
module Resource
|
4
|
+
class AvailableDid < Base
|
5
|
+
has_one :did_group
|
6
|
+
|
7
|
+
property :number, type: :string
|
8
|
+
# Type: String
|
9
|
+
# Description: The actual DID number in the format [country code][area code][subscriber number].
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/didww/resources/base.rb
CHANGED
@@ -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
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'forwardable'
|
2
3
|
require 'didww/complex_objects/cdr_export_filter'
|
3
4
|
require 'down/http'
|
@@ -7,6 +8,8 @@ module DIDWW
|
|
7
8
|
class CdrExport < Base
|
8
9
|
extend Forwardable
|
9
10
|
|
11
|
+
STATUS_COMPLETED = 'Completed'
|
12
|
+
|
10
13
|
property :filters, type: :cdr_export_filter
|
11
14
|
# Type: CDR Export Filters Object
|
12
15
|
# Nullable: No
|
@@ -27,6 +30,14 @@ module DIDWW
|
|
27
30
|
# Nullable: true
|
28
31
|
# Description: url of csv file for downloading. available only when status is "Completed"
|
29
32
|
|
33
|
+
property :callback_url, type: :string
|
34
|
+
# Type: String
|
35
|
+
# Description: valid URI for callbacks
|
36
|
+
|
37
|
+
property :callback_method, type: :string
|
38
|
+
# Type: String
|
39
|
+
# Description: GET or POST
|
40
|
+
|
30
41
|
def_delegators :filters, :year, :month, :did_number, :year=, :month=, :did_number=
|
31
42
|
|
32
43
|
def initialize(params = {})
|
@@ -39,7 +50,7 @@ module DIDWW
|
|
39
50
|
end
|
40
51
|
|
41
52
|
def complete?
|
42
|
-
status ==
|
53
|
+
status == STATUS_COMPLETED
|
43
54
|
end
|
44
55
|
alias_method :completed?, :complete?
|
45
56
|
end
|
data/lib/didww/resources/city.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module DIDWW
|
2
3
|
module Resource
|
3
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
|
+
|
4
9
|
property :name, type: :string
|
5
10
|
# Type: String
|
6
11
|
# Description: City name
|
data/lib/didww/resources/did.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module DIDWW
|
2
3
|
module Resource
|
3
4
|
class Did < Base
|
4
5
|
has_one :trunk
|
5
6
|
has_one :trunk_group
|
7
|
+
has_one :capacity_pool
|
8
|
+
has_one :shared_capacity_group
|
9
|
+
has_one :address_verification
|
6
10
|
|
7
11
|
property :blocked, type: :boolean
|
8
12
|
# Type: Boolean
|
@@ -16,7 +20,7 @@ module DIDWW
|
|
16
20
|
# Type: Boolean
|
17
21
|
# Description: Identifier for terminated DIDs that will be removed from service at the end of the billing cycle.
|
18
22
|
|
19
|
-
property :
|
23
|
+
property :billing_cycles_count, type: :integer
|
20
24
|
# Type: Boolean
|
21
25
|
# Description: Identifier for DIDs that are pending removal from your account.
|
22
26
|
|
@@ -36,6 +40,10 @@ module DIDWW
|
|
36
40
|
# Type: Integer
|
37
41
|
# Description: The number of channels included with this DID.
|
38
42
|
|
43
|
+
property :dedicated_channels_count, type: :integer
|
44
|
+
# Type: Integer
|
45
|
+
# Description: The number of channels included with this DID.
|
46
|
+
|
39
47
|
property :expires_at, type: :time
|
40
48
|
# Type: DateTime
|
41
49
|
# Description: DateTime when the DID expired or will expire. DateTime is in the ISO 8601 format "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", where "SSS" are milliseconds and 'Z' denotes Zulu time (UTC).
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module DIDWW
|
2
3
|
module Resource
|
3
4
|
class DidGroup < Base
|
@@ -49,6 +50,10 @@ module DIDWW
|
|
49
50
|
# TODO
|
50
51
|
# Meta attributes
|
51
52
|
#
|
53
|
+
# :available_dids_enabled
|
54
|
+
# Type: Boolean
|
55
|
+
# Description: Defines if particular DID from this DID group can be ordered via available_dids or did_reservations.
|
56
|
+
#
|
52
57
|
# needs_registration
|
53
58
|
# Type: Boolean
|
54
59
|
# Description: Defines if end-user registration is required for this DID Group.
|
@@ -56,10 +61,6 @@ module DIDWW
|
|
56
61
|
# is_available
|
57
62
|
# Type: Boolean
|
58
63
|
# Description: Defines if numbers in this DID Group are currently in stock.
|
59
|
-
#
|
60
|
-
# restrictions
|
61
|
-
# Type: String
|
62
|
-
# Description: Describes possible restrictions for the DID Group, such as "End User Registration is Required".
|
63
64
|
|
64
65
|
end
|
65
66
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module DIDWW
|
3
|
+
module Resource
|
4
|
+
class DidReservation < Base
|
5
|
+
has_one :available_did
|
6
|
+
|
7
|
+
property :expire_at, type: :time
|
8
|
+
# Type: DateTime
|
9
|
+
# Description: DateTime when the DID reservation expired or will expire. DateTime is in the ISO 8601 format "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", where "SSS" are milliseconds and 'Z' denotes Zulu time (UTC).
|
10
|
+
|
11
|
+
property :created_at, type: :time
|
12
|
+
# Type: DateTime
|
13
|
+
# Description: DID reservation created at DateTime.
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module DIDWW
|
3
|
+
module Resource
|
4
|
+
class EncryptedFile < Base
|
5
|
+
class UploadError < StandardError
|
6
|
+
end
|
7
|
+
|
8
|
+
property :description, type: :string
|
9
|
+
# Type: String
|
10
|
+
# Description:
|
11
|
+
|
12
|
+
property :expire_at, type: :date
|
13
|
+
# Type: Date
|
14
|
+
# Description:
|
15
|
+
|
16
|
+
# @return [Faraday::Connection]
|
17
|
+
def self.upload_connection
|
18
|
+
Faraday.new(url: site) do |connection|
|
19
|
+
connection.request :multipart
|
20
|
+
connection.request :url_encoded
|
21
|
+
connection.adapter Faraday.default_adapter
|
22
|
+
connection.use DIDWW::BaseMiddleware
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param files [Rack::Multipart::UploadedFile,(#tempfile,#content_type,#original_filename)]
|
27
|
+
# @return [Array<String>]
|
28
|
+
# @raise [DIDWW::Resource::EncryptedFile::UploadError]
|
29
|
+
def self.upload_files(files, fingerprint)
|
30
|
+
items = files.map do |file|
|
31
|
+
{
|
32
|
+
file: Faraday::UploadIO.new(file.tempfile, file.content_type),
|
33
|
+
description: file.original_filename
|
34
|
+
}
|
35
|
+
end
|
36
|
+
payload = { encryption_fingerprint: fingerprint, items: items }
|
37
|
+
upload(payload)
|
38
|
+
end
|
39
|
+
|
40
|
+
# @param payload [Hash]
|
41
|
+
# encryption_fingerprint [String] DIDWW::Encrypt#encryption_fingerprint
|
42
|
+
# items [Array]
|
43
|
+
# file [Faraday::UploadIO] upload io
|
44
|
+
# description [String,nil] optional description
|
45
|
+
# @return [Array<String>]
|
46
|
+
# @raise [DIDWW::Resource::EncryptedFile::UploadError]
|
47
|
+
def self.upload(payload)
|
48
|
+
connection = upload_connection
|
49
|
+
response = connection.post('/v3/encrypted_files', encrypted_files: payload)
|
50
|
+
if response.status == 201
|
51
|
+
JSON.parse(response.body, symbolize_names: true)[:ids]
|
52
|
+
else
|
53
|
+
raise UploadError, "Code: #{response.status} #{response.body}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module DIDWW
|
3
|
+
module Resource
|
4
|
+
class Identity < Base
|
5
|
+
IDENTITY_TYPE_PERSONAL = 'Personal'
|
6
|
+
IDENTITY_TYPE_BUSINESS = 'Business'
|
7
|
+
|
8
|
+
has_one :country, class_name: 'Country'
|
9
|
+
has_many :proofs, class_name: 'Proof'
|
10
|
+
has_many :addresses, class_name: 'Address'
|
11
|
+
has_many :permanent_documents, class_name: 'PermanentSupportingDocument'
|
12
|
+
|
13
|
+
property :first_name, type: :string
|
14
|
+
# Type: String
|
15
|
+
# Description:
|
16
|
+
|
17
|
+
property :last_name, type: :string
|
18
|
+
# Type: String
|
19
|
+
# Description:
|
20
|
+
|
21
|
+
property :phone_number, type: :string
|
22
|
+
# Type: String
|
23
|
+
# Description:
|
24
|
+
|
25
|
+
property :id_number, type: :string
|
26
|
+
# Type: String
|
27
|
+
# Description:
|
28
|
+
|
29
|
+
property :birth_date, type: :date
|
30
|
+
# Type: Date
|
31
|
+
# Description:
|
32
|
+
|
33
|
+
property :company_name, type: :string
|
34
|
+
# Type: String
|
35
|
+
# Description:
|
36
|
+
|
37
|
+
property :company_reg_number, type: :string
|
38
|
+
# Type: String
|
39
|
+
# Description:
|
40
|
+
|
41
|
+
property :vat_id, type: :string
|
42
|
+
# Type: String
|
43
|
+
# Description:
|
44
|
+
|
45
|
+
property :description, type: :string
|
46
|
+
# Type: String
|
47
|
+
# Description:
|
48
|
+
|
49
|
+
property :personal_tax_id, type: :string
|
50
|
+
# Type: String
|
51
|
+
# Description:
|
52
|
+
|
53
|
+
property :identity_type, type: :string
|
54
|
+
# Type: String
|
55
|
+
# Description:
|
56
|
+
|
57
|
+
property :created_at, type: :date
|
58
|
+
# Type: Date
|
59
|
+
# Description:
|
60
|
+
|
61
|
+
property :external_reference_id, type: :string
|
62
|
+
# Type: String
|
63
|
+
# Description:
|
64
|
+
|
65
|
+
property :verified, type: :boolean
|
66
|
+
# Type: Boolean
|
67
|
+
# Description:
|
68
|
+
|
69
|
+
def personal?
|
70
|
+
identity_type == IDENTITY_TYPE_PERSONAL
|
71
|
+
end
|
72
|
+
|
73
|
+
def business?
|
74
|
+
identity_type == IDENTITY_TYPE_BUSINESS
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'didww/complex_objects/did_order_item'
|
3
|
+
require 'didww/complex_objects/capacity_order_item'
|
2
4
|
|
3
5
|
module DIDWW
|
4
6
|
module Resource
|
@@ -45,6 +47,14 @@ module DIDWW
|
|
45
47
|
# Type: Boolean
|
46
48
|
# Description: Allowing back ordering
|
47
49
|
|
50
|
+
property :callback_url, type: :string
|
51
|
+
# Type: String
|
52
|
+
# Description: valid URI for callbacks
|
53
|
+
|
54
|
+
property :callback_method, type: :string
|
55
|
+
# Type: String
|
56
|
+
# Description: GET or POST
|
57
|
+
|
48
58
|
def initialize(*args)
|
49
59
|
super
|
50
60
|
self.items ||= []
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module DIDWW
|
3
|
+
module Resource
|
4
|
+
class PermanentSupportingDocument < Base
|
5
|
+
|
6
|
+
has_many :files, class_name: 'EncryptedFile'
|
7
|
+
has_one :template, class_name: 'SupportingDocumentTemplate'
|
8
|
+
has_one :identity, class_name: 'Identity'
|
9
|
+
|
10
|
+
property :created_at, type: :date
|
11
|
+
# Type: Date
|
12
|
+
# Description:
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|