Module: RockRMS::Client::PaymentDetail

Included in:
RockRMS::Client
Defined in:
lib/rock_rms/resources/payment_detail.rb

Instance Method Summary collapse

Instance Method Details

#create_payment_detail(payment_type: nil, foreign_key: nil, card_type: nil, last_4: nil, currency_type_value_id: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rock_rms/resources/payment_detail.rb', line 9

def create_payment_detail(
  payment_type: nil,
  foreign_key: nil,
  card_type: nil,
  last_4: nil,
  currency_type_value_id: nil
)
  options = {
    'CurrencyTypeValueId' => currency_type_value_id || cast_payment_type(payment_type),
    'CreditCardTypeValueId' => cast_card_type(card_type),
    'ForeignKey' => foreign_key
  }

  options['AccountNumberMasked'] = "************#{last_4}" if last_4

  post(payment_detail_path, options)
end

#delete_payment_detail(id) ⇒ Object



38
39
40
# File 'lib/rock_rms/resources/payment_detail.rb', line 38

def delete_payment_detail(id)
  delete(payment_detail_path(id))
end

#list_payment_details(options = {}) ⇒ Object



4
5
6
7
# File 'lib/rock_rms/resources/payment_detail.rb', line 4

def list_payment_details(options = {})
  res = get(payment_detail_path, options)
  Response::PaymentDetail.format(res)
end

#update_payment_detail(id, foreign_key: nil, card_type: nil, last_4: nil, currency_type_value_id: nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/rock_rms/resources/payment_detail.rb', line 27

def update_payment_detail(id, foreign_key: nil, card_type: nil, last_4: nil, currency_type_value_id: nil)
  options = {}

  options['CreditCardTypeValueId'] = cast_card_type(card_type) if card_type
  options['ForeignKey'] = foreign_key if foreign_key
  options['AccountNumberMasked'] = "************#{last_4}" if last_4
  options['CurrencyTypeValueId'] = currency_type_value_id if currency_type_value_id

  patch(payment_detail_path(id), options)
end