Koha::Patron::MessagePreference - Koha Patron Message Preference object class
my $preference = Koha::Patron::MessagePreference->new({ borrowernumber => 123, #categorycode => 'ABC', message_attribute_id => 4, message_transport_types => ['email', 'sms'], # see documentation below wants_digest => 1, days_in_advance => 7, });
Takes either borrowernumber or categorycode, but not both.
days_in_advance may not be available. See message_attributes table for takes_days configuration.
wants_digest may not be available. See message_transports table for is_digest configuration.
You can instantiate a new object without custom validation errors,
but when storing,
validation may throw exceptions.
See validate()
for more documentation.
message_transport_types
is a parameter that is not actually a column in this Koha-object.
Given this parameter,
the message transport types will be added as related transport types for this object.
For get and set,
you can access them via subroutine message_transport_types()
in this class.
my $preference = Koha::Patron::MessagePreference->new_from_default({ borrowernumber => 123, categorycode => 'ABC', # if not given, patron's categorycode will be used message_attribute_id => 1, });
NOTE: This subroutine initializes and STORES the object (in order to set message transport types for the preference), so no need to call ->store when preferences are initialized via this method.
Stores default messaging preference for categorycode
to patron for given message_attribute_id
.
Throws Koha::Exceptions::MissingParameter if any of following is missing: - borrowernumber - message_attribute_id
Throws Koha::Exceptions::ObjectNotFound if default preferences are not found.
$preference->message_name
Gets message_name for this messaging preference.
Setter not implemented.
$preference->message_transport_types Returns a HASHREF of message transport types for this messaging preference, e.g. if ($preference->message_transport_types->{'email'}) { # email is one of the transport preferences }
$preference->message_transport_types('email', 'sms'); Sets the given message transport types for this messaging preference
$preference->mtt_deliverable('sms'[, $borrowernumer]);
Returns true if given message transport type can be used to deliver message to patron.
By default,
uses the borrowernumber bound to $preference
,
but this may be overridden by providing optional $borrowernumber
parameter.
$preference->set({ message_transport_types => ['sms', 'phone'], wants_digest => 0, })->store;
Sets preference object values and additionally message_transport_types if given.
Makes a validation before actual Koha::Object->store so that proper exceptions can be thrown.
See validate()
for documentation about exceptions.
Makes a basic validation for object.
Returns Koha::Patron::MessagePreference object, or throws and exception.
Lari Taskula <lari.taskula@hypernova.fi>