Class: MoxiworksPlatform::Agent
- Defined in:
- lib/moxiworks_platform/agent.rb
Overview
Moxi Works Platform Agent
Instance Attribute Summary collapse
-
#address_city ⇒ String
The agent’s address, city.
-
#address_state ⇒ String
The agent’s address, state.
-
#address_street ⇒ String
The agent’s address, street and number.
-
#address_zip ⇒ String
The agent’s address, zip code.
-
#facebook ⇒ String
The agent’s facebook page.
-
#fax_phone_number ⇒ String
The agent’s fax phone number.
-
#google_plus ⇒ String
The agent’s google plus acount.
-
#home_page ⇒ String
The agent’s home page url.
-
#main_phone_number ⇒ String
The agent’s main phone number.
-
#mobile_phone_number ⇒ String
The agent’s fax phone number.
-
#moxi_works_agent_id ⇒ String
moxi_works_agent_id is the Moxi Works Platform ID of the agent which a contact is or is to be associated with.
-
#moxi_works_office_id ⇒ String
The UUID of the office which the Agent is associated.
-
#name ⇒ String
The agent’s full name.
-
#office_address_city ⇒ String
The agent’s office address, city.
-
#office_address_state ⇒ String
The agent’s office address, state.
-
#office_address_street ⇒ String
The agent’s office address, street and number.
-
#office_address_street2 ⇒ String
The agent’s office address, suite or office number.
-
#office_address_zip ⇒ String
The agent’s office address, zip code.
-
#office_phone_number ⇒ String
The agent’s office_phone number.
-
#primary_email_address ⇒ String
The agent’s primary email address.
-
#profile_image_url ⇒ String
Url to a full size image of the agent.
-
#profile_thumb_url ⇒ String
Url to a thumb size image of the agent.
-
#secondary_email_address ⇒ String
The agent’s secondary email address.
-
#title ⇒ String
Any business related titles associated with the agent.
-
#twitter ⇒ String
The agent’s twitter handle.
Class Method Summary collapse
-
.find(opts = {}) ⇒ MoxiworksPlatform::Agent
Find an Agent on the Moxi Works Platform.
-
.search(opts = {}) ⇒ Hash
Search For Agents in Moxi Works Platform.
- .send_request(method, opts = {}, url = nil) ⇒ Object
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_city ⇒ String
Returns the agent’s address, city.
27 28 29 |
# File 'lib/moxiworks_platform/agent.rb', line 27 def address_city @address_city end |
#address_state ⇒ String
Returns the agent’s address, state.
32 33 34 |
# File 'lib/moxiworks_platform/agent.rb', line 32 def address_state @address_state end |
#address_street ⇒ String
Returns 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_zip ⇒ String
Returns the agent’s address, zip code.
37 38 39 |
# File 'lib/moxiworks_platform/agent.rb', line 37 def address_zip @address_zip end |
#facebook ⇒ String
Returns the agent’s facebook page.
112 113 114 |
# File 'lib/moxiworks_platform/agent.rb', line 112 def facebook @facebook end |
#fax_phone_number ⇒ String
Returns 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_plus ⇒ String
Returns the agent’s google plus acount.
107 108 109 |
# File 'lib/moxiworks_platform/agent.rb', line 107 def google_plus @google_plus end |
#home_page ⇒ String
Returns 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_number ⇒ String
Returns 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_number ⇒ String
Returns 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_id ⇒ String
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
12 13 14 |
# File 'lib/moxiworks_platform/agent.rb', line 12 def moxi_works_agent_id @moxi_works_agent_id end |
#moxi_works_office_id ⇒ String
Returns 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 |
#name ⇒ String
Returns the agent’s full name.
67 68 69 |
# File 'lib/moxiworks_platform/agent.rb', line 67 def name @name end |
#office_address_city ⇒ String
Returns 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_state ⇒ String
Returns 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_street ⇒ String
Returns 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_street2 ⇒ String
Returns 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_zip ⇒ String
Returns 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_number ⇒ String
Returns 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_address ⇒ String
Returns 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_url ⇒ String
Returns 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_url ⇒ String
Returns 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_address ⇒ String
Returns 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 |
#title ⇒ String
Returns any business related titles associated with the agent.
132 133 134 |
# File 'lib/moxiworks_platform/agent.rb', line 132 def title @title end |
#twitter ⇒ String
Returns 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
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
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 |