Class: MoxiworksPlatform::Agent

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

Overview

Moxi Works Platform Agent

Instance Attribute Summary collapse

Attributes inherited from Resource

#headers

Class 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

#access_levelString

If include_access_level was passed as true, this can return one of the possible access levels: company-admin, manager, office-admin, office-owner, region-admin, user.

Returns:

  • (String)

    The access level of the agent.



254
255
256
# File 'lib/moxiworks_platform/agent.rb', line 254

def access_level
  @access_level
end

#agent_idString

Returns the UUID of the Agent.

Returns:

  • (String)

    the UUID of the Agent



28
29
30
# File 'lib/moxiworks_platform/agent.rb', line 28

def agent_id
  @agent_id
end

#alt_phone_numberString

Returns alternate phone number for agent.

Returns:

  • (String)

    alternate phone number for agent



46
47
48
# File 'lib/moxiworks_platform/agent.rb', line 46

def alt_phone_number
  @alt_phone_number
end

#alternate_officesArray

Returns any alternate offices the agent is associated with.

Returns:

  • (Array)

    any alternate offices the agent is associated with



94
95
96
# File 'lib/moxiworks_platform/agent.rb', line 94

def alternate_offices
  @alternate_offices
end

#altnernate_officesArray

Returns alternate offices for this agent.

Returns:

  • (Array)

    alternate offices for this agent



265
266
267
# File 'lib/moxiworks_platform/agent.rb', line 265

def altnernate_offices
  @altnernate_offices
end

#available_mlsArray

Returns available MLSs for this agent.

Returns:

  • (Array)

    available MLSs for this agent



259
260
261
# File 'lib/moxiworks_platform/agent.rb', line 259

def available_mls
  @available_mls
end

#buyer_commission_rateHash

Returns buyer commission rate for this agent.

Returns:

  • (Hash)

    buyer commission rate for this agent



82
83
84
# File 'lib/moxiworks_platform/agent.rb', line 82

def buyer_commission_rate
  @buyer_commission_rate
end

#client_agent_idString

Returns the id of the agent used by the company of the agent.

Returns:

  • (String)

    the id of the agent used by the company of the agent



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

def client_agent_id
  @client_agent_id
end

#client_company_idString

Returns the UUID of the office which the Agent is associated.

Returns:

  • (String)

    the UUID of the office which the Agent is associated



105
106
107
# File 'lib/moxiworks_platform/agent.rb', line 105

def client_company_id
  @client_company_id
end

#client_office_idString

Returns the internal of the office which the Agent is associated used by the company.

Returns:

  • (String)

    the internal of the office which the Agent is associated used by the company



100
101
102
# File 'lib/moxiworks_platform/agent.rb', line 100

def client_office_id
  @client_office_id
end

#company_idString

Returns the company id of the agent.

Returns:

  • (String)

    the company id of the agent



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

def company_id
  @company_id
end

#facebookString

Returns the agent's facebook page.

Returns:

  • (String)

    the agent's facebook page



211
212
213
# File 'lib/moxiworks_platform/agent.rb', line 211

def facebook
  @facebook
end

#fax_phone_numberString

Returns the agent's fax phone number.

Returns:

  • (String)

    the agent's fax phone number



176
177
178
# File 'lib/moxiworks_platform/agent.rb', line 176

def fax_phone_number
  @fax_phone_number
end

#first_nameString

Returns the agent's first name.

Returns:

  • (String)

    the agent's first name



156
157
158
# File 'lib/moxiworks_platform/agent.rb', line 156

def first_name
  @first_name
end

#gci_goalInteger

Returns GCI Goal for this agent.

Returns:

  • (Integer)

    GCI Goal for this agent



76
77
78
# File 'lib/moxiworks_platform/agent.rb', line 76

def gci_goal
  @gci_goal
end

#google_plusString

Returns the agent's google plus acount.

Returns:

  • (String)

    the agent's google plus acount



206
207
208
# File 'lib/moxiworks_platform/agent.rb', line 206

def google_plus
  @google_plus
end

#has_engage_accessString

Returns whether the agent has access to MoxiWorks Engage.

Returns:

  • (String)

    whether the agent has access to MoxiWorks Engage



248
249
250
# File 'lib/moxiworks_platform/agent.rb', line 248

def has_engage_access
  @has_engage_access
end

#home_pageString

Returns the agent's home page url.

Returns:

  • (String)

    the agent's home page url



216
217
218
# File 'lib/moxiworks_platform/agent.rb', line 216

def home_page
  @home_page
