IFD Tools
This gem provides common functionality for use with all IFD server applications, including:
- Base tweaks in styling and functionality for ActiveAdmin
Usermanagement for access to the /admin area- Management of
EmergencyMessage,NotifierUpdate&SoftwareUpdateresources - Management of
Customer IfdTools::Tracking::Event& framework for tracking API and reporting (customer trends, etc)- Automatic inclusion of modules for generating API XML responses for
/api/emergency_messages.xml,/api/notifier_updates.xml&/api/software_updates.xml - Protected API requests by Devise authentication (auth_token)
Usage
To install:
- Create a new Rails project
- Add
gem 'ifd_tools'to yourGemfile - Run
bundle - Run
rails g ifd_tools:install - Start your server, login credentials are "[email protected]" & "P@$$w0rd" for
http://localhost:5000/admin
Tracking
- There are several configuration options for color choices in the
ifd_tools.rbinitializer. - To track specific events, create subclasses of
IfdTools::Tracking::Eventin your application, inapp/models/ifd_tools/trackingfolder. - Be sure to override the
assign_trackable_item_by_idmethod per subclass (default implement is to raise an exception) - Tracking requests can be initiated via the API at
/api/track.xml?type=product_event&id=14. Thetypeparameter is the class name without the module prefixes, underscored -> "IfdTools::Tracking::ProductEvent" should be sent as "product_event". - Also have "batch tracking" functionality available, which will accept JSON or XML in a request to process multiple entries. Each "event" is id, type and optionally timestamp (UNIX) or platform.
Customer Creation
A special helper method is provided on the ApiController class to facilitate easy Customer creation. There is plenty of inline documentation on usage there, but here's an example:
class ApiController < ApplicationController
before_filter :authenticate_customer!, :except => [:software_updates, :emergency_messages, :notifier_updates]
respond_to :json, :xml
include IfdTools::ApiControllerExtensions
create_customer do |customer|
# customer = Customer.new(params[:request][:customer]) already passed in to us, just handle special use cases for data transformations
customer.account_level = CustomerAccountLevel.find_by_abbreviation(params[:account_level])
customer
end
end