This document details the Zastrozzi Rewards Network Tillo Library. This library is part of the Rewards Network module and provides functionality to manage digital codes, floats, brands, and related financial operations. It leverages NgRx state management, live and mock API service implementations, a comprehensive set of UI components, and centralized API routes, ensuring modularity and scalability in digital code and float management.
The Rewards Network Tillo Library provides a robust solution for managing digital gift codes, float resources, and brand integrations within the Rewards Network suite. Key features include:
TILLO_API_CONFIG and TILLO_API_BASE_URL) to support environment-specific settings.A high-level overview of the Tillo library layout (located in /packages/rewards-network/tillo):
.eslintrc.json
jest.config.ts
ng-package.json
package.json
project.json
README.md
tsconfig.json
tsconfig.lib.json
tsconfig.lib.prod.json
tsconfig.spec.json
src/
index.ts
test-setup.ts
lib/
rewards-network.tillo.module.ts // Main Angular module aggregating state, components, services, and API routes.
rewards-network.tillo.ts // Aggregates exports from state, services, components, and routes.
+state/
identifiers.ts // Defines namespaced keys and action identifiers (e.g. for digital codes, floats, brands).
index.ts // Re-exports state pieces.
state.ts // Combines reducers into a central state.
actions/ // Contains NgRx actions for digital code and float domains.
effects/ // Contains NgRx effects to handle asynchronous operations.
facades/ // Exposes high-level facades for state access (e.g. TilloDigitalGiftCodeFacade, TilloFloatFacade, TilloBrandFacade).
reducers/ // Reducers for processing actions.
selectors/ // Memoized selectors for accessing state slices.
api-routes/ // Centralized API route definitions for digital code, float, and brand operations.
components/ // Reusable Angular components (e.g. TilloHomeComponent, DigitalCodePaginatedListComponent, FloatPaginatedListComponent, BrandPaginatedListComponent).
config/ // Configuration tokens and files (e.g. TILLO_API_CONFIG, TILLO_API_BASE_URL).
model/ // Shared models, enums, filters, requests, and responses.
routes/ // Angular route definitions specific to Tillo features.
services/ // Contains abstract, live, and mock API service implementations.
rewards-network.tillo.module.ts, it imports essential Angular modules (e.g. CommonModule, platform-specific modules such as ZWPCommonModule, ZWPAuthModule, and analytics modules), registers state via NgRx, and declares its UI components.forRoot() method that accepts a configuration object (of type TilloAPIConfig) to set API endpoints (local and remote) and to determine whether live or mock services should be used.The library leverages NgRx to manage state for digital gift codes, floats, and brands.
+state/identifiers.ts, identifiers such as TILLO_ACTION_IDENTIFIER, DIGITAL_CODE_STATE_FEATURE_KEY, FLOAT_STATE_FEATURE_KEY, and BRAND_STATE_FEATURE_KEY are used to namespace actions.getDigitalCodes, listDigitalCodes, issueDigitalCode, issueDigitalCodeWithPersonalisation, and issueDigitalCodeTilloFulfilment.getFloat, listFloats, deleteFloat, and assignFloatToBrand.listBrands, getBrand, refreshBrands, deleteBrand, restoreBrand, and assignment operations.+state/effects/) listen for dispatched actions and trigger API calls. For example, TilloDigitalGiftCodeEffects handles remote calls for issuing and managing digital codes, while TilloFloatEffects manages float retrieval and deletion.+state/reducers/) update state in response to actions. Selectors (in +state/selectors/) offer memoized access to slices of state like a list of digital codes or current float data.digitalCodes$, selectedDigitalCode$, and methods like issueDigitalCode(request), listDigitalCodes(digitalCodeId, pagination), deleteDigitalCode(digitalCodeId), etc.floats$, selectedFloat$, and methods like getFloat(floatId), listFloats(floatId, pagination), deleteFloat(floatId), updateFloatFilters(filters, triggerRemoteFetch), and resetPagination().API routes for the Tillo library are defined under the api-routes/ folder. These routes aggregate endpoints for:
Configuration tokens defined in config/ (such as TILLO_API_CONFIG and TILLO_API_BASE_URL) manage environment-specific endpoints and settings.
The Tillo library provides a variety of reusable Angular components grouped by feature domain:
INTERNAL_COMPONENTS object aggregates all individual components (as defined in components/index.ts) to enable a streamlined import into Angular modules.Each component is designed to work seamlessly with the corresponding facades and services to ensure real-time state synchronization and data integrity.
The services layer implements API communication for Tillo operations.
Mock services simulate backend responses for development and testing. They adhere to the same interface contracts as the live services.
Abstract service definitions reside in the services/abstract/ folder, ensuring a consistent API contract. Injection tokens (e.g. DIGITAL_CODE_API_SERVICE, FLOAT_API_SERVICE, BRAND_API_SERVICE) determine whether to use live or mock implementations based on the configuration provided.
nx build rewards-network.tillo
nx test rewards-network.tillo
import { RewardsNetworkTilloModule } from '@zwp/rewards-network.tillo';
@NgModule({
imports: [
RewardsNetworkTilloModule.forRoot({
remoteBaseUrl: 'https://api.remote.example.com',
localBaseUrl: 'http://localhost:3000',
apiState: 'live' // or 'mock'
}),
// other modules...
]
})
export class AppModule {}
The Rewards Network Tillo Library offers a comprehensive and scalable solution for managing digital gift codes, floats, and brand data within the Rewards Network. With robust NgRx state management, flexible API integrations, a rich set of UI components, and environment-specific configuration, this library is well-suited to meet the evolving needs of modern financial services applications. Customize and extend the components, facades, and services as our project requirements evolve.