damsel/proto/domain.thrift

391 lines
8.9 KiB
Thrift
Raw Normal View History

/**
* Определения предметной области.
*/
include "base.thrift"
namespace java com.rbkmoney.damsel.domain
namespace erlang domain
typedef i32 SchemaRevision
typedef i64 DataRevision
const SchemaRevision SCHEMA_REVISION = 42
typedef i32 ObjectID
/* Common */
// В идеале надо использовать `typedef` над `base.Error`, но сейчас это приводит к ошибкам кодогенератора Go
struct OperationError {
/** Уникальный признак ошибки, пригодный для обработки машиной */
1: required string code;
/** Описание ошибки, пригодное для восприятия человеком */
2: optional string description;
}
/** Сумма в минимальных денежных единицах. */
typedef i64 Amount
/** Валюта. */
struct Currency {
1: required string name
2: required string symbolic_code
3: required i16 numeric_code
4: required i16 exponent
}
struct CurrencyRef { 1: required string symbolic_code }
struct CurrencyObject {
1: required CurrencyRef ref
2016-04-26 16:01:04 +00:00
2: required Currency data
}
/** Денежные средства, состоящий из суммы и валюты. */
struct Funds {
2016-05-18 16:27:06 +00:00
1: required Amount amount
2: required Currency currency
}
/* Contractor transactions */
struct TransactionInfo {
1: required string id
2: optional base.Timestamp timestamp
3: required base.StringMap extra = []
2016-05-18 16:27:06 +00:00
}
/* Invoices */
typedef base.ID InvoiceID
typedef base.ID InvoicePaymentID
typedef binary InvoiceContext
typedef string PaymentSession
typedef string Fingerprint
typedef string IPAddress
struct Invoice {
1: required InvoiceID id
2: required base.Timestamp created_at
3: required DataRevision domain_revision
4: required InvoiceStatus status
5: required base.Timestamp due
6: required string product
7: optional string description
8: required Funds cost
9: required InvoiceContext context
}
struct InvoiceUnpaid {}
struct InvoicePaid {}
struct InvoiceCancelled { 1: required string details }
struct InvoiceFulfilled { 1: required string details }
union InvoiceStatus {
1: InvoiceUnpaid unpaid
2: InvoicePaid paid
3: InvoiceCancelled cancelled
4: InvoiceFulfilled fulfilled
}
struct InvoicePayment {
1: required InvoicePaymentID id
2: required base.Timestamp created_at
3: required InvoicePaymentStatus status
4: optional TransactionInfo trx
5: required Payer payer
8: required Funds cost
}
struct InvoicePaymentPending {}
struct InvoicePaymentSucceeded {}
struct InvoicePaymentFailed { 1: OperationError err }
union InvoicePaymentStatus {
1: InvoicePaymentPending pending
2: InvoicePaymentSucceeded succeeded
3: InvoicePaymentFailed failed
}
struct Payer {
1: required PaymentTool payment_tool
2: required PaymentSession session
3: required ClientInfo client_info
}
struct ClientInfo {
1: optional IPAddress ip_address
2: optional Fingerprint fingerprint
}
/* Cash flows */
/** Распределение денежных потоков в системе. */
struct CashDistribution {
1: required string name
2: required string description = ""
3: required list<CashFlow> flows
}
/** Участник распределения денежных потоков. */
// Порядок следования `typedef`-`struct` важен для кодогенератора Go
typedef string CashFlowNode // FIXME: too broad
/** Денежный поток между двумя участниками. */
struct CashFlow {
1: required CashFlowNode source
2: required CashFlowNode destination
3: required CashVolume volume
}
/** Объём денежного потока. */
union CashVolume {
1: VolumeFixed fixed
2: VolumeShare share
}
/** Объём в абсолютных денежных единицах. */
struct VolumeFixed {
1: required Amount amount
}
/** Объём в относительных единицах. */
struct VolumeShare {
1: required base.Rational parts
2: optional CashFlowNode of
}
struct CashDistributionRef { 1: required ObjectID id }
struct CashDistributionObject {
1: required CashDistributionRef ref
2: required CashDistribution data
}
/* Merchants */
/** Мерчант. */
struct Merchant {
1: optional Contract contract
2: required list<Shop> shops = []
}
struct MerchantRef { 1: required base.ID id }
struct MerchantObject {
1: required MerchantRef ref
2: required Merchant data
}
/* Contracts */
/** Договор с юридическим лицом, в частности с мерчантом. */
struct Contract {
1: required string number
2: required base.Timestamp signed_at
2016-04-26 16:01:04 +00:00
3: required PartyRef party
4: required BankAccount account
5: required list<ContractTerm> terms
}
2016-04-26 16:01:04 +00:00
/** Лицо, выступающее стороной договора. */
struct Party {
2016-04-26 16:01:04 +00:00
1: required string registered_name
2: required LegalEntity legal_entity
}
/** Форма юридического лица. */
union LegalEntity {
}
2016-04-26 16:01:04 +00:00
struct PartyRef { 1: required ObjectID id }
struct PartyObject {
1: required PartyRef ref
2: required Party data
}
/** Банковский счёт. */
struct BankAccount {
}
/** Условие договора. */
union ContractTerm {
2016-04-26 16:01:04 +00:00
1: CashDistributionTerm cash_distribution
}
struct CashDistributionTerm {
}
/* Shops */
/** Магазин мерчанта. */
struct Shop {
1: required string name
2: optional string url
3: required Category category
}
/* Categories */
/** Категория продаваемых товаров или услуг. */
struct Category {
1: required string name
2: required string description = ""
}
struct CategoryRef { 1: required ObjectID id }
struct CategoryObject {
1: required CategoryRef ref
2: required Category data
}
/* Payment methods */
2016-04-26 16:01:04 +00:00
enum PaymentMethod {
bank_card = 1 // payment_card?
}
union PaymentTool {
1: BankCard bank_card
}
typedef string Token
struct BankCard {
1: required Token token
2: required BankCardPaymentSystem payment_system
3: required string bin
4: required string masked_pan
}
enum BankCardPaymentSystem {
visa
mastercard
}
2016-04-26 16:01:04 +00:00
/** Способ платежа, категория платёжного средства. */
2016-04-26 16:01:04 +00:00
struct PaymentMethodDefinition {
1: required string name
2: required string description = ""
}
2016-04-26 16:01:04 +00:00
struct PaymentMethodRef { 1: required PaymentMethod id }
struct PaymentMethodObject {
1: required PaymentMethodRef ref
2016-04-26 16:01:04 +00:00
2: required PaymentMethodDefinition data
}
/* Conditions */
/** Условие применимости. */
struct Condition {
1: required string name
2: required string description = ""
3: required ConditionDef definition
}
/** Варианты условий применимости. */
union ConditionDef {
/// basis and combinators
1: bool value_is
2: set<ConditionDef> all_of
3: set<ConditionDef> one_of
4: ConditionDef is_not
/// primitives
5: ConditionRef condition_is
6: CategoryRef category_is
7: PaymentMethodRef payment_method_is
8: FlowRef flow_is
}
struct ConditionRef { 1: required ObjectID id }
struct ConditionObject {
1: required ConditionRef ref
2: required Condition data
}
/* Flows */
/** Операция над бизнес-объектом, в частности инвойсом. */
struct Flow {
1: required string name
2: required string description = ""
}
struct FlowRef { 1: required ObjectID id }
struct FlowObject {
1: required FlowRef ref
2: required Flow data
}
/* Proxies */
typedef base.StringMap ProxyOptions
enum ProxyType {
provider
}
struct Proxy {
1: required ProxyType type
2: required string url
3: optional ProxyOptions options
}
struct ProxyRef { 1: required ObjectID id }
struct ProxyObject {
1: required ProxyRef ref
2: required ProxyObject object
}
/* Merchant prototype */
2016-05-18 16:27:06 +00:00
struct MerchantPrototypeRef {}
/** Прототип мерчанта по умолчанию. */
struct MerchantPrototype {
2016-05-18 16:27:06 +00:00
1: required MerchantPrototypeRef ref
2: required Merchant data
}
/* Type enumerations */
union Reference {
1: CategoryRef category
2: PaymentMethodRef payment_method
3: FlowRef flow
4: CurrencyRef currency
5: ConditionRef condition
6: CashDistributionRef cash_distribution
2016-04-26 16:01:04 +00:00
7: PartyRef party
8: MerchantPrototypeRef merchant_prototype
9: ProxyRef proxy
}
union DomainObject {
1: CategoryObject category
2: PaymentMethodObject payment_method
3: FlowObject flow
4: CurrencyObject currency
5: ConditionObject condition
6: CashDistributionObject cash_distribution
2016-04-26 16:01:04 +00:00
7: PartyObject party
8: MerchantPrototype merchant_prototype
9: ProxyObject proxy
}
/* Domain */
typedef map<Reference, DomainObject> Domain