lib/square/api/subscriptions_api.rb
# Creates a subscription to a subscription plan by a customer.
# If you provide a card on file in the request, Square charges the card for
# the subscription. Otherwise, Square bills 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.
# @param [CreateSubscriptionRequest] body Required parameter: An object
# containing the fields to POST for the request.  See the corresponding
# object definition for field details.
# @return [CreateSubscriptionResponse Hash] response from the API call
Creates a subscription to a subscription plan by a customer.
If you provide a card on file in the request, Square charges the card for
the subscription. Otherwise, Square bills 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.
Creates a subscription to a subscription plan by a customer . If you provide a card on file in the request Square charges the card for the subscription . Otherwise Square bills 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 .
def create_subscription(body:)
      _query_builder = config.get_base_uri
      _query_builder << '/v2/subscriptions'
      _query_url = APIHelper.clean_url _query_builder
      _headers = {
        'accept' => 'application/json',
        'Content-Type' => 'application/json'
      }
      _request = config.http_client.post(
        _query_url,
        headers: _headers,
        parameters: body.to_json
      )
      OAuth2.apply(config, _request)
      _response = execute_request(_request)
      decoded = APIHelper.json_deserialize(_response.raw_body)
      _errors = APIHelper.map_response(decoded, ['errors'])
      ApiResponse.new(
        _response, data: decoded, errors: _errors
      )
    end
def create_subscription ( body : ) _query_builder = config . get_base_uri _query_builder << '/v2/subscriptions' _query_url = APIHelper . clean_url _query_builder _headers = { 'accept' => 'application/json' , 'Content-Type' => 'application/json' } _request = config . http_client . post ( _query_url , headers : _headers , parameters : body . to_json ) OAuth2 . apply ( config , _request ) _response = execute_request ( _request ) decoded = APIHelper . json_deserialize ( _response . raw_body ) _errors = APIHelper . map_response ( decoded , [ 'errors' ] ) ApiResponse . new ( _response , data : decoded , errors : _errors ) end
Creates a subscription to a subscription plan by a customer.
Creates a subscription to a subscription plan by a customer .
# Prepare query url. # Prepare headers. # Prepare and execute HttpRequest. # Return appropriate response type.
response from the API call
response from the API call
CreateSubscriptionResponse Hash
body
<not_specific>
<not_specific>
body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.
body Required parameter : An object containing the fields to POST for the request . See the corresponding object definition for field details .