end

#last_nameString

Returns the agent's last name.

Returns:

  • (String)

    the agent's last name



161
162
163
# File 'lib/moxiworks_platform/agent.rb', line 161

def last_name
  @last_name
end

#lead_routing_email_addressString

Returns the lead routing email address of the agent.

Returns:

  • (String)

    the lead routing email address of the agent



52
53
54
# File 'lib/moxiworks_platform/agent.rb', line 52

def lead_routing_email_address
  @lead_routing_email_address
end

#licenseString

Returns license number for the listing agent.

Returns:

  • (String)

    license number for the listing agent



115
116
117
# File 'lib/moxiworks_platform/agent.rb', line 115

def license
  @license
end

#main_phone_numberString

Returns the agent's main phone number.

Returns:

  • (String)

    the agent's main phone number



181
182
183
# File 'lib/moxiworks_platform/agent.rb', line 181

def main_phone_number
  @main_phone_number
end

#mls_abbreviationString

Returns This is the standard abbreviation of the primary MLS utilized by the agent.

Returns:

  • (String)

    This is the standard abbreviation of the primary MLS utilized by the agent



125
126
127
# File 'lib/moxiworks_platform/agent.rb', line 125

def mls_abbreviation
  @mls_abbreviation
end

#mls_agent_idString

Returns MLS ID for the listing agent.

Returns:

  • (String)

    MLS ID for the listing agent



110
111
112
# File 'lib/moxiworks_platform/agent.rb', line 110

def mls_agent_id
  @mls_agent_id
end

#mls_nameString

Returns the name of the listing Agent's mls.

Returns:

  • (String)

    the name of the listing Agent's mls



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

def mls_name
  @mls_name
end

#mobile_phone_numberString

Returns the agent's fax phone number.

Returns:

  • (String)

    the agent's fax phone number



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

def mobile_phone_number
  @mobile_phone_number
end

#moxi_works_agent_idString

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

this must be set for any Moxi Works Platform transaction

Returns:

  • (String)

    the Moxi Works Platform ID of the agent



12
13
14
# File 'lib/moxiworks_platform/agent.rb', line 12

def moxi_works_agent_id
  @moxi_works_agent_id
end

#moxi_works_office_idString

Returns the UUID of the office which the Agent is associated.

Returns:

  • (String)

    the UUID of the office which the Agent is associated



17
18
19
# File 'lib/moxiworks_platform/agent.rb', line 17

def moxi_works_office_id
  @moxi_works_office_id
end

#nameString

Returns the agent's full name.

Returns:

  • (String)

    the agent's full name



166
167
168
# File 'lib/moxiworks_platform/agent.rb', line 166

def name
  @name
end

#office_address_cityString

Returns the agent's office address, city.

Returns:

  • (String)

    the agent's office address, city



141
142
143
# File 'lib/moxiworks_platform/agent.rb', line 141

def office_address_city
  @office_address_city
end

#office_address_stateString

Returns the agent's office address, state.

Returns:

  • (String)

    the agent's office address, state



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

def office_address_state
  @office_address_state
end

#office_address_streetString

Returns the agent's office address, street and number.

Returns:

  • (String)

    the agent's office address, street and number



131
132
133
# File 'lib/moxiworks_platform/agent.rb', line 131

def office_address_street
  @office_address_street
end

#office_address_street2String

Returns the agent's office address, suite or office number.

Returns:

  • (String)

    the agent's office address, suite or office number



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

def office_address_street2
  @office_address_street2
end

#office_address_zipString

Returns the agent's office address, zip code.

Returns:

  • (String)

    the agent's office address, zip code



151
152
153
# File 'lib/moxiworks_platform/agent.rb', line 151

def office_address_zip
  @office_address_zip
end

#office_idString

Returns the office ID of the agent.

Returns:

  • (String)

    the office ID of the agent



34
35
36
# File 'lib/moxiworks_platform/agent.rb', line 34

def office_id
  @office_id
end

#office_phone_numberString

Returns the agent's office_phone number.

Returns:

  • (String)

    the agent's office_phone number



186
187
188
# File 'lib/moxiworks_platform/agent.rb', line 186

def office_phone_number
  @office_phone_number
end

#primary_email_addressString

Returns the agent's primary email address.

Returns:

  • (String)

    the agent's primary email address



191
192
193
# File 'lib/moxiworks_platform/agent.rb', line 191

def primary_email_address
  @primary_email_address
end

#profile_image_urlString

Returns url to a full size image of the agent.

Returns:

  • (String)

    url to a full size image of the agent



