Class: Square::SubscriptionsApi
- Defined in:
- lib/square/api/subscriptions_api.rb
Overview
SubscriptionsApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#bulk_swap_plan(body:) ⇒ ApiResponse
Schedules a plan variation change for all active subscriptions under a given plan variation.
-
#cancel_subscription(subscription_id:) ⇒ ApiResponse
Schedules a ‘CANCEL` action to cancel an active subscription.
-
#change_billing_anchor_date(subscription_id:, body:) ⇒ ApiResponse
Changes the [billing anchor date](developer.squareup.com/docs/subscriptions-api/subscription-b illing#billing-dates) for a subscription.
-
#create_subscription(body:) ⇒ ApiResponse
Enrolls a customer in a subscription.
-
#delete_subscription_action(subscription_id:, action_id:) ⇒ ApiResponse
Deletes a scheduled action for a subscription.
-
#list_subscription_events(subscription_id:, cursor: nil, limit: nil) ⇒ ApiResponse
Lists all [events](developer.squareup.com/docs/subscriptions-api/actions-eve nts) for a specific subscription.
-
#pause_subscription(subscription_id:, body:) ⇒ ApiResponse
Schedules a ‘PAUSE` action to pause an active subscription.
-
#resume_subscription(subscription_id:, body:) ⇒ ApiResponse
Schedules a ‘RESUME` action to resume a paused or a deactivated subscription.
-
#retrieve_subscription(subscription_id:, include: nil) ⇒ ApiResponse
Retrieves a specific subscription.
-
#search_subscriptions(body:) ⇒ ApiResponse
Searches for subscriptions.
-
#swap_plan(subscription_id:, body:) ⇒ ApiResponse
Schedules a ‘SWAP_PLAN` action to swap a subscription plan variation in an existing subscription.
-
#update_subscription(subscription_id:, body:) ⇒ ApiResponse
Updates a subscription by modifying or clearing ‘subscription` field values.
Methods inherited from BaseApi
#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from Square::BaseApi
Instance Method Details
#bulk_swap_plan(body:) ⇒ ApiResponse
Schedules a plan variation change for all active subscriptions under a given plan variation. For more information, see [Swap Subscription Plan Variations](developer.squareup.com/docs/subscriptions-api/swap-pla n-variations). the fields to POST for the request. See the corresponding object definition for field details.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/square/api/subscriptions_api.rb', line 44 def bulk_swap_plan(body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/subscriptions/bulk-swap-plan', 'default') .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#cancel_subscription(subscription_id:) ⇒ ApiResponse
Schedules a ‘CANCEL` action to cancel an active subscription. This sets the `canceled_date` field to the end of the active billing period. After this date, the subscription status changes from ACTIVE to CANCELED. subscription to cancel.
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/square/api/subscriptions_api.rb', line 212 def cancel_subscription(subscription_id:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/subscriptions/{subscription_id}/cancel', 'default') .template_param(new_parameter(subscription_id, key: 'subscription_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#change_billing_anchor_date(subscription_id:, body:) ⇒ ApiResponse
Changes the [billing anchor date](developer.squareup.com/docs/subscriptions-api/subscription-b illing#billing-dates) for a subscription. subscription to update the billing anchor date. containing the fields to POST for the request. See the corresponding object definition for field details.
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/square/api/subscriptions_api.rb', line 185 def change_billing_anchor_date(subscription_id:, body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/subscriptions/{subscription_id}/billing-anchor', 'default') .template_param(new_parameter(subscription_id, key: 'subscription_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#create_subscription(body:) ⇒ ApiResponse
Enrolls a customer in a subscription. If you provide a card on file in the request, Square charges the card for the subscription. Otherwise, Square sends an invoice to the customer’s email address. The subscription starts immediately, unless the request includes the optional ‘start_date`. Each individual subscription is associated with a particular location. For more information, see [Create a subscription](developer.squareup.com/docs/subscriptions-api/manage -subscriptions#create-a-subscription). containing the fields to POST for the request. See the corresponding object definition for field details.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/square/api/subscriptions_api.rb', line 18 def create_subscription(body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/subscriptions', 'default') .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#delete_subscription_action(subscription_id:, action_id:) ⇒ ApiResponse
Deletes a scheduled action for a subscription. subscription the targeted action is to act upon. action to be deleted.
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/square/api/subscriptions_api.rb', line 156 def delete_subscription_action(subscription_id:, action_id:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::DELETE, '/v2/subscriptions/{subscription_id}/actions/{action_id}', 'default') .template_param(new_parameter(subscription_id, key: 'subscription_id') .should_encode(true)) .template_param(new_parameter(action_id, key: 'action_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#list_subscription_events(subscription_id:, cursor: nil, limit: nil) ⇒ ApiResponse
Lists all [events](developer.squareup.com/docs/subscriptions-api/actions-eve nts) for a specific subscription. subscription to retrieve the events for. resulting subscription events exceeds the limit of a paged response, specify the cursor returned from a preceding response here to fetch the next set of results. If the cursor is unset, the response contains the last page of the results. For more information, see [Pagination](developer.squareup.com/docs/build-basics/common-api-p atterns/pagination). of subscription events to return in a paged response.
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/square/api/subscriptions_api.rb', line 243 def list_subscription_events(subscription_id:, cursor: nil, limit: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/subscriptions/{subscription_id}/events', 'default') .template_param(new_parameter(subscription_id, key: 'subscription_id') .should_encode(true)) .query_param(new_parameter(cursor, key: 'cursor')) .query_param(new_parameter(limit, key: 'limit')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#pause_subscription(subscription_id:, body:) ⇒ ApiResponse
Schedules a ‘PAUSE` action to pause an active subscription. subscription to pause. containing the fields to POST for the request. See the corresponding object definition for field details.
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/square/api/subscriptions_api.rb', line 270 def pause_subscription(subscription_id:, body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/subscriptions/{subscription_id}/pause', 'default') .template_param(new_parameter(subscription_id, key: 'subscription_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#resume_subscription(subscription_id:, body:) ⇒ ApiResponse
Schedules a ‘RESUME` action to resume a paused or a deactivated subscription. subscription to resume. containing the fields to POST for the request. See the corresponding object definition for field details.
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/square/api/subscriptions_api.rb', line 298 def resume_subscription(subscription_id:, body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/subscriptions/{subscription_id}/resume', 'default') .template_param(new_parameter(subscription_id, key: 'subscription_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#retrieve_subscription(subscription_id:, include: nil) ⇒ ApiResponse
Retrieves a specific subscription. subscription to retrieve. related information to be included in the response. The supported query parameter values are: - ‘actions`: to include scheduled actions on the targeted subscription.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/square/api/subscriptions_api.rb', line 103 def retrieve_subscription(subscription_id:, include: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/subscriptions/{subscription_id}', 'default') .template_param(new_parameter(subscription_id, key: 'subscription_id') .should_encode(true)) .query_param(new_parameter(include, key: 'include')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#search_subscriptions(body:) ⇒ ApiResponse
Searches for subscriptions. Results are ordered chronologically by subscription creation date. If the request specifies more than one location ID, the endpoint orders the result by location ID, and then by creation date within each location. If no locations are given in the query, all locations are searched. You can also optionally specify ‘customer_ids` to search by customer. If left unset, all customers associated with the specified locations are returned. If the request specifies customer IDs, the endpoint orders results first by location, within location by customer ID, and within customer by subscription creation date. containing the fields to POST for the request. See the corresponding object definition for field details.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/square/api/subscriptions_api.rb', line 78 def search_subscriptions(body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/subscriptions/search', 'default') .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#swap_plan(subscription_id:, body:) ⇒ ApiResponse
Schedules a ‘SWAP_PLAN` action to swap a subscription plan variation in an existing subscription. For more information, see [Swap Subscription Plan Variations](developer.squareup.com/docs/subscriptions-api/swap-pla n-variations). subscription to swap the subscription plan for. fields to POST for the request. See the corresponding object definition for field details.
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/square/api/subscriptions_api.rb', line 329 def swap_plan(subscription_id:, body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/subscriptions/{subscription_id}/swap-plan', 'default') .template_param(new_parameter(subscription_id, key: 'subscription_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#update_subscription(subscription_id:, body:) ⇒ ApiResponse
Updates a subscription by modifying or clearing ‘subscription` field values. To clear a field, set its value to `null`. subscription to update. containing the fields to POST for the request. See the corresponding object definition for field details.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/square/api/subscriptions_api.rb', line 130 def update_subscription(subscription_id:, body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::PUT, '/v2/subscriptions/{subscription_id}', 'default') .template_param(new_parameter(subscription_id, key: 'subscription_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |