Skip to content

Commit b06758c

Browse files
Merge pull request #42 from starkbank/fix/darf-payment-log-created-type
Fix DarfPayment.Log created string type
2 parents 4a80cc0 + 6c0f5f5 commit b06758c

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

lib/darf_payment/darf_payment_log.ex

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@ defmodule StarkBank.DarfPayment.Log do
22
alias __MODULE__, as: Log
33
alias StarkBank.Utils.Rest
44
alias StarkBank.Utils.API
5+
alias StarkBank.Utils.Check
56
alias StarkBank.DarfPayment
67
alias StarkBank.User.Project
78
alias StarkBank.User.Organization
89
alias StarkBank.Error
9-
10+
1011
@moduledoc """
1112
Groups DarfPayment.Log related functions
1213
"""
13-
14+
1415
@doc """
1516
Every time a DarfPayment entity is modified, a corresponding DarfPayment.Log
1617
is generated for the entity. This log is never generated by the user, but it can
1718
be retrieved to check additional information on the DarfPayment.
18-
19+
1920
## Attributes (return-only):
2021
- `:id` [string]: unique id returned when payment is created. ex: "5656565656565656"
2122
- `:payment` [DarfPayment]: DarfPayment entity to which the log refers to.
@@ -31,45 +32,45 @@ defmodule StarkBank.DarfPayment.Log do
3132
:type,
3233
:created,
3334
]
34-
35+
3536
@type t() :: %__MODULE__{}
3637

3738
@doc """
3839
Receive a single DarfPayment Log struct previously created by the Stark Bank API by passing its id
39-
40+
4041
## Parameters (required):
4142
- `:id` [string]: entity unique id. ex: "5656565656565656"
42-
43+
4344
## Options:
4445
- `:user` [Organization/Project, default nil]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
45-
46+
4647
## Return:
4748
- DarfPayment Log struct with updated attributes
4849
"""
4950
@spec get(binary, user: Project.t() | Organization.t() | nil) :: {:ok, Log.t()} | {:error, [%Error{}]}
5051
def get(id, options \\ []) do
5152
Rest.get_id(resource(), id, options)
5253
end
53-
54+
5455
@doc """
5556
Same as get(), but it will unwrap the error tuple and raise in case of errors.
5657
"""
5758
@spec get!(binary, user: Project.t() | Organization.t() | nil) :: Log.t()
5859
def get!(id, options \\ []) do
5960
Rest.get_id!(resource(), id, options)
6061
end
61-
62+
6263
@doc """
6364
Receive a stream of DarfPayment Log structs previously created in the Stark Bank API
64-
65+
6566
## Options:
6667
- `:limit` [integer, default nil]: maximum number of entities to be retrieved. Unlimited if nil. ex: 35
6768
- `:after` [Date or string, default nil]: date filter for entities created only after specified date. ex: ~D[2020-03-25]
6869
- `:before` [Date or string, default nil]: date filter for entities created only before specified date. ex: ~D[2020-03-25]
6970
- `:types` [list of strings, default null]: filter retrieved structs by event types. ex: 'paid' or 'registered'
7071
- `:payment_ids` [list of strings, default null]: list of DarfPayment ids to filter retrieved structs. ex: ['5656565656565656', '4545454545454545']
7172
- `:user` [Organization/Project, default nil]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
72-
73+
7374
## Return:
7475
- stream of DarfPayment Log structs with updated attributes
7576
"""
@@ -90,7 +91,7 @@ defmodule StarkBank.DarfPayment.Log do
9091
def query(options \\ []) do
9192
Rest.get_list(resource(), options)
9293
end
93-
94+
9495
@doc """
9596
Same as query(), but it will unwrap the error tuple and raise in case of errors.
9697
"""
@@ -106,11 +107,11 @@ defmodule StarkBank.DarfPayment.Log do
106107
def query!(options \\ []) do
107108
Rest.get_list!(resource(), options)
108109
end
109-
110+
110111
@doc """
111112
Receive a list of up to 100 DarfPayment structs previously created in the Stark Bank API and the cursor to the next page.
112113
Use this function instead of query if you want to manually page your requests.
113-
114+
114115
## Options:
115116
- `:cursor` [string, default nil]: cursor returned on the previous page function call
116117
- `:limit` [integer, default nil]: maximum number of entities to be retrieved. Unlimited if nil. ex: 35
@@ -119,7 +120,7 @@ defmodule StarkBank.DarfPayment.Log do
119120
- `:types` [list of strings, default null]: filter retrieved structs by event types. ex: 'paid' or 'registered'
120121
- `:payment_ids` [list of strings, default null]: list of DarfPayment ids to filter retrieved structs. ex: ['5656565656565656', '4545454545454545']
121122
- `:user` [Organization/Project, default nil]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
122-
123+
123124
## Return:
124125
- list of DarfPayment Log structs with updated attributes and cursor to retrieve the next page of DarfPayment structs
125126
"""
@@ -131,12 +132,12 @@ defmodule StarkBank.DarfPayment.Log do
131132
types: [binary],
132133
payment_ids: [binary],
133134
user: Project.t() | Organization.t()
134-
) ::
135-
{:ok, {binary, [Log.t()]}} | {:error, [%Error{}]}
135+
) ::
136+
{:ok, {binary, [Log.t()]}} | {:error, [%Error{}]}
136137
def page(options \\ []) do
137138
Rest.get_page(resource(), options)
138139
end
139-
140+
140141
@doc """
141142
Same as page(), but it will unwrap the error tuple and raise in case of errors.
142143
"""
@@ -149,7 +150,7 @@ defmodule StarkBank.DarfPayment.Log do
149150
types: [binary],
150151
payment_ids: [binary],
151152
user: Project.t() | Organization.t()
152-
) ::
153+
) ::
153154
[Log.t()]
154155
def page!(options \\ []) do
155156
Rest.get_page!(resource(), options)
@@ -162,16 +163,15 @@ defmodule StarkBank.DarfPayment.Log do
162163
&resource_maker/1
163164
}
164165
end
165-
166+
166167
@doc false
167168
def resource_maker(json) do
168169
%Log{
169170
id: json[:id],
170171
payment: json[:payment] |> API.from_api_json(&DarfPayment.resource_maker/1),
171172
errors: json[:errors],
172173
type: json[:type],
173-
created: json[:created],
174+
created: json[:created] |> Check.datetime(),
174175
}
175176
end
176177
end
177-

0 commit comments

Comments
 (0)