=begin #Subskribe API #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) OpenAPI spec version: 1.0.0 Generated by: https://github.com/swagger-api/swagger-codegen.git Swagger Codegen version: 2.4.41 =end require 'uri' module SwaggerClient class SubscriptionsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Delete subscription # Deletes the subscription for given subscription Id if invoices have not been generated and revenue has not been recognized # @param id subscription id # @param version subscription version # @param [Hash] opts the optional parameters # @return [nil] def delete_subscription(id, version, opts = {}) delete_subscription_with_http_info(id, version, opts) nil end # Delete subscription # Deletes the subscription for given subscription Id if invoices have not been generated and revenue has not been recognized # @param id subscription id # @param version subscription version # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def delete_subscription_with_http_info(id, version, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SubscriptionsApi.delete_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.delete_subscription" end # verify the required parameter 'version' is set if @api_client.config.client_side_validation && version.nil? fail ArgumentError, "Missing the required parameter 'version' when calling SubscriptionsApi.delete_subscription" end # resource path local_var_path = '/subscriptions/{id}/{version}'.sub('{' + 'id' + '}', id.to_s).sub('{' + 'version' + '}', version.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: SubscriptionsApi#delete_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get billing periods # Gets the billing periods for the specified subscription. # @param id subscription id # @param [Hash] opts the optional parameters # @return [Array] def get_subscription_billing_periods(id, opts = {}) data, _status_code, _headers = get_subscription_billing_periods_with_http_info(id, opts) data end # Get billing periods # Gets the billing periods for the specified subscription. # @param id subscription id # @param [Hash] opts the optional parameters # @return [Array<(Array, Fixnum, Hash)>] Array data, response status code and response headers def get_subscription_billing_periods_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SubscriptionsApi.get_subscription_billing_periods ...' 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_billing_periods" end # resource path local_var_path = '/subscriptions/{id}/billingPeriods'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'Array') if @api_client.config.debugging @api_client.config.logger.debug "API called: SubscriptionsApi#get_subscription_billing_periods\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get subscription details # Gets the details of the specified subscription. # @param id subscription id # @param [Hash] opts the optional parameters # @return [SubscriptionJson] def get_subscription_by_id(id, opts = {}) data, _status_code, _headers = get_subscription_by_id_with_http_info(id, opts) data end # Get subscription details # Gets the details of the specified subscription. # @param id subscription id # @param [Hash] opts the optional parameters # @return [Array<(SubscriptionJson, Fixnum, Hash)>] SubscriptionJson data, response status code and response headers def get_subscription_by_id_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SubscriptionsApi.get_subscription_by_id ...' 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_by_id" end # resource path local_var_path = '/subscriptions/{id}'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'SubscriptionJson') if @api_client.config.debugging @api_client.config.logger.debug "API called: SubscriptionsApi#get_subscription_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get subscription metrics # Returns the metrics associated with the specified subscription. Metrics include ACV, ARR, etc. # @param id id of the subscription # @param [Hash] opts the optional parameters # @option opts [Integer] :target_date As of date for the metrics. If omitted defaults to now. # @return [MetricsJson] def get_subscription_metrics(id, opts = {}) data, _status_code, _headers = get_subscription_metrics_with_http_info(id, opts) data end # Get subscription metrics # Returns the metrics associated with the specified subscription. Metrics include ACV, ARR, etc. # @param id id of the subscription # @param [Hash] opts the optional parameters # @option opts [Integer] :target_date As of date for the metrics. If omitted defaults to now. # @return [Array<(MetricsJson, Fixnum, Hash)>] MetricsJson data, response status code and response headers def get_subscription_metrics_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SubscriptionsApi.get_subscription_metrics ...' 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_metrics" end # resource path local_var_path = '/subscriptions/{id}/metrics'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} query_params[:'targetDate'] = opts[:'target_date'] if !opts[:'target_date'].nil? # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'MetricsJson') if @api_client.config.debugging @api_client.config.logger.debug "API called: SubscriptionsApi#get_subscription_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get paginated subscriptions # returns all Subscriptions in the system in a paginated fashion # @param [Hash] opts the optional parameters # @option opts [Integer] :limit number of items per page # @option opts [String] :page_token pass this to subsequent calls # @option opts [String] :account_id optionally pass in account Id, only subscriptions for this account will will returned # @return [PaginatedResponse] def get_subscriptions(opts = {}) data, _status_code, _headers = get_subscriptions_with_http_info(opts) data end # Get paginated subscriptions # returns all Subscriptions in the system in a paginated fashion # @param [Hash] opts the optional parameters # @option opts [Integer] :limit number of items per page # @option opts [String] :page_token pass this to subsequent calls # @option opts [String] :account_id optionally pass in account Id, only subscriptions for this account will will returned # @return [Array<(PaginatedResponse, Fixnum, Hash)>] PaginatedResponse data, response status code and response headers def get_subscriptions_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SubscriptionsApi.get_subscriptions ...' end # resource path local_var_path = '/subscriptions' # query parameters query_params = {} query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'pageToken'] = opts[:'page_token'] if !opts[:'page_token'].nil? query_params[:'accountId'] = opts[:'account_id'] if !opts[:'account_id'].nil? # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'PaginatedResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: SubscriptionsApi#get_subscriptions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Revert subscription # Reverts the subscription for given subscription Id and version to it's previous version. Operation is allowed only if invoices have not been generated and revenue has not been recognized # @param id subscription id # @param version subscription version # @param [Hash] opts the optional parameters # @return [nil] def revert_subscription(id, version, opts = {}) revert_subscription_with_http_info(id, version, opts) nil end # Revert subscription # Reverts the subscription for given subscription Id and version to it's previous version. Operation is allowed only if invoices have not been generated and revenue has not been recognized # @param id subscription id # @param version subscription version # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def revert_subscription_with_http_info(id, version, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SubscriptionsApi.revert_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.revert_subscription" end # verify the required parameter 'version' is set if @api_client.config.client_side_validation && version.nil? fail ArgumentError, "Missing the required parameter 'version' when calling SubscriptionsApi.revert_subscription" end # resource path local_var_path = '/subscriptions/{id}/{version}/revert'.sub('{' + 'id' + '}', id.to_s).sub('{' + 'version' + '}', version.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: SubscriptionsApi#revert_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Subscription can be modified # Returns true if subscription can be deleted. # @param id subscription id # @param [Hash] opts the optional parameters # @return [nil] def subscription_modifiable(id, opts = {}) subscription_modifiable_with_http_info(id, opts) nil end # Subscription can be modified # Returns true if subscription can be deleted. # @param id subscription id # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def subscription_modifiable_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SubscriptionsApi.subscription_modifiable ...' 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.subscription_modifiable" end # resource path local_var_path = '/subscriptions/{id}/modifiable'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: SubscriptionsApi#subscription_modifiable\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Subscription can be reverted # Returns true if subscription can be reverted to a prior version. # @param id subscription id # @param [Hash] opts the optional parameters # @return [nil] def subscription_reversible(id, opts = {}) subscription_reversible_with_http_info(id, opts) nil end # Subscription can be reverted # Returns true if subscription can be reverted to a prior version. # @param id subscription id # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def subscription_reversible_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SubscriptionsApi.subscription_reversible ...' 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.subscription_reversible" end # resource path local_var_path = '/subscriptions/{id}/reversible'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: SubscriptionsApi#subscription_reversible\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Link renewal opportunity to subscription # Update renewal opportunity CRM id on subscription # @param id subscription id # @param renewal_opportunity_crm_id renewal opportunity CRM id # @param [Hash] opts the optional parameters # @return [nil] def update_renewal_opportunity(id, renewal_opportunity_crm_id, opts = {}) update_renewal_opportunity_with_http_info(id, renewal_opportunity_crm_id, opts) nil end # Link renewal opportunity to subscription # Update renewal opportunity CRM id on subscription # @param id subscription id # @param renewal_opportunity_crm_id renewal opportunity CRM id # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def update_renewal_opportunity_with_http_info(id, renewal_opportunity_crm_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SubscriptionsApi.update_renewal_opportunity ...' 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_renewal_opportunity" end # verify the required parameter 'renewal_opportunity_crm_id' is set if @api_client.config.client_side_validation && renewal_opportunity_crm_id.nil? fail ArgumentError, "Missing the required parameter 'renewal_opportunity_crm_id' when calling SubscriptionsApi.update_renewal_opportunity" end # resource path local_var_path = '/subscriptions/{id}/renewalOpportunity'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} query_params[:'renewalOpportunityCrmId'] = renewal_opportunity_crm_id # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: SubscriptionsApi#update_renewal_opportunity\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update subscription details # Updates the details of the specified subscription. # @param id subscription id # @param body subscription details in json # @param [Hash] opts the optional parameters # @return [nil] def update_subscription(id, body, opts = {}) update_subscription_with_http_info(id, body, opts) nil end # Update subscription details # Updates the details of the specified subscription. # @param id subscription id # @param body subscription details in json # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def update_subscription_with_http_info(id, body, 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 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling SubscriptionsApi.update_subscription" end # resource path local_var_path = '/subscriptions/{id}'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(body) auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) 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 end end