# Flipkart Games SDK

### Installation

- Install fk-games-sdk into your npm project. You can use the following command and run it in your terminal at the project root.
```sh
npm install fk-games-sdk
```

- You could also use fk-games-sdk by directly including the script into your html file.
```sh
http://img1a.flixcart.com/linchpin-web/batman-returns/build/fk-game-sdk@0.0.1-alpha.27.js
```
- Minified and GZipped script
```sh
http://img1a.flixcart.com/linchpin-web/batman-returns/build/fk-game-sdk-min@0.0.1-alpha.27.js
```

You could replace version numbers in the script tag with the latest npm version if the README isn't up to date.

### Initialize using NPM
```sh
// NPM only : import will make sure we create FKExtension on the window object to give clients a way to create new platform instance and access modules
import * as GamesSDK from  "fk-games-sdk";
// NOTE - please refrain from calling any module before the DOMContentLoaded callback
window.addEventListener('DOMContentLoaded', function() {
    const fkPlatform = FKExtension.newPlatformInstance();
    fkPlatform.getModuleHelper().getAnalyticsModule().sendGameAnalyticsEvent({
            gameName: 'bestGame'
            campaignId?: 'abc-zyx';
            energyPoints?: 300;
            league?: 'gold';
            badgesCount?: 2;
            friendCount?: 150;
            position?: 4;
            transactions?: ['power', 'time'];
            rewards?: ['first', 'second'];
            powers?: ['strength'];
            deathCount?: 3;
            livesLeft?: 2;
            actionType: GameActionType.SHARE;
        }
    ).then((data) => {
        // Do something based on data
    });
});
```

### Usage 
fk-games-sdk is a set of modules that help client use Flipkart functionalities for easy game development. All modules are promisified.

- [NavigationModule](https://github.com/muskeinsingh/fk-games-sdk/blob/master/src/interfaces/NavigationModule.ts "Navigation Module") - fkPlatform.getModuleHelper().getNavigationModule()

~~~
goBack()
navigate(action)
~~~

- [AnalyticsModule](https://github.com/muskeinsingh/fk-games-sdk/blob/master/src/interfaces/OmnitureModule.ts "Analytics Module") - fkPlatform.getModuleHelper().getAnalyticsModule()
~~~
sendGameAnalyticsEvent(gameEventData)
~~~

- [ServerTimeModule](https://github.com/muskeinsingh/fk-games-sdk/blob/master/src/interfaces/ServerTimeModule.ts "Server Time Module") - fkPlatform.getModuleHelper().getServerTimeModule()
~~~
getCurrentTime()
~~~

- [ShareModule](https://github.com/muskeinsingh/fk-games-sdk/blob/master/src/interfaces/ShareModule.ts "Share Module") - fkPlatform.getModuleHelper().getShareModule()
~~~
share(url, title)
~~~

- [ImageResolverModule](https://github.com/muskeinsingh/fk-games-sdk/blob/master/src/interfaces/ImageResolverModule.ts "Image Resolver Module") - fkPlatform.getModuleHelper().getImageResolverModule()
~~~
resolveImage(url, width, height, quality)
~~~

- [AssetsModule](https://github.com/muskeinsingh/fk-games-sdk/blob/master/src/interfaces/AssetsModule.ts "Assets Module") - fkPlatform.getModuleHelper().getAssetsModule()
~~~
getAssetMap(themeId)
~~~

- [GenericUtilsModule](https://github.com/muskeinsingh/fk-games-sdk/blob/master/src/interfaces/GenericUtilsModule.ts "Generic Utils Module") - fkPlatform.getModuleHelper().getGenericUtilsModule()
~~~
setStatusBarColor(color)
disableFlyout()
enableFlyout()
~~~
