User Tools

Site Tools


developers:getting-started

Differences

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

Link to this comparison view

Next revision
Previous revision
developers:getting-started [2016/10/26 07:48]
127.0.0.1 external edit
— (current)
Line 1: Line 1:
-====== Developers - Getting started ====== 
- 
-====== 1. Android implementation of Papi ====== 
- 
-//See DemoBank MainFragment.java example// 
- 
-Prerequisites: used external libraries: 
- 
-  * [[https://github.com/loopj/android-async-http|https://github.com/loopj/android-async-http]] 
-  * [[https://github.com/smarek/httpclient-android|https://github.com/smarek/httpclient-android]] 
- 
-ADUCID PEIG API (Papi) provides simple way how to integrate ADUCID to custom client application. To keep session cookies, Papi uses http async client. (papi.getAsyncClient()) 
- 
-===== 1.1. How to make an authentication request? ===== 
- 
-  - First create an instance of Papi \\ (only one per application / set of requests) 
-  - Prepare a handler which is going to be called when Papi is finished (see below) 
-  - Call Papi method aducidAuthentication (): 
- 
-<font inherit/courier new;;inherit;;inherit>aducidAuthentication(String **url**, Handler **handler**)</font> 
- 
-  * **url**  is address of your **application**  including protocol, e.g. https://demobank.aducid.com/demobank 
-  * **handler**  is code that is called to evaluate authentication 
- 
-In your Handler override **handleMessage** (Message msg) and get the result: 
- 
-<font inherit/courier new;;inherit;;inherit>PapiResult result = msg.getData().getParcelable(</font>**<font inherit/courier new;;green;;inherit>"result"</font>** <font inherit/courier new;;inherit;;inherit>);</font> 
- 
-<code> 
-</code> 
- 
-The evaluate it - see Responses: 
- 
-===== 1.2. Responses ===== 
- 
-Your code should evaluate these possible outcomes: 
- 
-**<font inherit/courier new;;navy;;inherit>I.</font>** 
- 
-**<font inherit/courier new;;navy;;inherit>if</font>** <font inherit/courier new;;inherit;;inherit>result.isOK()</font> 
- 
-Your session is authenticated 
- 
-In DemoBank, result.gerRedirect() contains link to page with account data 
- 
-**<font inherit/courier new;;navy;;inherit>II.</font>** 
- 
-**<font inherit/courier new;;navy;;inherit>else if</font>** <font inherit/courier new;;inherit;;inherit>(result.peigNotInstalled())</font> 
- 
-PEIG is not installed. To fix it, you can display a dialog and then open GooglePlay to install it: 
- 
-<code>//getPapi// ().installPEIG(getActivity()); 
-</code> 
- 
-**<font inherit/courier new;;navy;;inherit>III.</font>** 
- 
-**<font inherit/courier new;;navy;;inherit>else if</font>** <font inherit/courier new;;inherit;;inherit>(result.</font><font inherit/courier new;;inherit;;inherit>isNetworkError())</font> 
- 
-Communication error occurred – either phone has no connectivity or destination cannot be reached (wrong URL or server is not running). 
- 
-**<font inherit/courier new;;navy;;inherit>IV.</font>** 
- 
-**<font inherit/courier new;;navy;;inherit>else {other exception / redirect / state}</font>** 
- 
-Custom application errors, authentication failed! 
- 
-  * result.getException() contains ADUCID exception, there are possible states: 
-      * result.notAcceptedByUser(): user rejected 
-      * result.isFactorAbsent(): user doesn’t have personal factor (and server requires it) 
-  * 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. 
- 
-//See PapiResult class for all details// 
- 
-===== 1.3. Retrieve data when <font inherit/arial,sans-serif;;inherit;;inherit>authenticated</font>// ===== 
- 
-In case I. your result is “OK” and your mobile application is authenticated. Use this session to contact your application server. AsyncHttpClient is used as http client to keep session cookies and GET/POST/PUT/DELETE operations. Following example shows how to use this client to GET a page when authenticated: 
- 
-<code>//getPapi// ().getAsyncClient().get(String url, RequestParams parameters, ResponseHandlerInterface responseHandler) 
-</code>  * **url**  – target page / method URL, e.g. https://demobank.aducid.com/demobank/**payment** 
-  * **parameters**  – specify https(s) request parameters for your request if needed 
-  * **AsyncHttpResponseHandler**  – callback to be executed when data is loaded 
-==== 1.3.1. Try to get data if not authenticated ==== 
- 
-To check your setup, test if you get error response from the server 
- 
-===== 1.4. Advanced requests ===== 
- 
-To accomplish a specific action like transaction use <font inherit/courier new;;inherit;;inherit>aducidFullOperation()</font> 
- 
-See DemoBank PaymentFragment.java example 
- 
-<font inherit/courier new;;inherit;;inherit>aducidFullOperationPost(String url, String methodName,</font>RequestParams<font inherit/courier new;;inherit;;inherit>parameters, Handler handler)</font> 
- 
-  * **url**  is address of your **application**  including protocol, e.g. https://demobank.aducid.com/demobank 
-  * **methodName**  is path to required page / method (e.g. “/remotePayment”) 
-  * **parameters**  are set of parameters which will be sent to the server, null if there is no parameter 
-  * **handler**  – see above – your callback after ADUCID is done 
-Get the result: 
- 
-<font inherit/courier new;;inherit;;inherit>PapiResult result = msg.getData().getParcelable(</font>**<font inherit/courier new;;green;;inherit>"result"</font>** <font inherit/courier new;;inherit;;inherit>);</font> 
- 
-<code> 
-</code><font 10.0pt/arial,sans-serif;;inherit;;inherit>And parse it – see responses.</font>