Sha256: 76d49d7e8293a53eef510e281f7b984f670dce63d0893f10cdcffb1fe209b1c9
Contents?: true
Size: 1.19 KB
Versions: 8
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true require_relative '../operation' module Desertcart class Operation class Find include Desertcart::Operation::Mixin private def find_in_ledger case response.status when 200 LedgerSync::Result.Success(response) when 404 not_found else fail(response.status) end end def operate find_in_ledger .and_then { success } end def response @response ||= client.read( 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 def not_found failure( LedgerSync::Error::OperationError::NotFoundError.new( operation: self, response: response ), resource: @resource ) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems