feat(sum-up): change affiliate key on runtime (#3223)

* feat(sum-up): change affiliate key on runtime

* Update index.ts
This commit is contained in:
Marius Backes 2019-11-19 09:33:38 +01:00 committed by Daniel Sogl
parent 2fd4885fb1
commit 4c56d227a8

View File

@ -52,6 +52,23 @@ export interface SumUpPayment {
installments: number; installments: number;
} }
/**
* @hidden
*/
export class SumUpKeys {
// The generated accessToken, to automate the login process
accessToken: string;
// affiliateKey can also be set in the object, if it has to be changed on runtime
affiliateKey: string;
constructor() {
this.accessToken = '';
this.affiliateKey = '';
}
}
/** /**
* @name SumUp * @name SumUp
* @description * @description
@ -64,11 +81,15 @@ export interface SumUpPayment {
* *
* constructor(private sumUp: SumUp) { } * constructor(private sumUp: SumUp) { }
* *
* this.sumUp.login("ACCESS_TOKEN") * const sumUpKeys: SumUpKeys = new SumUpKeys();
* sumUpKeys.affiliateKey = 'YOUR_API_KEY'; // if not provided in installation
* sumUpKeys.accessToken = 'YOUR_ACCESS_TOKEN';
*
* this.sumUp.login(sumUpKeys)
* .then((res: SumUpResponse) => console.log(res)) * .then((res: SumUpResponse) => console.log(res))
* .catch((error: SumUpResponse) => console.error(error)); * .catch((error: SumUpResponse) => console.error(error));
* *
* this.sumUp.auth("ACCESS_TOKEN") * this.sumUp.auth('YOUR_ACCESS_TOKEN')
* .then((res: SumUpResponse) => console.log(res)) * .then((res: SumUpResponse) => console.log(res))
* .catch((error: SumUpResponse) => console.error(error)); * .catch((error: SumUpResponse) => console.error(error));
* *
@ -92,7 +113,7 @@ export interface SumUpPayment {
* .then((res: SumUpResponse) => console.log(res)) * .then((res: SumUpResponse) => console.log(res))
* .catch((error: SumUpResponse) => console.error(error)); * .catch((error: SumUpResponse) => console.error(error));
* *
* this.sumUp.pay(10.0, "EUR") * this.sumUp.pay(10.0, 'EUR')
* .then((res: SumUpPayment) => console.log(res)) * .then((res: SumUpPayment) => console.log(res))
* .catch((error: SumUpPayment) => console.error(error)); * .catch((error: SumUpPayment) => console.error(error));
* *
@ -114,11 +135,11 @@ export class SumUp extends IonicNativePlugin {
* Login a user with an optional access token. * Login a user with an optional access token.
* If the access token is provided and valid, the user is logged in autmatically. * If the access token is provided and valid, the user is logged in autmatically.
* Otherwise the user has to type in the credentials * Otherwise the user has to type in the credentials
* @param accessToken {string} * @param sumUpKeys {SumUpKeys}
* @return {Promise<SumUpResponse>} Return a SumUpResponse object * @return {Promise<SumUpResponse>} Return a SumUpResponse object
*/ */
@Cordova() @Cordova()
login(accessToken?: string): Promise<SumUpResponse> { login(sumUpKeys: SumUpKeys): Promise<SumUpResponse> {
return; return;
} }