def create(request:, timeout_ms: nil, http_headers: nil)
def create(request:, timeout_ms: nil, http_headers: nil)
# create - Create Discount
# Create a discount.
#
# **Scopes**: `discounts:write`
url, params = @sdk_configuration.get_server_details
base_url = Utils.template_url(url, params)
url = "#{base_url}/v1/discounts/"
headers = {}
headers = T.cast(headers, T::Hash[String, String])
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
headers["content-type"] = req_content_type
raise StandardError, "request body is required" if data.nil? && form.nil?
if form && !form.empty?
body = Utils.encode_form(form)
elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
else
body = data
end
headers["Accept"] = "application/json"
headers["user-agent"] = @sdk_configuration.user_agent
security = @sdk_configuration.security_source&.call
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
timeout ||= @sdk_configuration.timeout
connection = @sdk_configuration.client
hook_ctx = SDKHooks::HookContext.new(
config: @sdk_configuration,
base_url: base_url,
oauth2_scopes: nil,
operation_id: "discounts:create",
security_source: @sdk_configuration.security_source
)
error = T.let(nil, T.nilable(StandardError))
http_response = T.let(nil, T.nilable(Faraday::Response))
begin
http_response = T.must(connection).post(url) do |req|
req.body = body
req.headers.merge!(headers)
req.options.timeout = timeout unless timeout.nil?
Utils.configure_request_security(req, security)
http_headers&.each do |key, value|
req.headers[key.to_s] = value
end
@sdk_configuration.hooks.before_request(
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
hook_ctx: hook_ctx
),
request: req
)
end
rescue StandardError => e
error = e
ensure
if http_response.nil? || Utils.error_status?(http_response.status)
http_response = @sdk_configuration.hooks.after_error(
error: error,
hook_ctx: SDKHooks::AfterErrorHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
else
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
end
if http_response.nil?
raise error if !error.nil?
raise "no response"
end
end
content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
if Utils.match_status_code(http_response.status, ["201"])
if Utils.match_content_type(content_type, "application/json")
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
response_data = http_response.env.response_body
obj = Crystalline.unmarshal_json(
JSON.parse(response_data),
Crystalline::Union.new(
Models::Components::DiscountFixedOnceForeverDuration,
Models::Components::DiscountFixedRepeatDuration,
Models::Components::DiscountPercentageOnceForeverDuration,
Models::Components::DiscountPercentageRepeatDuration
)
)
response = Models::Operations::DiscountsCreateResponse.new(
status_code: http_response.status,
content_type: content_type,
raw_response: http_response,
discount: T.unsafe(obj)
)
return response
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown content type received"
)
end
elsif Utils.match_status_code(http_response.status, ["422"])
if Utils.match_content_type(content_type, "application/json")
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
response_data = http_response.env.response_body
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
raise obj
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown content type received"
)
end
elsif Utils.match_status_code(http_response.status, ["4XX"])
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"API error occurred"
)
elsif Utils.match_status_code(http_response.status, ["5XX"])
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"API error occurred"
)
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown status code received"
)
end
end
def delete(id:, timeout_ms: nil, http_headers: nil)
def delete(id:, timeout_ms: nil, http_headers: nil)
# delete - Delete Discount
# Delete a discount.
#
# **Scopes**: `discounts:write`
request = Models::Operations::DiscountsDeleteRequest.new(
id: id
)
url, params = @sdk_configuration.get_server_details
base_url = Utils.template_url(url, params)
url = Utils.generate_url(
Models::Operations::DiscountsDeleteRequest,
base_url,
"/v1/discounts/{id}",
request
)
headers = {}
headers = T.cast(headers, T::Hash[String, String])
headers["Accept"] = "application/json"
headers["user-agent"] = @sdk_configuration.user_agent
security = @sdk_configuration.security_source&.call
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
timeout ||= @sdk_configuration.timeout
connection = @sdk_configuration.client
hook_ctx = SDKHooks::HookContext.new(
config: @sdk_configuration,
base_url: base_url,
oauth2_scopes: nil,
operation_id: "discounts:delete",
security_source: @sdk_configuration.security_source
)
error = T.let(nil, T.nilable(StandardError))
http_response = T.let(nil, T.nilable(Faraday::Response))
begin
http_response = T.must(connection).delete(url) do |req|
req.headers.merge!(headers)
req.options.timeout = timeout unless timeout.nil?
Utils.configure_request_security(req, security)
http_headers&.each do |key, value|
req.headers[key.to_s] = value
end
@sdk_configuration.hooks.before_request(
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
hook_ctx: hook_ctx
),
request: req
)
end
rescue StandardError => e
error = e
ensure
if http_response.nil? || Utils.error_status?(http_response.status)
http_response = @sdk_configuration.hooks.after_error(
error: error,
hook_ctx: SDKHooks::AfterErrorHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
else
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
end
if http_response.nil?
raise error if !error.nil?
raise "no response"
end
end
content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
if Utils.match_status_code(http_response.status, ["204"])
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
return Models::Operations::DiscountsDeleteResponse.new(
status_code: http_response.status,
content_type: content_type,
raw_response: http_response
)
elsif Utils.match_status_code(http_response.status, ["404"])
if Utils.match_content_type(content_type, "application/json")
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
response_data = http_response.env.response_body
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ResourceNotFound)
raise obj
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown content type received"
)
end
elsif Utils.match_status_code(http_response.status, ["422"])
if Utils.match_content_type(content_type, "application/json")
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
response_data = http_response.env.response_body
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
raise obj
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown content type received"
)
end
elsif Utils.match_status_code(http_response.status, ["4XX"])
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"API error occurred"
)
elsif Utils.match_status_code(http_response.status, ["5XX"])
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"API error occurred"
)
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown status code received"
)
end
end
def get(id:, timeout_ms: nil, http_headers: nil)
def get(id:, timeout_ms: nil, http_headers: nil)
# get - Get Discount
# Get a discount by ID.
#
# **Scopes**: `discounts:read` `discounts:write`
request = Models::Operations::DiscountsGetRequest.new(
id: id
)
url, params = @sdk_configuration.get_server_details
base_url = Utils.template_url(url, params)
url = Utils.generate_url(
Models::Operations::DiscountsGetRequest,
base_url,
"/v1/discounts/{id}",
request
)
headers = {}
headers = T.cast(headers, T::Hash[String, String])
headers["Accept"] = "application/json"
headers["user-agent"] = @sdk_configuration.user_agent
security = @sdk_configuration.security_source&.call
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
timeout ||= @sdk_configuration.timeout
connection = @sdk_configuration.client
hook_ctx = SDKHooks::HookContext.new(
config: @sdk_configuration,
base_url: base_url,
oauth2_scopes: nil,
operation_id: "discounts:get",
security_source: @sdk_configuration.security_source
)
error = T.let(nil, T.nilable(StandardError))
http_response = T.let(nil, T.nilable(Faraday::Response))
begin
http_response = T.must(connection).get(url) do |req|
req.headers.merge!(headers)
req.options.timeout = timeout unless timeout.nil?
Utils.configure_request_security(req, security)
http_headers&.each do |key, value|
req.headers[key.to_s] = value
end
@sdk_configuration.hooks.before_request(
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
hook_ctx: hook_ctx
),
request: req
)
end
rescue StandardError => e
error = e
ensure
if http_response.nil? || Utils.error_status?(http_response.status)
http_response = @sdk_configuration.hooks.after_error(
error: error,
hook_ctx: SDKHooks::AfterErrorHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
else
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
end
if http_response.nil?
raise error if !error.nil?
raise "no response"
end
end
content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
if Utils.match_status_code(http_response.status, ["200"])
if Utils.match_content_type(content_type, "application/json")
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
response_data = http_response.env.response_body
obj = Crystalline.unmarshal_json(
JSON.parse(response_data),
Crystalline::Union.new(
Models::Components::DiscountFixedOnceForeverDuration,
Models::Components::DiscountFixedRepeatDuration,
Models::Components::DiscountPercentageOnceForeverDuration,
Models::Components::DiscountPercentageRepeatDuration
)
)
response = Models::Operations::DiscountsGetResponse.new(
status_code: http_response.status,
content_type: content_type,
raw_response: http_response,
discount: T.unsafe(obj)
)
return response
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown content type received"
)
end
elsif Utils.match_status_code(http_response.status, ["404"])
if Utils.match_content_type(content_type, "application/json")
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
response_data = http_response.env.response_body
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ResourceNotFound)
raise obj
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown content type received"
)
end
elsif Utils.match_status_code(http_response.status, ["422"])
if Utils.match_content_type(content_type, "application/json")
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
response_data = http_response.env.response_body
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
raise obj
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown content type received"
)
end
elsif Utils.match_status_code(http_response.status, ["4XX"])
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"API error occurred"
)
elsif Utils.match_status_code(http_response.status, ["5XX"])
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"API error occurred"
)
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown status code received"
)
end
end
def list(request:, timeout_ms: nil, http_headers: nil)
def list(request:, timeout_ms: nil, http_headers: nil)
# list - List Discounts
# List discounts.
#
# **Scopes**: `discounts:read` `discounts:write`
url, params = @sdk_configuration.get_server_details
base_url = Utils.template_url(url, params)
url = "#{base_url}/v1/discounts/"
headers = {}
headers = T.cast(headers, T::Hash[String, String])
query_params = Utils.get_query_params(Models::Operations::DiscountsListRequest, request, nil)
headers["Accept"] = "application/json"
headers["user-agent"] = @sdk_configuration.user_agent
security = @sdk_configuration.security_source&.call
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
timeout ||= @sdk_configuration.timeout
connection = @sdk_configuration.client
hook_ctx = SDKHooks::HookContext.new(
config: @sdk_configuration,
base_url: base_url,
oauth2_scopes: nil,
operation_id: "discounts:list",
security_source: @sdk_configuration.security_source
)
error = T.let(nil, T.nilable(StandardError))
http_response = T.let(nil, T.nilable(Faraday::Response))
begin
http_response = T.must(connection).get(url) do |req|
req.headers.merge!(headers)
req.options.timeout = timeout unless timeout.nil?
req.params = query_params
Utils.configure_request_security(req, security)
http_headers&.each do |key, value|
req.headers[key.to_s] = value
end
@sdk_configuration.hooks.before_request(
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
hook_ctx: hook_ctx
),
request: req
)
end
rescue StandardError => e
error = e
ensure
if http_response.nil? || Utils.error_status?(http_response.status)
http_response = @sdk_configuration.hooks.after_error(
error: error,
hook_ctx: SDKHooks::AfterErrorHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
else
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
end
if http_response.nil?
raise error if !error.nil?
raise "no response"
end
end
content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
if Utils.match_status_code(http_response.status, ["200"])
if Utils.match_content_type(content_type, "application/json")
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
response_data = http_response.env.response_body
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::ListResourceDiscount)
response = Models::Operations::DiscountsListResponse.new(
status_code: http_response.status,
content_type: content_type,
raw_response: http_response,
list_resource_discount: T.unsafe(obj)
)
sdk = self
response.next_page = proc do
request_page = T.must(!request.page.nil? ? request.page : 1)
next_page = request_page + 1
num_pages = Janeway.enum_for("$.pagination.max_page", JSON.parse(response_data)).search
if num_pages.nil? || num_pages[0] <= request_page
next nil
end
if !response_data
next nil
end
results = Janeway.enum_for("$.items", JSON.parse(response_data)).search
if results.is_a?(Array)
results = results[0]
end
if results.count.zero?
next nil
end
request_limit = !request.limit.nil? ? request.limit : 1
if results.count < request_limit
next nil
end
sdk.list(
request: Models::Operations::DiscountsListRequest.new(
organization_id: request.organization_id,
query: request.query,
page: next_page,
limit: request.limit,
sorting: request.sorting
),
http_headers: http_headers
)
end
return response
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown content type received"
)
end
elsif Utils.match_status_code(http_response.status, ["422"])
if Utils.match_content_type(content_type, "application/json")
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
response_data = http_response.env.response_body
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
raise obj
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown content type received"
)
end
elsif Utils.match_status_code(http_response.status, ["4XX"])
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"API error occurred"
)
elsif Utils.match_status_code(http_response.status, ["5XX"])
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"API error occurred"
)
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown status code received"
)
end
end
def update(body:, id:, timeout_ms: nil, http_headers: nil)
def update(body:, id:, timeout_ms: nil, http_headers: nil)
# update - Update Discount
# Update a discount.
#
# **Scopes**: `discounts:write`
request = Models::Operations::DiscountsUpdateRequest.new(
id: id,
body: body
)
url, params = @sdk_configuration.get_server_details
base_url = Utils.template_url(url, params)
url = Utils.generate_url(
Models::Operations::DiscountsUpdateRequest,
base_url,
"/v1/discounts/{id}",
request
)
headers = {}
headers = T.cast(headers, T::Hash[String, String])
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
headers["content-type"] = req_content_type
raise StandardError, "request body is required" if data.nil? && form.nil?
if form && !form.empty?
body = Utils.encode_form(form)
elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
else
body = data
end
headers["Accept"] = "application/json"
headers["user-agent"] = @sdk_configuration.user_agent
security = @sdk_configuration.security_source&.call
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
timeout ||= @sdk_configuration.timeout
connection = @sdk_configuration.client
hook_ctx = SDKHooks::HookContext.new(
config: @sdk_configuration,
base_url: base_url,
oauth2_scopes: nil,
operation_id: "discounts:update",
security_source: @sdk_configuration.security_source
)
error = T.let(nil, T.nilable(StandardError))
http_response = T.let(nil, T.nilable(Faraday::Response))
begin
http_response = T.must(connection).patch(url) do |req|
req.body = body
req.headers.merge!(headers)
req.options.timeout = timeout unless timeout.nil?
Utils.configure_request_security(req, security)
http_headers&.each do |key, value|
req.headers[key.to_s] = value
end
@sdk_configuration.hooks.before_request(
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
hook_ctx: hook_ctx
),
request: req
)
end
rescue StandardError => e
error = e
ensure
if http_response.nil? || Utils.error_status?(http_response.status)
http_response = @sdk_configuration.hooks.after_error(
error: error,
hook_ctx: SDKHooks::AfterErrorHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
else
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
end
if http_response.nil?
raise error if !error.nil?
raise "no response"
end
end
content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
if Utils.match_status_code(http_response.status, ["200"])
if Utils.match_content_type(content_type, "application/json")
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
response_data = http_response.env.response_body
obj = Crystalline.unmarshal_json(
JSON.parse(response_data),
Crystalline::Union.new(
Models::Components::DiscountFixedOnceForeverDuration,
Models::Components::DiscountFixedRepeatDuration,
Models::Components::DiscountPercentageOnceForeverDuration,
Models::Components::DiscountPercentageRepeatDuration
)
)
response = Models::Operations::DiscountsUpdateResponse.new(
status_code: http_response.status,
content_type: content_type,
raw_response: http_response,
discount: T.unsafe(obj)
)
return response
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown content type received"
)
end
elsif Utils.match_status_code(http_response.status, ["404"])
if Utils.match_content_type(content_type, "application/json")
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
response_data = http_response.env.response_body
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ResourceNotFound)
raise obj
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown content type received"
)
end
elsif Utils.match_status_code(http_response.status, ["422"])
if Utils.match_content_type(content_type, "application/json")
http_response = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: http_response
)
response_data = http_response.env.response_body
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
raise obj
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown content type received"
)
end
elsif Utils.match_status_code(http_response.status, ["4XX"])
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"API error occurred"
)
elsif Utils.match_status_code(http_response.status, ["5XX"])
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"API error occurred"
)
else
raise(
::OpenApiSDK::Models::Errors::APIError.new(
status_code: http_response.status,
body: http_response.env.response_body,
raw_response: http_response
),
"Unknown status code received"
)
end
end