Sha256: 1b36c7edab829f48f3471e20b609337d8c0afa5f6e9199aaa6f41a34551abef9

Contents?: true

Size: 658 Bytes

Versions: 3

Compression:

Stored size: 658 Bytes

Contents

module FlexmlsApi
  module Models
    class Contact < Base
      self.element_name="contacts"
      
      def save
        begin
          return save!
        rescue BadResourceRequest => e
        rescue NotFound => e
          # log and leave
          FlexmlsApi.logger.error("Failed to save contact #{self}: #{e.message}")
        end
        false
      end
      def save!
        results = connection.post self.class.path, "Contacts" => [ attributes ]
        result = results.first
        attributes['ResourceUri'] = result['ResourceUri']
        attributes['Id'] = result['ResourceUri'][/\/.*\/(.+)$/, 1]
        true
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flexmls_api-0.3.6 lib/flexmls_api/models/contact.rb
flexmls_api-0.3.3 lib/flexmls_api/models/contact.rb
flexmls_api-0.3.2 lib/flexmls_api/models/contact.rb