class Conekta::SubscriptionsApi

Attributes

api_client[RW]

Public Class Methods

new(api_client = ApiClient.default) click to toggle source
# File lib/conekta/api/subscriptions_api.rb, line 19
def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Public Instance Methods

cancel_subscription(id, opts = {}) click to toggle source

Cancel Subscription You can cancel the subscription to stop the plans that your customers consume @param id [String] Identifier of the resource @param [Hash] opts the optional parameters @option opts [String] :accept_language Use for knowing which language to use (default to ‘es’) @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. @return [SubscriptionResponse]

# File lib/conekta/api/subscriptions_api.rb, line 29
def cancel_subscription(id, opts = {})
  data, _status_code, _headers = cancel_subscription_with_http_info(id, opts)
  data
end
cancel_subscription_with_http_info(id, opts = {}) click to toggle source

Cancel Subscription You can cancel the subscription to stop the plans that your customers consume @param id [String] Identifier of the resource @param [Hash] opts the optional parameters @option opts [String] :accept_language Use for knowing which language to use (default to ‘es’) @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. @return [Array<(SubscriptionResponse, Integer, Hash)>] SubscriptionResponse data, response status code and response headers

# File lib/conekta/api/subscriptions_api.rb, line 41
def cancel_subscription_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SubscriptionsApi.cancel_subscription ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling SubscriptionsApi.cancel_subscription"
  end
  allowable_values = ["es", "en"]
  if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])
    fail ArgumentError, "invalid value for \"accept_language\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/customers/{id}/subscription/cancel'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json'])
  header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?
  header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'SubscriptionResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"SubscriptionsApi.cancel_subscription",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SubscriptionsApi#cancel_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
create_subscription(id, subscription_request, opts = {}) click to toggle source

Create Subscription You can create the subscription to include the plans that your customers consume @param id [String] Identifier of the resource @param subscription_request [SubscriptionRequest] requested field for subscriptions @param [Hash] opts the optional parameters @option opts [String] :accept_language Use for knowing which language to use (default to ‘es’) @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. @return [SubscriptionResponse]

# File lib/conekta/api/subscriptions_api.rb, line 103
def create_subscription(id, subscription_request, opts = {})
  data, _status_code, _headers = create_subscription_with_http_info(id, subscription_request, opts)
  data
end
create_subscription_with_http_info(id, subscription_request, opts = {}) click to toggle source

Create Subscription You can create the subscription to include the plans that your customers consume @param id [String] Identifier of the resource @param subscription_request [SubscriptionRequest] requested field for subscriptions @param [Hash] opts the optional parameters @option opts [String] :accept_language Use for knowing which language to use (default to ‘es’) @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. @return [Array<(SubscriptionResponse, Integer, Hash)>] SubscriptionResponse data, response status code and response headers

# File lib/conekta/api/subscriptions_api.rb, line 116
def create_subscription_with_http_info(id, subscription_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SubscriptionsApi.create_subscription ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling SubscriptionsApi.create_subscription"
  end
  # verify the required parameter 'subscription_request' is set
  if @api_client.config.client_side_validation && subscription_request.nil?
    fail ArgumentError, "Missing the required parameter 'subscription_request' when calling SubscriptionsApi.create_subscription"
  end
  allowable_values = ["es", "en"]
  if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])
    fail ArgumentError, "invalid value for \"accept_language\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/customers/{id}/subscription'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?
  header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(subscription_request)

  # return_type
  return_type = opts[:debug_return_type] || 'SubscriptionResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"SubscriptionsApi.create_subscription",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SubscriptionsApi#create_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
get_all_events_from_subscription(id, opts = {}) click to toggle source

Get Events By Subscription You can get the events of the subscription(s) of a client, with the customer id @param id [String] Identifier of the resource @param [Hash] opts the optional parameters @option opts [String] :accept_language Use for knowing which language to use (default to ‘es’) @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. @return [SubscriptionEventsResponse]

# File lib/conekta/api/subscriptions_api.rb, line 186
def get_all_events_from_subscription(id, opts = {})
  data, _status_code, _headers = get_all_events_from_subscription_with_http_info(id, opts)
  data
end
get_all_events_from_subscription_with_http_info(id, opts = {}) click to toggle source

Get Events By Subscription You can get the events of the subscription(s) of a client, with the customer id @param id [String] Identifier of the resource @param [Hash] opts the optional parameters @option opts [String] :accept_language Use for knowing which language to use (default to ‘es’) @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. @return [Array<(SubscriptionEventsResponse, Integer, Hash)>] SubscriptionEventsResponse data, response status code and response headers

# File lib/conekta/api/subscriptions_api.rb, line 198
def get_all_events_from_subscription_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SubscriptionsApi.get_all_events_from_subscription ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling SubscriptionsApi.get_all_events_from_subscription"
  end
  allowable_values = ["es", "en"]
  if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])
    fail ArgumentError, "invalid value for \"accept_language\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/customers/{id}/subscription/events'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json'])
  header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?
  header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'SubscriptionEventsResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"SubscriptionsApi.get_all_events_from_subscription",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SubscriptionsApi#get_all_events_from_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
get_subscription(id, opts = {}) click to toggle source

Get Subscription @param id [String] Identifier of the resource @param [Hash] opts the optional parameters @option opts [String] :accept_language Use for knowing which language to use (default to ‘es’) @return [SubscriptionResponse]

# File lib/conekta/api/subscriptions_api.rb, line 257
def get_subscription(id, opts = {})
  data, _status_code, _headers = get_subscription_with_http_info(id, opts)
  data
