fcx-minddale
v1.1.2
Published
This is an Angular client library for Minddale
Downloads
8
Maintainers
Readme
Minddale
Minddale is a suite of services provided by Firecodex to help you build your brands digitally immortal!
Library
This fcx-mindale (v1) is an Angular client library for Minddale, i.e. an ngx library to get your Angular web page connected to the platform and get the services done.
This library has both service to post newsletter or contact and components to have newsletter or contact forms.
Setup
This library is a very simple module added to your Angular project to use the service or components.
Install
Run cd your-app
& npm i fcx-minddale --save
Import
As any other module, first import MinddaleModule
in the app.module.ts
file.
import { MinddaleModule } from 'fcx-minddale';
@NgModule({
...,
imports: [
...,
MinddaleModule
],
...
})
export class AppModule { }
Note: There is a good chance that the public APIs in the library are not exposed to import. In that case, you may have to add them to the
tsconfig.json
file compiler path explicitly as follows.
"compilerOptions": {
...,
"paths": {
"fcx-minddale":[
"./node_modules/fcx-minddale/src/public-api"
]
}
},
Dependency
As this library uses rxjs v7.x
features like firstValueForm
module, please upgrade your project rxjs
version to at least v7.x
, as detailed here.
e.g. "rxjs": "~7.8.1"
Use
Once a client is registered with Minddale, it will be provided with a Client ID and Client Secret to connect with the platform.
Note: Make sure you keep the Client ID and Secret securely in environment file or any other secure methods.
For the purpose of publishing any Newsletter or Contact JSON data, you may use contact or newsletter components as it is, or make use of the service methods to publish contact or newsletter.
Note: In case you are not making the request from your registered domain (website), make sure you are setting the registered client domain as well in the request.
Service Methods
In order to publish either Newsletter or Contact JSON data, use the service methods as follows.
// Import Service and Models
import { MinddaleClient, MinddaleService, Newsletter, Contact } from 'fcx-minddale';
...
private minddaleClient: MinddaleClient;
// Inject Service
constructor(private minddaleService: MinddaleService) {
this.minddaleClient = {
id: environment.clientId,
secret: environment.clientSecret,
domain: environment.clientDomain // Required only if from locahost or unregistered domain
} as MinddaleClient;
}
...
// Publish Newsletter
public async publishNewsletter() {
if(this.email) {
let message = await this.minddaleService.publishNewsletter(this.minddaleClient, {email: this.email} as Newsletter);
alert(message);
}else {
alert('Please enter valid email to subscribe!');
}
}
...
// Publish Contact
public async publishContact() {
if(this.email && this.subject && this.message) {
let status = await this.minddaleService.publishContact(this.minddaleClient, {email: this.email, subject: this.subject, message: this.message} as Contact);
alert(status);
}else {
alert('Please enter valid contact info to post!');
}
}
Component Forms
In case you wanted to use the components as they are to show our ready-made pretty forms as newsletter section or contact section, just use them as any other component.
The minddale component needs the Client ID and Secret as it goes without saying, so is with newsletter component.
<fcx-mdl-newsletter [minddaleClient]="minddaleClient"></fcx-mdl-newsletter>
To use contact component as well, provide Client ID and Secret.
<fcx-mdl-contact [minddaleClient]="minddaleClient"></fcx-mdl-contact>
Note: In case you are not running the app from your registered domain (website), make sure you are setting the registered client domain as well in the input param.
Support
We, at Firecodex, would like to support anybody with queries or suggestions. Please feel free to reach out to us:
Happy Coding!