Sha256: 4d9b94e03354a5389059bb41bd1e7c50a482eab84cab0d747c8024a2dcab4e16

Contents?: true

Size: 1.26 KB

Versions: 18

Compression:

Stored size: 1.26 KB

Contents

module Ecoportal
  module API
    class Internal
      class Person < V1::Person
        def as_json
          super.update("account" => account&.as_json)
        end

        def account
          return @account if defined?(@account)
          return @account = nil if doc["account"].nil?
          @account = Internal::Account.new(doc["account"])
        end

        def account=(value)
          case value
          when NilClass
            doc["account"] = nil
          when Internal::Account
            doc["account"] = JSON.parse(value.to_json)
          when Hash
            # TODO
            doc["account"] = value.slice(%w[policy_group_ids landing_page_id permissions_preset permissions_custom preferences prefilter filter_tags login_provider_ids starred_ids])
          else
            # TODO
            raise "Invalid set on account: Need nil, Account or Hash; got #{value.class}"
          end
          remove_instance_variable("@account") if defined?(@account)
          return account
        end

        def add_account
          self.account = {}
        end

        private

        def person_schema_class
          Internal::PersonSchema
        end

        def person_details_class
          Internal::PersonDetails
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
ecoportal-api-0.3.8 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.3.6 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.3.5 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.3.4 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.3.3 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.3.1 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.3.0 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.3.0.pre1 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.2.2 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.2.1 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.2.0 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.1.12 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.1.11 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.1.10 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.1.9 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.1.8 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.1.7 lib/ecoportal/api/internal/person.rb
ecoportal-api-0.1.6 lib/ecoportal/api/internal/person.rb