lib/desertcart/operation/create.rb in desertcart-1.1.5 vs lib/desertcart/operation/create.rb in desertcart-1.2.0

- old
+ new

@@ -8,13 +8,18 @@ include Desertcart::Operation::Mixin private def create_in_ledger - return LedgerSync::Result.Success(response) if response.success? - - fail(response.status) + case response.status + when 201 + LedgerSync::Result.Success(response) + when 422 + rejected + else + fail(response.status) + end end def operate create_in_ledger .and_then { success } @@ -38,9 +43,19 @@ failure( LedgerSync::Error::OperationError.new( operation: self, response: response, message: "Status code: #{status}" + ), + resource: @resource + ) + end + + def rejected + failure( + LedgerSync::Error::OperationError::UnprocessableEntityError.new( + operation: self, + response: response ), resource: @resource ) end end