Class: Stripe::TestHelpers::TestClock
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::TestHelpers::TestClock
- Extended by:
- APIOperations::Create, APIOperations::List
- Includes:
- APIOperations::Delete
- Defined in:
- lib/stripe/resources/test_helpers/test_clock.rb
Overview
A test clock enables deterministic control over objects in testmode. With a test clock, you can create objects 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, you 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.
Defined Under Namespace
Classes: AdvanceParams, CreateParams, DeleteParams, ListParams, StatusDetails
Constant Summary collapse
- OBJECT_NAME =
"test_helpers.test_clock"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#created ⇒ Object
readonly
Time at which the object was created.
-
#deleted ⇒ Object
readonly
Always true for a deleted object.
-
#deletes_after ⇒ Object
readonly
Time at which this clock is scheduled to auto delete.
-
#frozen_time ⇒ Object
readonly
Time at which all objects belonging to this clock are frozen.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#livemode ⇒ Object
readonly
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
-
#name ⇒ Object
readonly
The custom name supplied at creation.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#status ⇒ Object
readonly
The status of the Test Clock.
-
#status_details ⇒ Object
readonly
Attribute for field status_details.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.advance(test_clock, params = {}, opts = {}) ⇒ Object
Starts advancing a test clock to a specified time in the future.
-
.create(params = {}, opts = {}) ⇒ Object
Creates a new test clock that can be attached to new customers and quotes.
-
.delete(test_clock, params = {}, opts = {}) ⇒ Object
Deletes a test clock.
- .field_remappings ⇒ Object
- .inner_class_types ⇒ Object
-
.list(params = {}, opts = {}) ⇒ Object
Returns a list of your test clocks.
- .object_name ⇒ Object
Instance Method Summary collapse
-
#advance(params = {}, opts = {}) ⇒ Object
Starts advancing a test clock to a specified time in the future.
-
#delete(params = {}, opts = {}) ⇒ Object
Deletes a test clock.
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods included from APIOperations::Delete
Methods inherited from APIResource
class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource
Methods included from APIOperations::Request
Methods inherited from StripeObject
#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values
Constructor Details
This class inherits a constructor from Stripe::StripeObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject
Instance Attribute Details
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
91 92 93 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 91 def created @created end |
#deleted ⇒ Object (readonly)
Always true for a deleted object
109 110 111 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 109 def deleted @deleted end |
#deletes_after ⇒ Object (readonly)
Time at which this clock is scheduled to auto delete.
93 94 95 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 93 def deletes_after @deletes_after end |
#frozen_time ⇒ Object (readonly)
Time at which all objects belonging to this clock are frozen.
95 96 97 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 95 def frozen_time @frozen_time end |
#id ⇒ Object (readonly)
Unique identifier for the object.
97 98 99 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 97 def id @id end |
#livemode ⇒ Object (readonly)
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
99 100 101 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 99 def livemode @livemode end |
#name ⇒ Object (readonly)
The custom name supplied at creation.
101 102 103 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 101 def name @name end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
103 104 105 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 103 def object @object end |
#status ⇒ Object (readonly)
The status of the Test Clock.
105 106 107 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 105 def status @status end |
#status_details ⇒ Object (readonly)
Attribute for field status_details
107 108 109 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 107 def status_details @status_details end |
Class Method Details
.advance(test_clock, params = {}, opts = {}) ⇒ Object
Starts advancing a test clock to a specified time in the future. Advancement is done when status changes to Ready.
122 123 124 125 126 127 128 129 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 122 def self.advance(test_clock, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/test_helpers/test_clocks/%<test_clock>s/advance", { test_clock: CGI.escape(test_clock) }), params: params, opts: opts ) end |
.create(params = {}, opts = {}) ⇒ Object
Creates a new test clock that can be attached to new customers and quotes.
132 133 134 135 136 137 138 139 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 132 def self.create(params = {}, opts = {}) request_stripe_object( method: :post, path: "/v1/test_helpers/test_clocks", params: params, opts: opts ) end |
.delete(test_clock, params = {}, opts = {}) ⇒ Object
Deletes a test clock.
142 143 144 145 146 147 148 149 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 142 def self.delete(test_clock, params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/test_helpers/test_clocks/%<test_clock>s", { test_clock: CGI.escape(test_clock) }), params: params, opts: opts ) end |
.field_remappings ⇒ Object
175 176 177 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 175 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
171 172 173 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 171 def self.inner_class_types @inner_class_types = { status_details: StatusDetails } end |
.list(params = {}, opts = {}) ⇒ Object
Returns a list of your test clocks.
162 163 164 165 166 167 168 169 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 162 def self.list(params = {}, opts = {}) request_stripe_object( method: :get, path: "/v1/test_helpers/test_clocks", params: params, opts: opts ) end |
.object_name ⇒ Object
15 16 17 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 15 def self.object_name "test_helpers.test_clock" end |
Instance Method Details
#advance(params = {}, opts = {}) ⇒ Object
Starts advancing a test clock to a specified time in the future. Advancement is done when status changes to Ready.
112 113 114 115 116 117 118 119 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 112 def advance(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/test_helpers/test_clocks/%<test_clock>s/advance", { test_clock: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#delete(params = {}, opts = {}) ⇒ Object
Deletes a test clock.
152 153 154 155 156 157 158 159 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 152 def delete(params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/test_helpers/test_clocks/%<test_clock>s", { test_clock: CGI.escape(self["id"]) }), params: params, opts: opts ) end |