Module: MangoApi::Wallets

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

Overview

Provides API method delegates concerning the Wallet entity.

Class Method Summary collapse

Methods included from UriProvider

provide_uri

Class Method Details

.create(wallet, id_key = nil) ⇒ Wallet

Creates a new wallet entity.

Wallet properties:

  • Required

    • owners

    • description

    • currency

  • Optional

    • tag

Parameters:

  • +wallet+ (Wallet)

    model object of wallet to be created

  • +id_key+ (String)

    idempotency key for future response replication

Returns:

  • (Wallet)

    the newly-created Wallet entity object



24
25
26
27
28
# File 'lib/mangopay/api/service/wallets.rb', line 24

def create(wallet, id_key = nil)
  uri = provide_uri(:create_wallet)
  response = HttpClient.post(uri, wallet, id_key)
  parse response
end

.get(id) ⇒ Wallet

Retrieves a wallet entity.

Parameters:

  • +id+ (String)

    ID of the wallet to be retrieved

Returns:

  • (Wallet)

    the requested entity



50
51
52
53
54
# File 'lib/mangopay/api/service/wallets.rb', line 50

def get(id)
  uri = provide_uri(:get_wallet, id)
  response = HttpClient.get(uri)
  parse response
end

.of_user(id) {|filter_request = FilterRequest.new| ... } ⇒ Array

Retrieves pages of wallet entities belonging to a certain user entity. 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

Parameters:

  • +id+ (String)

    ID of the user whose wallets to retrieve

Yields:

Returns:

  • (Array)

    the requested entities



68
69
70
71
72
73
74
# File 'lib/mangopay/api/service/wallets.rb', line 68

def of_user(id)
  uri = provide_uri(:get_users_wallets, id)
  filter_request = nil
  yield filter_request = FilterRequest.new if block_given?
  results = HttpClient.get(uri, filter_request)
  parse_results results
end

.update(wallet) ⇒ Wallet

Updates the wallet entity identifiable by the provided wallet object’s ID.

Wallet optional properties:

  • tag

  • description

and updated data

Parameters:

  • +wallet+ (Wallet)

    wallet object with corresponding ID

Returns:

  • (Wallet)

    updated wallet entity



40
41
42
43
44
# File 'lib/mangopay/api/service/wallets.rb', line 40

def update(wallet)
  uri = provide_uri(:update_wallet, wallet)
  response = HttpClient.put(uri, wallet)
  parse response
end