Class: MoxiworksPlatform::Agent

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

Overview

Moxi Works Platform Agent

Instance Attribute Summary collapse

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

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

#address_cityString

Returns the agent’s address, city.

Returns:

  • (String)

    the agent’s address, city



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

def address_city
  @address_city
end

#address_stateString

Returns the agent’s address, state.

Returns:

  • (String)

    the agent’s address, state



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

def address_state
  @address_state
end

#address_streetString

Returns the agent’s address, street and number.

Returns:

  • (String)

    the agent’s address, street and number



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

def address_street
  @address_street
end

#address_zipString

Returns the agent’s address, zip code.

Returns:

  • (String)

    the agent’s address, zip code



37
38
39
# File 'lib/moxiworks_platform/agent.rb', line 37

def address_zip
  @address_zip
end

#facebookString

Returns the agent’s facebook page.

Returns:

  • (String)

    the agent’s facebook page



112
113
114
# File 'lib/moxiworks_platform/agent.rb', line 112

def facebook
  @facebook
end

#fax_phone_numberString

Returns the agent’s fax phone number.

Returns:

  • (String)

    the agent’s fax phone number



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

def fax_phone_number
  @fax_phone_number
end

#google_plusString

Returns the agent’s google plus acount.

Returns:

  • (String)

    the agent’s google plus acount



107
108
109
# File 'lib/moxiworks_platform/agent.rb', line 107

def google_plus
  @google_plus
end

#home_pageString

Returns the agent’s home page url.

Returns:

  • (String)

    the agent’s home page url



117
118
119
# File 'lib/moxiworks_platform/agent.rb', line 117

def home_page
  @home_page
end

#main_phone_numberString

Returns the agent’s main phone number.

Returns:

  • (String)

    the agent’s main phone number



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

def main_phone_number
  @main_phone_number
end

#mobile_phone_numberString

Returns the agent’s fax phone number.

Returns:

  • (String)

    the agent’s fax phone number



72
73
74
# File 'lib/moxiworks_platform/agent.rb', line 72

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



67
68
69
# File 'lib/moxiworks_platform/agent.rb', line 67

def name
  @name
end

#office_address_cityString

Returns the agent’s office address, city.

Returns:

  • (String)

    the agent’s office address, city



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

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



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

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



42
43
44
# File 'lib/moxiworks_platform/agent.rb', line 42

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



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

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



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

def office_address_zip
  @office_address_zip
end

#office_phone_numberString

Returns the agent’s office_phone number.

Returns:

  • (String)

    the agent’s office_phone number



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

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



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

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



122
123
124
# File 'lib/moxiworks_platform/agent.rb', line 122

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



127
128
129
# File 'lib/moxiworks_platform/agent.rb', line 127

def profile_thumb_url
  @profile_thumb_url
end

#secondary_email_addressString

Returns the agent’s secondary email address.

Returns:

  • (String)

    the agent’s secondary email address



97
98
99
# File 'lib/moxiworks_platform/agent.rb', line 97

def secondary_email_address
  @secondary_email_address
end

#titleString

Returns any business related titles associated with the agent.

Returns:

  • (String)

    any business related titles associated with the agent



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

def title
  @title
end

#twitterString

Returns the agent’s twitter handle.

Returns:

  • (String)

    the agent’s twitter handle



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

def twitter
  @twitter
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 The Moxi Works Agent ID for the agent

Returns:

Raises:

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



143
144
145
146
# File 'lib/moxiworks_platform/agent.rb', line 143

def self.find(opts={})
  url = "#{MoxiworksPlatform::Config.url}/api/agents/#{opts[:moxi_works_agent_id]}"
  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)

    REQUIRED 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



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/moxiworks_platform/agent.rb', line 188

def self.search(opts={})
  url ||= "#{MoxiworksPlatform::Config.url}/api/agents"
  required_opts = [:moxi_works_company_id, :updated_since]
  required_opts.each do |opt|
    raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
        opts[opt].nil? or opts[opt].to_s.empty?
  end
  results = []
  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
    self.check_for_error_in_response(response)
    json = JSON.parse(response)
    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



148
149
150
151
152
153
154
155
156
157
158
# File 'lib/moxiworks_platform/agent.rb', line 148

def self.send_request(method, opts={}, url=nil)
  url ||= "#{MoxiworksPlatform::Config.url}/api/agents"
  required_opts = [:moxi_works_agent_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