Sha256: cbc8f6549924df47ee8c49ea424812c4890ae90f9ac05ba5602beb51f7e0ff0c
Contents?: true
Size: 979 Bytes
Versions: 7
Compression:
Stored size: 979 Bytes
Contents
# frozen_string_literal: true require_relative '../operation' module Desertcart class Operation class Create include Desertcart::Operation::Mixin private def create_in_ledger return LedgerSync::Result.Success(response) if response.success? fail(response.status) end def operate create_in_ledger .and_then { success } end def response @response ||= client.create( body: serializer.serialize(resource: resource), path: ledger_resource_path ) end def success super( resource: deserialized_resource, response: response ) end def fail(status) failure( LedgerSync::Error::OperationError.new( operation: self, response: response, message: "Status code: #{status}" ), resource: @resource ) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems