mirror of
https://github.com/valitydev/damsel.git
synced 2024-11-06 01:35:19 +00:00
HG-47: Design party management interfaces (#44)
* HG-47: Change regulatory domain for timestamps to RFC 3339 * HG-47: Draft party management interfaces + update related domain types * HG-47: Isolate any possible party modification in changeset * HG-47: Make blockage / suspension signaling more straightfowrard * HG-47: Fix a bit Makefile sanity * HG-47: Introduce ownership to invoices * HG-47: Distinguish between shop name and id + autogenerate latter * HG-47: Simplify ShopUpdate definition * HG-47: Use refs to a category instead * HG-47: Separate party definition from data revision + provide GetShop function * HG-47: Include party events into processing event set * HG-47: Barely acknowledge party creation rather than reply with initial state * HG-47: Fuse domain objects into party state as is + fix wording
This commit is contained in:
parent
c3c1218409
commit
e305b7c33b
6
Makefile
6
Makefile
@ -16,6 +16,10 @@ DESTDIR = _gen
|
||||
CALL_ANYWHERE := clean all create java_compile compile doc deploy_nexus
|
||||
CALL_W_CONTAINER := $(CALL_ANYWHERE)
|
||||
|
||||
BASE_IMAGE ?= rbkmoney/build
|
||||
|
||||
all: compile
|
||||
|
||||
include utils.mk
|
||||
|
||||
define generate
|
||||
@ -36,8 +40,6 @@ LANGUAGE_TARGETS = $(foreach lang, $(THRIFT_LANGUAGES), verify-$(lang))
|
||||
create:
|
||||
mkdir -p _build/test/logs && touch _build/test/logs/index.html
|
||||
|
||||
all: compile
|
||||
|
||||
compile: $(LANGUAGE_TARGETS)
|
||||
@echo "Ok"
|
||||
|
||||
|
@ -17,7 +17,7 @@ typedef i64 EventID
|
||||
typedef binary Opaque
|
||||
|
||||
/**
|
||||
* Отметка во времени согласно ISO 8601.
|
||||
* Отметка во времени согласно RFC 3339.
|
||||
*
|
||||
* Строка должна содержать дату и время в UTC в следующем формате:
|
||||
* `2016-03-22T06:12:27Z`.
|
||||
|
@ -65,17 +65,18 @@ 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
|
||||
2: required PartyRef owner
|
||||
3: required ShopID shop_id
|
||||
4: required base.Timestamp created_at
|
||||
5: required DataRevision domain_revision
|
||||
6: required InvoiceStatus status
|
||||
7: required base.Timestamp due
|
||||
8: required string product
|
||||
9: optional string description
|
||||
10: required Funds cost
|
||||
11: required InvoiceContext context
|
||||
}
|
||||
|
||||
struct InvoiceUnpaid {}
|
||||
@ -120,8 +121,6 @@ struct ClientInfo {
|
||||
2: optional Fingerprint fingerprint
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Cash flows */
|
||||
|
||||
/** Распределение денежных потоков в системе. */
|
||||
@ -167,34 +166,81 @@ struct CashDistributionObject {
|
||||
2: required CashDistribution data
|
||||
}
|
||||
|
||||
/* Merchants */
|
||||
/* Blocking and suspension */
|
||||
|
||||
/** Мерчант. */
|
||||
struct Merchant {
|
||||
1: optional Contract contract
|
||||
2: required list<Shop> shops = []
|
||||
union Blocking {
|
||||
1: Unblocked unblocked
|
||||
2: Blocked blocked
|
||||
}
|
||||
|
||||
struct MerchantRef { 1: required base.ID id }
|
||||
struct Unblocked {
|
||||
1: required string reason
|
||||
}
|
||||
|
||||
struct MerchantObject {
|
||||
1: required MerchantRef ref
|
||||
2: required Merchant data
|
||||
struct Blocked {
|
||||
1: required string reason
|
||||
}
|
||||
|
||||
union Suspension {
|
||||
1: Active active
|
||||
2: Suspended suspended
|
||||
}
|
||||
|
||||
struct Active {}
|
||||
struct Suspended {}
|
||||
|
||||
/* Parties */
|
||||
|
||||
typedef base.ID PartyID
|
||||
|
||||
/** Участник. */
|
||||
struct Party {
|
||||
1: required PartyID id
|
||||
2: required Blocking blocking
|
||||
3: required Suspension suspension
|
||||
4: required map<ShopID, Shop> shops = []
|
||||
}
|
||||
|
||||
struct PartyRef {
|
||||
1: required PartyID id
|
||||
2: required DataRevision revision
|
||||
}
|
||||
|
||||
/* Shops */
|
||||
|
||||
typedef string ShopID
|
||||
|
||||
/** Магазин мерчанта. */
|
||||
struct Shop {
|
||||
1: required ShopID id
|
||||
2: required Blocking blocking
|
||||
3: required Suspension suspension
|
||||
4: required CategoryObject category
|
||||
5: required ShopDetails details
|
||||
6: optional Contractor contractor
|
||||
7: optional ShopContract contract
|
||||
}
|
||||
|
||||
struct ShopDetails {
|
||||
1: required string name
|
||||
2: optional string description
|
||||
3: optional string location
|
||||
}
|
||||
|
||||
/* Contracts */
|
||||
|
||||
/** Договор с юридическим лицом, в частности с мерчантом. */
|
||||
struct Contract {
|
||||
/** Договор между юридическими лицами, в частности между системой и участником. */
|
||||
struct ShopContract {
|
||||
1: required string number
|
||||
2: required base.Timestamp signed_at
|
||||
3: required PartyRef party
|
||||
4: required BankAccount account
|
||||
5: required list<ContractTerm> terms
|
||||
2: required ContractorObject system_contractor
|
||||
3: required base.Timestamp concluded_at
|
||||
4: required base.Timestamp valid_since
|
||||
5: required base.Timestamp valid_until
|
||||
6: optional base.Timestamp terminated_at
|
||||
}
|
||||
|
||||
/** Лицо, выступающее стороной договора. */
|
||||
struct Party {
|
||||
struct Contractor {
|
||||
1: required string registered_name
|
||||
2: required LegalEntity legal_entity
|
||||
}
|
||||
@ -203,34 +249,17 @@ struct Party {
|
||||
union LegalEntity {
|
||||
}
|
||||
|
||||
struct PartyRef { 1: required ObjectID id }
|
||||
struct ContractorRef { 1: required ObjectID id }
|
||||
|
||||
struct PartyObject {
|
||||
1: required PartyRef ref
|
||||
2: required Party data
|
||||
struct ContractorObject {
|
||||
1: required ContractorRef ref
|
||||
2: required Contractor data
|
||||
}
|
||||
|
||||
/** Банковский счёт. */
|
||||
struct BankAccount {
|
||||
}
|
||||
|
||||
/** Условие договора. */
|
||||
union ContractTerm {
|
||||
1: CashDistributionTerm cash_distribution
|
||||
}
|
||||
|
||||
struct CashDistributionTerm {
|
||||
}
|
||||
|
||||
/* Shops */
|
||||
|
||||
/** Магазин мерчанта. */
|
||||
struct Shop {
|
||||
1: required string name
|
||||
2: optional string url
|
||||
3: required Category category
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
|
||||
/** Категория продаваемых товаров или услуг. */
|
||||
@ -351,12 +380,12 @@ struct ProxyObject {
|
||||
|
||||
/* Merchant prototype */
|
||||
|
||||
struct MerchantPrototypeRef {}
|
||||
struct PartyPrototypeRef {}
|
||||
|
||||
/** Прототип мерчанта по умолчанию. */
|
||||
struct MerchantPrototype {
|
||||
1: required MerchantPrototypeRef ref
|
||||
2: required Merchant data
|
||||
struct PartyPrototype {
|
||||
1: required PartyPrototypeRef ref
|
||||
2: required Party data
|
||||
}
|
||||
|
||||
/* Type enumerations */
|
||||
@ -368,8 +397,8 @@ union Reference {
|
||||
4: CurrencyRef currency
|
||||
5: ConditionRef condition
|
||||
6: CashDistributionRef cash_distribution
|
||||
7: PartyRef party
|
||||
8: MerchantPrototypeRef merchant_prototype
|
||||
7: ContractorRef contractor
|
||||
8: PartyPrototypeRef party_prototype
|
||||
9: ProxyRef proxy
|
||||
}
|
||||
|
||||
@ -380,8 +409,8 @@ union DomainObject {
|
||||
4: CurrencyObject currency
|
||||
5: ConditionObject condition
|
||||
6: CashDistributionObject cash_distribution
|
||||
7: PartyObject party
|
||||
8: MerchantPrototype merchant_prototype
|
||||
7: ContractorObject contractor
|
||||
8: PartyPrototype party_prototype
|
||||
9: ProxyObject proxy
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,8 @@ typedef list<Event> Events
|
||||
union EventPayload {
|
||||
/** Некоторое событие, порождённое инвойсом. */
|
||||
1: InvoiceEvent invoice_event
|
||||
/** Некоторое событие, порождённое участником. */
|
||||
2: PartyEvent party_event
|
||||
}
|
||||
|
||||
/**
|
||||
@ -189,10 +191,16 @@ struct InvoicePaymentParams {
|
||||
|
||||
exception InvalidUser {}
|
||||
exception UserInvoiceNotFound {}
|
||||
exception InvoicePaymentPending { 1: required domain.InvoicePaymentID id }
|
||||
exception InvoicePaymentNotFound {}
|
||||
exception EventNotFound {}
|
||||
exception InvalidInvoiceStatus { 1: required domain.InvoiceStatus status }
|
||||
|
||||
exception InvoicePaymentPending {
|
||||
1: required domain.InvoicePaymentID id
|
||||
}
|
||||
|
||||
exception InvalidInvoiceStatus {
|
||||
1: required domain.InvoiceStatus status
|
||||
}
|
||||
|
||||
service Invoicing {
|
||||
|
||||
@ -234,6 +242,228 @@ service Invoicing {
|
||||
|
||||
}
|
||||
|
||||
/* Party management service definitions */
|
||||
|
||||
// Types
|
||||
|
||||
typedef domain.PartyID PartyID
|
||||
typedef domain.ShopID ShopID
|
||||
|
||||
struct PartyState {
|
||||
1: required domain.Party party
|
||||
2: required domain.DataRevision revision
|
||||
}
|
||||
|
||||
struct ShopState {
|
||||
1: required domain.Shop shop
|
||||
2: required domain.DataRevision revision
|
||||
}
|
||||
|
||||
struct ShopParams {
|
||||
1: required domain.CategoryObject category
|
||||
2: required domain.ShopDetails details
|
||||
3: optional domain.Contractor contractor
|
||||
}
|
||||
|
||||
union PartyModification {
|
||||
1: domain.Blocking blocking
|
||||
2: domain.Suspension suspension
|
||||
3: domain.Shop shop_creation
|
||||
4: ShopModificationUnit shop_modification
|
||||
}
|
||||
|
||||
typedef list<PartyModification> PartyChangeset
|
||||
|
||||
struct ShopModificationUnit {
|
||||
1: required ShopID id
|
||||
2: ShopModification modification
|
||||
}
|
||||
|
||||
union ShopModification {
|
||||
1: domain.Blocking blocking
|
||||
2: domain.Suspension suspension
|
||||
3: ShopUpdate update
|
||||
}
|
||||
|
||||
struct ShopUpdate {
|
||||
1: optional domain.CategoryObject category
|
||||
2: optional domain.ShopDetails details
|
||||
3: optional domain.Contractor contractor
|
||||
}
|
||||
|
||||
typedef base.ID ClaimID
|
||||
|
||||
struct Claim {
|
||||
1: required ClaimID id
|
||||
2: required ClaimStatus status
|
||||
3: required PartyChangeset changeset
|
||||
}
|
||||
|
||||
union ClaimStatus {
|
||||
1: ClaimPending pending
|
||||
2: ClaimAccepted approved
|
||||
3: ClaimDenied declined
|
||||
}
|
||||
|
||||
struct ClaimPending {}
|
||||
|
||||
struct ClaimAccepted {
|
||||
1: required domain.DataRevision revision
|
||||
}
|
||||
|
||||
struct ClaimDenied {
|
||||
1: required string reason
|
||||
}
|
||||
|
||||
struct ClaimResult {
|
||||
1: required ClaimID id
|
||||
2: required ClaimStatus status
|
||||
}
|
||||
|
||||
// Events
|
||||
|
||||
union PartyEvent {
|
||||
1: PartyCreated party_created
|
||||
2: ClaimCreated claim_created
|
||||
3: ClaimStatusChanged claim_status_changed
|
||||
}
|
||||
|
||||
struct PartyCreated {
|
||||
1: required PartyState party
|
||||
}
|
||||
|
||||
struct ClaimCreated {
|
||||
1: required Claim claim
|
||||
}
|
||||
|
||||
struct ClaimStatusChanged {
|
||||
1: required ClaimID id
|
||||
2: required ClaimStatus status
|
||||
}
|
||||
|
||||
// Exceptions
|
||||
|
||||
exception PartyExists {}
|
||||
exception PartyNotFound {}
|
||||
exception ShopNotFound {}
|
||||
exception ClaimNotFound {}
|
||||
|
||||
exception InvalidClaimStatus {
|
||||
1: required ClaimStatus status
|
||||
}
|
||||
|
||||
union InvalidStatus {
|
||||
1: domain.Blocking blocking
|
||||
2: domain.Suspension suspension
|
||||
}
|
||||
|
||||
exception InvalidPartyStatus {
|
||||
1: required InvalidStatus status
|
||||
}
|
||||
|
||||
exception InvalidShopStatus {
|
||||
1: required InvalidStatus status
|
||||
}
|
||||
|
||||
// Service
|
||||
|
||||
service PartyManagement {
|
||||
|
||||
void Create (1: UserInfo user, 2: PartyID party_id)
|
||||
throws (1: InvalidUser ex1, 2: PartyExists ex2)
|
||||
|
||||
PartyState Get (1: UserInfo user, 2: PartyID party_id)
|
||||
throws (1: InvalidUser ex1, 2: PartyNotFound ex2)
|
||||
|
||||
ClaimResult CreateShop (1: UserInfo user, 2: PartyID party_id, 3: ShopParams params)
|
||||
throws (
|
||||
1: InvalidUser ex1,
|
||||
2: PartyNotFound ex2,
|
||||
3: InvalidPartyStatus ex3,
|
||||
4: base.InvalidRequest ex4
|
||||
)
|
||||
|
||||
ClaimResult GetShop (1: UserInfo user, 2: PartyID party_id, 3: ShopID id)
|
||||
throws (1: InvalidUser ex1, 2: PartyNotFound ex2, 3: ShopNotFound ex3)
|
||||
|
||||
ClaimResult UpdateShop (1: UserInfo user, 2: PartyID party_id, 3: ShopID id, 4: ShopUpdate update)
|
||||
throws (
|
||||
1: InvalidUser ex1,
|
||||
2: PartyNotFound ex2,
|
||||
3: ShopNotFound ex3,
|
||||
4: InvalidPartyStatus ex4,
|
||||
5: InvalidShopStatus ex5,
|
||||
6: base.InvalidRequest ex6
|
||||
)
|
||||
|
||||
// TODO do we really need that?
|
||||
// ClaimResult RemoveShop (1: UserInfo user, 2: PartyID party_id, 3: domain.ShopID shop_id)
|
||||
// throws (1: InvalidUser ex1, 2: PartyNotFound ex2, 3: ShopNotFound ex3)
|
||||
|
||||
/* Claims */
|
||||
|
||||
Claim GetClaim (1: UserInfo user, 2: PartyID party_id, 3: ClaimID id)
|
||||
throws (1: InvalidUser ex1, 2: PartyNotFound ex2, 3: ClaimNotFound ex3)
|
||||
|
||||
Claim GetPendingClaim (1: UserInfo user, 2: PartyID party_id)
|
||||
throws (1: InvalidUser ex1, 2: PartyNotFound ex2, 3: ClaimNotFound ex3)
|
||||
|
||||
void AcceptClaim (1: UserInfo user, 2: PartyID party_id, 3: ClaimID id)
|
||||
throws (
|
||||
1: InvalidUser ex1,
|
||||
2: PartyNotFound ex2,
|
||||
3: ClaimNotFound ex3,
|
||||
4: InvalidClaimStatus ex4
|
||||
)
|
||||
|
||||
void DenyClaim (1: UserInfo user, 2: PartyID party_id, 3: ClaimID id, 4: string reason)
|
||||
throws (
|
||||
1: InvalidUser ex1,
|
||||
2: PartyNotFound ex2,
|
||||
3: ClaimNotFound ex3,
|
||||
4: InvalidClaimStatus ex4
|
||||
)
|
||||
|
||||
/* Party blocking / suspension */
|
||||
|
||||
ClaimResult Suspend (1: UserInfo user, 2: PartyID party_id)
|
||||
throws (1: InvalidUser ex1, 2: PartyNotFound ex2, 3: InvalidPartyStatus ex3)
|
||||
|
||||
ClaimResult Activate (1: UserInfo user, 2: PartyID party_id)
|
||||
throws (1: InvalidUser ex1, 2: PartyNotFound ex2, 3: InvalidPartyStatus ex3)
|
||||
|
||||
ClaimResult Block (1: UserInfo user, 2: PartyID party_id, 3: string reason)
|
||||
throws (1: InvalidUser ex1, 2: PartyNotFound ex2, 3: InvalidPartyStatus ex3)
|
||||
|
||||
ClaimResult Unblock (1: UserInfo user, 2: PartyID party_id, 3: string reason)
|
||||
throws (1: InvalidUser ex1, 2: PartyNotFound ex2, 3: InvalidPartyStatus ex3)
|
||||
|
||||
/* Shop blocking / suspension */
|
||||
|
||||
ClaimResult SuspendShop (1: UserInfo user, 2: PartyID party_id, 3: ShopID id)
|
||||
throws (1: InvalidUser ex1, 2: PartyNotFound ex2, 3: ShopNotFound ex3, 4: InvalidShopStatus ex4)
|
||||
|
||||
ClaimResult ActivateShop (1: UserInfo user, 2: PartyID party_id, 3: ShopID id)
|
||||
throws (1: InvalidUser ex1, 2: PartyNotFound ex2, 3: ShopNotFound ex3, 4: InvalidShopStatus ex4)
|
||||
|
||||
ClaimResult BlockShop (1: UserInfo user, 2: PartyID party_id, 3: ShopID id, 4: string reason)
|
||||
throws (1: InvalidUser ex1, 2: PartyNotFound ex2, 3: ShopNotFound ex3, 4: InvalidShopStatus ex4)
|
||||
|
||||
ClaimResult UnblockShop (1: UserInfo user, 2: PartyID party_id, 3: ShopID id, 4: string reason)
|
||||
throws (1: InvalidUser ex1, 2: PartyNotFound ex2, 3: ShopNotFound ex3, 4: InvalidShopStatus ex4)
|
||||
|
||||
/* Event polling */
|
||||
|
||||
Events GetEvents (1: UserInfo user, 2: domain.PartyID party_id, 3: EventRange range)
|
||||
throws (
|
||||
1: InvalidUser ex1,
|
||||
2: PartyNotFound ex2,
|
||||
3: EventNotFound ex3,
|
||||
4: base.InvalidRequest ex4
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
/* Event sink service definitions */
|
||||
|
||||
/** Исключение, сигнализирующее о том, что последнего события не существует. */
|
||||
|
Loading…
Reference in New Issue
Block a user