lib/desertcart/operation/update.rb in desertcart-1.1.5 vs lib/desertcart/operation/update.rb in desertcart-1.2.0
- old
+ new
@@ -8,13 +8,20 @@
include Desertcart::Operation::Mixin
private
def update_in_ledger
- return LedgerSync::Result.Success(response) if response.success?
-
- fail(response.status)
+ case response.status
+ when 200
+ LedgerSync::Result.Success(response)
+ when 404
+ not_found
+ when 422
+ rejected
+ else
+ fail(response.status)
+ end
end
def operate
update_in_ledger
.and_then { success }
@@ -38,9 +45,29 @@
failure(
LedgerSync::Error::OperationError.new(
operation: self,
response: response,
message: "Status code: #{status}"
+ ),
+ resource: @resource
+ )
+ end
+
+ def not_found
+ failure(
+ LedgerSync::Error::OperationError::NotFoundError.new(
+ operation: self,
+ response: response
+ ),
+ resource: @resource
+ )
+ end
+
+ def rejected
+ failure(
+ LedgerSync::Error::OperationError::UnprocessableEntityError.new(
+ operation: self,
+ response: response
),
resource: @resource
)
end
end