221
222
223
# File 'lib/moxiworks_platform/agent.rb', line 221

def profile_image_url
  @profile_image_url
end

#profile_thumb_urlString

Returns url to a thumb size image of the agent.

Returns:

  • (String)

    url to a thumb size image of the agent



226
227
228
# File 'lib/moxiworks_platform/agent.rb', line 226

def profile_thumb_url
  @profile_thumb_url
end

#regionString

Returns region for this agent.

Returns:

  • (String)

    region for this agent



277
278
279
# File 'lib/moxiworks_platform/agent.rb', line 277

def region
  @region
end

#secondary_email_addressString

Returns the agent's secondary email address.

Returns:

  • (String)

    the agent's secondary email address



196
197
198
# File 'lib/moxiworks_platform/agent.rb', line 196

def secondary_email_address
  @secondary_email_address
end

#seller_commission_rateHash

Returns seller commission rate for this agent.

Returns:

  • (Hash)

    seller commission rate for this agent



88
89
90
# File 'lib/moxiworks_platform/agent.rb', line 88

def seller_commission_rate
  @seller_commission_rate
end

#string :client_agent_id(: client_agent_id) ⇒ String

Returns the id of the agent used by the company of the agent.

Returns:

  • (String)

    the id of the agent used by the company of the agent



22
# File 'lib/moxiworks_platform/agent.rb', line 22

attr_accessor :client_agent_id

#string agent_id(agent_id) ⇒ String

Returns the UUID of the Agent.

Returns:

  • (String)

    the UUID of the Agent



28
# File 'lib/moxiworks_platform/agent.rb', line 28

attr_accessor :agent_id

#string alt_phone_number(alt_phone_number) ⇒ String

Returns alternate phone number for agent.

Returns:

  • (String)

    alternate phone number for agent



46
# File 'lib/moxiworks_platform/agent.rb', line 46

attr_accessor :alt_phone_number

#string alternate_offices(alternate_offices) ⇒ Array

Returns any alternate offices the agent is associated with.

Returns:

  • (Array)

    any alternate offices the agent is associated with



94
# File 'lib/moxiworks_platform/agent.rb', line 94

attr_accessor :alternate_offices

#string buyer_commission_rate(buyer_commission_rate) ⇒ String

Returns the buyer commission rate of the Agent.

Returns:

  • (String)

    the buyer commission rate of the Agent



82
# File 'lib/moxiworks_platform/agent.rb', line 82

attr_accessor :buyer_commission_rate

#string company_id(company_id) ⇒ String

Returns the company id of the agent.

Returns:

  • (String)

    the company id of the agent



40
# File 'lib/moxiworks_platform/agent.rb', line 40

attr_accessor :company_id

#string gci_goal(gci_goal) ⇒ String

Returns the GCI goal of the Agent.

Returns:

  • (String)

    the GCI goal of the Agent



76
# File 'lib/moxiworks_platform/agent.rb', line 76

attr_accessor :gci_goal

#string lead_routing_email_address(lead_routing_email_address) ⇒ String

Returns the lead routing email address of the agent.

Returns:

  • (String)

    the lead routing email address of the agent



52
# File 'lib/moxiworks_platform/agent.rb', line 52

attr_accessor :lead_routing_email_address

#string office_id(office_id) ⇒ String

Returns the office ID of the agent.

Returns:

  • (String)

    the office ID of the agent



34
# File 'lib/moxiworks_platform/agent.rb', line 34

attr_accessor :office_id

#string seller_commission_rate(seller_commission_rate) ⇒ String

Returns the seller commission rate of the Agent.

Returns:

  • (String)

    the seller commission rate of the Agent



88
# File 'lib/moxiworks_platform/agent.rb', line 88

attr_accessor :seller_commission_rate

#string the id of the company used by the company of the agent(theidofthecompanyusedbythecompanyoftheagent) ⇒ String

Returns the UUID of the office which the Agent is associated.

Returns:

  • (String)

    the UUID of the office which the Agent is associated



105
# File 'lib/moxiworks_platform/agent.rb', line 105

attr_accessor :client_company_id

#string the id office used by the company of the agent(theidofficeusedbythecompanyoftheagent) ⇒ String

Returns the internal of the office which the Agent is associated used by the company.

Returns:

  • (String)

    the internal of the office which the Agent is associated used by the company



100
# File 'lib/moxiworks_platform/agent.rb', line 100

attr_accessor :client_office_id

#string title(title) ⇒ String

Returns the title of the Agent.

