=begin
#Extend API Reference
## Introduction Welcome to the Extend API Documentation! Our goal is to make your integration as clear and easy as possible, so if you have feedback or suggestions for our API or reference docs, [please let us know](mailto:devs@helloextend.com). If you are implementing the API for the first time, please use the latest \"2019-08-01\" API version. If you have already implemented the API and haven't specified a version, you are on the \"Default\" API version. #### You can get up and running with Extend with just 5 simple steps: * Create an account with Extend, and get an access token from your Extend merchant portal * Sync your store's products to Extend * Get the relevant Extend warranty SKUs and add them to your store * Add the JS SDK snippets to your store's website, which will enable warranty offers to be displayed in your store * Record warranty purchases with Extend so we can create a new contract and deliver it to the customer, or record warranty returns / refunds so we can cancel the contract and account for the refunded amount
Pro Tip! Keep your store's products up to date
To make sure you are selling warranty plans on all eligible products (and not selling them on ineligible ones), it is best to keep your store's products in sync with Extend. If you update your products infrequently, it might be easiest to manually upload or edit products in your merchant portal. If you do update frequently, though, consider integrating with our Products API resource.
Need help? Contact us! We love to help!
The version of the OpenAPI document: Default
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 4.3.1-SNAPSHOT
=end
require 'cgi'
module HelloextendApiClient
class ContractsApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Get invoice information for a contract
# Extend automatically generates an invoice to the merchant whenever a warranty contract is sold. If it helps with your record-keeping and back end reconciliation, you can get the invoice details using this API call. If you sent us a purchase order number when making the 'Create a warranty contract' call, we'll include that in the invoice, too, for your reference.
# @param store_id [String] Unique identifier for a Store on Extend
# @param contract_id [String] Unique identifier for an Extend warranty Contract
# @param [Hash] opts the optional parameters
# @return [Invoice]
def contract_invoice(store_id, contract_id, opts = {})
data, _status_code, _headers = contract_invoice_with_http_info(store_id, contract_id, opts)
data
end
# Get invoice information for a contract
# Extend automatically generates an invoice to the merchant whenever a warranty contract is sold. If it helps with your record-keeping and back end reconciliation, you can get the invoice details using this API call. If you sent us a purchase order number when making the 'Create a warranty contract' call, we'll include that in the invoice, too, for your reference.
# @param store_id [String] Unique identifier for a Store on Extend
# @param contract_id [String] Unique identifier for an Extend warranty Contract
# @param [Hash] opts the optional parameters
# @return [Array<(Invoice, Integer, Hash)>] Invoice data, response status code and response headers
def contract_invoice_with_http_info(store_id, contract_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ContractsApi.contract_invoice ...'
end
# verify the required parameter 'store_id' is set
if @api_client.config.client_side_validation && store_id.nil?
fail ArgumentError, "Missing the required parameter 'store_id' when calling ContractsApi.contract_invoice"
end
# verify the required parameter 'contract_id' is set
if @api_client.config.client_side_validation && contract_id.nil?
fail ArgumentError, "Missing the required parameter 'contract_id' when calling ContractsApi.contract_invoice"
end
# resource path
local_var_path = '/stores/{storeId}/contracts/{contractId}/invoice'.sub('{' + 'storeId' + '}', CGI.escape(store_id.to_s)).sub('{' + 'contractId' + '}', CGI.escape(contract_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/json'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:body]
# return_type
return_type = opts[:return_type] || 'Invoice'
# auth_names
auth_names = opts[:auth_names] || ['ExtendAccessToken']
new_options = opts.merge(
: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: ContractsApi#contract_invoice\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Create a warranty contract
# @param store_id [String] Unique identifier for a Store on Extend
# @param contract [Contract]
# @param [Hash] opts the optional parameters
# @return [Contract]
def create_contracts(store_id, contract, opts = {})
data, _status_code, _headers = create_contracts_with_http_info(store_id, contract, opts)
data
end
# Create a warranty contract
# @param store_id [String] Unique identifier for a Store on Extend
# @param contract [Contract]
# @param [Hash] opts the optional parameters
# @return [Array<(Contract, Integer, Hash)>] Contract data, response status code and response headers
def create_contracts_with_http_info(store_id, contract, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ContractsApi.create_contracts ...'
end
# verify the required parameter 'store_id' is set
if @api_client.config.client_side_validation && store_id.nil?
fail ArgumentError, "Missing the required parameter 'store_id' when calling ContractsApi.create_contracts"
end
# verify the required parameter 'contract' is set
if @api_client.config.client_side_validation && contract.nil?
fail ArgumentError, "Missing the required parameter 'contract' when calling ContractsApi.create_contracts"
end
# resource path
local_var_path = '/stores/{storeId}/contracts'.sub('{' + 'storeId' + '}', CGI.escape(store_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/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:body] || @api_client.object_to_http_body(contract)
# return_type
return_type = opts[:return_type] || 'Contract'
# auth_names
auth_names = opts[:auth_names] || ['ExtendAccessToken']
new_options = opts.merge(
: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: ContractsApi#create_contracts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Cancel a warranty contract and request a refund
# This endpoint is your way to report a refunded warranty contract to Extend. If a customer returns an item for which a warranty was purchased, or just the warranty itself, to your store, you should let Extend know so we can cancel the warranty contract. We will also refund you, the merchant, in the next invoice. The amount Extend will refund you (and the amount you should refund to the customer), depends on the date of the refund and the terms of the warranty contract. Pro Tip! Check the refund amount before you refund your customer
To make sure you refund your customer the same amount as Extend will be refunding you, there is a three-step process:
- Send the cancellation API request to Extend with query parameter \"commit\" set to FALSE. This gives you a preview of the cancellation, Including the amount that would be refunded (the \"cancellation quote\")
- Issue a refund to the customer for the amount matching the cancellation quote
- Re-send the cancellation API request to Extend with query parameter \"commit\" set to TRUE. This will cause Extend to cancel the contract and issue the merchant refund for the amount matching the cancellation quote
Important:
Please note that this endpoint does not cause Extend to refund the customer - they would get the refund from the store where they purchased the product and warranty contract. A successful call to this endpoint will void the customer’s warranty contract, and initiate reimbursement to you, the merchant.
# @param store_id [String] Unique identifier for a Store on Extend
# @param contract_id [String] Unique identifier for an Extend warranty Contract
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :commit Use the value <strong>\"false\"</strong> to get a preview of the cancellation quote - the amount you will be refunded for the cancelled contract. If you use the value <strong>\"true\"</strong> or omit the query parameter, Extend will execute the contract cancellation.
# @return [nil]
def refund_contract(store_id, contract_id, opts = {})
refund_contract_with_http_info(store_id, contract_id, opts)
nil
end
# Cancel a warranty contract and request a refund
# This endpoint is your way to report a refunded warranty contract to Extend. If a customer returns an item for which a warranty was purchased, or just the warranty itself, to your store, you should let Extend know so we can cancel the warranty contract. We will also refund you, the merchant, in the next invoice. The amount Extend will refund you (and the amount you should refund to the customer), depends on the date of the refund and the terms of the warranty contract. <div class='wrapper tip'><h2>Pro Tip! Check the refund amount before you refund your customer</h2> To make sure you refund your customer the same amount as Extend will be refunding you, there is a three-step process: <ul><li>Send the cancellation API request to Extend with query parameter \"commit\" set to FALSE. This gives you a preview of the cancellation, Including the amount that would be refunded (the \"cancellation quote\") </li><li>Issue a refund to the customer for the amount matching the cancellation quote</li><li>Re-send the cancellation API request to Extend with query parameter \"commit\" set to TRUE. This will cause Extend to cancel the contract and issue the merchant refund for the amount matching the cancellation quote</li></ul></div><div class='wrapper important'><h2>Important:</h2> Please note that this endpoint <strong>does not cause Extend to refund the customer</strong> - they would get the refund from the store where they purchased the product and warranty contract. A successful call to this endpoint <strong>will void the customer’s warranty contract</strong>, and initiate reimbursement to you, the merchant.</div>
# @param store_id [String] Unique identifier for a Store on Extend
# @param contract_id [String] Unique identifier for an Extend warranty Contract
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :commit Use the value <strong>\"false\"</strong> to get a preview of the cancellation quote - the amount you will be refunded for the cancelled contract. If you use the value <strong>\"true\"</strong> or omit the query parameter, Extend will execute the contract cancellation.
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def refund_contract_with_http_info(store_id, contract_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ContractsApi.refund_contract ...'
end
# verify the required parameter 'store_id' is set
if @api_client.config.client_side_validation && store_id.nil?
fail ArgumentError, "Missing the required parameter 'store_id' when calling ContractsApi.refund_contract"
end
# verify the required parameter 'contract_id' is set
if @api_client.config.client_side_validation && contract_id.nil?
fail ArgumentError, "Missing the required parameter 'contract_id' when calling ContractsApi.refund_contract"
end
# resource path
local_var_path = '/stores/{storeId}/contracts/{contractId}/refund'.sub('{' + 'storeId' + '}', CGI.escape(store_id.to_s)).sub('{' + 'contractId' + '}', CGI.escape(contract_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'commit'] = opts[:'commit'] if !opts[:'commit'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:body]
# return_type
return_type = opts[:return_type]
# auth_names
auth_names = opts[:auth_names] || ['ExtendAccessToken']
new_options = opts.merge(
: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: ContractsApi#refund_contract\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end