Class: MoxiworksPlatform::SellerTransaction

Inherits:
Resource
  • Object
show all
Defined in:
lib/moxiworks_platform/seller_transaction.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#headers

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

accept_header, attr_accessor, attributes, #attributes, auth_header, check_for_error_in_response, content_type_header, #float_attrs, headers, #init_attrs_from_hash, #initialize, #int_attrs, #method_missing, #numeric_attrs, #numeric_value_for, #to_hash, underscore, underscore_array, underscore_attribute_names, underscore_hash, user_agent_header

Constructor Details

This class inherits a constructor from MoxiworksPlatform::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class MoxiworksPlatform::Resource

Instance Attribute Details

#addressString

Returns street address of property being sold.

Returns:

  • (String)

    street address of property being sold



84
85
86
# File 'lib/moxiworks_platform/seller_transaction.rb', line 84

def address
  @address
end

#bathsFloat

Returns number of bathrooms in property being sold.

Returns:

  • (Float)

    number of bathrooms in property being sold



120
121
122
# File 'lib/moxiworks_platform/seller_transaction.rb', line 120

def baths
  @baths
end

#bedsInteger

Returns number of bedrooms in property being sold.

Returns:

  • (Integer)

    number of bedrooms in property being sold



114
115
116
# File 'lib/moxiworks_platform/seller_transaction.rb', line 114

def beds
  @beds
end

#cityString

Returns city or township of property being sold.

Returns:

  • (String)

    city or township of property being sold



90
91
92
# File 'lib/moxiworks_platform/seller_transaction.rb', line 90

def city
  @city
end

#closing_priceInteger

This is the closing price for the sale . This should be null if the SellerTransaction is not yet in complete state.

Returns:

  • (Integer)

    closing price for this SellerTransaction



213
214
215
# File 'lib/moxiworks_platform/seller_transaction.rb', line 213

def closing_price
  @closing_price
end

#closing_timestampInteger

A Unix timestamp representing the point in time when the transaction for this SellerTransaction object was completed. This should be null if the SellerTransaction is not yet in stage 5 (complete) state.

Returns:

  • (Integer)

    Unix timestamp representing the date the transaction closed



223
224
225
# File 'lib/moxiworks_platform/seller_transaction.rb', line 223

def closing_timestamp
  @closing_timestamp
end

#commission_flat_feeInteger

If the agent is to receive a flat-rate commission upon sale of the property associated with this SellerTransaction, then this will represent the commission that the agent is to receive. This should be null if the SellerTransaction uses commission_percentage.

– both commission_flat_fee and commission_percentage cannot be set

Returns:

  • (Integer)


171
172
173
# File 'lib/moxiworks_platform/seller_transaction.rb', line 171

def commission_flat_fee
  @commission_flat_fee
end

#commission_percentageFloat

If the agent is to receive commission based on percentage of sale price for the property associated with this SellerTransaction, then this will represent the commission that the agent is to receive.This should be null if the SellerTransaction uses commission_flat_fee.

– both commission_flat_fee and commission_percentage cannot be set

Returns:

  • (Float)


159
160
161
# File 'lib/moxiworks_platform/seller_transaction.rb', line 159

def commission_percentage
  @commission_percentage
end

#is_mls_transactionBoolean

Returns Whether the property being sold is being listed on an MLS.

Returns:

  • (Boolean)

    Whether the property being sold is being listed on an MLS.



126
127
128
# File 'lib/moxiworks_platform/seller_transaction.rb', line 126

def is_mls_transaction
  @is_mls_transaction
end

#max_priceInteger

The maximum price range for the property if using a price range rather than target price.

– both target_price and max_price cannot be set

Returns:

  • (Integer)


204
205
206
# File 'lib/moxiworks_platform/seller_transaction.rb', line 204

def max_price
  @max_price
end

#min_priceInteger

The minimum price range for the property if using a price range rather than target price.

– both target_price and min_price cannot be set

Returns:

  • (Integer)


