module MangoApi::Reports

Provides API method delegates concerning the Report entity

Public Class Methods

all() { |filter_request = filter_request| ... } click to toggle source

Retrieves report entities. Allows configuration of paging and sorting parameters by yielding a filtering object to a provided block. When no filters are specified, will retrieve the first page of 10 newest results.

Allowed FilterRequest params:

  • page

  • per_page

  • sort_field and sort_direction

  • before_date

  • after_date

@return [Array] corresponding Report entity objects

# File lib/mangopay/api/service/reports.rb, line 120
def all
  uri = provide_uri(:get_reports)
  filter_request = nil
  yield filter_request = FilterRequest.new if block_given?
  results = HttpClient.get(uri, filter_request)
  parse_results results
end
create_for_transactions(report) { |filters| ... } click to toggle source

Requests creation of a transaction report. Yields a ReportFilter object for caller to specify filtering parameters in a provided block.

Report properties:

  • Optional

    • tag

    • callback_url

    • download_format

    • sort

    • preview

    • columns

Available columns values: Alias, AuthorId, BankAccountId, BankWireRef, CardId, CardType, Country, CreationDate, CreditedFundsAmount, CreditedFundsCurrency, CreditedUserId, CreditedWalletId, Culture, DebitedFundsAmount, DebitedFundsCurrency, DebitedWalletId, DeclaredDebitedFundsAmount, DeclaredDebitedFundsCurrency, DeclaredFeesAmount, DeclaredFeesCurrency, ExecutionDate, ExecutionType, ExpirationDate, FeesAmount, FeesCurrency, Id, Nature, PaymentType, PreauthorizationId, ResultCode, ResultMessage, Status, Tag, Type, WireReference

Allowed ReportFilter params:

  • after_date

  • before_date

  • type

  • status

  • nature

  • min_debited_funds_amount

  • min_debited_funds_currency

  • max_debited_funds_amount

  • max_debited_funds_currency

  • min_fees_amount

  • min_fees_currency

  • max_fees_amount

  • max_fees_currency

  • author_id

  • wallet_id

@param report [Report] model object of the report to be created @return [Report] the newly-created Report entity object

# File lib/mangopay/api/service/reports.rb, line 53
def create_for_transactions(report)
  uri = provide_uri(:create_transaction_report)
  report.filters = ReportFilter.new unless report.filters
  yield report.filters if block_given?
  response = HttpClient.post(uri, report)
  parse response
end
create_for_wallets(report) { |filters| ... } click to toggle source

Requests creation of a wallet report. Yields a ReportFilter object for caller to specify filtering parameters in a provided block.

Report properties:

  • Optional

    • tag

    • callback_url

    • download_format

    • sort

    • preview

    • columns

Available columns values: Id, Tag, CreationDate, Owners, Description, BalanceAmount, BalanceCurrency, Currency, FundsType

Allowed FilterRequest params:

  • after_date

  • before_date

  • owner_id

  • currency

  • min_balance_amount

  • min_balance_currency

  • max_balance_amount

  • max_balance_currency

@param report [Report] model object of the report to be created @return [Report] the newly-created Report entity object

# File lib/mangopay/api/service/reports.rb, line 89
def create_for_wallets(report)
  uri = provide_uri(:create_wallet_report)
  report.filters = ReportFilter.new unless report.filters
  yield report.filters if block_given?
  response = HttpClient.post(uri, report)
  parse response
end
get(id) click to toggle source

Retrieves a report entity.

@param id [String] ID of the report to retrieve @return [Report] the requested Report entity object

# File lib/mangopay/api/service/reports.rb, line 101
def get(id)
  uri = provide_uri(:get_report, id)
  response = HttpClient.get(uri)
  parse response
end

Private Class Methods

parse(response) click to toggle source

Parses a JSON-originating hash into the corresponding Report entity object.

@param response [Hash] JSON-originating data hash @return [Report] corresponding Report entity object

# File lib/mangopay/api/service/reports.rb, line 146
def parse(response)
  MangoModel::Report.new.dejsonify response
end
parse_results(results) click to toggle source

Parses an array of JSON-originating hashes into the corresponding Report entity objects.

@param results [Array] JSON-originating data hashes @return [Array] parsed Report entity objects

# File lib/mangopay/api/service/reports.rb, line 135
def parse_results(results)
  results.collect do |entity|
    parse entity
  end
end