Module: MangoApi::PreAuthorizations

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

Overview

Provides API method delegates concerning the PreAuthorization entity

Class Method Summary collapse

Methods included from UriProvider

provide_uri

Class Method Details

.cancel(id) ⇒ PreAuthorization

Cancels a Pre-Authorization entity.

entity object

Parameters:

  • +id+ (String)

    ID of the pre-authorization to cancel

Returns:

  • (PreAuthorization)

    the requested Pre-Authorization



73
74
75
76
77
78
# File 'lib/mangopay/api/service/pre_authorizations.rb', line 73

def cancel(id)
  uri = provide_uri(:cancel_pre_authorization, id)
  cancel_request = CancelRequest.new
  response = HttpClient.put(uri, cancel_request)
  parse response
end

.create(pre_auth, id_key = nil) ⇒ PreAuthorization

Creates a new Pre-Authorization entity.

PreAuthorization properties:

  • Required

    • author_id

    • debited_funds

    • card_id

    • secure_mode_return_url

  • Optional

    • tag

    • secure_mode

data model object entity object

Parameters:

  • +pre_auth+ (PreAuthorization)

    the pre-authorization

  • +id_key+ (String)

    idempotency key for future response replication

Returns:

  • (PreAuthorization)

    the newly-created PreAuthorization



28
29
30
31
32
# File 'lib/mangopay/api/service/pre_authorizations.rb', line 28

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

.get(id) ⇒ PreAuthorization

Retrieves a Pre-Authorization entity.

entity object

Parameters:

  • +id+ (String)

    ID of the pre-authorization to retrieve

Returns:

  • (PreAuthorization)

    the requested Pre-Authorization



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

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

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

Retrieves pre-authorization entities belonging to a certain card. 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

  • result_code

  • status

  • payment_status

Parameters:

  • +id+ (String)

    ID of the card whose pre-authorizations to retrieve

Yields:

Returns:

  • (Array)

    corresponding PreAuthorization entity objects



96
97
98
99
100
101
102
# File 'lib/mangopay/api/service/pre_authorizations.rb', line 96

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

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

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

  • status

  • result_code

  • payment_status

Parameters:

  • +id+ (String)

    ID of the dispute whose transactions to retrieve

Yields:

Returns:

  • (Array)

    the requested Transaction entity objects



60
61
62
63
64
65
66
# File 'lib/mangopay/api/service/pre_authorizations.rb', line 60

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