Module: MangoApi::EMoney

Extended by:
UriProvider
Defined in:
lib/mangopay/api/service/e_money.rb

Overview

Provides API method delegates concerning the EMoney entity

Class Method Summary collapse

Methods included from UriProvider

provide_uri

Class Method Details

.of_user_month(user_id, year, month, currency = nil) ⇒ EMoney

Retrieves a user’s e-money for year/month.

defaults to EUR.

Parameters:

  • +user_id+ (String)

    ID of the user whose e-money to retrieve

  • +year+ (Int)

    year for which to retrieve e-money

  • +month+ (Int)

    month for which to retrieve e-money

  • +currency+ (CurrencyIso)

    currency in which to represent results -

Returns:

  • (EMoney)

    the specified user’s EMoney entity object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/mangopay/api/service/e_money.rb', line 39

def of_user_month(user_id, year, month, currency = nil)
  uri = provide_uri(:get_users_e_money_month, user_id, year, month)
  if currency
    response = HttpClient.get_raw(uri) do |request|
      HttpClient.api_headers.each {|k, v| request.add_field(k, v)}
      request.body = CurrencyRequest.new(currency).jsonify!
    end
  else
    response = HttpClient.get(uri)
  end
  parse response
end

.of_user_year(user_id, year, currency = nil) ⇒ EMoney

Retrieves a user’s e-money for year.

defaults to EUR.

Parameters:

  • +user_id+ (String)

    ID of the user whose e-money to retrieve

  • +year+ (Int)

    year for which to retrieve e-money

  • +currency+ (CurrencyIso)

    currency in which to represent results -

Returns:

  • (EMoney)

    the specified user’s EMoney entity object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mangopay/api/service/e_money.rb', line 18

def of_user_year(user_id, year, currency = nil)
  uri = provide_uri(:get_users_e_money_year, user_id, year)
  if currency
    response = HttpClient.get_raw(uri) do |request|
      HttpClient.api_headers.each {|k, v| request.add_field(k, v)}
      request.body = CurrencyRequest.new(currency).jsonify!
    end
  else
    response = HttpClient.get(uri)
  end
  parse response
end