tangany 0.0.1
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 +7 -0
- data/.reek.yml +4 -0
- data/.rspec +3 -0
- data/.rubycritic.yml +7 -0
- data/.sasori/Dockerfile +51 -0
- data/.simplecov +13 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +210 -0
- data/LICENSE.txt +21 -0
- data/README.md +410 -0
- data/Rakefile +133 -0
- data/bin/console +22 -0
- data/bin/setup +8 -0
- data/bin/test-live +170 -0
- data/lib/config/chains.json +22 -0
- data/lib/tangany/application_contract.rb +19 -0
- data/lib/tangany/collection.rb +13 -0
- data/lib/tangany/config.rb +24 -0
- data/lib/tangany/custody/client.rb +37 -0
- data/lib/tangany/custody/collection.rb +17 -0
- data/lib/tangany/custody/contracts/wallets/create.rb +23 -0
- data/lib/tangany/custody/contracts/wallets/list.rb +37 -0
- data/lib/tangany/custody/contracts/wallets/update.rb +21 -0
- data/lib/tangany/custody/contracts/wallets.rb +3 -0
- data/lib/tangany/custody/contracts.rb +1 -0
- data/lib/tangany/custody/objects/wallet.rb +17 -0
- data/lib/tangany/custody/objects/wallet_recovery.rb +10 -0
- data/lib/tangany/custody/objects/wallet_status.rb +10 -0
- data/lib/tangany/custody/objects.rb +3 -0
- data/lib/tangany/custody/resource.rb +29 -0
- data/lib/tangany/custody/resources/wallet_statuses_resource.rb +9 -0
- data/lib/tangany/custody/resources/wallets_resource.rb +34 -0
- data/lib/tangany/custody/resources.rb +2 -0
- data/lib/tangany/custody.rb +7 -0
- data/lib/tangany/customers/application_contract.rb +6 -0
- data/lib/tangany/customers/client.rb +37 -0
- data/lib/tangany/customers/collection.rb +16 -0
- data/lib/tangany/customers/contracts/customers/create.rb +17 -0
- data/lib/tangany/customers/contracts/customers/create_schemas/contract.rb +21 -0
- data/lib/tangany/customers/contracts/customers/create_schemas/customer.rb +34 -0
- data/lib/tangany/customers/contracts/customers/list.rb +17 -0
- data/lib/tangany/customers/contracts/customers/update.rb +14 -0
- data/lib/tangany/customers/contracts/customers/update_schemas/customer.rb +15 -0
- data/lib/tangany/customers/contracts/customers.rb +3 -0
- data/lib/tangany/customers/contracts/natural_persons/create.rb +23 -0
- data/lib/tangany/customers/contracts/natural_persons/create_schemas/address.rb +23 -0
- data/lib/tangany/customers/contracts/natural_persons/create_schemas/document.rb +25 -0
- data/lib/tangany/customers/contracts/natural_persons/create_schemas/kyc.rb +24 -0
- data/lib/tangany/customers/contracts/natural_persons/create_schemas/natural_person.rb +44 -0
- data/lib/tangany/customers/contracts/natural_persons/create_schemas/pep.rb +22 -0
- data/lib/tangany/customers/contracts/natural_persons/create_schemas/sanctions.rb +22 -0
- data/lib/tangany/customers/contracts/natural_persons/list.rb +17 -0
- data/lib/tangany/customers/contracts/natural_persons/update.rb +14 -0
- data/lib/tangany/customers/contracts/natural_persons/update_schemas/natural_person.rb +15 -0
- data/lib/tangany/customers/contracts/natural_persons.rb +3 -0
- data/lib/tangany/customers/contracts/wallet_links/create.rb +28 -0
- data/lib/tangany/customers/contracts/wallet_links/list.rb +17 -0
- data/lib/tangany/customers/contracts/wallet_links.rb +2 -0
- data/lib/tangany/customers/contracts.rb +3 -0
- data/lib/tangany/customers/objects/address.rb +11 -0
- data/lib/tangany/customers/objects/contract.rb +13 -0
- data/lib/tangany/customers/objects/customer.rb +14 -0
- data/lib/tangany/customers/objects/document.rb +17 -0
- data/lib/tangany/customers/objects/kyc.rb +16 -0
- data/lib/tangany/customers/objects/natural_person.rb +30 -0
- data/lib/tangany/customers/objects/pep.rb +12 -0
- data/lib/tangany/customers/objects/sanctions.rb +12 -0
- data/lib/tangany/customers/objects/wallet_link.rb +14 -0
- data/lib/tangany/customers/objects.rb +5 -0
- data/lib/tangany/customers/resource.rb +11 -0
- data/lib/tangany/customers/resources/customers_resource.rb +27 -0
- data/lib/tangany/customers/resources/natural_persons_resource.rb +26 -0
- data/lib/tangany/customers/resources/wallet_links_resource.rb +37 -0
- data/lib/tangany/customers/resources.rb +3 -0
- data/lib/tangany/customers.rb +8 -0
- data/lib/tangany/error.rb +34 -0
- data/lib/tangany/json_patch.rb +65 -0
- data/lib/tangany/object.rb +43 -0
- data/lib/tangany/operation.rb +10 -0
- data/lib/tangany/resource.rb +80 -0
- data/lib/tangany/types.rb +7 -0
- data/lib/tangany/version.rb +3 -0
- data/lib/tangany.rb +47 -0
- data/sig/tangany.rbs +4 -0
- metadata +217 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
module Contracts
|
4
|
+
module Customers
|
5
|
+
class List < ApplicationContract
|
6
|
+
schema do
|
7
|
+
config.validate_keys = true
|
8
|
+
|
9
|
+
optional(:pageToken).maybe(:string)
|
10
|
+
optional(:limit).filled(:integer, gteq?: 1, lteq?: 100)
|
11
|
+
optional(:sort).filled(:string, included_in?: ALLOWED_SORTS)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative "create"
|
2
|
+
require_relative "update_schemas/customer"
|
3
|
+
|
4
|
+
module Tangany
|
5
|
+
module Customers
|
6
|
+
module Contracts
|
7
|
+
module Customers
|
8
|
+
class Update < Create
|
9
|
+
schema(UpdateSchemas::Customer.schema) { config.validate_keys = true }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative "create_schemas/natural_person"
|
2
|
+
|
3
|
+
module Tangany
|
4
|
+
module Customers
|
5
|
+
module Contracts
|
6
|
+
module NaturalPersons
|
7
|
+
class Create < ApplicationContract
|
8
|
+
schema(CreateSchemas::NaturalPerson.schema) { config.validate_keys = true }
|
9
|
+
|
10
|
+
rule(pep: :source) do
|
11
|
+
key.failure("must be present if pep.isExposed is true") if values.dig(:pep, :isExposed) && !value
|
12
|
+
key.failure("must not be present if pep.isExposed is false") if !values.dig(:pep, :isExposed) && value
|
13
|
+
end
|
14
|
+
|
15
|
+
rule(sanctions: :source) do
|
16
|
+
key.failure("must be present if sanctions.isSanctioned is true") if values.dig(:sanctions, :isSanctioned) && !value
|
17
|
+
key.failure("must not be present if sanctions.isSanctioned is false") if !values.dig(:sanctions, :isSanctioned) && value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
module Contracts
|
4
|
+
module NaturalPersons
|
5
|
+
module CreateSchemas
|
6
|
+
module Address
|
7
|
+
class << self
|
8
|
+
def schema
|
9
|
+
Dry::Schema.Params do
|
10
|
+
required(:country).filled(:string, format?: Tangany::ApplicationContract::COUNTRY_CODE_REGEX)
|
11
|
+
required(:city).filled(:string, max_size?: 255)
|
12
|
+
required(:postcode).filled(:string, max_size?: 255)
|
13
|
+
required(:streetName).filled(:string, max_size?: 255)
|
14
|
+
required(:streetNumber).filled(:string, max_size?: 255)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
module Contracts
|
4
|
+
module NaturalPersons
|
5
|
+
module CreateSchemas
|
6
|
+
module Document
|
7
|
+
class << self
|
8
|
+
def schema
|
9
|
+
Dry::Schema.Params do
|
10
|
+
required(:country).filled(:string, format?: Tangany::ApplicationContract::COUNTRY_CODE_REGEX)
|
11
|
+
required(:nationality).filled(:string, format?: Tangany::ApplicationContract::COUNTRY_CODE_REGEX)
|
12
|
+
required(:number).filled(:string, max_size?: 255)
|
13
|
+
required(:issuedBy).filled(:string, max_size?: 255)
|
14
|
+
required(:issueDate).filled(:string, format?: Tangany::ApplicationContract::DATE_REGEX)
|
15
|
+
required(:validUntil).filled(:string, format?: Tangany::ApplicationContract::DATE_REGEX)
|
16
|
+
required(:type).filled(:string, included_in?: Tangany::Customers::Document::ALLOWED_TYPES)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative "document"
|
2
|
+
|
3
|
+
module Tangany
|
4
|
+
module Customers
|
5
|
+
module Contracts
|
6
|
+
module NaturalPersons
|
7
|
+
module CreateSchemas
|
8
|
+
module Kyc
|
9
|
+
class << self
|
10
|
+
def schema
|
11
|
+
Dry::Schema.Params do
|
12
|
+
required(:id).filled(:string, max_size?: 255)
|
13
|
+
required(:date).filled(:string, format?: Tangany::ApplicationContract::DATE_REGEX)
|
14
|
+
required(:method).filled(:string, included_in?: Tangany::Customers::Kyc::ALLOWED_METHODS)
|
15
|
+
optional(:document).hash(Document.schema)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative "address"
|
2
|
+
require_relative "kyc"
|
3
|
+
require_relative "pep"
|
4
|
+
require_relative "sanctions"
|
5
|
+
|
6
|
+
module Tangany
|
7
|
+
module Customers
|
8
|
+
module Contracts
|
9
|
+
module NaturalPersons
|
10
|
+
module CreateSchemas
|
11
|
+
module NaturalPerson
|
12
|
+
module ClassMethods
|
13
|
+
def schema
|
14
|
+
Dry::Schema.Params do
|
15
|
+
required(:id).filled(:string, max_size?: 40)
|
16
|
+
optional(:title).maybe(:string, max_size?: 255)
|
17
|
+
required(:firstName).filled(:string, max_size?: 255)
|
18
|
+
required(:lastName).filled(:string, max_size?: 255)
|
19
|
+
optional(:gender).maybe(:string, included_in?: Tangany::Customers::NaturalPerson::ALLOWED_GENDERS)
|
20
|
+
required(:birthDate).filled(:string, format?: Tangany::ApplicationContract::DATE_REGEX)
|
21
|
+
required(:birthPlace).filled(:string, max_size?: 255)
|
22
|
+
required(:birthCountry).filled(:string, format?: Tangany::ApplicationContract::COUNTRY_CODE_REGEX)
|
23
|
+
optional(:birthName).maybe(:string, max_size?: 255)
|
24
|
+
optional(:nationality).maybe(:string, format?: Tangany::ApplicationContract::COUNTRY_CODE_REGEX)
|
25
|
+
optional(:address).hash(Address.schema)
|
26
|
+
optional(:email).maybe(:string, max_size?: 255)
|
27
|
+
optional(:kyc).hash(Kyc.schema)
|
28
|
+
optional(:pep).hash(Pep.schema)
|
29
|
+
optional(:sanctions).hash(Sanctions.schema)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
extend ClassMethods
|
35
|
+
|
36
|
+
def self.included(base)
|
37
|
+
base.extend(ClassMethods)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
module Contracts
|
4
|
+
module NaturalPersons
|
5
|
+
module CreateSchemas
|
6
|
+
module Pep
|
7
|
+
class << self
|
8
|
+
def schema
|
9
|
+
Dry::Schema.Params do
|
10
|
+
required(:checkDate).filled(:string, format?: Tangany::ApplicationContract::DATETIME_REGEX)
|
11
|
+
required(:isExposed).filled(:bool)
|
12
|
+
optional(:source).maybe(:string, max_size?: 255)
|
13
|
+
optional(:reason).maybe(:string, max_size?: 255)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
module Contracts
|
4
|
+
module NaturalPersons
|
5
|
+
module CreateSchemas
|
6
|
+
module Sanctions
|
7
|
+
class << self
|
8
|
+
def schema
|
9
|
+
Dry::Schema.Params do
|
10
|
+
required(:checkDate).filled(:string, format?: Tangany::ApplicationContract::DATETIME_REGEX)
|
11
|
+
required(:isSanctioned).filled(:bool)
|
12
|
+
optional(:source).maybe(:string, max_size?: 255)
|
13
|
+
optional(:reason).maybe(:string, max_size?: 255)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
module Contracts
|
4
|
+
module NaturalPersons
|
5
|
+
class List < ApplicationContract
|
6
|
+
schema do
|
7
|
+
config.validate_keys = true
|
8
|
+
|
9
|
+
optional(:pageToken).maybe(:string)
|
10
|
+
optional(:limit).filled(:integer, gteq?: 1, lteq?: 100)
|
11
|
+
optional(:sort).filled(:string, included_in?: ALLOWED_SORTS)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative "create"
|
2
|
+
require_relative "update_schemas/natural_person"
|
3
|
+
|
4
|
+
module Tangany
|
5
|
+
module Customers
|
6
|
+
module Contracts
|
7
|
+
module NaturalPersons
|
8
|
+
class Update < Create
|
9
|
+
schema(UpdateSchemas::NaturalPerson.schema) { config.validate_keys = true }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative "../create_schemas/natural_person"
|
2
|
+
|
3
|
+
module Tangany
|
4
|
+
module Customers
|
5
|
+
module Contracts
|
6
|
+
module NaturalPersons
|
7
|
+
module UpdateSchemas
|
8
|
+
module NaturalPerson
|
9
|
+
include CreateSchemas::NaturalPerson
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
module Contracts
|
4
|
+
module WalletLinks
|
5
|
+
class Create < ApplicationContract
|
6
|
+
ALLOWED_TYPES = ["waas"].freeze
|
7
|
+
|
8
|
+
schema do
|
9
|
+
config.validate_keys = true
|
10
|
+
|
11
|
+
required(:id).filled(:string, max_size?: 40)
|
12
|
+
optional(:address).filled(:string, format?: ApplicationContract::ETHEREUM_ADDRESS_REGEX)
|
13
|
+
optional(:wallet).filled(:string)
|
14
|
+
required(:assetId).filled(:string, included_in?: Tangany::Customers::WalletLink::ALLOWED_CHAIN_IDS)
|
15
|
+
optional(:assignment).hash do
|
16
|
+
required(:customerId).filled(:string)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
rule do
|
21
|
+
key.failure("one ne of address or wallet must be present") if !values[:address] && !values[:wallet]
|
22
|
+
key.failure("only one of address or wallet must be present") if values[:address] && values[:wallet]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
module Contracts
|
4
|
+
module WalletLinks
|
5
|
+
class List < ApplicationContract
|
6
|
+
schema do
|
7
|
+
config.validate_keys = true
|
8
|
+
|
9
|
+
optional(:limit).filled(:integer, gt?: 0, lteq?: 100)
|
10
|
+
optional(:sort).filled(:string, included_in?: ALLOWED_SORTS)
|
11
|
+
optional(:pageToken).maybe(:string)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
class Address < Object
|
4
|
+
attribute :country, Types::String
|
5
|
+
attribute :city, Types::String
|
6
|
+
attribute :postcode, Types::String
|
7
|
+
attribute :streetName, Types::String
|
8
|
+
attribute :streetNumber, Types::String
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
class Contract < Object
|
4
|
+
ALLOWED_TYPES = %w[standard].freeze
|
5
|
+
|
6
|
+
attribute :type, Types::String
|
7
|
+
attribute :signedDate, Types::Date
|
8
|
+
attribute? :cancelledDate, Types::Date.optional
|
9
|
+
|
10
|
+
to_date :signedDate, :cancelledDate
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
class Customer < Object
|
4
|
+
attribute :id, Types::String
|
5
|
+
attribute :owner do
|
6
|
+
attribute :entityId, Types::String
|
7
|
+
end
|
8
|
+
attribute :authorized, Types::Array do
|
9
|
+
attribute :entityId, Types::String
|
10
|
+
end
|
11
|
+
attribute :contracts, Types::Array.of(Contract)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
class Document < Object
|
4
|
+
ALLOWED_TYPES = %w[id_card passport other].freeze
|
5
|
+
|
6
|
+
attribute :country, Types::String
|
7
|
+
attribute :nationality, Types::String
|
8
|
+
attribute :number, Types::String
|
9
|
+
attribute :issuedBy, Types::String
|
10
|
+
attribute :issueDate, Types::Date
|
11
|
+
attribute :validUntil, Types::Date
|
12
|
+
attribute :type, Types::String
|
13
|
+
|
14
|
+
to_date :issueDate, :validUntil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative "document"
|
2
|
+
|
3
|
+
module Tangany
|
4
|
+
module Customers
|
5
|
+
class Kyc < Object
|
6
|
+
ALLOWED_METHODS = %w[video_ident id_copy auto_ident in_person].freeze
|
7
|
+
|
8
|
+
attribute :id, Types::String
|
9
|
+
attribute :date, Types::DateTime
|
10
|
+
attribute :method, Types::String
|
11
|
+
attribute? :document, Document
|
12
|
+
|
13
|
+
to_datetime :date
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative "address"
|
2
|
+
require_relative "kyc"
|
3
|
+
require_relative "pep"
|
4
|
+
require_relative "sanctions"
|
5
|
+
|
6
|
+
module Tangany
|
7
|
+
module Customers
|
8
|
+
class NaturalPerson < Object
|
9
|
+
ALLOWED_GENDERS = %w[F M X].freeze
|
10
|
+
|
11
|
+
attribute :id, Types::String
|
12
|
+
attribute? :title, Types::String.optional
|
13
|
+
attribute :firstName, Types::String
|
14
|
+
attribute :lastName, Types::String
|
15
|
+
attribute? :gender, Types::String.optional
|
16
|
+
attribute :birthDate, Types::Date
|
17
|
+
attribute :birthPlace, Types::String
|
18
|
+
attribute :birthCountry, Types::String
|
19
|
+
attribute? :birthName, Types::String.optional
|
20
|
+
attribute? :nationality, Types::String.optional
|
21
|
+
attribute? :address, Address
|
22
|
+
attribute? :email, Types::String.optional
|
23
|
+
attribute? :kyc, Kyc
|
24
|
+
attribute? :pep, Pep
|
25
|
+
attribute? :sanctions, Sanctions
|
26
|
+
|
27
|
+
to_date :birthDate
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
class Pep < Object
|
4
|
+
attribute :checkDate, Types::DateTime
|
5
|
+
attribute :isExposed, Types::Bool
|
6
|
+
attribute? :source, Types::String.optional
|
7
|
+
attribute? :reason, Types::String.optional
|
8
|
+
|
9
|
+
to_datetime :checkDate
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
class Sanctions < Object
|
4
|
+
attribute :checkDate, Types::DateTime
|
5
|
+
attribute :isSanctioned, Types::Bool
|
6
|
+
attribute? :source, Types::String.optional
|
7
|
+
attribute? :reason, Types::String.optional
|
8
|
+
|
9
|
+
to_datetime :checkDate
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
class WalletLink < Object
|
4
|
+
ALLOWED_CHAIN_IDS = Tangany.chains.map { |chain| chain["asset_id"] }.freeze
|
5
|
+
|
6
|
+
attribute :id, Types::String
|
7
|
+
attribute :address, Types::String
|
8
|
+
attribute :assetId, Types::String
|
9
|
+
attribute? :assignment do
|
10
|
+
attribute :customerId, Types::String
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
class CustomersResource < Resource
|
4
|
+
BASE_PATH = "customers"
|
5
|
+
|
6
|
+
def create(**params)
|
7
|
+
Customer.new(post_request(BASE_PATH, body: sanitize_params!(params).to_json).body)
|
8
|
+
end
|
9
|
+
|
10
|
+
def delete(customer_id)
|
11
|
+
delete_request("#{BASE_PATH}/#{customer_id}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def list(**params)
|
15
|
+
Collection.from_response(get_request(BASE_PATH, params: sanitize_params!(params)), type: Customer)
|
16
|
+
end
|
17
|
+
|
18
|
+
def retrieve(customer_id)
|
19
|
+
Customer.new(get_request("#{BASE_PATH}/#{customer_id}").body)
|
20
|
+
end
|
21
|
+
|
22
|
+
def update(customer_id, **params)
|
23
|
+
Customer.new(put_request("#{BASE_PATH}/#{customer_id}", body: sanitize_params!(params).to_json).body)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
class NaturalPersonsResource < Resource
|
4
|
+
BASE_PATH = "entities/natural-persons"
|
5
|
+
def create(**params)
|
6
|
+
NaturalPerson.new(post_request(BASE_PATH, body: sanitize_params!(params).to_json).body)
|
7
|
+
end
|
8
|
+
|
9
|
+
def delete(entity_id)
|
10
|
+
delete_request("#{BASE_PATH}/#{entity_id}")
|
11
|
+
end
|
12
|
+
|
13
|
+
def list(**params)
|
14
|
+
Collection.from_response(get_request(BASE_PATH, params: sanitize_params!(params)), type: NaturalPerson)
|
15
|
+
end
|
16
|
+
|
17
|
+
def retrieve(entity_id)
|
18
|
+
NaturalPerson.new(get_request("#{BASE_PATH}/#{entity_id}").body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def update(entity_id, **params)
|
22
|
+
NaturalPerson.new(put_request("#{BASE_PATH}/#{entity_id}", body: sanitize_params!(params).to_json).body)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Tangany
|
2
|
+
module Customers
|
3
|
+
class WalletLinksResource < Resource
|
4
|
+
BASE_PATH = "wallet-links"
|
5
|
+
|
6
|
+
def create(**params)
|
7
|
+
contract_hash = sanitize_params!(params)
|
8
|
+
WalletLink.new(post_request(BASE_PATH, body: prepare_create_hash(contract_hash).to_json).body)
|
9
|
+
end
|
10
|
+
|
11
|
+
def delete(wallet_link_id)
|
12
|
+
delete_request("#{BASE_PATH}/#{wallet_link_id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def list(**params)
|
16
|
+
Collection.from_response(get_request(BASE_PATH, params: sanitize_params!(params)), type: WalletLink)
|
17
|
+
end
|
18
|
+
|
19
|
+
def retrieve(wallet_link_id)
|
20
|
+
WalletLink.new(get_request("#{BASE_PATH}/#{wallet_link_id}").body)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def prepare_create_hash(hash)
|
26
|
+
# TODO: derive wallet address from secp256k1 public key instead of using the Custody API
|
27
|
+
if hash[:wallet]
|
28
|
+
custody_client = Tangany::Custody::Client.new
|
29
|
+
wallet_status = custody_client.wallet_statuses(asset_id: hash[:assetId]).retrieve(hash[:wallet])
|
30
|
+
hash[:address] = wallet_status.address
|
31
|
+
hash.delete(:wallet)
|
32
|
+
end
|
33
|
+
hash
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require_relative "customers/application_contract"
|
2
|
+
require_relative "customers/client"
|
3
|
+
require_relative "customers/collection"
|
4
|
+
require_relative "customers/objects"
|
5
|
+
require_relative "customers/resource"
|
6
|
+
|
7
|
+
require_relative "customers/contracts"
|
8
|
+
require_relative "customers/resources"
|