end
get_subscription_with_http_info(id, opts = {}) click to toggle source

Get Subscription @param id [String] Identifier of the resource @param [Hash] opts the optional parameters @option opts [String] :accept_language Use for knowing which language to use (default to ‘es’) @return [Array<(SubscriptionResponse, Integer, Hash)>] SubscriptionResponse data, response status code and response headers

# File lib/conekta/api/subscriptions_api.rb, line 267
def get_subscription_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SubscriptionsApi.get_subscription ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling SubscriptionsApi.get_subscription"
  end
  allowable_values = ["es", "en"]
  if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])
    fail ArgumentError, "invalid value for \"accept_language\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/customers/{id}/subscription'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json'])
  header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'SubscriptionResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"SubscriptionsApi.get_subscription",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SubscriptionsApi#get_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
pause_subscription(id, opts = {}) click to toggle source

Pause Subscription You can pause the subscription to stop the plans that your customers consume @param id [String] Identifier of the resource @param [Hash] opts the optional parameters @option opts [String] :accept_language Use for knowing which language to use (default to ‘es’) @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. @return [SubscriptionResponse]

# File lib/conekta/api/subscriptions_api.rb, line 327
def pause_subscription(id, opts = {})
  data, _status_code, _headers = pause_subscription_with_http_info(id, opts)
  data
end
pause_subscription_with_http_info(id, opts = {}) click to toggle source

Pause Subscription You can pause the subscription to stop the plans that your customers consume @param id [String] Identifier of the resource @param [Hash] opts the optional parameters @option opts [String] :accept_language Use for knowing which language to use (default to ‘es’) @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. @return [Array<(SubscriptionResponse, Integer, Hash)>] SubscriptionResponse data, response status code and response headers

# File lib/conekta/api/subscriptions_api.rb, line 339
def pause_subscription_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SubscriptionsApi.pause_subscription ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling SubscriptionsApi.pause_subscription"
  end
  allowable_values = ["es", "en"]
  if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])
    fail ArgumentError, "invalid value for \"accept_language\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/customers/{id}/subscription/pause'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json'])
  header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?
  header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'SubscriptionResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"SubscriptionsApi.pause_subscription",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SubscriptionsApi#pause_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
resume_subscription(id, opts = {}) click to toggle source

Resume Subscription You can resume the subscription to start the plans that your customers consume @param id [String] Identifier of the resource @param [Hash] opts the optional parameters @option opts [String] :accept_language Use for knowing which language to use (default to ‘es’) @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. @return [SubscriptionResponse]

# File lib/conekta/api/subscriptions_api.rb, line 400
def resume_subscription(id, opts = {})
  data, _status_code, _headers = resume_subscription_with_http_info(id, opts)
  data
end
resume_subscription_with_http_info(id, opts = {}) click to toggle source

Resume Subscription You can resume the subscription to start the plans that your customers consume @param id [String] Identifier of the resource @param [Hash] opts the optional parameters @option opts [String] :accept_language Use for knowing which language to use (default to ‘es’) @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. @return [Array<(SubscriptionResponse, Integer, Hash)>] SubscriptionResponse data, response status code and response headers

# File lib/conekta/api/subscriptions_api.rb, line 412
def resume_subscription_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SubscriptionsApi.resume_subscription ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling SubscriptionsApi.resume_subscription"
  end
  allowable_values = ["es", "en"]
  if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])
    fail ArgumentError, "invalid value for \"accept_language\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/customers/{id}/subscription/resume'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json'])
  header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?
  header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'SubscriptionResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"SubscriptionsApi.resume_subscription",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SubscriptionsApi#resume_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
update_subscription(id, subscription_update_request, opts = {}) click to toggle source

Update Subscription You can modify the subscription to change the plans that your customers consume @param id [String] Identifier of the resource @param subscription_update_request [SubscriptionUpdateRequest] requested field for update a subscription @param [Hash] opts the optional parameters @option opts [String] :accept_language Use for knowing which language to use (default to ‘es’) @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. @return [SubscriptionResponse]

# File lib/conekta/api/subscriptions_api.rb, line 474
def update_subscription(id, subscription_update_request, opts = {})
  data, _status_code, _headers = update_subscription_with_http_info(id, subscription_update_request, opts)
  data
end
update_subscription_with_http_info(id, subscription_update_request, opts = {}) click to toggle source

Update Subscription You can modify the subscription to change the plans that your customers consume @param id [String] Identifier of the resource @param subscription_update_request [SubscriptionUpdateRequest] requested field for update a subscription @param [Hash] opts the optional parameters @option opts [String] :accept_language Use for knowing which language to use (default to ‘es’) @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. @return [Array<(SubscriptionResponse, Integer, Hash)>] SubscriptionResponse data, response status code and response headers

# File lib/conekta/api/subscriptions_api.rb, line 487
def update_subscription_with_http_info(id, subscription_update_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SubscriptionsApi.update_subscription ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling SubscriptionsApi.update_subscription"
  end
  # verify the required parameter 'subscription_update_request' is set
  if @api_client.config.client_side_validation && subscription_update_request.nil?
    fail ArgumentError, "Missing the required parameter 'subscription_update_request' when calling SubscriptionsApi.update_subscription"
  end
  allowable_values = ["es", "en"]
  if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])
    fail ArgumentError, "invalid value for \"accept_language\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/customers/{id}/subscription'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?
  header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(subscription_update_request)

  # return_type
  return_type = opts[:debug_return_type] || 'SubscriptionResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"SubscriptionsApi.update_subscription",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SubscriptionsApi#update_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end