• SDK requirements

    - Android minSdkVersion 15
    - Gradle version 2.1.2

  • SDK structure

    SDK consists of 10 main packages: one of them is mandatory and others are optional. Check detailed descriptions for all packages below.


    1) Mandatory package

      - com.coriunder.base - this package is included to SDK by default. It deals with internet connection, users' sessions, base models, base responses' parsing and other commonly used things.

    You may read more about adding this package here


    2) Optional packages

      - com.coriunder.account - this package is designed to make calls to the Account service. All service's methods can be accessed using AccountSDK class

      - com.coriunder.appidentity - this package is designed to make calls to the AppIdentity service. All service's methods can be accessed using AppIdentitySDK class

      - com.coriunder.balance - this package is designed to make calls to the Balance service. All service's methods can be accessed using BalanceSDK class

      - com.coriunder.customer - this package is designed to make calls to the Customer service. All service's methods are divided by groups depending on their purposes. Methods which deal with customer data can be accessed using CustomerSDKCustomers class, methods which deal with friends can be accessed using CustomerSDKFriends class and methods which deal with user's shipping addresses can be accessed using CustomerSDKShippingAddresses class

      - com.coriunder.international - this package is designed to make calls to the International service. All service's methods can be accessed using InternationalSDK class

      - com.coriunder.merchant - this package is designed to make calls to the Merchant service. All service's methods can be accessed using MerchantSDK class

      - com.coriunder.paymentmethods - this package is designed to make calls to the PaymentMethods service. All service's methods can be accessed using PaymentMethodsSDK class

      - com.coriunder.shop - this package is designed to make calls to the Shop service. All service's methods are divided by groups depending on their purposes. Methods which deal with carts can be accessed using ShopSDKCarts class, methods which deal with downloads can be accessed using ShopSDKDownloads class, methods which deal with merchants can be accessed using ShopSDKMerchants class, methods which deal with products can be accessed using ShopSDKProducts class and methods which deal with shops can be accessed using ShopSDKShops class

      - com.coriunder.transactions - this package is designed to make calls to the Transactions service. All service's methods can be accessed using TransactionsSDK class

    You may read more about adding these packages here

  • Adding Coriunder SDK to your project

    1) Pull Coriunder base project. That is the base for any Coriunder SDK you are going to use. It contains commonly used methods and helps SDKs to communicate with each other.

    2) Import it as a module to your project (File -> New -> Import Module). Your settings.gradle file should be automatically updated and should list ':coriunder' now. If not - add it manually.

    include ':app', ':coriunder'

    3) Go to build.gradle file of your main application's module (by default - build.gradle(Module:app)), add coriunder as dependency and sync changes.

    dependencies {
        compile project(":coriunder")
    }

    Now Coriunder SDK is successfully imported to your project.

  • Prepare SDK for your needs

    Coriunder SDK is flexible: it allows you to use only those parts which you really need. Just download SDK parts you need and add them to com.coriunder package. Here is a more detailed instruction on how to do that.

    1) Now you already have a package called com.coriunder.base.

    Android project structure at this step

    Make your Android Studio to show all packages: right click on the top panel or on the Project toolbar -> uncheck "Compact Empty Middle Packages" option.

    Compact Empty Middle Packages position

    As a result, you'll see such structure

    Android project structure at this step

    2) Download the folder with the SDK part you need, copy it and paste to com.coriunder package

    Copying process example

    The result will look like this

    Android project structure at this step

    Add all SDK parts you need this way to use them with your app.

    NOTE: you should add Coriunder base to your project only once. All SDK parts for the project should be pasted to the same com.coriunder package in the same module

    Android project structure at this step
  • Prepare your application

    1) Create a class which would extend Application and init Coriunder SDK in its onCreate

    public class MyApp extends Application {
        @Override
        public final void onCreate() {
            super.onCreate();
            Coriunder.init(getApplicationContext());
        }
    }

    2) Make several changes in your AndroidManifest.xml

    Add recently created Application class under the application tag like this

    <application android:name="com.testapp.MyApp">

    Add Internet permission

    <uses-permission android:name="android.permission.INTERNET"/>

    If you are going to use Customer SDK, add SaveCustomerAsyncService to your manifest too. It is used to perform time consuming user data saving task in a separate thread which would not depend on activity.

    <service android:name="com.coriunder.customer.SaveCustomerAsyncService"/>

    3) Go to com.coriunder.base.utils.Constants file and set mandatory parameters there:

      a) SERVICE_URL - this is your server URL which leads to your services location, but doesn't specify exact service. It should look like "http://yourdomain.com/v2/". Depending on the service you call the last part of the URL is being added automatically by the SDK (Customer.svc, Shop.svc, etc). In case later you'll need to change the URL dynamically in your app, you may call setServiceUrl method

      b) APP_TOKEN - this is your application token, which should be generated in your services' admin panel. It is automatically added to requests' headers or bodies when required. In case later you'll need to change the application token dynamically in your app, you may call setAppToken method

      c) SHA256_SALT - this is salt, which is being used when requests' signatures are being created. It should be generated in your services' admin panel for the specified application token

    Other features

    1) SDK encrypts stored user data using SimpleCrypto. To enable this option go to com.coriunder.base.utils.Constants and set your crypto seed to the CRYPTO_SEED variable

    2) To enable or disable logging requests and responses in the logcat go to com.coriunder.base.utils.Constants and set corresponding value to the ENABLE_LOGS variable

    3) Volley, which is used in the SDK, allows to change timeout and retries' amount. To change that go to com.coriunder.base.utils.Constants and update DEFAULT_TIMEOUT_MS, DEFAULT_MAX_RETRIES and DEFAULT_BACKOFF_MULTIPLIER variables.

    4) In case user's session expires or any method which requires user to be logged in is being accessed when nobody is logged in, local broadcast with action Coriunder.SESSION_EXPIRED is being sent. So to be notified about session expiration add local broadcast receiver for the corresponding action

    LocalBroadcastManager.getInstance(this).registerReceiver(
        new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                // do required stuff here
            }
        },
        new IntentFilter(Coriunder.SESSION_EXPIRED));
  • Using the SDK

    To use Coriunder SDK just call the required method of the corresponding SDK part. Last parameter is usually a callback, which returns full info about the request's result.

    Example:
    (new AccountSDK()).setNewPassword("newPassword", "yourOldPassword", new ReceivedServiceCallback() {
        @Override
        public void onResultReceived(boolean isSuccess, ServiceResult serviceResult, String message) {
            if (isSuccess) {
    	        // do your stuff here
    	    } else {
    		    // do your stuff here
    	    }
    	}
    });