Beispiel #1
0
    public static void AllBanks(ResponseCallback callback, ResponseFallback fallback)
    {
        HttpClient httpClient = new HttpClient();

        Request request = new Request(HttpClient.Method.GET, Route.GET_BANKS_ROUTE);

        httpClient.Request(
            request,
            (statusCode, response) => {
            BanksResponse banksResponse = Deserialize(response);

            callback(banksResponse);
        },
            (statusCode, error) => {
            if (statusCode == StatusCodes.CODE_VALIDATION_ERROR)
            {
                ValidationError validationError = ErrorDeserilizer.DeserializeValidationErrorData(error);
                fallback(statusCode, validationError);
            }
            else
            {
                GenericError genericError = ErrorDeserilizer.DeserializeGenericErrorData(error);
                fallback(statusCode, genericError);
            }
        }
            );
    }
Beispiel #2
0
    private void GetBanksList()
    {
        GetAllBanks.AllBanks(

            (response) => {
            BanksResponse depositResponse = (BanksResponse)response;

            banks = depositResponse.banks;

            banksList.options.Clear();
            //fill the dropdown menu OptionData with all COM's Name in ports[]
            foreach (BankModel bm in banks)
            {
                banksList.options.Add(new Dropdown.OptionData()
                {
                    text = bm.name
                });
            }
        },

            (statusCode, error) => {
            if (statusCode == StatusCodes.CODE_VALIDATION_ERROR)
            {
                ValidationError validationError = (ValidationError)error;
                menuManager.StartCoroutine(menuManager.showPopUpT(validationError.errors.First().Value[0], "error"));
            }
            else
            {
                GenericError genericError = (GenericError)error;
                menuManager.StartCoroutine(menuManager.showPopUpT(genericError.message, "error"));
            }
        }

            );
    }
Beispiel #3
0
    private static BanksResponse Deserialize(object response)
    {
        var responseJson = (string)response;

        var data = fsJsonParser.Parse(responseJson);

        object deserialized = null;

        serializer.TryDeserialize(data, typeof(BanksResponse), ref deserialized);

        BanksResponse serializedData = deserialized as BanksResponse;

        return(serializedData);
    }
Beispiel #4
0
        public async Task <IActionResult> GetBanks(string lppId)
        {
            object response;

            try
            {
                if (lppId == "eps")
                {
                    client.DefaultRequestHeaders.Clear();
                    client.DefaultRequestHeaders.Add("Authorization", apiOptions.PublicKey);
                    HttpResponseMessage result = await client.GetAsync($"{apiOptions.GatewayUri}/giropay/eps/banks");

                    string content = await result.Content.ReadAsStringAsync();

                    BanksResponse banksResponse = JsonConvert.DeserializeObject <BanksResponse>(content);
                    response = banksResponse;
                }
                else if (lppId == "giropay")
                {
                    client.DefaultRequestHeaders.Clear();
                    client.DefaultRequestHeaders.Add("Authorization", apiOptions.PublicKey);
                    HttpResponseMessage result = await client.GetAsync($"{apiOptions.GatewayUri}/giropay/banks");

                    string content = await result.Content.ReadAsStringAsync();

                    BanksResponse banksResponse = JsonConvert.DeserializeObject <BanksResponse>(content);
                    response = banksResponse;
                }
                else if (lppId == "ideal")
                {
                    client.DefaultRequestHeaders.Clear();
                    client.DefaultRequestHeaders.Add("Authorization", apiOptions.PublicKey);
                    HttpResponseMessage result = await client.GetAsync($"{apiOptions.GatewayUri}/ideal-external/issuers");

                    string content = await result.Content.ReadAsStringAsync();

                    IssuersResponse issuersResponse = JsonConvert.DeserializeObject <IssuersResponse>(content);
                    response = issuersResponse;
                }
                else
                {
                    throw new KeyNotFoundException();
                }
                return(Ok(response));
            }
            catch (Exception e)
            {
                return(NotFound(e.Message));
            }
        }
Beispiel #5
0
        void when_get_banks()
        {
            context["given ~/ideal/banks"] = () =>
            {
                beforeAllAsync = async() =>
                {
                    lppId  = "ideal";
                    result = await controller.GetBanks(lppId);

                    legacyBanks = (result as ObjectResult).Value as IssuersResponse;
                };

                it["should return 200 - OK"] = () =>
                {
                    (result as OkObjectResult).StatusCode.ShouldBe(StatusCodes.Status200OK);
                };

                it["should return a non-empty list of legacy typed banks"] = () =>
                {
                    legacyBanks.Countries.ShouldNotBeNull();
                };

                it["should contain single legacy typed bank with name 'Issuer Simulation V3 - ING' and bic 'INGBNL2A'"] = () =>
                {
                    legacyBanks.Countries.Single(country => (country.Issuers.First().Name == "Issuer Simulation V3 - ING" && country.Issuers.First().Bic == "INGBNL2A"));
                };
            };

            context["given ~/giropay/banks"] = () =>
            {
                beforeAllAsync = async() =>
                {
                    lppId  = "giropay";
                    result = await controller.GetBanks(lppId);

                    banks = (result as ObjectResult).Value as BanksResponse;
                };

                it["should return 200 - OK"] = () =>
                {
                    (result as OkObjectResult).StatusCode.ShouldBe(StatusCodes.Status200OK);
                };

                it["should return True for property 'HasBanks'"] = () =>
                {
                    banks.HasBanks.ShouldBeTrue();
                };

                it["should return a type of Dictionary<string, string> for property 'Banks'"] = () =>
                {
                    banks.Banks.ShouldBeOfType <Dictionary <string, string> >();
                };

                it["should return a non-empty Dictionary for property 'Banks'"] = () =>
                {
                    banks.Banks.Count.ShouldBeGreaterThan(0);
                };

                it["should contain KeyValuePair 'TESTDETT421': 'giropay Testinstitut'"] = () =>
                {
                    banks.Banks.ShouldContainKeyAndValue("TESTDETT421", "giropay Testinstitut");
                };
            };

            context["given ~/ducks/banks"] = () =>
            {
                beforeAllAsync = async() =>
                {
                    lppId  = "ducks";
                    result = await controller.GetBanks(lppId);
                };

                it["should return 404 - Not Found"] = () =>
                {
                    (result as NotFoundObjectResult).StatusCode.ShouldBe(StatusCodes.Status404NotFound);
                };
            };
        }