Module: MangoApi::Cards

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

Overview

Provides API method delegates concerning the Card entity

Class Method Summary collapse

Methods included from UriProvider

provide_uri

Class Method Details

.complete_registration(id, registration_data) ⇒ CardRegistration

Allows completion of a card registration with the registration data received from the Tokenization Server.

Tokenization Server object

Parameters:

  • +registration_data+ (String)

    registration data from the

Returns:

  • (CardRegistration)

    the completed CardRegistration entity



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

def complete_registration(id, registration_data)
  uri = provide_uri(:complete_card_registration, id)
  request = CompleteRegistrationRequest.new(registration_data)
  response = HttpClient.put(uri, request)
  parse_registration response
end

.create_registration(card_registration, id_key = nil) ⇒ CardRegistration

Creates a new card registration entity.

CardRegistration properties:

  • Required

    • user_id

    • currency

  • Optional

    • tag

    • card_type

card registration to be created object

Parameters:

  • +card_registration+ (CardRegistration)

    model object of

  • +id_key+ (String)

    idempotency key for future response replication

Returns:

  • (CardRegistration)

    the newly-created CardRegistration entity



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

def create_registration(card_registration, id_key = nil)
  uri = provide_uri(:create_card_registration)
  response = HttpClient.post(uri, card_registration, id_key)
  parse_registration response
end

.deactivate(id) ⇒ Card

Deactivates the card entity specified by an id.

Parameters:

  • +id+ (String)

    ID of the card to deactivate

Returns:

  • (Card)

    the deactivated card entity object



114
115
116
117
118
# File 'lib/mangopay/api/service/cards.rb', line 114

def deactivate(id)
  uri = provide_uri(:deactivate_card, id)
  response = HttpClient.put(uri, DeactivationRequest.new)
  parse_card response
end

.get(id) ⇒ Card

Retrieves a card entity.

Parameters:

  • +id+ (String)

    ID of the card entity to retrieve

Returns:

  • (Card)

    the requested Card entity object



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

def get(id)
  uri = provide_uri(:get_card, id)
  response = HttpClient.get(uri)
  parse_card response
end

.get_registration(id) ⇒ CardRegistration

Retrieves a card registration entity.

Parameters:

  • +id+ (String)

    ID of the card registration to retrieve

Returns:

  • (CardRegistration)

    the requested entity object



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

def get_registration(id)
  uri = provide_uri(:get_card_registration, id)
  response = HttpClient.get(uri)
  parse_registration response
end

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

Retrieves pages of a user’s card 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

to provided filters

Parameters:

  • +id+ (String)

    ID of the user whose cards to retrieve

Yields:

Returns:

  • (Array)

    array of hashed card entities corresponding



81
82
83
84
85
86
87
# File 'lib/mangopay/api/service/cards.rb', line 81

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

.validate(id) ⇒ Card

Validates the card entity specified by an id.

Parameters:

  • +id+ (String)

    ID of the card to validate

Returns:

  • (Card)

    the validated card entity object



124
125
126
127
128
# File 'lib/mangopay/api/service/cards.rb', line 124

def validate(id)
  uri = provide_uri(:card_validate, id)
  response = HttpClient.post(uri, nil)
  parse_card response
end

.with_fingerprint(fingerprint) {|filter_request = FilterRequest.new| ... } ⇒ Array

Retrieves pages of card entities corresponding to a certain fingerprint. The Fingerprint is a unique hash key uniquely generated per 16-digit card number.

Allowed FilterRequest params:

  • page

  • per_page

  • sort_field and sort_direction

which to search for to provided filters

Parameters:

  • +fingerprint+ (String)

    uniquely hashed card number

Yields:

Returns:

  • (Array)

    array of hashed card entities corresponding



102
103
104
105
106
107
108
# File 'lib/mangopay/api/service/cards.rb', line 102

def with_fingerprint(fingerprint)
  uri = provide_uri(:get_cards_by_fingerprint, fingerprint)
  filter_request = nil
  yield filter_request = FilterRequest.new if block_given?
  results = HttpClient.get(uri, filter_request)
  parse_cards results
end