Commit 662a3ef1 authored by Husnan's avatar Husnan

Add README.md

parents
Pipeline #96 canceled with stages
# MDD Update Balance Library
Easily update balance for UNIK (Uang Elektronik)
### How to use
#### Dependencies
- Android Studio
- Java
- Android minimum version 22
- Permissions `android.permission.READ_PHONE_STATE` and `android.permission.INTERNET`
### Usage
1. Add MDD repository url to your `project/build.gradle`
```gradle
allprojects {
repositories {
...
maven {
url "https://repo.emhusnan.id/artifactory/android-libs/"
credentials {
username = given_username
password = given_password
}
}
...
}
}
```
2. Add MDD Service dependencies to your `app/build.gradle` with this line
```gradle
dependencies {
....
implementation 'com.mdd.service:partner-connect:1.0.0'
...
}
```
3. On your Application class create configuration for MDD Service, example
```java
import id.emhusnan.mdd.service.ConfigService;
import id.emhusnan.mdd.service.MDDService;
public class MyApp extends Application {
....
String GIVE_MID=""; // please ask us for credential
String GIVE_TID="";// please ask us for credential
String GIVEN_TOKEN="";// please ask us for credential
public void initConfig() {
ConfigService configService = new ConfigService();
configService.setMid(GIVE_MID);
configService.setTid(GIVE_TID);
configService.setToken(GIVEN_TOKEN);
MDDService initialize = MDDService.with(this, configService);
// for debugging purpose
if (initialize.isValid())
Toast.makeText(this, "MDD Service has valid configuration and ready to use", Toast.LENGTH_SHORT).show();
else
Toast.makeText(this, "Invalid configuration for MDD Service", Toast.LENGTH_SHORT).show();
}
....
}
```
4. Extend your activity with `MDDUpdateBalanceActivity` this will implement abstract method `getCommand` and `getMDDView`
Example:
```java
public class MainActivity extends MDDUpdateBalanceActivity implements MDDUpdateBalanceView {
private int MY_PERMISSIONS_REQUEST_READ_CONTACTS = 1;
private int COMMAND = MDDCommand.COMMAND_GET_BALANCE;
@Override
protected int getCommand() {
return COMMAND;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((MyApp) getApplication()).initConfig();
}
@Override
protected MDDUpdateBalanceView getMDDView() {
return this;
}
@Override
public void onNFcCardNotSupported(int error_code) {
Toast.makeText(this, "onNFcCardNotSupported", Toast.LENGTH_SHORT).show();
}
@Override
public void onNfcCardFound() {
Toast.makeText(this, "Card found", Toast.LENGTH_SHORT).show();
}
@Override
public void onFinishOperation() {
}
@Override
public void onUpdateBalanceError(String reason) {
}
@Override
public void onBeginOperation() {
}
@Override
public void onUpdateBalaceSuccess(SuccessUpdateBalance successUpdateBalance) {
Toast.makeText(this, successUpdateBalance.getMessage(), Toast.LENGTH_SHORT).show();
}
@Override
public void onBalanceInfoAvailable(CardInfo cardInfo) {
Toast.makeText(this, "Balance " + cardInfo.getBalance(), Toast.LENGTH_SHORT).show();
COMMAND = MDDCommand.COMMAND_UPDATE_BALANCE;
}
}
```
### Classess
##### MDDCommand
Responsibility: Handle constants for command
Available values:
* `COMMAND_GET_BALANCE`: get card balance
* `COMMAND_UPDATE_BALANCE`: update pending balance to card
##### MDDService
Responsibility: Singleton for activation service
How to use:
```java
//1. Initialize instance,
MDDService initialize = MDDService.with(context, configService);
//2. Validate
boolean isValidService = initialize.isValid();
//3. Get instance
MDDService sameInstance= MDDService.getInstance();
```
##### MDDUpdateBalanceView
Responsibility: Library communication using this view
Available methods:
```java
void onNFcCardNotSupported(int error_code);
void onNfcCardFound();
void onFinishOperation();
void onBalanceInfoAvailable(CardInfo cardInfo);
void onUpdateBalaceSuccess(SuccessUpdateBalance successUpdateBalance);
void onUpdateBalanceError(String reason);
void onBeginOperation();
```
License
Confidential for MDD Partner Only
----
PT. Multidaya Dinamika
**term and condition applied**
[//]: # (These are reference links used in the body of this note and get stripped out when the markdown processor does its job. There is no need to format nicely because it shouldn't be seen. Thanks SO - http://stackoverflow.com/questions/4823468/store-comments-in-markdown-syntax)
[dill]: <https://github.com/joemccann/dillinger>
[git-repo-url]: <https://github.com/joemccann/dillinger.git>
[john gruber]: <http://daringfireball.net>
[df1]: <http://daringfireball.net/projects/markdown/>
[markdown-it]: <https://github.com/markdown-it/markdown-it>
[Ace Editor]: <http://ace.ajax.org>
[node.js]: <http://nodejs.org>
[Twitter Bootstrap]: <http://twitter.github.com/bootstrap/>
[jQuery]: <http://jquery.com>
[@tjholowaychuk]: <http://twitter.com/tjholowaychuk>
[express]: <http://expressjs.com>
[AngularJS]: <http://angularjs.org>
[Gulp]: <http://gulpjs.com>
[PlDb]: <https://github.com/joemccann/dillinger/tree/master/plugins/dropbox/README.md>
[PlGh]: <https://github.com/joemccann/dillinger/tree/master/plugins/github/README.md>
[PlGd]: <https://github.com/joemccann/dillinger/tree/master/plugins/googledrive/README.md>
[PlOd]: <https://github.com/joemccann/dillinger/tree/master/plugins/onedrive/README.md>
[PlMe]: <https://github.com/joemccann/dillinger/tree/master/plugins/medium/README.md>
[PlGa]: <https://github.com/RahulHP/dillinger/blob/master/plugins/googleanalytics/README.md>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment