Class: Stripe::SubscriptionScheduleService

Inherits:
StripeService show all
Defined in:
lib/stripe/services/subscription_schedule_service.rb

Instance Method Summary collapse

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
# File 'lib/stripe/services/subscription_schedule_service.rb', line 29

def create(params = {}, opts = {})
  params = SubscriptionScheduleCreateParams.coerce_params(params) unless params.is_a?(Stripe::RequestParams)

  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.



42
43
44
45
46
47
48
49
50
# File 'lib/stripe/services/subscription_schedule_service.rb', line 42

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.



53
54
55
56
57
58
59
60
61
# File 'lib/stripe/services/subscription_schedule_service.rb', line 53

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.



64
65
66
67
68
69
70
71
72
# File 'lib/stripe/services/subscription_schedule_service.rb', line 64

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.



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/stripe/services/subscription_schedule_service.rb', line 75

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.



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/stripe/services/subscription_schedule_service.rb', line 90

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.



104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/stripe/services/subscription_schedule_service.rb', line 104

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.



119
120
121
122
123
124
125
126
127
128
129
# File 'lib/stripe/services/subscription_schedule_service.rb', line 119

def update(schedule, params = {}, opts = {})
  params = SubscriptionScheduleUpdateParams.coerce_params(params) unless params.is_a?(Stripe::RequestParams)

  request(
    method: :post,
    path: format("/v1/subscription_schedules/%<schedule>s", { schedule: CGI.escape(schedule) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end