UNPKG

@magic.batua/utility

Version:

The Utility module manages all the utility bills functionalities of the Magic Batua platform.

47 lines (42 loc) 1.42 kB
/** * @module Provider * @overview Defines the utility service `Provider` class * * @author Animesh Mishra <hello@animesh.ltd> * @copyright © 2018 Animesh Ltd. All Rights Reserved. */ /** Utility providers as supported by Rocket in Pocket */ export class Provider { public code: string public name: string public constructor(json: GetProviderResponse) { this.code = json.provider_code this.name = json.connection_provider } /** * Given an array of provider responses from Rocket in Pocket, instantiates and * returns a `Provider` array. */ public static InitList(json: Array<GetProviderResponse>): Array<Provider> { let providers = Array<Provider>() for(var provider of json) { providers.push(new Provider(provider)) } return providers } /** * Returns a `Provider` with the given provider `code` amongst the list of * `providers` given. If no match is found, returns `null`. */ public static WithCode(code: string, providers: Array<Provider>): Provider | null { for (var operator of providers) { if(operator.code == code) { return operator } } return null } } /** Response sent by Rocket in Pocket to a get all providers query */ interface GetProviderResponse { connection_provider: string, provider_code: string }