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, RetrieveParams, 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(id, params = {}, opts = {}) ⇒ Object
Deletes a test clock.
-
.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
#==, #[], #[]=, 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
118 119 120 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 118 def deleted @deleted end |
#deletes_after ⇒ Object (readonly)
Time at which this clock is scheduled to auto delete.
94 95 96 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 94 def deletes_after @deletes_after end |
#frozen_time ⇒ Object (readonly)
Time at which all objects belonging to this clock are frozen.
97 98 99 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 97 def frozen_time @frozen_time end |
#id ⇒ Object (readonly)
Unique identifier for the object.
100 101 102 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 100 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.
103 104 105 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 103 def livemode @livemode end |
#name ⇒ Object (readonly)
The custom name supplied at creation.
106 107 108 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 106 def name @name end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
109 110 111 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 109 def object @object end |
#status ⇒ Object (readonly)
The status of the Test Clock.
112 113 114 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 112 def status @status end |
#status_details ⇒ Object (readonly)
Attribute for field status_details
115 116 117 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 115 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.
131 132 133 134 135 136 137 138 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 131 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.
141 142 143 144 145 146 147 148 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 141 def self.create(params = {}, opts = {}) request_stripe_object( method: :post, path: "/v1/test_helpers/test_clocks", params: params, opts: opts ) end |
.delete(id, params = {}, opts = {}) ⇒ Object
Deletes a test clock.
151 152 153 154 155 156 157 158 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 151 def self.delete(id, params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/test_helpers/test_clocks/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.list(params = {}, opts = {}) ⇒ Object
Returns a list of your test clocks.
171 172 173 174 175 176 177 178 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 171 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.
121 122 123 124 125 126 127 128 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 121 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.
161 162 163 164 165 166 167 168 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 161 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 |