All Projects → uphold → Uphold Sdk Android

uphold / Uphold Sdk Android

Licence: mit
Uphold Android SDK

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Uphold Sdk Android

React Native Midtrans
Midtrans Mobile SDK for React Native
Stars: ✭ 57 (+78.13%)
Mutual labels:  sdk, mobile
Uploadcare Php
PHP API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.
Stars: ✭ 77 (+140.63%)
Mutual labels:  sdk, upload
Clarifai Apple Sdk
Artificial Intelligence with a Vision
Stars: ✭ 46 (+43.75%)
Mutual labels:  sdk, mobile
Cloudinary ios
Cloudinary iOS SDK
Stars: ✭ 133 (+315.63%)
Mutual labels:  sdk, upload
Countly Server
Countly helps you get insights from your application. Available self-hosted or on private cloud.
Stars: ✭ 4,857 (+15078.13%)
Mutual labels:  sdk, mobile
Voucherify Android Sdk
Android SDK for Voucherify - coupons, vouchers, promo codes
Stars: ✭ 13 (-59.37%)
Mutual labels:  sdk, mobile
Countly Sdk Cordova
Countly Product Analytics SDK for Cordova, Icenium and Phonegap
Stars: ✭ 69 (+115.63%)
Mutual labels:  sdk, mobile
Amplitude Ios
Native iOS/tvOS/macOS SDK
Stars: ✭ 216 (+575%)
Mutual labels:  sdk, mobile
Weex
A framework for building Mobile cross-platform UI
Stars: ✭ 17,793 (+55503.13%)
Mutual labels:  sdk, mobile
Countly Sdk Ios
Countly Product Analytics iOS SDK with macOS, watchOS and tvOS support.
Stars: ✭ 585 (+1728.13%)
Mutual labels:  sdk, mobile
Tiny Qiniu
A tiny qiniu sdk for uploading file.
Stars: ✭ 15 (-53.12%)
Mutual labels:  sdk, upload
Bitopro Api Node
Official nodejs SDK for the Bitopro(幣託) cryptocurrency exchange.
Stars: ✭ 29 (-9.37%)
Mutual labels:  sdk
Aeris Ios Library
Contains a demo project utilizing the AerisWeather SDK for iOS to help you get started with using our library.
Stars: ✭ 21 (-34.37%)
Mutual labels:  sdk
Magma
Platform for building access networks and modular network services
Stars: ✭ 913 (+2753.13%)
Mutual labels:  mobile
Intellij Sdk Docs
IntelliJ SDK Platform Documentation
Stars: ✭ 913 (+2753.13%)
Mutual labels:  sdk
Ios P2p Engine
Let your viewers become your unlimitedly scalable CDN.
Stars: ✭ 31 (-3.12%)
Mutual labels:  sdk
Mangosta Ios
MongooseIM client for iOS
Stars: ✭ 28 (-12.5%)
Mutual labels:  mobile
Gocertcenter
CertCenter API Go Implementation
Stars: ✭ 21 (-34.37%)
Mutual labels:  sdk
House
A runtime mobile application analysis toolkit with a Web GUI, powered by Frida, written in Python.
Stars: ✭ 910 (+2743.75%)
Mutual labels:  mobile
Ask Utils
utility functions for ask-sdk
Stars: ✭ 20 (-37.5%)
Mutual labels:  sdk

Uphold SDK for Android Build Status Release

Uphold is a next generation platform that allows anyone to transfer and exchange value for free, instantly and securely.

The Uphold SDK for Android provides an easy way for developers to integrate Android applications with the Uphold API.

Requirements

  • Android Studio
  • Minimum Android SDK Version - 16 (4.1)

Installation

Using gradle:

repositories {
	// Add the jitpack maven repository url.
	maven {
		url "https://jitpack.io"
	}
}

dependencies {
	// Add the classifier `sandboxRelease`, i.e. `'com.github.uphold:uphold-sdk-android:0.16.0:[email protected]'`, to use the sandbox environment.
	compile ('com.github.uphold:uphold-sdk-android:[email protected]') {
	    transitive = true
	}
}

Basic usage

In order to learn more about the Uphold API, please visit the developer website.

To use the SDK you must first register an Application and obtain a unique client_id and client_secret combination. We recommend your first app be registered in the Sandbox environment, so you can safely play around during development.

From the application page in your account you can get the Client ID, Client Secret and configure the redirect URI and the desired Scopes.

Authenticate User

Before instantiating the Uphold client to start the OAuth authentication flow, you must first initialize it:

UpholdClient.initialize(MainActivity.this);

Now we can start the authentication process by calling the beginAuthorization method:

