Module usr

API and server code for the mobile subscriber database.

Copyright © 2009 Francseco Cesarini and Simon Thompson

Authors: Francseco Cesarini (support@erlang-consulting.com), Simon Thompson (s.j.thompson@kent.ac.uk).

References

Description

API and server code for the mobile subscriber database. The functions exported by the module fall into three classes:

System start and stop

start/0, start/1, stop/0

Customer Service API

add_usr/3, delete_usr/1, set_service/3, set_status/2, delete_disabled/0, lookup_id/1

Service API

lookup_msisdn/1, service_flag/2

Data Types

instTime()

instTime() = instance | timeout

Two different errors.

plan()

plan() = prepay | postpay

The two payment types for mobile subscribers.

service()

service() = atom()

Services are specified by atoms, including (but not limited to) data, lbs and sms. Data confirms the user has subscribed to a data plan, sms allows the user to send and receive premium rated smses, while lbs would allow third parties to execute location lookups on this particular user.

status()

status() = enabled | disabled

The status of a customer can be enabled or disabled.

usr()

usr() = #usr{msisdn = integer(), id = integer(), status = status(), plan = plan(), services = [service()]}

Record for users. The default value of status is enabled and of services is [].

Function Index

add_usr/3Add a user with specified phone number, customer id and plan type.
delete_disabled/0Traverses the table and deletes all users whose status is set to disabled.
delete_usr/1Delete a user and all their associated entries.
lookup_id/1Lookup a user based on their CustId and return a record of type usr.
lookup_msisdn/1Lookup the usr record for a customer, specified by a PhoneNo.
service_flag/2This function will check if a user exists and has an enabled status.
set_service/3Set or unset a particular service for a particular customer.
set_status/2Set the status of a customer to be enabled or disabled.
start/0Start the system with the default filename.
start/1Start the system with the given Filename.
stop/0Stop the system.

Function Details

add_usr/3

add_usr(PhoneNum::integer(), CustId::integer(), Plan::plan()) -> ok | {error, instTime()}

Add a user with specified phone number, customer id and plan type. Returns ok or an error tuple.

delete_disabled/0

delete_disabled() -> ok | {error, timeout}

Traverses the table and deletes all users whose status is set to disabled.

delete_usr/1

delete_usr(CustId) -> any()

Delete a user and all their associated entries.

lookup_id/1

lookup_id(CustId::integer()) -> {ok, #usr{}} | {error, instance}

Lookup a user based on their CustId and return a record of type usr. If the customer does not exist, an error tuple is returned.

lookup_msisdn/1

lookup_msisdn(PhoneNo::integer()) -> {ok, #usr{}} | {error, instance}

Lookup the usr record for a customer, specified by a PhoneNo. If successful return an ok tuple with the record; otherwise return an error tuple.

service_flag/2

service_flag(PhoneNo::integer(), Service::service()) -> bool() | {error, instance | disabled}

This function will check if a user exists and has an enabled status. If so, it will traverse the list of services to determine if the subscriber is allowed to use this Service in a particular request. This is a variant of the lookup_msisdn/1 function, where logical checks are done in this module.

set_service/3

set_service(CustId::integer(), Service::service(), Flag::bool()) -> ok | {error, instTime()}

Set or unset a particular service for a particular customer. A true Flag sets the service and false unsets it.

set_status/2

set_status(CustId::integer(), Status::status()) -> ok | {error, instTime()}

Set the status of a customer to be enabled or disabled.

start/0

start() -> ok | {error, starting}

Start the system with the default filename. Returns ok or an error tuple.

start/1

start(FileName::string()) -> ok | {error, starting}

Start the system with the given Filename. Returns ok or an error tuple.

stop/0

stop() -> ok | {error, string()}

Stop the system. Returns ok or an error tuple, containing the reason for failure.


Generated by EDoc, Feb 28 2009, 12:50:24.