class ApraService::Notification
Constants
- NON_NILLABLE_KEYS
Attributes
amount[RW]
expense_amount[RW]
expense_description[RW]
grant_date[RW]
granted_to_group[RW]
grantee[RW]
ignore_work_duration[RW]
purpose[RW]
purpose_description[RW]
reference[RW]
work_duration_days[RW]
work_duration_months[RW]
work_duration_years[RW]
work_end_date[RW]
work_start_date[RW]
Public Class Methods
from_hash(hash)
click to toggle source
# File lib/apralib/notification.rb, line 55 def self.from_hash(hash) notification = Notification.new notification.purpose = hash[:kayttotarkoitus] notification.purpose_description = hash[:kayttotarkoitustarkenne] notification.expense_amount = hash[:kuluosuusrahamaara] notification.expense_description = hash[:kuluosuusteksti] notification.grant_date = hash[:myontopaatoksen_antopvm] notification.granted_to_group = hash[:onko_myonnetty_tyoryhmalle] notification.amount = hash[:rahamaara] notification.grantee = Grantee.from_hash(hash[:saajatiedot]) notification.work_duration_months = hash[:tyon_kesto_kuukausia] notification.work_duration_days = hash[:tyon_kesto_paivia] notification.work_duration_years = hash[:tyon_kesto_vuosia] notification.ignore_work_duration = hash[:tyonkestoeikantaa] notification.work_start_date = hash[:tyoskentelyn_alkamispvm] notification.work_end_date = hash[:tyoskentelyn_paattymispvm] notification.reference = hash[:viite] notification end
new()
click to toggle source
# File lib/apralib/notification.rb, line 14 def initialize @ignore_work_duration = false @granted_to_group = false @work_duration_days = 0 @work_duration_months = 0 @work_duration_years = 0 @expense_amount = 0 end
Public Instance Methods
to_hash()
click to toggle source
# File lib/apralib/notification.rb, line 23 def to_hash NON_NILLABLE_KEYS.each do |key| raise "Variable #{key} cannot be nil" if instance_variable_get("@#{key}").nil? end result = {} result[:kayttotarkoitus] = purpose result[:kayttotarkoitustarkenne] = purpose_description if purpose_description result[:kuluosuusrahamaara] = expense_amount result[:kuluosuusteksti] = expense_description if expense_description result[:myontopaatoksen_antopvm] = grant_date.rfc3339 result[:onko_myonnetty_tyoryhmalle] = granted_to_group result[:rahamaara] = amount result[:saajatiedot] = grantee.to_hash result[:sisaltaako_kuluja] = expense_amount.positive? if ignore_work_duration result[:tyon_kesto_kuukausia] = 0 result[:tyon_kesto_paivia] = 0 result[:tyon_kesto_vuosia] = 0 else result[:tyon_kesto_kuukausia] = work_duration_months result[:tyon_kesto_paivia] = work_duration_days result[:tyon_kesto_vuosia] = work_duration_years end result[:tyonkestoeikantaa] = ignore_work_duration result[:tyoskentelyn_alkamispvm] = work_start_date.rfc3339 if work_start_date result[:tyoskentelyn_paattymispvm] = work_end_date.rfc3339 if work_end_date result[:viite] = reference result end