Skip to content

Commit

Permalink
Ensure "file" is converted to "FileUpload" struct
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed Jan 13, 2019
1 parent 6b16049 commit e17eaa4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/stripe/converter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule Stripe.Converter do
dispute
event
external_account
file_upload
file
invoice
invoiceitem
line_item
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lib/stripe/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e17eaa4

Please sign in to comment.