194
195
196
# File 'lib/moxiworks_platform/seller_transaction.rb', line 194

def min_price
  @min_price
end

#mls_numberString

**MLS TRANSACTIONS ONLY** mls number for the listing associated with this SellerTransaction

– mls_number should be populated only if is_mls_transaction is true.

Returns:

  • (String)


136
137
138
# File 'lib/moxiworks_platform/seller_transaction.rb', line 136

def mls_number
  @mls_number
end

#moxi_works_agent_idString

moxi_works_agent_id is the Moxi Works Platform ID of the agent which a SellerTransaction is or is to be associated with.

Returns:

  • (String)

    the Moxi Works Platform ID of the agent



11
12
13
# File 'lib/moxiworks_platform/seller_transaction.rb', line 11

def moxi_works_agent_id
  @moxi_works_agent_id
end

#moxi_works_contact_idObject

The Moxi Works Platform unique identifier for the Contact



22
23
24
# File 'lib/moxiworks_platform/seller_transaction.rb', line 22

def moxi_works_contact_id
  @moxi_works_contact_id
end

#moxi_works_transaction_idString

Returns The Moxi Works Platform unique identifier for the SellerTransaction.

Returns:

  • (String)

    The Moxi Works Platform unique identifier for the SellerTransaction



16
17
18
# File 'lib/moxiworks_platform/seller_transaction.rb', line 16

def moxi_works_transaction_id
  @moxi_works_transaction_id
end

#notesString

Brief, human readable content that is shown to the agent as notes about the SellerTransaction. Use this attribute to store and display data to the agent that is not otherwise explicitly available via attributes for the entity.

Returns:

  • (String)

    human readable notes about this SellerTransaction



50
51
52
# File 'lib/moxiworks_platform/seller_transaction.rb', line 50

def notes
  @notes
end

#partner_contact_idString

*your system's* unique ID for the Contact

this or moxi_works_contact_id can be used in operations that require a Contact ID

this will only be populated for Contact objects that your system has created on the Moxi Works Platform

Returns:

  • (String)

    your system's unique ID for the contact



32
33
34
# File 'lib/moxiworks_platform/seller_transaction.rb', line 32

def partner_contact_id
  @partner_contact_id
end

#promote_transactionObject

In order to promote a SellerTransaction to the next stage, set the promote_transaction attribute to true. For more information about SellerTransaction stages, see Moxi Works Platform Documentation. promote_transaction is only available for SellerTransaction updates. Newly created SellerTransaction objects will automatically be created in stage 3 (active)



233
234
235
# File 'lib/moxiworks_platform/seller_transaction.rb', line 233

def promote_transaction
  @promote_transaction
end

#sqftInteger

Returns living area of property being sold.

Returns:

  • (Integer)

    living area of property being sold



108
109
110
# File 'lib/moxiworks_platform/seller_transaction.rb', line 108

def sqft
  @sqft
end

#stageObject

Each SellerTransaction has five stages (1-5). stage displays the

stage number that the SellerTransaction is currently in.

This will be a single digit integer that can be [1,2,3,4,5].

