# Ledger/Sales service

<h3>Using Swagger documentation in Postman</h3><br>
You can find instructions on how to convert swagger documentation to Postman collection
<a href='https://medium.com/c-sharp-progarmming/convert-swagger-documentation-to-postman-collection-d67fc95c7b14'>here</a>.<br>
There is a known problem in Postman with env variables being imported as parameters (<b>:schemaName</b>
instead of <b>{{schemaName}}</b>. More info on the issue can be found
<a href='https://github.com/postmanlabs/postman-app-support/issues/4598'>here</a>.<br>
Possible workaround is to find and replace all parameters with env variables inside Postman. For example search for
:schemaName and replace with {{schemaName}}. Instructions how to do it in Postman are
<a href='https://blog.postman.com/find-and-replace-text-code-and-variables-in-postman/'>here</a>.
<hr/><h3>Authorization</h3>
To obtain a token, start by visiting the
<a href='/apis/identifier/swagger/authentication/login'>identifier service documentation</a>
and make a request with your username and password.<br>
Once you receive the response, copy the <code>access_token</code> and use it for making requests to ledger services.

Version: 1.0

## Servers

Beta
```
https://ledger.app.beta.insly.training
```

Demo
```
https://ledger.app.demo.insly.com
```

## Security

### bearerAuth

Login with email and password to get the authentication token

Type: http
In: header
Name: Token based Auth
Scheme: bearer
Bearer Format: JWT

## Download OpenAPI description

 - [Ledger/Sales service](https://ledger.docs.insly.com/_bundle/apis/ledger/bundled.yaml)

## Quote Create

 - [POST /api/v1/ledger/sales/policies/create](https://ledger.docs.insly.com/apis/ledger/bundled/quote-create/quote-create.md): Create a new quote by schema, you can get schema in Schemes section
 - [POST /api/v1/ledger/sales/policies/mta](https://ledger.docs.insly.com/apis/ledger/bundled/quote-create/policy-mta.md)
## Quote Data

 - [GET /api/v1/ledger/sales/policies/{policyId}](https://ledger.docs.insly.com/apis/ledger/bundled/quote-data/get-quote-data.md)
 - [GET /api/v1/ledger/sales/policies/actions/{id}](https://ledger.docs.insly.com/apis/ledger/bundled/quote-data/get-quote-actions.md): Get available actions. This route has to be called after each change quote data to get to know that action is done
 - [GET /api/v1/ledger/sales/policies/{policyId}/installments-schedule](https://ledger.docs.insly.com/apis/ledger/bundled/quote-data/quote-get-installments-schedule.md)
## Quote Edit

 - [PUT /api/v1/ledger/sales/policies/{policyId}/](https://ledger.docs.insly.com/apis/ledger/bundled/quote-edit/update-quote-data.md)
 - [POST /api/v1/ledger/sales/policies/{policyId}/decline](https://ledger.docs.insly.com/apis/ledger/bundled/quote-edit/quote-decline.md)
## Quote Calculation

 - [POST /api/v1/ledger/sales/policies/{id}/calculate](https://ledger.docs.insly.com/apis/ledger/bundled/quote-calculation/quote-update-and-calculate.md): Calculate quote
 - [GET /api/v1/ledger/sales/policies/{id}/calculation](https://ledger.docs.insly.com/apis/ledger/bundled/quote-calculation/get-quote-financials.md): Get quote financials by quote id
## Quote Documents

 - [POST /api/v1/ledger/sales/policies/{id}/generated-documents](https://ledger.docs.insly.com/apis/ledger/bundled/quote-documents/generate-quote-documents.md)
 - [GET /api/v1/ledger/documents/{id}](https://ledger.docs.insly.com/apis/ledger/bundled/quote-documents/get-document.md)
## Quote Referrals

 - [POST /api/v1/ledger/sales/policies/{policyId}/referrals](https://ledger.docs.insly.com/apis/ledger/bundled/quote-referrals/send-quote-to-referral.md): It's async request, UI sends "actions" endpoint and waits until lock is released
## Quote Binding

 - [POST /api/v1/ledger/sales/policies/{policyId}/bind](https://ledger.docs.insly.com/apis/ledger/bundled/quote-binding/quote-bind.md)
## Quote Issue

 - [POST /api/v1/ledger/sales/policies/{id}/issue](https://ledger.docs.insly.com/apis/ledger/bundled/quote-issue/issue-quote.md): Issue quote, after got success please check process status by /api/v1/ledger/requests/{requestId} you can find it in this doc
## Policy Data

 - [GET /api/v1/ledger/policies/{policyId}/renewal](https://ledger.docs.insly.com/apis/ledger/bundled/policy-data/get-policy-renewal-data.md): Preparing data before renewal quote create
 - [GET /api/v1/ledger/policies/{policyId}/links](https://ledger.docs.insly.com/apis/ledger/bundled/policy-data/get-policy-with-links.md)
 - [GET /api/v1/ledger/policies/{policyId}/invoices](https://ledger.docs.insly.com/apis/ledger/bundled/policy-data/get-policy-invoices.md)
 - [GET /api/v1/ledger/policies/{id}/period-totals](https://ledger.docs.insly.com/apis/ledger/bundled/policy-data/get-policy-period-totals.md)
## Policy Documents

 - [GET /api/v1/ledger/documents/{id}](https://ledger.docs.insly.com/apis/ledger/bundled/policy-documents/get-document.md)
## Policy Termination

 - [POST /api/v1/ledger/policies/{policyId}/terminate/premiums](https://ledger.docs.insly.com/apis/ledger/bundled/policy-termination/get-policy-termination-premiums.md)
 - [POST /api/v1/ledger/policies/{policyId}/terminate](https://ledger.docs.insly.com/apis/ledger/bundled/policy-termination/terminate-policy.md)
## Schemes

 - [GET /api/v1/ledger/schemes/{type}/regular/{name}](https://ledger.docs.insly.com/apis/ledger/bundled/schemes/get-schema-regular.md): Json schema specification. * Get schema according to your rights, you can use React jsonschema form builder to create payload for quote create
## Customers by identity

 - [GET /api/v1/ledger/customers/policies/{policyId}/custom-view/installments](https://ledger.docs.insly.com/apis/ledger/bundled/customers-by-identity/get-customer-policies-installments-by-identity.md)
## Payments

 - [POST /api/v1/ledger/brokerpayments](https://ledger.docs.insly.com/apis/ledger/bundled/payments/insert-payment.md)
 - [POST /api/v1/ledger/brokerpayments/allocate](https://ledger.docs.insly.com/apis/ledger/bundled/payments/allocate-payment.md)
## Invoice

 - [POST /api/v1/ledger/broker-payments/{eventId}/credit](https://ledger.docs.insly.com/apis/ledger/bundled/invoice/credit-invoice.md): Tool for removing (edit) incorrect added invoice into payment bdx.
## Policy Technical MTA

 - [PUT /api/v1/ledger/policies/{id}/data-change](https://ledger.docs.insly.com/apis/ledger/bundled/policy-technical-mta/policy-technical-mta-data-change.md)
## Async Request

 - [GET /api/v1/ledger/requests/{requestId}](https://ledger.docs.insly.com/apis/ledger/bundled/async-request/get-quote-issue-status.md): Policy issuing happens asynchronously. Call current endpoint to validate, if policy has been issued before requesting policy data. The endpoint needs to be called until the `success` or `failure` stat
