BananaCrystal / email-templates

This repository contains in-house email templates that serve as structure for our emails. Each template can be updated and modified to fit requirements.
MIT License
0 stars 0 forks source link

fees_controller.rb #37

Open geekelo opened 2 months ago

geekelo commented 2 months ago
module Api::V1::P2pTrades
  class FeesController < Api::BaseController
    def index
      gross_amount = params[:gross_amount] || 0.00

      transfer_fees = FeeService.new(gross_amount, 'p2p', 0, 'bananacrystal').bananacrystal_trading_fee

      render json: transfer_fees
    end
  end
end
geekelo commented 2 months ago

The Api::V1::P2pTrades::FeesController is a straightforward controller responsible for handling requests related to fees in P2P trades. Here’s a breakdown:

Controller Overview

The FeesController calculates and returns the trading fees based on the given gross amount.

Actions

  1. index:
    • Purpose: Calculates and returns the trading fees for a given gross amount.
    • Details:
      • Parameters:
      • gross_amount: The gross amount for which the fee is calculated. Defaults to 0.00 if not provided.
      • Process:
      • Initializes a FeeService object with the given gross_amount, the type of fee ('p2p'), a placeholder value (0), and the fee provider ('bananacrystal').
      • Calls the bananacrystal_trading_fee method on the FeeService instance to compute the fees.
      • Response:
      • Renders the calculated transfer fees as JSON.

Summary

This controller is designed to interact with the FeeService for calculating fees, keeping the controller's logic focused on handling requests and delegating the fee calculation to a service object.