-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from buckaroo-it/BP-3190-Improvements
execution of Prettier & adjustments on ActiveSubscription class
- Loading branch information
Showing
9 changed files
with
121 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,45 @@ | ||
import {DataRequestData, Request} from "../Request"; | ||
import {HttpMethods, RequestTypes} from "../Constants"; | ||
import {ITransactionResponse, ServiceList, TransactionResponse} from "../Models"; | ||
export default class ActiveSubscriptions { | ||
import { DataRequestData, Request } from '../Request'; | ||
import { HttpMethods, RequestTypes } from '../Constants'; | ||
import { ITransactionResponse, ServiceList, TransactionResponse } from '../Models'; | ||
|
||
export interface IActiveSubscription { | ||
serviceCode: string; | ||
currencies: string[]; | ||
} | ||
|
||
export default class ActiveSubscriptions extends Request<typeof TransactionResponse, DataRequestData> { | ||
private readonly _serviceCode: string = 'GetActiveSubscriptions'; | ||
|
||
async get(){ | ||
return this.buildRequest().request().then((response) => { | ||
constructor() { | ||
super(RequestTypes.Data, HttpMethods.POST, new DataRequestData(), TransactionResponse); | ||
} | ||
async get() { | ||
this.data.setServiceList( | ||
new ServiceList({ | ||
name: this._serviceCode, | ||
version: 1, | ||
action: this._serviceCode, | ||
}) | ||
); | ||
return this.request().then((response) => { | ||
return this.format(response.data); | ||
}); | ||
} | ||
private buildRequest(){ | ||
const data = new DataRequestData().setServiceList(new ServiceList({ | ||
name: this._serviceCode, | ||
version: 1, | ||
action: this._serviceCode, | ||
})); | ||
return new Request(RequestTypes.Data, HttpMethods.POST,data,TransactionResponse) | ||
} | ||
private format(data:ITransactionResponse){ | ||
let activeSubscriptions:IActiveSubscription[] = [] | ||
const xmlData = data.services?.[0].parameters[0].value; | ||
if(typeof xmlData === 'string'){ | ||
private format(data: ITransactionResponse) { | ||
let activeSubscriptions: IActiveSubscription[] = []; | ||
const xmlData = data.services?.[0].parameters[0].value; | ||
if (typeof xmlData === 'string') { | ||
let parseString = require('xml2js').parseString; | ||
|
||
parseString(xmlData,function (err:any, result:any) { | ||
activeSubscriptions = result['ArrayOfServiceCurrencies']['ServiceCurrencies'].map((service:any) => { | ||
parseString(xmlData, function (err: any, result: Record<string, any>) { | ||
activeSubscriptions = result['ArrayOfServiceCurrencies']['ServiceCurrencies'].map((service: any) => { | ||
return { | ||
serviceCode: service['ServiceCode'][0], | ||
currencies: service['Currencies'][0]['string'] | ||
} | ||
currencies: service['Currencies'][0]['string'], | ||
}; | ||
}); | ||
}); | ||
} | ||
return activeSubscriptions | ||
return activeSubscriptions; | ||
} | ||
} | ||
export interface IActiveSubscription { | ||
serviceCode: string; | ||
currencies: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './PayablePaymentMethod'; | ||
export { default as ActiveSubscriptions } from './ActiveSubscriptions'; | ||
export { default as PaymentMethod } from './PaymentMethod'; | ||
export { default as PayablePaymentMethod } from './PayablePaymentMethod'; | ||
export { default as TransactionService } from './TransactionService'; | ||
export { default as TransactionService } from './TransactionService'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,37 +3,38 @@ import buckarooClientTest from '../BuckarooClient.test'; | |
const subscription = buckarooClientTest.method('subscriptions'); | ||
|
||
describe('Subscription methods', () => { | ||
test('Create', async () => { | ||
test('Create', () => { | ||
return subscription | ||
.create({ | ||
additionalParameters: { | ||
signature: 'XXXXXXXX' | ||
signature: 'XXXXXXXX', | ||
}, | ||
ratePlans: { | ||
add: { | ||
startDate: '2024-07-23', | ||
ratePlanCode: 'XXXXXXXX' | ||
} | ||
ratePlanCode: 'XXXXXXXX', | ||
}, | ||
}, | ||
ratePlanCharges: { | ||
add: { | ||
ratePlanChargeCode: 'XXXXXXXX' | ||
} | ||
ratePlanChargeCode: 'XXXXXXXX', | ||
}, | ||
}, | ||
configurationCode: 'XXXXXXXX', | ||
configuration: { | ||
name: 'XXXXXXXX' | ||
name: 'XXXXXXXX', | ||
}, | ||
debtor: { | ||
code: 'XXXXXXXX' | ||
} | ||
code: 'XXXXXXXX', | ||
}, | ||
}) | ||
.request().then((data) => { | ||
.request() | ||
.then((data) => { | ||
expect(data.hasError()).toBeTruthy(); | ||
}); | ||
}); | ||
test('Update', async () => { | ||
return subscription | ||
subscription | ||
.update({ | ||
email: '[email protected]', | ||
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', | ||
|
@@ -85,7 +86,7 @@ describe('Subscription methods', () => { | |
country: 'NL', | ||
}, | ||
}); | ||
return subscription | ||
subscription | ||
.combine('ideal') | ||
.pay({ | ||
issuer: 'ABNANL2A', | ||
|
@@ -101,7 +102,7 @@ describe('Subscription methods', () => { | |
subscription.updateCombined({ | ||
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', | ||
}); | ||
return subscription | ||
subscription | ||
.combine('ideal') | ||
.pay({ | ||
issuer: 'ABNANL2A', | ||
|
@@ -113,21 +114,27 @@ describe('Subscription methods', () => { | |
}); | ||
}); | ||
test('Stop Subscription', async () => { | ||
return subscription.stop({ | ||
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', | ||
}).request().then((res) => { | ||
expect(res.httpResponse.status === 200).toBeTruthy(); | ||
}); | ||
subscription | ||
.stop({ | ||
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', | ||
}) | ||
.request() | ||
.then((res) => { | ||
expect(res.httpResponse.status === 200).toBeTruthy(); | ||
}); | ||
}); | ||
test('Subscription Info', async () => { | ||
return await subscription.info({ | ||
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', | ||
}).request().then((res) => { | ||
expect(res.httpResponse.status === 200).toBeTruthy(); | ||
}); | ||
await subscription | ||
.info({ | ||
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', | ||
}) | ||
.request() | ||
.then((res) => { | ||
expect(res.httpResponse.status === 200).toBeTruthy(); | ||
}); | ||
}); | ||
test('Delete Subscription Config', async () => { | ||
return subscription | ||
subscription | ||
.deletePaymentConfig({ | ||
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', | ||
}) | ||
|
@@ -137,19 +144,25 @@ describe('Subscription methods', () => { | |
}); | ||
}); | ||
test('Subscription Pause', async () => { | ||
return subscription.pause({ | ||
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', | ||
resumeDate: '2030-01-01', | ||
}).request().then((res) => { | ||
expect(res.httpResponse.status === 200).toBeTruthy(); | ||
}) | ||
subscription | ||
.pause({ | ||
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', | ||
resumeDate: '2030-01-01', | ||
}) | ||
.request() | ||
.then((res) => { | ||
expect(res.httpResponse.status === 200).toBeTruthy(); | ||
}); | ||
}); | ||
test('Subscription Resume', async () => { | ||
return subscription.resume({ | ||
resumeDate: '2030-01-01', | ||
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', | ||
}).request().then((res) => { | ||
expect(res.httpResponse.status === 200).toBeTruthy(); | ||
}); | ||
subscription | ||
.resume({ | ||
resumeDate: '2030-01-01', | ||
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', | ||
}) | ||
.request() | ||
.then((res) => { | ||
expect(res.httpResponse.status === 200).toBeTruthy(); | ||
}); | ||
}); | ||
}); |