UpholdClient upholdClient = new UpholdClient();
upholdClient.beginAuthorization(MainActivity.this, CLIENT_ID, scopes, state);

To receive an intent for the callback URL it is necessary to register an intent filter for one of your Android activities in order for users to be redirected to your app after the authorization process:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data
        android:pathPrefix="/connect/uphold"
        android:scheme="uphold-demo" />
</intent-filter>

In the Android activity with the intent filter override the onNewIntent method to receive the redirect code:

@Override
protected void onNewIntent(final Intent intent) {
	if (intent == null || intent.getAction() == null || !intent.getAction().equals("android.intent.action.VIEW")) {
	    return;
	}

	upholdClient.completeAuthorization(intent.getData(), CLIENT_ID, CLIENT_SECRET, "authorization_code", state).then(new PromiseAction<AuthenticationResponse>() {
        @Override
        public void call(AuthenticationResponse authenticationResponse) {
            // Get the user bearer token from the authenticationResponse.
        }
    }).fail(new PromiseAction<Exception>() {
        @Override
        public void call(Exception e) {
            // Handle the Error.
        }
    });
}

To get the current user information, just instantiate the Uphold client with the user bearer token:

UpholdClient upholdClient = new UpholdClient(bearerToken);
upholdClient.getUser().then(new PromiseAction<User>() {
    @Override
    public void call(User user) {
        // The user information is available at the user object.
    }
});

Get user accounts

UpholdClient upholdClient = new UpholdClient(bearerToken);
upholdClient.getUser().getAccounts().then(new PromiseAction<List<Account>>() {
    @Override
    public void call(List<Account> accounts) {
        // Do something with the list of accounts.
    }
});

Get user cards with chaining

UpholdClient upholdClient = new UpholdClient(bearerToken);
upholdClient.getUser().then(new RepromiseFunction<User, List<Card>>() {
    @Override
    public Promise<List<Card>> call(User user) {
        // Do something with the user.
        return user.getCards();
    }
}).then(new PromiseAction<List<Card>>() {
    @Override
    public void call(List<Card> cards) {
        // Do something with the list of cards.
    }
}).fail(new PromiseAction<Exception>() {
    @Override
    public void call(Exception e) {
        // Do something with the error.
    }
});

Get user cards

user.getCards().then(new PromiseAction<List<Card>>() {
    @Override
    public void call(List<Card> cards) {
        // Do something with the list of cards.
    }
});

Create new card

// You can create a simple card request with just the label and the currency.
CardRequest cardRequest = new CardRequest("label", "USD");
user.createCard(cardRequest);

// Or a card request with the label, currency, position and whether it is starred or not.
CardRequest cardRequest = new CardRequest("label", "USD", new Settings(1, true));
user.createCard(cardRequest);

Handling the success and error flow:

user.createCard(cardRequest).then(new PromiseAction<Card>() {
    @Override
    public void call(Card card) {
	    // Do something with the card created.
    }
}).fail(new PromiseAction<Exception>() {
    @Override
    public void call(Exception e) {
        // Handle the error.
    }
});

Create new card address

// In the address request you need to specify the network for the address.
AddressRequest addressRequest = new AddressRequest("bitcoin");
card.createAddress(addressRequest);

Handling the success and error flow:

card.createAddress(addressRequest).then(new PromiseAction<Address>() {
    @Override
    public void call(Address address) {
	    // Do something with the address created.
    }
}).fail(new PromiseAction<Exception>() {
    @Override
    public void call(Exception e) {
        // Handle the error.
    }
});

Get ticker

// Instantiate the client. In this case, we don't need an
// AUTHORIZATION_TOKEN because the Ticker endpoint is public.
UpholdClient upholdClient = new UpholdClient();

// Get tickers.
upholdClient.getTicker().then(new PromiseAction<List<Rate>>() {
    @Override
    public void call(List<Rate> rates) {
        // Do something with the rates list.
    }
});

Or you could get a ticker for a specific currency:

// Get tickers for BTC.
upholdClient.getTickersByCurrency("BTC").then(new PromiseAction<List<Rate>>() {
    @Override
    public void call(List<Rate> rates) {
        // Do something with the rates list.
    }
});

Create and commit a new transaction

TransactionDenominationRequest transactionDenominationRequest = new TransactionDenominationRequest("1.0", "BTC");

// A transaction to a destination (card id, crypto address, email, phone number or username).
TransactionTransferRequest transactionTransferRequest = new TransactionTransferRequest(transactionDenominationRequest, "[email protected]");

card.createTransaction(transactionTransferRequest).then(new PromiseAction<Transaction>() {
    @Override
    public void call(Transaction transaction) {
        // Commit the transaction.
        transaction.commit();
    }
});

