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: 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.
44 45 46 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 44 def created @created end |
#deleted ⇒ Object (readonly)
Always true for a deleted object
62 63 64 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 62 def deleted @deleted end |
#deletes_after ⇒ Object (readonly)
Time at which this clock is scheduled to auto delete.
46 47 48 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 46 def deletes_after @deletes_after end |
#frozen_time ⇒ Object (readonly)
Time at which all objects belonging to this clock are frozen.
48 49 50 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 48 def frozen_time @frozen_time end |
#id ⇒ Object (readonly)
Unique identifier for the object.
50 51 52 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 50 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.
52 53 54 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 52 def livemode @livemode end |
#name ⇒ Object (readonly)
The custom name supplied at creation.
54 55 56 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 54 def name @name end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
56 57 58 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 56 def object @object end |
#status ⇒ Object (readonly)
The status of the Test Clock.
58 59 60 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 58 def status @status end |
#status_details ⇒ Object (readonly)
Attribute for field status_details
60 61 62 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 60 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.
75 76 77 78 79 80 81 82 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 75 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.
85 86 87 88 89 90 91 92 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 85 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.
95 96 97 98 99 100 101 102 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 95 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
128 129 130 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 128 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
124 125 126 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 124 def self.inner_class_types @inner_class_types = { status_details: StatusDetails } end |
.list(params = {}, opts = {}) ⇒ Object
Returns a list of your test clocks.
115 116 117 118 119 120 121 122 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 115 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.
65 66 67 68 69 70 71 72 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 65 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.
105 106 107 108 109 110 111 112 |
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 105 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 |