Class: K2ConnectRuby::K2Entity::K2FinancialEntities::Destination::ExternalMpesaWallet

Inherits:
DestinationRequest
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_mpesa_wallet.rb

Instance Attribute Summary collapse

Attributes inherited from DestinationRequest

#amount, #description, #favourite, #nickname, #type

Instance Method Summary collapse

Methods inherited from DestinationRequest

#initialize

Constructor Details

This class inherits a constructor from K2ConnectRuby::K2Entity::K2FinancialEntities::Destination::DestinationRequest

Instance Attribute Details

#networkObject

Returns the value of attribute network.



12
13
14
# File 'lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_mpesa_wallet.rb', line 12

def network
  @network
end

#phone_numberObject

Returns the value of attribute phone_number.



12
13
14
# File 'lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_mpesa_wallet.rb', line 12

def phone_number
  @phone_number
end

Instance Method Details

#destination_payloadObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_mpesa_wallet.rb', line 17

def destination_payload
  {
    type: type,
    nickname: nickname,
    phone_number: phone_number,
    network: network,
    amount: amount,
    description: description,
    favourite: ActiveModel::Type::Boolean.new.cast(favourite),
  }
end

#phone_number_formatObject



29
30
31
32
33
# File 'lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_mpesa_wallet.rb', line 29

def phone_number_format
  unless phone_number&.match?(/^(254\d{9})$/)
    errors.add(:phone_number, "#{phone_number} has an invalid length or format. Must be 254XXXXXXXXX.")
  end
end