diff --git a/box/entities/account.rb b/box/entities/account.rb deleted file mode 100644 index 32a32b63..00000000 --- a/box/entities/account.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -require "grape-entity" - -require_relative "ebics_user" - -module Box - module Entities - class Account < Grape::Entity - expose :name, documentation: {type: "String", desc: "Display name for given bank account"} - expose :iban, documentation: {type: "String", desc: "Unique bank account IBAN"} - expose :bic, documentation: {type: "String", desc: "Bank branch's unique BIC"} - expose :bankname, documentation: {type: "String", desc: "Name of bank account's hosting bank"} - expose :creditor_identifier, documentation: {type: "String", desc: "Creditor identifier used for direct debits"} - expose :balance_date, documentation: {type: "Date", desc: "Date of balance"} - expose :balance_in_cents, documentation: {type: "Integer", desc: "Account balance"} - - expose(:test_mode, documentation: {type: "Boolean", desc: "Whether this is a test account"}) do |account| - account.mode == "File" || account.mode == "Fake" - end - - expose(:ebics_user, if: ->(_account, options) { options[:include].try(:include?, "ebics_user") }) do |account| - ebics_user = account.ebics_user_for(options[:env]["box.user"].id) - if ebics_user - Entities::EbicsUser.represent(ebics_user, only: %i[ebics_user signature_class state submitted_at activated_at]) - end - end - - expose(:_links, documentation: {type: "Hash", desc: "Links to resources"}) do |account, _options| - { - self: Box.configuration.app_url + "/#{account.iban}", - credit: Box.configuration.app_url + "/#{account.iban}/credits", - debit: Box.configuration.app_url + "/#{account.iban}/debits", - statements: Box.configuration.app_url + "/#{account.iban}/statements", - transactions: Box.configuration.app_url + "/#{account.iban}/transactions" - } - end - end - end -end diff --git a/box/entities/event.rb b/box/entities/event.rb deleted file mode 100644 index 11a15c4f..00000000 --- a/box/entities/event.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -require "grape-entity" - -require_relative "webhook_delivery" - -module Box - module Entities - class Event < Grape::Entity - expose :public_id, as: "id" - expose(:account, documentation: {type: "String", desc: "Display name for given bank account"}) do |event| - event.account.try(:iban) - end - expose :type - expose(:payload) do |event| - event.payload.delete "public_id" - event.payload - end - expose :triggered_at - expose :signature - expose :webhook_status - expose :webhook_retries - - expose :webhook_deliveries, using: Entities::WebhookDelivery, if: {type: "full"} - - expose(:_links, documentation: {type: "Hash", desc: "Links to resources"}) do |event, _options| - { - self: Box.configuration.app_url + "/events/#{event.public_id}", - account: Box.configuration.app_url + "/accounts/#{event.account.try(:iban)}" - } - end - end - end -end diff --git a/box/validations/unique_transaction.rb b/box/validations/unique_transaction.rb deleted file mode 100644 index cd7ac3ab..00000000 --- a/box/validations/unique_transaction.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -require "grape" - -require_relative "../models/transaction" - -module Box - class UniqueTransaction < Grape::Validations::Validators::Base - def validate_param!(attr_name, params) - unless Transaction.where(attr_name => params[attr_name]).count == 0 - raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: "must be unique" - end - end - end -end