public final class ApiManagement extends ServiceConnector implements IApiManagement
ServiceConnector.InternalServiceConnection
ACTION_BIND_V2, SERVICES_PACKAGE
Modifier and Type | Method and Description |
---|---|
static IApiManagement |
getInstance(android.content.Context context)
Return a global instance of ApiManagement, which is the default implementation of
IApiManagement , and instantiate it if needed. |
protected java.lang.String |
getServiceName()
Must be overrided to provide service class name used for binding.
|
ApiManagementToken |
getUsageToken()
Deprecated.
|
protected void |
onServiceReady(android.os.IBinder service)
Internal callback when service is connected.
|
protected void |
onServiceUnbinded()
Internal callback when service is disconnected.
|
long |
subscribe(java.lang.String apiKey)
Request a new token and register it for API usage.
|
long |
subscribe(java.lang.String apiKey,
boolean forceRenewal)
Request a new token and register it for API usage.
|
long |
subscribe(java.lang.String apiKey,
java.lang.String isvRecord)
Request a new token and register it for API usage.
|
long |
subscribe(java.lang.String apiKey,
java.lang.String isvRecord,
boolean forceRenewal)
Request a new token and register it for API usage.
|
connect, connectSync, disconnect, ensureServiceIsReady, getBindIntent, getContext, isConnected
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
connect, disconnect, isConnected
public static IApiManagement getInstance(android.content.Context context)
IApiManagement
, and instantiate it if needed.
Be aware that only one instance will be created for the whole application, so the associated
context should not be a component which could be destroyed at some point, ie. an Activity.
Passing the Application
to this method is preferred over other context types.
context
- A valid context to initialize the instance.public long subscribe(java.lang.String apiKey) throws IngenicoException
This method make network requests and can be blocking, it must NOT be called from the main thread.
subscribe
in interface IApiManagement
apiKey
- the secret authenticating the registered right to use the API setIngenicoException
- errors subscribing to the API management, see message for detailspublic long subscribe(java.lang.String apiKey, java.lang.String isvRecord) throws IngenicoException
This method make network requests and can be blocking, it must NOT be called from the main thread.
subscribe
in interface IApiManagement
apiKey
- the secret authenticating the registered right to use the API setisvRecord
- an ISV defined record (json) containing detailed information on its
application installation and configuration (this information can be used
later to associate the token request to ISV own billing system).IngenicoException
- errors subscribing to the API management, see message for detailspublic long subscribe(java.lang.String apiKey, boolean forceRenewal) throws IngenicoException
IApiManagement
This method make network requests and can be blocking, it must NOT be called from the main thread.
If forceRenewal is true, a new usage token with an updated expiration date will be requested on the token server. If false, the previous token is reused if not expired, or a new token will be requested.
subscribe
in interface IApiManagement
apiKey
- the secret authenticating the registered right to use the API setforceRenewal
- set true to ensure the renewal of the existing tokenIngenicoException
- errors subscribing to the API management, see message for detailspublic long subscribe(java.lang.String apiKey, java.lang.String isvRecord, boolean forceRenewal) throws IngenicoException
IApiManagement
This method make network requests and can be blocking, it must NOT be called from the main thread.
If forceRenewal is true, a new usage token with an updated expiration date will be requested on the token server. If false, the previous token is reused if not expired, or a new token will be requested.
subscribe
in interface IApiManagement
apiKey
- the secret authenticating the registered right to use the API setisvRecord
- an ISV defined record (json) containing detailed information on its
application installation and configuration (this information can be used
later to associate the token request to ISV own billing system)forceRenewal
- set true to ensure the renewal of the existing tokenIngenicoException
- errors subscribing to the API management, see message for details@Deprecated public ApiManagementToken getUsageToken() throws IngenicoException
getUsageToken
in interface IApiManagement
IngenicoException
protected java.lang.String getServiceName()
ServiceConnector
getServiceName
in class ServiceConnector
protected void onServiceReady(android.os.IBinder service)
ServiceConnector
onServiceReady
in class ServiceConnector
protected void onServiceUnbinded()
ServiceConnector
onServiceUnbinded
in class ServiceConnector