/
test_helpers__test_clock.ex
204 lines (187 loc) · 7.52 KB
/
test_helpers__test_clock.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
defmodule Stripe.TestHelpers.TestClock do
use Stripe.Entity
@moduledoc "A test clock enables deterministic control over objects in testmode. With a test clock, you can create\nobjects at a frozen time in the past or future, and advance to a specific future time to observe webhooks and state changes. After the clock advances,\nyou can either validate the current state of your scenario (and test your assumptions), change the current state of your scenario (and test more complex scenarios), or keep advancing forward in time."
(
defstruct [:created, :deletes_after, :frozen_time, :id, :livemode, :name, :object, :status]
@typedoc "The `test_helpers.test_clock` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `deletes_after` Time at which this clock is scheduled to auto delete.\n * `frozen_time` Time at which all objects belonging to this clock are frozen.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `name` The custom name supplied at creation.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `status` The status of the Test Clock.\n"
@type t :: %__MODULE__{
created: integer,
deletes_after: integer,
frozen_time: integer,
id: binary,
livemode: boolean,
name: binary | nil,
object: binary,
status: binary
}
)
(
nil
@doc "<p>Retrieves a test clock.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/test_helpers/test_clocks/{test_clock}`\n"
(
@spec retrieve(
test_clock :: binary(),
params :: %{optional(:expand) => list(binary)},
opts :: Keyword.t()
) ::
{:ok, Stripe.TestHelpers.TestClock.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def retrieve(test_clock, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/test_helpers/test_clocks/{test_clock}",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "test_clock",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "test_clock",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[test_clock]
)
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:get)
|> Stripe.Request.make_request()
end
)
)
(
nil
@doc "<p>Creates a new test clock that can be attached to new customers and quotes.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/test_clocks`\n"
(
@spec create(
params :: %{
optional(:expand) => list(binary),
optional(:frozen_time) => integer,
optional(:name) => binary
},
opts :: Keyword.t()
) ::
{:ok, Stripe.TestHelpers.TestClock.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def create(params \\ %{}, opts \\ []) do
path = Stripe.OpenApi.Path.replace_path_params("/v1/test_helpers/test_clocks", [], [])
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:post)
|> Stripe.Request.make_request()
end
)
)
(
nil
@doc "<p>Deletes a test clock.</p>\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/test_helpers/test_clocks/{test_clock}`\n"
(
@spec delete(test_clock :: binary(), opts :: Keyword.t()) ::
{:ok, Stripe.DeletedTestHelpers.TestClock.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def delete(test_clock, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/test_helpers/test_clocks/{test_clock}",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "test_clock",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "test_clock",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[test_clock]
)
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_method(:delete)
|> Stripe.Request.make_request()
end
)
)
(
nil
@doc "<p>Starts advancing a test clock to a specified time in the future. Advancement is done when status changes to <code>Ready</code>.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/test_clocks/{test_clock}/advance`\n"
(
@spec advance(
test_clock :: binary(),
params :: %{optional(:expand) => list(binary), optional(:frozen_time) => integer},
opts :: Keyword.t()
) ::
{:ok, Stripe.TestHelpers.TestClock.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def advance(test_clock, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/test_helpers/test_clocks/{test_clock}/advance",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "test_clock",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "test_clock",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[test_clock]
)
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:post)
|> Stripe.Request.make_request()
end
)
)
(
nil
@doc "<p>Returns a list of your test clocks.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/test_helpers/test_clocks`\n"
(
@spec list(
params :: %{
optional(:ending_before) => binary,
optional(:expand) => list(binary),
optional(:limit) => integer,
optional(:starting_after) => binary
},
opts :: Keyword.t()
) ::
{:ok, Stripe.List.t(Stripe.TestHelpers.TestClock.t())}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def list(params \\ %{}, opts \\ []) do
path = Stripe.OpenApi.Path.replace_path_params("/v1/test_helpers/test_clocks", [], [])
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:get)
|> Stripe.Request.make_request()
end
)
)
end