Module: RockRMS::Client::SavedPaymentMethod

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

Instance Method Summary collapse

Instance Method Details

#create_saved_payment_method(gateway_id:, gateway_person_id: nil, is_default: 0, payment_detail_id:, person_alias_id:, name:, reference_number:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rock_rms/resources/saved_payment_method.rb', line 9

def create_saved_payment_method(
  gateway_id:,
  gateway_person_id: nil,
  is_default: 0,
  payment_detail_id:,
  person_alias_id:,
  name:,
  reference_number:
)
  options = {
    'FinancialGatewayId'       => gateway_id,
    'FinancialPaymentDetailId' => payment_detail_id,
    'IsDefault'                => is_default,
    'Name'                     => name,
    'PersonAliasId'            => person_alias_id,
    'ReferenceNumber'          => reference_number
  }

  if gateway_person_id
    options['GatewayPersonIdentifier'] = gateway_person_id
  end

  post(saved_payment_method_path, options)
end

#delete_saved_payment_method(id) ⇒ Object



57
58
59
# File 'lib/rock_rms/resources/saved_payment_method.rb', line 57

def delete_saved_payment_method(id)
  delete(saved_payment_method_path(id))
end

#list_saved_payment_methods(options = {}) ⇒ Object



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

def list_saved_payment_methods(options = {})
  res = get(saved_payment_method_path, options)
  Response::SavedPaymentMethod.format(res)
end

#update_saved_payment_method(id, gateway_id: nil, gateway_person_id: nil, is_default: nil, payment_detail_id: nil, person_alias_id: nil, name: nil, reference_number: nil) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rock_rms/resources/saved_payment_method.rb', line 34

def update_saved_payment_method(
  id,
  gateway_id: nil,
  gateway_person_id: nil,
  is_default: nil,
  payment_detail_id: nil,
  person_alias_id: nil,
  name: nil,
  reference_number: nil
)
  options = {}

  options['FinancialGatewayId']       = gateway_id        if gateway_id
  options['GatewayPersonIdentifier']  = gateway_person_id if gateway_person_id
  options['IsDefault']                = is_default        if is_default
  options['FinancialPaymentDetailId'] = payment_detail_id if payment_detail_id
  options['Name']                     = name              if name
  options['PersonAliasId']            = person_alias_id   if person_alias_id
  options['ReferenceNumber']          = reference_number  if reference_number

  patch(saved_payment_method_path(id), options)
end