Sha256: a2a09ffe869008f761774401af216c5ecea982d6eafe64212db7ced01910b78e

Contents?: true

Size: 1.39 KB

Versions: 77

Compression:

Stored size: 1.39 KB

Contents

module Eco
  module API
    class MicroCases
      # It updates an idividual person.
      # @note if it succeeds the update, it calls `person.consolidate!`
      # @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
      # @param context [String] main part of the message.
      # @param reason [String] why are we updating now.
      # @return [Boolean] `true` if it succeded to update, and `false` otherwise
      def person_update!(person, context: "Session", reason: "")
        logger.debug("#{context}, going to \"#{reason}\".\nPerson: #{person_ref(person)}")
        if response = api.people.update(person)
          if response.success?
            person.consolidate!
            true
          else
            msg  = "#{context} Error #{response.status}: #{response.body}\n"
            msg += " -- Failed to \"#{reason}\".\n"
            msg += "  • Person: #{person_ref(person)}"
            logger.error(msg)
            false
          end
        else
          msg  = "#{context} Error (connection error)\n"
          msg += " -- Failed to \"#{reason}\".\n"
          msg += "  • Person: #{person_ref(person)}"
          logger.error(msg)
          false
        end
      end

      private

      def person_ref(person)
        Eco::API::Session::Batch::Feedback.person_ref(person)
      end
    end
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
eco-helpers-2.7.24 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.23 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.22 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.21 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.20 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.19 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.18 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.17 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.16 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.15 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.14 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.13 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.12 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.4 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.2 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.1 lib/eco/api/microcases/person_update.rb
eco-helpers-2.7.0 lib/eco/api/microcases/person_update.rb
eco-helpers-2.6.4 lib/eco/api/microcases/person_update.rb
eco-helpers-2.6.3 lib/eco/api/microcases/person_update.rb
eco-helpers-2.6.2 lib/eco/api/microcases/person_update.rb