# Calculator

POST /partner/v3/shops/:shopUuid/rental/products/:productCode/calculations

The e-shop can use this request to get a monthly payment calculation from Inbank for provided devices.
Please note that only one hero device can be sent in calculation request.

Endpoint: POST /partner/v3/shops/{shopUuid}/rental/products/{productCode}/calculations
Security: bearerAuth

## Path parameters:

  - `shopUuid` (string, required)
    Example: "a93f1f44-d5dd-4469-bfcc-c1de9e969213"

  - `productCode` (string, required)
    Example: "example_code"

## Request fields (application/json):

  - `period` (number, required)
    Number of months for repayments. Available options for model are provided in [Rental Conditions](#operation/getRentalConditions) API response e.g. 12, 24 and 36.

  - `insuranceUsed` (boolean, required)
    Whether insurance is added to the assets. If no value is passed in the request, default value true is used.

  - `assets` (array, required)
    Information on the items that are to be the objects of Smart Rent.

  - `assets.[0]` (object)

  - `assets.[0].type` (string, required)
    The type of asset categorisation.
- MODEL_BASED (the assets are categorised by manufacturer and model).
- CATEGORY_BASED (the assets are categorised by product category).
    Enum: "MODEL_BASED", "CATEGORY_BASED"

  - `assets.[0].modelId` (string)
    Required if assets["type"] is MODEL_BASED 
The identifier of the model of the product.

  - `assets.[0].categoryCode` (string)
    Required if assets["type"] is CATEGORY_BASED 
Category code of the asset from the predefined list and agreed with Inbank prior the launch. Additional category codes can be agreed with Inbank. Currently available category codes are:
- phone
- tablet
- computer
- watch
- add_on
- copying_fee (is applicable for only Latvia)
- shipping_fee

  - `assets.[0].netPrice` (number, required)
    Net price of the asset, without VAT. NB! If a fixed price model is used (where the hero device sales price for the Inbank is pre-agreed), then the agreed net price will be used in monthly payment calculations, regardless of any other net price provided.

  - `assets.[0].grossPrice` (number)
    Gross price of the asset.

  - `assets.[0].modelName` (string)
    Required if assets["type"] is CATEGORY_BASED 
Asset name.

  - `grossTradeInAmount` (number)
    Gross amount for traded-in asset. Can be used only when trade-in is available.

  - `grossCampaignDiscount` (number)
    Gross amount for campaign discount. Can be used only when campaign discount is available.

## Response 200 fields (application/json):

  - `grossMonthlyPayment` (number)
    The gross monthly payment.

  - `vat` (number)
    The vat.

  - `netMonthlyPayment` (number)
    The monthly net payment.

  - `grossTradeInAmount` (number)
    The gross trade in amount.

  - `grossCampaignDiscount` (number)
    The gross campaign discount.

  - `netMonthlyPaymentDiscount` (number)
    The monthly net payment deduction (due to both campaign discount and trade-in).

  - `totalNetPriceWithDiscount` (number)
    The total net price including all deductions (both campaign discount and trade-in).

  - `totalGrossPriceWithDiscount` (number)
    The total gross price including all deductions (both campaign discount and trade-in).

  - `period` (number)
    The period.

  - `totalNetPrice` (number)
    The total net price.

  - `totalGrossPrice` (number)
    The total gross price.

  - `assets` (array)
    Information on the items that are to be the objects of Smart Rent.

  - `assets.[0]` (object)

  - `assets.[0].modelName` (string)
    The asset name.

  - `assets.[0].name` (string)
    The asset name.

  - `assets.[0].status` (string)
    Asset status.

  - `assets.[0].categoryType` (string)
    The type of asset categorisation.

  - `assets.[0].categoryCode` (string)
    Category code of the asset from the predefined list. Additional category codes can be agreed with Inbank. Currently available category codes are:
  - phone
  - tablet
  - computer
  - watch
  - add_on
  - copying_fee (is applicable for only Latvia)
  - shipping_fee

  - `assets.[0].categoryName` (string)
    The catergory name.

  - `assets.[0].netPrice` (number)
    The net price.

  - `assets.[0].grossPrice` (number)
    The gross price.

  - `assets.[0].vat` (number)
    The vat.

  - `assets.[0].identifier` (string)
    The identifier.

  - `assets.[0].identifierType` (string)
    The identifier type.

  - `assets.[0].residualValue` (number)
    The residual value.

  - `assets.[0].netMonthlyPayment` (number)
    The monthly net payment.

  - `assets.[0].grossMonthlyPayment` (number)
    The gross monthly payment.

  - `assets.[0].modelId` (string)
    The identifier of the model of the product.

  - `assets.[0].type` (string)
    The type of asset categorisation.

  - `insuranceRequirement` (string)
    Information on whether insurance is required.
    Enum: "INSURANCE_NEVER_APPLIED", "INSURANCE_OPTIONAL", "INSURANCE_ALWAYS_APPLIED"

  - `insuranceUsed` (boolean)
    Whether insurance is used.

## Response 400 fields (application/json):

  - `message` (string)
    Additional information in human readable format. This field is not intended to be used by the API client.
    Example: "resources[0].identifier: must not be blank"

  - `errorCode` (string)
    The error code giving additional information about the nature of the error.
    Example: "CONSTRAINTS_VIOLATED_GENERAL"

## Response 401 fields (application/json):

  - `message` (string)
    Unauthorized
    Example: "unauthorized"

## Response 403 fields (application/json):

  - `message` (string)
    Unauthorized access
    Example: "User is not authorized to access this resource with an explicit deny"

## Response 404 fields (application/json):

  - `message` (string)
    Not Found
    Example: "not_found"

## Response 422 fields (application/json):

  - `message` (string)
    Additional information in human readable format. This field is not intended to be used by the API client.
    Example: "Asset model not found"

  - `errorCode` (string)
    The error code giving additional information about the nature of the error.
    Example: "ASSET_MODEL_NOT_FOUND"

## Response 500 fields (application/json):

  - `message` (string)
    Internal server error
    Example: "internal_server_error"