// A transaction to a destination (card id, crypto address, email, phone number or username) with reference.
TransactionTransferRequest transactionTransferRequest = new TransactionTransferRequest(transactionDenominationRequest, "[email protected]", "12345");

card.createTransaction(transactionTransferRequest).then(new PromiseAction<Transaction>() {
    @Override
    public void call(Transaction transaction) {
        // Commit the transaction.
        transaction.commit();
    }
});

// A deposit from an ACH or SEPA account.
TransactionDepositRequest transactionDepositRequest = new TransactionDepositRequest(transactionDenominationRequest, "accountId");

card.createTransaction(transactionDepositRequest).then(new PromiseAction<Transaction>() {
    @Override
    public void call(Transaction transaction) {
        // Commit the transaction.
        transaction.commit();
    }
});

// A deposit from a credit card.
TransactionCardDepositRequest transactionCardDepositRequest = new TransactionCardDepositRequest(transactionDenominationRequest, "creditCardId", "1234");

card.createTransaction(transactionCardDepositRequest).then(new PromiseAction<Transaction>() {
    @Override
    public void call(Transaction transaction) {
        // Commit the transaction.
        transaction.commit();
    }
});

If you want to commit the transaction on the creation process, call the createTransaction method with the second parameter set to true.

card.createTransaction(transactionRequest, true);

Get all public transactions

// Instantiate the client. In this case, we don't need an
// AUTHORIZATION_TOKEN because the Ticker endpoint is public.
UpholdClient upholdClient = new UpholdClient();

Paginator<Transaction> paginator = upholdClient.getReserve().getTransactions();

// Get the list of transactions.
paginator.getElements().then(new PromiseAction<List<Transaction>>() {
    @Override
    public void call(List<Transaction> transactions) {
        // Do something with the list of transactions.
    }
});

// Get the next page of transactions.
paginator.getNext().then(new PromiseAction<List<Transaction>>() {
    @Override
    public void call(List<Transaction> transactions) {
        // Do something with the list of transactions.
    }
});

Or you could get a specific public transaction:

// Get one public transaction.
upholdClient.getReserve().getTransactionById("a97bb994-6e24-4a89-b653-e0a6d0bcf634").then(new PromiseAction<Transaction>() {
    @Override
    public void call(Transaction transaction) {
        // Do something with the transaction.
    }
});

Get reserve status

// Instantiate the client. In this case, we don't need an
// AUTHORIZATION_TOKEN because the Ticker endpoint is public.
UpholdClient upholdClient = new UpholdClient();

// Get the reserve summary of all the obligations and assets within it.
upholdClient.getReserve().getStatistics().then(new PromiseAction<List<ReserveStatistics>>() {
    @Override
    public void call(List<ReserveStatistics> reserveStatisticses) {
        // Do something with the reserve statistics.
    }
});

Pagination

Some endpoints will return a paginator. Here are some examples on how to handle it:

// Get public transactions paginator.
Paginator<Transaction> paginator = upholdClient.getReserve().getTransactions();

// Get the first page of transactions.
paginator.getElements().then(new PromiseAction<List<Transaction>>() {
    @Override
    public void call(List<Transaction> transactions) {
	    // Do something with the list of transactions.
    }
});

// Check if the paginator has a valid next page.
paginator.hasNext().then(new PromiseAction<Boolean>() {
    @Override
    public void call(Boolean hasNext) {
		// Do something with the hasNext.
    }
});

// Get the number of paginator elements.
paginator.count().then(new PromiseAction<Integer>() {
    @Override
    public void call(Integer count) {
        // Do something with the count.
    }
});

// Get the next page.
paginator.getNext().then(new PromiseAction<List<Transaction>>() {
    @Override
    public void call(List<Transaction> transactions) {
        // Do something with the list of transactions.
    }
});

Uphold SDK sample

Check the sample application to explore a application using the Uphold Android SDK.

Building

To build the sample application you need the Android Studio. Steps to build:

  1. Clone the repository.
  2. Open Android Studio.
  3. Click 'Import project...'.
  4. Open the sample/Uphold-android-sdk-demo directory in the cloned repository.
  5. Build and run the app from inside Android Studio.

The sample application is configured to use the sandbox environment, make sure you use a sandbox account to perform the login.

Contributing & Development

Contributing

Have you found a bug or want to suggest something? Please search the issues first and, if it is new, go ahead and submit it.

Develop

It will be awesome if you can help us evolve uphold-sdk-android. Want to help?

  1. Fork it.
  2. Hack away.
  3. Run the tests.
  4. Create a Pull Request.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].