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.
-
.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.
75 76 77 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 75 def created @created end |
#deleted ⇒ Object (readonly)
Always true for a deleted object
93 94 95 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 93 def deleted @deleted end |
#deletes_after ⇒ Object (readonly)
Time at which this clock is scheduled to auto delete.
77 78 79 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 77 def deletes_after @deletes_after end |
#frozen_time ⇒ Object (readonly)
Time at which all objects belonging to this clock are frozen.
79 80 81 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 79 def frozen_time @frozen_time end |
#id ⇒ Object (readonly)
Unique identifier for the object.
81 82 83 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 81 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.
83 84 85 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 83 def livemode @livemode end |
#name ⇒ Object (readonly)
The custom name supplied at creation.
85 86 87 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 85 def name @name end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
87 88 89 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 87 def object @object end |
#status ⇒ Object (readonly)
The status of the Test Clock.
89 90 91 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 89 def status @status end |
#status_details ⇒ Object (readonly)
Attribute for field status_details
91 92 93 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 91 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.
106 107 108 109 110 111 112 113 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 106 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.
116 117 118 119 120 121 122 123 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 116 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.
126 127 128 129 130 131 132 133 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 126 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 |
.list(params = {}, opts = {}) ⇒ Object
Returns a list of your test clocks.
146 147 148 149 150 151 152 153 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 146 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.
96 97 98 99 100 101 102 103 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 96 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.
136 137 138 139 140 141 142 143 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 136 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 |