Class: Stripe::SubscriptionScheduleService
- Inherits:
-
StripeService
- Object
- StripeService
- Stripe::SubscriptionScheduleService
- Defined in:
- lib/stripe/services/subscription_schedule_service.rb
Instance Method Summary collapse
-
#amend(schedule, params = {}, opts = {}) ⇒ Object
Amends an existing subscription schedule.
-
#cancel(schedule, params = {}, opts = {}) ⇒ Object
Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription).
-
#create(params = {}, opts = {}) ⇒ Object
Creates a new subscription schedule object.
-
#list(params = {}, opts = {}) ⇒ Object
Retrieves the list of your subscription schedules.
-
#release(schedule, params = {}, opts = {}) ⇒ Object
Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place.
-
#retrieve(schedule, params = {}, opts = {}) ⇒ Object
Retrieves the details of an existing subscription schedule.
-
#serialize_batch_cancel(schedule, params = {}, opts = {}) ⇒ Object
Serializes a SubscriptionSchedule cancel request into a batch job JSONL line.
-
#serialize_batch_create(params = {}, opts = {}) ⇒ Object
Serializes a SubscriptionSchedule create request into a batch job JSONL line.
-
#serialize_batch_update(schedule, params = {}, opts = {}) ⇒ Object
Serializes a SubscriptionSchedule update request into a batch job JSONL line.
-
#update(schedule, params = {}, opts = {}) ⇒ Object
Updates an existing subscription schedule.
Methods inherited from StripeService
#initialize, #request, #request_stream
Constructor Details
This class inherits a constructor from Stripe::StripeService
Instance Method Details
#amend(schedule, params = {}, opts = {}) ⇒ Object
Amends an existing subscription schedule.
7 8 9 10 11 12 13 14 15 |
# File 'lib/stripe/services/subscription_schedule_service.rb', line 7 def amend(schedule, params = {}, opts = {}) request( method: :post, path: format("/v1/subscription_schedules/%<schedule>s/amend", { schedule: CGI.escape(schedule) }), params: params, opts: opts, base_address: :api ) end |
#cancel(schedule, params = {}, opts = {}) ⇒ Object
Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). A subscription schedule can only be canceled if its status is not_started or active.
18 19 20 21 22 23 24 25 26 |
# File 'lib/stripe/services/subscription_schedule_service.rb', line 18 def cancel(schedule, params = {}, opts = {}) request( method: :post, path: format("/v1/subscription_schedules/%<schedule>s/cancel", { schedule: CGI.escape(schedule) }), params: params, opts: opts, base_address: :api ) end |
#create(params = {}, opts = {}) ⇒ Object
Creates a new subscription schedule object. Each customer can have up to 500 active or scheduled subscriptions.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/stripe/services/subscription_schedule_service.rb', line 29 def create(params = {}, opts = {}) unless params.is_a?(Stripe::RequestParams) params = ::Stripe::SubscriptionScheduleCreateParams.coerce_params(params) end request( method: :post, path: "/v1/subscription_schedules", params: params, opts: opts, base_address: :api ) end |
#list(params = {}, opts = {}) ⇒ Object
Retrieves the list of your subscription schedules.
44 45 46 47 48 49 50 51 52 |
# File 'lib/stripe/services/subscription_schedule_service.rb', line 44 def list(params = {}, opts = {}) request( method: :get, path: "/v1/subscription_schedules", params: params, opts: opts, base_address: :api ) end |
#release(schedule, params = {}, opts = {}) ⇒ Object
Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. A schedule can only be released if its status is not_started or active. If the subscription schedule is currently associated with a subscription, releasing it will remove its subscription property and set the subscription’s ID to the released_subscription property.
55 56 57 58 59 60 61 62 63 |
# File 'lib/stripe/services/subscription_schedule_service.rb', line 55 def release(schedule, params = {}, opts = {}) request( method: :post, path: format("/v1/subscription_schedules/%<schedule>s/release", { schedule: CGI.escape(schedule) }), params: params, opts: opts, base_address: :api ) end |
#retrieve(schedule, params = {}, opts = {}) ⇒ Object
Retrieves the details of an existing subscription schedule. You only need to supply the unique subscription schedule identifier that was returned upon subscription schedule creation.
66 67 68 69 70 71 72 73 74 |
# File 'lib/stripe/services/subscription_schedule_service.rb', line 66 def retrieve(schedule, params = {}, opts = {}) request( method: :get, path: format("/v1/subscription_schedules/%<schedule>s", { schedule: CGI.escape(schedule) }), params: params, opts: opts, base_address: :api ) end |
#serialize_batch_cancel(schedule, params = {}, opts = {}) ⇒ Object
Serializes a SubscriptionSchedule cancel request into a batch job JSONL line.
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/stripe/services/subscription_schedule_service.rb', line 77 def serialize_batch_cancel(schedule, params = {}, opts = {}) item_id = SecureRandom.uuid stripe_version = opts[:stripe_version] || Stripe.api_version item = { id: item_id, params: params, stripe_version: stripe_version, } item[:path_params] = { schedule: schedule } item[:context] = opts[:stripe_context] if opts[:stripe_context] JSON.generate(item) end |
#serialize_batch_create(params = {}, opts = {}) ⇒ Object
Serializes a SubscriptionSchedule create request into a batch job JSONL line.
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/stripe/services/subscription_schedule_service.rb', line 92 def serialize_batch_create(params = {}, opts = {}) item_id = SecureRandom.uuid stripe_version = opts[:stripe_version] || Stripe.api_version item = { id: item_id, params: params, stripe_version: stripe_version, } item[:context] = opts[:stripe_context] if opts[:stripe_context] JSON.generate(item) end |
#serialize_batch_update(schedule, params = {}, opts = {}) ⇒ Object
Serializes a SubscriptionSchedule update request into a batch job JSONL line.
106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/stripe/services/subscription_schedule_service.rb', line 106 def serialize_batch_update(schedule, params = {}, opts = {}) item_id = SecureRandom.uuid stripe_version = opts[:stripe_version] || Stripe.api_version item = { id: item_id, params: params, stripe_version: stripe_version, } item[:path_params] = { schedule: schedule } item[:context] = opts[:stripe_context] if opts[:stripe_context] JSON.generate(item) end |
#update(schedule, params = {}, opts = {}) ⇒ Object
Updates an existing subscription schedule.
121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/stripe/services/subscription_schedule_service.rb', line 121 def update(schedule, params = {}, opts = {}) unless params.is_a?(Stripe::RequestParams) params = ::Stripe::SubscriptionScheduleUpdateParams.coerce_params(params) end request( method: :post, path: format("/v1/subscription_schedules/%<schedule>s", { schedule: CGI.escape(schedule) }), params: params, opts: opts, base_address: :api ) end |