For more information on SellerTransaction stages see
  {https://moxiworks-platform.github.io/#sellertransaction-stages The Moxi Works Platform Documentation}


62
63
64
# File 'lib/moxiworks_platform/seller_transaction.rb', line 62

def stage
  @stage
end

#stage_nameObject

This attribute displays a human readable stage name that is associated with the current stage attribute. When created through the Moxi Works Platform SellerTransaction objects will automatically be configured as 'active' transactions.

This will be an enumerated string that can be can be 'initialized', 'configured' , 'active' , 'pending' or 'complete' For more information on SellerTransaction stages see

{https://moxiworks-platform.github.io/#sellertransaction-stages The Moxi Works Platform Documentation}


78
79
80
# File 'lib/moxiworks_platform/seller_transaction.rb', line 78

def stage_name
  @stage_name
end

#start_timestampObject

this is the Unix timestamp

representing the date the agent initiated transaction discussions
with the client.


146
147
148
# File 'lib/moxiworks_platform/seller_transaction.rb', line 146

def start_timestamp
  @start_timestamp
end

#stateString

Returns state or province of property being sold.

Returns:

  • (String)

    state or province of property being sold



96
97
98
# File 'lib/moxiworks_platform/seller_transaction.rb', line 96

def state
  @state
end

#target_priceInteger

The desired selling price for the property if using target rather than range.

– both target_price and min_price cannot be set – both target_price and max_price cannot be set

Returns:

  • (Integer)


183
184
185
# File 'lib/moxiworks_platform/seller_transaction.rb', line 183

def target_price
  @target_price
end

#transaction_nameString

A brief, human readable title that is shown to the agent as the subject of the SellerTransaction.

Returns:

  • (String)

    name of transaction



40
41
42
# File 'lib/moxiworks_platform/seller_transaction.rb', line 40

def transaction_name
  @transaction_name
end

#zip_codeString

Returns postal code of property being sold.

Returns:

  • (String)

    postal code of property being sold



102
103
104
# File 'lib/moxiworks_platform/seller_transaction.rb', line 102

def zip_code
  @zip_code
end

Class Method Details

.create(opts = {}) ⇒ MoxiworksPlatform::SellerTransaction

Creates a new SellerTransaction in Moxi Works Platform

– Either moxi_works_contact_id or partner_contact_id must be

 populated; however, you should only populate one of these attributes.

optional SellerTransaction parameters

Examples:

Resource::TechConnectGateway::SellerTransaction.create(
     agent_identifier:'testis@testomatical.com',
     moxi_works_contact_id:'deadbeef-dead-beef-bad4-feedfacebad',
     notes: 'foo deeaz',
     transaction_name: 'whateverz'
     address: '1234 there ave',
     city: 'cityville'
     state:  'provinceland',
     zip_code: '12323',
     beds: 12,
     baths: 34.5,
     sqft: 12345,
     is_mls_transaction: true,
     commission_flat_fee: nil,
     commission_percentage: 12.34,
     target_price: 12345,
     min_price: nil,
     max_price: nil,
     mls_number: 'abc1234'
)

Parameters:

  • opts (Hash) (defaults to: {})

    named parameter Hash

Options Hash (opts):

  • :moxi_works_agent_id (String)

    REQUIRED The Moxi Works Agent ID for the agent to which this transaction is to be associated

  • :moxi_works_contact_id (String)

    REQUIRED The unique identifier for the Contact on the Moxi Works Platform. Either moxi_works_contact_id or partner_contact_id is required when creating SellerTransaction objects

  • :partner_contact_id (String)

    REQUIRED Your system's unique id for associated contact. should already have been created in Moxi Works Platform. If the Contact was not created by your system, use the moxi_works_contact_id attribute. Either moxi_works_contact_id or partner_contact_id is required when creating SellerTransaction objects

  • :transaction_name (String)

    REQUIRED short description of the transaction meaningful to the agent

  • :notes (String)

    human readable notes associated with the transaction meaningful to the agent

  • :address (String)

    street address of the property associated with the transaction

  • :city (String)

    city of the property associated with the transaction

  • :state (String)

    state or province of the property associated with the transaction

  • :zip_code (String)

    postal code of the property associated with the transaction

  • :sqft (Integer)

    square feet of living area in the property being sold

  • :beds (Integer)

    number of bedrooms in the property being sold

  • :baths (Integer or Float)

    number of bathrooms in the property being sold

  • :is_mls_transaction (Boolean)

    Whether the property being sold is being listed on an MLS. This should be false for paperwork-only, for sale by owner, off-market, or pocket listing type transactions or any transactions that will not be tracked through an MLS.

  • :mls_number (String)

    mls number associated with the transaction – mls_number should be populated only if is_mls_transaction is true.

  • :start_timestamp (Integer)

    Unix timestamp representing the date the agent initiated transaction discussions with the client.

  • :commission_percentage (Float)

    what percentage the commission is if percentage based – A SellerTransaction can only have either commission_percentage or commission_flat_fee populated. Both can not be populated.

  • :commission_flat_fee (Integer)

    how much the commission is if flat fee – A SellerTransaction can only have either commission_percentage or commission_flat_fee populated. Both can not be populated.

  • :target_price (Integer)

    target price associated with the transaction if using a target price rather than price range

  • :min_price (Integer)

    minimum acceptable price associated with the transaction if using a price range rather than target price

  • :max_price (Integer)

    maximum price associated with the transaction if using a price range rather than target price

Returns:

Raises:

  • ::MoxiworksPlatform::Exception::ArgumentError if required named parameters aren't included



296
297
298
299
300
301
302
303
304
305
306
# File 'lib/moxiworks_platform/seller_transaction.rb', line 296

def self.create(opts={})
 required_opts = [:moxi_works_agent_id]
 required_opts.each do |opt|
   raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
       opts[opt].nil? or opts[opt].to_s.empty?
 end
 raise ::MoxiworksPlatform::Exception::ArgumentError,
       'moxi_works_contact_id or partner_contact_id required' unless
     (opts.include?(:moxi_works_contact_id) or opts.include?(:partner_contact_id))
 self.send_request(:post, opts)
end

.find(opts = {}) ⇒ MoxiworksPlatform::SellerTransaction

Find a SellerTransaction using The Moxi Works Platform

Parameters:

  • opts (Hash) (defaults to: {})

    named parameter Hash

Options Hash (opts):

  • :moxi_works_agent_id (String)

    REQUIRED The Moxi Works Agent ID for the agent to which this transaction is associated

  • :moxi_works_transaction_id (String)

    REQUIRED The Moxi Works Platform ID for this transaction.

Returns:

Raises:

  • ::MoxiworksPlatform::Exception::ArgumentError if required named parameters aren't included



318
319
320
321
322
323
324
325
326
# File 'lib/moxiworks_platform/seller_transaction.rb', line 318

def self.find(opts={})
  required_opts = [:moxi_works_agent_id, :moxi_works_transaction_id]
  required_opts.each do |opt|
    raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
        opts[opt].nil? or opts[opt].to_s.empty?
  end
  url = "#{MoxiworksPlatform::Config.url}/api/seller_transactions/#{opts[:moxi_works_transaction_id]}"
  self.send_request(:get, opts, url)
end

.search(opts = {}) ⇒ Hash

Search Agent's SellerTransactions in Moxi Works Platform

Examples:

results = MoxiworksPlatform::Transaction.search(
moxi_works_agent_id: '123abc',
page_number: 2
)

Parameters:

  • opts (Hash) (defaults to: {})

    named parameter Hash

Options Hash (opts):

  • :moxi_works_agent_id (String)

    REQUIRED The Moxi Works Agent ID for the agent to which this contact is associated

    optional Search parameters

  • :moxi_works_contact_id (String)

    The Moxi Works Contact ID for the contact whose SellerTransactions you are searching for

  • :partner_contact_id (String)

    The partner's ID for the contact whose SellerTransactions they are looking for

  • :page_number (Integer)

    the page of results to return

Returns:

  • (Hash)

    with the format:

    page_number: [Integer],
    total_pages: [Integer],
    transactions:  [Array] containing MoxiworkPlatform::SellerTransaction objects
    

Raises:

  • ::MoxiworksPlatform::Exception::ArgumentError if required named parameters aren't included



358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/moxiworks_platform/seller_transaction.rb', line 358

def self.search(opts={})
  raise ::MoxiworksPlatform::Exception::ArgumentError,
        'arguments must be passed as named parameters' unless opts.is_a? Hash
  url ||= "#{MoxiworksPlatform::Config.url}/api/seller_transactions"
  required_opts = [:moxi_works_agent_id]
  required_opts.each do |opt|
    raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
        opts[opt].nil? or opts[opt].to_s.empty?
  end
  results = MoxiResponseArray.new()
  json = { 'page_number': 1, 'total_pages': 0, 'transactions':[]}
  RestClient::Request.execute(method: :get,
                              url: url,
                              payload: opts, headers: self.headers) do |response|
    puts response if MoxiworksPlatform::Config.debug
    results.headers = response.headers
    self.check_for_error_in_response(response)
    json = JSON.parse(response)

    results.page_number = json['page_number'] if(json.is_a?(Hash) && json['page_number'])
    results.total_pages = json['total_pages'] if(json.is_a?(Hash) && json['total_pages'])

    json['transactions'].each do |r|
      results << MoxiworksPlatform::SellerTransaction.new(r) unless r.nil? or r.empty?
    end
    json['transactions'] = results
  end
  json
end

.send_request(method, opts = {}, url = nil) ⇒ MoxiworksPlatform::Transaction

Send our remote request to the Moxi Works Platform

Parameters:

  • opts (Hash) (defaults to: {})

    named parameter Hash

Options Hash (opts):

  • :moxi_works_agent_id (String)

    REQUIRED The Moxi Works Agent ID for the agent to which this transaction is to be associated

  • :moxi_works_transaction_id (String)

    REQUIRED The Moxi Works Platform unique ID for this transaction.

  • :partner_contact_id (String)

    REQUIRED Your system's unique ID for the Contact for whom this SellerTransaction is to be associated.

    optional SellerTransaction parameters

  • :transaction_name (String)

    short description of the transaction meaningful to the agent

  • :description (String)

    longer description of the transaction

  • :due_at (Integer)

    Unix timestamp representing the due date

  • :duration (Integer)

    Length of time in minutes that the transaction should take

  • :completed_at (Integer)

    Unix timestamp representing the date the transaction was completed

  • :status (String)

    enumerated string representing transaction status

Returns:

  • (MoxiworksPlatform::Transaction)

Raises:

  • ::MoxiworksPlatform::Exception::ArgumentError if required named parameters aren't included



483
484
485
486
487
488
489
490
491
492
493
# File 'lib/moxiworks_platform/seller_transaction.rb', line 483

def self.send_request(method, opts={}, url=nil)
  raise ::MoxiworksPlatform::Exception::ArgumentError,
        'arguments must be passed as named parameters' unless opts.is_a? Hash
  url ||= "#{MoxiworksPlatform::Config.url}/api/seller_transactions"
  required_opts = [:moxi_works_agent_id]
  required_opts.each do |opt|
    raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
        opts[opt].nil? or opts[opt].to_s.empty?
  end
  super(method, opts, url)
end

.update(opts = {}) ⇒ MoxiworksPlatform::Transaction

Updates an existing SellerTransaction in Leads Gateway

Examples:

Resource::TechConnectGateway::SellerTransaction.update(
     agent_identifier:'testis@testomatical.com',
     moxi_works_transaction_id:'deadbeef-dead-beef-bad4-feedfacebad',
     notes: 'foo deeaz',
     transaction_name: 'whateverz'
     address: '1234 there ave',
     city: 'cityville'
     state:  'provinceland',
     zip_code: '12323',
     beds: 12,
     baths: 34.5,
     sqft: 12345,
     is_mls_transaction: true,
     commission_flat_fee: nil,
     commission_percentage: 12.34,
     target_price: 12345,
     min_price: nil,
     max_price: nil,
     mls_number: 'abc1234',
     closing_price: 123456,
     closing_timestamp: Time.now.to_i,
     promote_transaction: true
)

Parameters:

  • opts (Hash) (defaults to: {})

    named parameter Hash

Options Hash (opts):

  • :moxi_works_agent_id (String)

    REQUIRED The Moxi Works Agent ID for the agent to which this transaction is associated

  • :moxi_works_transaction_id (String)

    REQUIRED partner system's unique ID for this transaction.

    optional SellerTransaction parameters

  • :transaction_name (String)

    short description of the transaction meaningful to the agent

  • :notes (String)

    human readable notes associated with the transaction meaningful to the agent

  • :address (String)

    street address of the property associated with the transaction

  • :city (String)

    city of the property associated with the transaction

  • :state (String)

    state or province of the property associated with the transaction

  • :zip_code (String)

    postal code of the property associated with the transaction

  • :sqft (Integer)

    square feet of living area in the property being sold

  • :beds (Integer)

    number of bedrooms in the property being sold

  • :baths (Integer or Float)

    number of bathrooms in the property being sold

  • :is_mls_transaction (Boolean)

    Whether the property being sold is being listed on an MLS. This should be false for paperwork-only, for sale by owner, off-market, or pocket listing type transactions or any transactions that will not be tracked through an MLS.

  • :mls_number (String)

    mls number associated with the transaction – mls_number should be populated only if is_mls_transaction is true.

  • :start_timestamp (Integer)

    Unix timestamp representing the date the agent initiated transaction discussions with the client.

  • :commission_percentage (Float)

    what percentage the commission is if percentage based – A SellerTransaction can only have either commission_percentage or commission_flat_fee populated. Both can not be populated.

  • :commission_flat_fee (Integer)

    how much the commission is if flat fee – A SellerTransaction can only have either commission_percentage or commission_flat_fee populated. Both can not be populated.

  • :target_price (Integer)

    target price associated with the transaction if using a target price rather than price range

  • :min_price (Integer)

    minimum acceptable price associated with the transaction if using a price range rather than target price

  • :max_price (Integer)

    maximum price associated with the transaction if using a price range rather than target price

  • :closing_timestamp (Integer)

    Unix timestamp representing the date the sale of the property closed – closing_timestamp should only be used when the SellerTransaction state = 5 (complete)

  • :closing_price (Integer)

    selling price of the property – closing_price should only be used when the SellerTransaction state = 5 (complete)

  • :promote_transaction (Boolean)

    If this is set to true then The Moxi Works Platform will promote this transaction to the next stage

Returns:

  • (MoxiworksPlatform::Transaction)

Raises:

  • ::MoxiworksPlatform::Exception::ArgumentError if required named parameters aren't included



450
451
452
453
454
455
456
457
458
# File 'lib/moxiworks_platform/seller_transaction.rb', line 450

def self.update(opts={})
  required_opts = [:moxi_works_agent_id, :moxi_works_transaction_id]
  required_opts.each do |opt|
    raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
        opts[opt].nil? or opts[opt].to_s.empty?
  end
  url = "#{MoxiworksPlatform::Config.url}/api/seller_transactions/#{opts[:moxi_works_transaction_id]}"
   self.send_request(:put, opts, url)
end

Instance Method Details

#promoteObject



515
516
517
518
# File 'lib/moxiworks_platform/seller_transaction.rb', line 515

def promote
  self.promote_transaction = true
  self.save
end

#saveMoxiWorksPlatform:SellerTransaction

Save an instance of MoxiWorksPlatform::SellerTransaction to Moxi Works Platform

Examples:

transaction = MoxiWorksPlatform::SellerTransaction.new()
transaction.moxi_works_agent_id = '1234abc'
transaction.moxi_works_transaction_id = 'burbywurb'
transaction.promote_transaction = true
transaction.closing_timestamp =  Time.now.to_i
transaction.closing_price = 1234567
transaction.save

Returns:

  • (MoxiWorksPlatform:SellerTransaction)


507
508
509
510
511
512
513
# File 'lib/moxiworks_platform/seller_transaction.rb', line 507

def save
  response = MoxiworksPlatform::SellerTransaction.update(self.to_hash)
  return if response.nil? or response.moxi_works_transaction_id.nil? or response.moxi_works_transaction_id.empty?
  response.attributes.each {|r| self.send("#{r}=", response.send(r))}
  self.promote_transaction = false
  self
end