From e17eaa47e7478e27f3d97a97d89802ec9ac8b93d Mon Sep 17 00:00:00 2001 From: snewcomer Date: Thu, 27 Dec 2018 11:35:31 -0800 Subject: [PATCH] Ensure "file" is converted to "FileUpload" struct --- lib/stripe/converter.ex | 18 +++++++++--------- lib/stripe/util.ex | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/stripe/converter.ex b/lib/stripe/converter.ex index 3db25a4ae..94cf8e603 100644 --- a/lib/stripe/converter.ex +++ b/lib/stripe/converter.ex @@ -26,7 +26,7 @@ defmodule Stripe.Converter do dispute event external_account - file_upload + file invoice invoiceitem line_item @@ -78,16 +78,16 @@ defmodule Stripe.Converter do processed_map = struct_keys |> Enum.reduce(%{}, fn key, acc -> - string_key = to_string(key) + string_key = to_string(key) - converted_value = - case string_key do - string_key when string_key in @no_convert_maps -> Map.get(value, string_key) - _ -> Map.get(value, string_key) |> convert_value() - end + converted_value = + case string_key do + string_key when string_key in @no_convert_maps -> Map.get(value, string_key) + _ -> Map.get(value, string_key) |> convert_value() + end - Map.put(acc, key, converted_value) - end) + Map.put(acc, key, converted_value) + end) |> module.__from_json__() struct(module, processed_map) diff --git a/lib/stripe/util.ex b/lib/stripe/util.ex index 9374de7e3..1a5502afc 100644 --- a/lib/stripe/util.ex +++ b/lib/stripe/util.ex @@ -51,6 +51,7 @@ defmodule Stripe.Util do def atomize_key(k), do: k @spec object_name_to_module(String.t()) :: module + def object_name_to_module("file"), do: object_name_to_module("file_upload") def object_name_to_module(object_name) do module_name = object_name