User Tools

Site Tools


developers:peig-api:android

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
developers:peig-api:android [2018/07/04 08:48]
dskrbek [Creating authentication request]
developers:peig-api:android [2018/09/24 09:38]
tjotov [Developing Android application with ADUCID]
Line 1: Line 1:
 ====== Developing Android application with ADUCID ====== ====== Developing Android application with ADUCID ======
- 
-//See [[https://github.com/aducid-dev/peigapi-android/|DemoBank]] example - [[https://github.com/aducid-dev/peigapi-android/blob/master/demobank/bank/src/main/java/com/aducid/demo/bank/MainFragment.java|MainFragment.java]]// 
- 
 Prerequisites: used external libraries: Prerequisites: used external libraries:
  
Line 12: Line 9:
 ===== Creating authentication request ===== ===== Creating authentication request =====
  
-  - First create an instance of PEIG API \\ (only one per application object / set of requests)+1) First create an instance of PEIG API \\ (only one per application object / set of requests)
 <code java> <code java>
-com.aducid.peig.lib2.PeigAPI peigApi = new com.aducid.peig.lib2.PeigAPI(Context ctx)+com.aducid.peig.api.Papi papi = new com.aducid.peig.api.Papi(android.content.Context ctx) 
 +com.aducid.peig.lib2.PeigAPI peigApi = new com.aducid.peig.lib2.PeigAPI(android.content.Context ctx)
 </code> </code>
  
 +or create DummyApplication    
  
-  - Prepare a handler which is going to be called when PEIG API is finished (see below) +<code java> 
-  Call PEIG API method aducidAuthentication ():+public class DummyApplication extends com.aducid.peig.lib2.PeigAPILibApplication { 
 +    protected com.aducid.peig.api.Papi papi; 
 +    protected com.aducid.peig.lib2.PeigAPI peigApi; 
 +     
 +    public DummyApplication() { 
 +       peigApi = getPeigAPI(); 
 +       papi = getPapi(); 
 +    } 
 + 
 +... 
 +
 +</code> 
 + 
 +2) Prepare a handler which is going to be called when PEIG API is finished (see below) 
 + 
 +3) Call PEIG API method aducidAuthentication ():
  
 <code java> <code java>
-peigApi.aducidAuthentication(String url, Handler handler)+peigApi.aducidAuthentication(java.lang.String url, android.os.Handler handler)
 </code> </code>
  
   * **url**  is address of your **application**  including protocol, e.g. [[https://demobank.aducid.com/demobank|https://demobank.aducid.com/demobank]]   * **url**  is address of your **application**  including protocol, e.g. [[https://demobank.aducid.com/demobank|https://demobank.aducid.com/demobank]]
   * **handler**  is code that is called to evaluate authentication   * **handler**  is code that is called to evaluate authentication
-In your Handler override **handleMessage**  (Message msg) and get the result:+ 
 +4) In your Handler override **handleMessage**  (Message msg) and get the result:
  
 <code java> <code java>
Line 47: Line 62:
 Your session is authenticated Your session is authenticated
  
-In DemoBank, result.gerRedirect() contains link to page with account data+In DemoBank, result.gerRedirect() contains link to page with account data. Method result.containsRedirectUri() returns //true//, if redirect contains some link.
  
 II. II.
Line 58: Line 73:
  
 <code> <code>
-getPapi().installPEIG(getActivity());+papi.installPEIG(getActivity());
 </code> </code>
  
Line 80: Line 95:
       * result.notAcceptedByUser(): user rejected       * result.notAcceptedByUser(): user rejected
       * result.isFactorAbsent(): user doesn’t have personal factor (and server requires it)       * result.isFactorAbsent(): user doesn’t have personal factor (and server requires it)
-  * result.getData() contains error Message / reason+  * result.getData() contains error message / reason
   * result.getRedirect() contains page that could be opened using browser / contains additional content to download/ display to the user.   * result.getRedirect() contains page that could be opened using browser / contains additional content to download/ display to the user.
  
-//See PapiResult class for all details//+//See com.aducid.peig.lib2.Result class for all details//
  
 ===== Retrieve data when authenticated ===== ===== Retrieve data when authenticated =====
Line 90: Line 105:
  
 <code> <code>
-getPapi().getAsyncClient().get(String url, RequestParams parametersResponseHandlerInterface responseHandler)+peigApi.aducidContent(java.lang.String url, java.lang.String methodNameandroid.os.Handler handler)
 </code> </code>
  
-  * **url**  – target page / method URL, e.g. [[https://demobank.aducid.com/demobank/|https://demobank.aducid.com/demobank/]]**payment** +  * **url**  – target page / method URL, e.g. [[https://demobank.aducid.com/demobank|https://demobank.aducid.com/demobank]] 
-  * **parameters**  – specify https(s) request parameters for your request if needed +  * **methodName** - method path, e.g. /accountRemote 
-  * **AsyncHttpResponseHandler**  – callback to be executed when data is loaded+  * **handler**  – Android callback to be executed when data is loaded
 ==== Try to get data if not authenticated ==== ==== Try to get data if not authenticated ====
  
Line 102: Line 117:
 ===== Advanced requests ===== ===== Advanced requests =====
  
-To accomplish a specific action like transaction use aducidFullOperation()+To accomplish a specific action like transaction use aducidFullOperationGet() or aducidFullOperationPost().
  
-See DemoBank PaymentFragment.java example 
  
 <code java> <code java>
-aducidFullOperationPost(String url, String methodName,RequestParamsparameters, Handler handler)+peigApi.aducidFullOperationPost(String url, String methodName, com.loopj.android.http.RequestParams parametersandroid.os.Handler handler)
 </code> </code>
  
Line 117: Line 131:
  
 <code java> <code java>
-PapiResult result = msg.getData().getParcelable("result");+Handler handler = new Handler() { 
 +                    @Override 
 +                    public void handleMessage(Message msg) { 
 +                      
 +                        if (msg.getData() != null) { 
 +                            com.aducid.peig.lib2.Result result = msg.getData().getParcelable("result"); 
 +                            // do something with result 
 +                        } 
 +                    } 
 +                }
 </code> </code>