Class: Stripe::TestHelpers::TestClock

Inherits:
APIResource show all
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.

Constant Summary collapse

OBJECT_NAME =
"test_helpers.test_clock"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::Delete

included

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

included

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

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.



30
31
32
33
34
35
36
37
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 30

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.



40
41
42
43
44
45
46
47
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 40

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.



50
51
52
53
54
55
56
57
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 50

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(filters = {}, opts = {}) ⇒ Object

Returns a list of your test clocks.



70
71
72
73
74
75
76
77
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 70

def self.list(filters = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: "/v1/test_helpers/test_clocks",
    params: filters,
    opts: opts
  )
end

.object_nameObject



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.



20
21
22
23
24
25
26
27
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 20

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.



60
61
62
63
64
65
66
67
# File 'lib/stripe/resources/test_helpers/test_clock.rb', line 60

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