Returns:

  • (String)

    the title of the Agent



58
# File 'lib/moxiworks_platform/agent.rb', line 58

attr_accessor :title

#string twitter(twitter) ⇒ String

Returns the twitter handle of the agent.

Returns:

  • (String)

    the twitter handle of the agent



70
# File 'lib/moxiworks_platform/agent.rb', line 70

attr_accessor :twitter

#string uuid(uuid) ⇒ String

Returns the UUID of the Agent.

Returns:

  • (String)

    the UUID of the Agent



64
# File 'lib/moxiworks_platform/agent.rb', line 64

attr_accessor :uuid

#titleString

Returns any business related titles associated with the agent.

Returns:

  • (String)

    any business related titles associated with the agent



58
59
60
# File 'lib/moxiworks_platform/agent.rb', line 58

def title
  @title
end

#twitterString

Returns the agent's twitter handle.

Returns:

  • (String)

    the agent's twitter handle



70
71
72
# File 'lib/moxiworks_platform/agent.rb', line 70

def twitter
  @twitter
end

#uuidString

identifier in determining associations between Agent objects and Listing objects.

Returns:

  • (String)

    UUID of the agent. Can be used as a unique



64
65
66
# File 'lib/moxiworks_platform/agent.rb', line 64

def uuid
  @uuid
end

#website_base_urlString

Returns the agent's website base url.

Returns:

  • (String)

    the agent's website base url



243
244
245
# File 'lib/moxiworks_platform/agent.rb', line 243

def website_base_url
  @website_base_url
end

Class Method Details

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

Find an Agent on the Moxi Works Platform

Parameters:

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

    named parameter Hash

Options Hash (opts):

  • :moxi_works_agent_id (String)

    REQUIRED – either :moxi_works_agent_id or :agent_uuid is required – The Moxi Works Agent ID for the agent

  • :agent_uuid (String)

    REQUIRED – either :moxi_works_agent_id or :agent_uuid is required – The Moxi Works Agent ID for the agent

Returns:

Raises:

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



303
304
305
306
307
308
309
310
# File 'lib/moxiworks_platform/agent.rb', line 303

def self.find(opts={})
  agent_identifier = opts[:agent_uuid] unless(opts[:agent_uuid].nil? or opts[:agent_uuid].empty?)
   agent_identifier ||= opts[:moxi_works_agent_id] unless(opts[:moxi_works_agent_id].nil? or opts[:moxi_works_agent_id].empty?)
  raise ::MoxiworksPlatform::Exception::ArgumentError, "#agent_uuid or moxi_works_agent_id required" if
      agent_identifier.nil?
  url = "#{MoxiworksPlatform::Config.url}/api/agents/#{agent_identifier}"
  self.send_request(:get, opts, url)
end

.search(opts = {}) ⇒ Hash

Search For Agents in Moxi Works Platform

Examples:

results = MoxiworksPlatform::Agent.search(
moxi_works_company_id: 'the_company',
updated_since:  Time.now.to_i - 1296000,
page_number: 2
)

Parameters:

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

    named parameter Hash

Options Hash (opts):

  • :moxi_works_company_id (String)

    REQUIRED The Moxi Works Company ID For the search (use Company.search to determine available moxi_works_company_id)

  • :updated_since (Integer)

    Unix timestamp; Only Agents updated after this date will be returned

    optional Search parameters

  • :page_number (Integer)

    the page of results to return

Returns:

  • (Hash)

    with the format:

    page_number: [Integer],
    total_pages: [Integer],
    agents:  [Array] containing MoxiworkPlatform::Agent objects
    

Raises:

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



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# File 'lib/moxiworks_platform/agent.rb', line 352

def self.search(opts={})
  url ||= "#{MoxiworksPlatform::Config.url}/api/agents"
  required_opts = [:moxi_works_company_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, 'agents':[]}
  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['agents'].each do |r|
      results << MoxiworksPlatform::Agent.new(r) unless r.nil? or r.empty?
    end
    json['agents'] = results
  end
  json
end

.send_request(method, opts = {}, url = nil) ⇒ Object



312
313
314
315
316
317
318
319
320
321
322
# File 'lib/moxiworks_platform/agent.rb', line 312

def self.send_request(method, opts={}, url=nil)
  url ||= "#{MoxiworksPlatform::Config.url}/api/agents"
  required_opts = [:moxi_works_company_id]
  raise ::MoxiworksPlatform::Exception::ArgumentError,
        'arguments must be passed as named parameters' unless opts.is_a? Hash
  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