=begin #Conekta API #Conekta sdk The version of the OpenAPI document: 2.1.0 Contact: engineering@conekta.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.6.0 =end require 'spec_helper' require 'json' # Unit tests for Conekta::SubscriptionsApi # Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'SubscriptionsApi' do before do # run before each test @api_instance = Conekta::SubscriptionsApi.new end after do # run after each test end describe 'test an instance of SubscriptionsApi' do it 'should create an instance of SubscriptionsApi' do expect(@api_instance).to be_instance_of(Conekta::SubscriptionsApi) end end # unit tests for cancel_subscription # Cancel Subscription # You can cancel the subscription to stop the plans that your customers consume # @param id Identifier of the resource # @param [Hash] opts the optional parameters # @option opts [String] :accept_language Use for knowing which language to use # @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] describe 'cancel_subscription test' do it 'should work' do customer_id = 'cus_2tZWxbTPtQgGJGh8P' response = @api_instance.cancel_subscription(customer_id, { accept_language: 'es' }) expect(response).to be_instance_of(Conekta::SubscriptionResponse) expect(response.customer_id).to eq(customer_id) expect(response.status).to eq('canceled') expect(response.canceled_at).to eq(1679431258) end end # unit tests for create_subscription # Create Subscription # You can create the subscription to include the plans that your customers consume # @param id Identifier of the resource # @param subscription_request requested field for subscriptions # @param [Hash] opts the optional parameters # @option opts [String] :accept_language Use for knowing which language to use # @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] describe 'create_subscription test' do it 'should work' do customer_id = 'cus_2tXx8KUxw6311kEbs' subscription_request = Conekta::SubscriptionRequest.new({plan_id: "contracargos-plan"}) response = @api_instance.create_subscription(customer_id, subscription_request) expect(response).to be_instance_of(Conekta::SubscriptionResponse) expect(response.customer_id).to eq(customer_id) expect(response.status).to eq('past_due') expect(response.object).to eq('subscription') expect(response.plan_id).to eq(subscription_request.plan_id) expect(response.created_at).to eq(1679431660) end end # unit tests for get_all_events_from_subscription # Get Events By Subscription # You can get the events of the subscription(s) of a client, with the customer id # @param id Identifier of the resource # @param [Hash] opts the optional parameters # @option opts [String] :accept_language Use for knowing which language to use # @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] describe 'get_all_events_from_subscription test' do it 'should work' do response = @api_instance.get_all_events_from_subscription('cus_2rKpeXQpapLonfVke', { accept_language: 'es' }) expect(response).to be_instance_of(Conekta::SubscriptionEventsResponse) expect(response.has_more).to eq(false) end end # unit tests for get_subscription # Get Subscription # @param id Identifier of the resource # @param [Hash] opts the optional parameters # @option opts [String] :accept_language Use for knowing which language to use # @return [SubscriptionResponse] describe 'get_subscription test' do it 'should work' do response = @api_instance.get_subscription('cus_2tZWxbTPtQgGJGh8P', { accept_language: 'es' }) expect(response).to be_instance_of(Conekta::SubscriptionResponse) expect(response.customer_id).to eq('cus_2tZWxbTPtQgGJGh8P') expect(response.object).to eq('subscription') end end # unit tests for pause_subscription # Pause Subscription # You can pause the subscription to stop the plans that your customers consume # @param id Identifier of the resource # @param [Hash] opts the optional parameters # @option opts [String] :accept_language Use for knowing which language to use # @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] describe 'pause_subscription test' do it 'should work' do customer_id = 'cus_2tZWxbTPtQgGJGh8P' response = @api_instance.pause_subscription(customer_id, { accept_language: 'es' }) expect(response).to be_instance_of(Conekta::SubscriptionResponse) expect(response.customer_id).to eq(customer_id) expect(response.status).to eq('paused') expect(response.paused_at).to eq(1679429155) end end # unit tests for resume_subscription # Resume Subscription # You can resume the subscription to start the plans that your customers consume # @param id Identifier of the resource # @param [Hash] opts the optional parameters # @option opts [String] :accept_language Use for knowing which language to use # @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] describe 'resume_subscription test' do it 'should work' do customer_id = 'cus_2tZWxbTPtQgGJGh8P' response = @api_instance.resume_subscription(customer_id, { accept_language: 'es' }) expect(response).to be_instance_of(Conekta::SubscriptionResponse) expect(response.customer_id).to eq(customer_id) expect(response.status).to eq('active') expect(response.paused_at).to be_nil end end # unit tests for update_subscription # Update Subscription # You can modify the subscription to change the plans that your customers consume # @param id Identifier of the resource # @param subscription_update_request requested field for update a subscription # @param [Hash] opts the optional parameters # @option opts [String] :accept_language Use for knowing which language to use # @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] describe 'update_subscription test' do it 'should work' do customer_id = 'cus_2tZWxbTPtQgGJGh8P' subscription_update_request = Conekta::SubscriptionUpdateRequest.new({ trial_end: 1679752328}) response = @api_instance.update_subscription(customer_id, subscription_update_request, { accept_language: 'es' }) expect(response).to be_instance_of(Conekta::SubscriptionResponse) end end end