Skip to content

Instantly share code, notes, and snippets.

@antoniogarrote
Created February 16, 2018 04:42
Show Gist options
  • Save antoniogarrote/315bb475610754fee0cf9230a287f645 to your computer and use it in GitHub Desktop.
Save antoniogarrote/315bb475610754fee0cf9230a287f645 to your computer and use it in GitHub Desktop.
#%RAML Async 0.1
title: Loan Async API
version: 1.0
description: Asynchronous API used to track changes in the loans processing pipeline.
transport: amqp
types:
MonetaryAmountData:
properties:
value: number
currency: string
LoanCreatedEvent:
properties:
uuid: string
loan_id: string
customer_id: string
amount: MonetaryAmountData
interest_rate: number
timestamp: datetime
LoanChangeEvent:
properties:
uuid: string
loan_id: string
timestamp: datetime
old_state:
enum:
- underwriting
- cancelled
- repayment
- closed
- failed
new_state:
enum:
- underwriting
- cancelled
- repayment
- closed
- failed
LoanFailedEvent:
properties:
uuid: string
loan_id: string
customer_id: string
amountPaid: MonetaryAmountData
amountFailed: MonetaryAmountData
interest_rate: number
timestamp: datetime
LoanRepaymentEvent:
properties:
uuid: string
customer_id: string
principal_repaid: MonetaryAmountData
interest_repaid: MonetaryAmountData
loan_id: string
connection:
scheme: amqp
host: rabbit.myorg.com
port: 5672
# default serialization
serialization: application/json
# global bindings
bindings:
amqp_exchange: loans_exchange
amqp_exchange_type: topic
endpoints:
/loans:
pattern: publish-subscribe
description: Subscribes to all loan events for all loans
operations:
subscribe:
message:
schema: LoanCreatedEvent | LoanChangeEvent | LoanFailedEvent
publish:
message:
schema: LoanCreatedEvent
bindings:
amqp_routing_key: "*.*"
/loans/{loan_id}:
pattern: publish-subscribe
description: Subscribes to all loan events for an existing loan
operations:
subscribe:
message:
schema: LoanChangeEvent | LoanFailedEvent
publish:
message:
schema: LoanChangeEvent | LoanFailedEvent
parameters:
- name: loan_id
schema: string
bindings:
amqp_routing_key: "{loan_id}.*"
/loans/created:
pattern: publish-subscribe
description: Subscribes to all loan creation events
operations:
publish:
message:
schema: LoanCreatedEvent
subscribe:
message:
schema: LoanCreatedEvent
bindings:
amqp_routing_key: "*.created"
/loans/underwritten:
pattern: publish-subscribe
description: Subscribes to all loan underwritten events
operations:
subscribe:
message:
schema: LoanChangeEvent
bindings:
amqp_routing_key: "*.underwritten"
/loans/cancelled:
pattern: publish-subscribe
description: Subscribes to all loan cancelation events
operations:
subscribe:
message:
schema: LoanChangeEvent
bindings:
amqp_routing_key: "*.cancelled"
/loans/repayments:
pattern: publish-subscribe
description: Subscribes to all loan repayments events for all loans
operations:
subscribe:
message:
schema: LoanRepaymentEvent
bindings:
amqp_exchange: repayments_exchange
amqp_routing_key: "*"
/loans/{loan_id}/repayments:
pattern: publish-subscribe
pattern: publish-subscribe
description: Subscribes to all repayments events for a particular loan
parameters:
- name: loan_id
schema: string
operations:
subscribe:
message:
schema: LoanRepaymentEvent
publish:
message:
schema: LoanRepaymentEvent
bindings:
amqp_exchange: repayments_exchange
amqp_routing_key: "{loan_id}"
/loans/failures:
pattern: publish-subscribe
description: Subscribes to all loan failed payments events for all loans
operations:
subscribe:
message:
schema: LoanFailedEvent
bindings:
amqp_routing_key: "*.failures"
/loans/closed:
pattern: publish-subscribe
description: Sbuscribe to all closed events for all loans
operations:
subscribe:
message:
schema: LoanChangeEvent
bindings:
amqp_routing_key: "*.closed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment