Class: MoxiworksPlatform::Office
- Defined in:
- lib/moxiworks_platform/office.rb
Overview
Moxi Works Platform Office
Instance Attribute Summary collapse
-
#address ⇒ String
The office's address, street and number.
-
#address2 ⇒ String
Address cont.
-
#alt_phone ⇒ String
The office's alternate phone number.
-
#city ⇒ String
The office's address, city.
-
#client_office_id ⇒ String
This is the ID of the office utilized by the company.
-
#common_name ⇒ String
The commonly used name of the office.
-
#county ⇒ String
The office's address, county.
-
#email ⇒ String
The office's email address.
-
#facebook ⇒ String
The office's facebook page URL.
-
#google_plus ⇒ String
The office's google_plus account.
-
#image_url ⇒ String
A URL to an image of the office.
-
#moxi_works_office_id ⇒ String
The UUID of the office.
-
#name ⇒ String
The legal name of the office.
-
#office_website ⇒ String
Url of the office's website.
-
#phone ⇒ String
The office's primary phone number.
-
#region ⇒ String
Office's region.
-
#state ⇒ String
The office's address, state.
-
#timezone ⇒ String
The office's timezone.
-
#twitter ⇒ String
The office's twitter handle.
-
#zip_code ⇒ String
The office's address, zip code.
Attributes inherited from Resource
Class Method Summary collapse
-
.find(opts = {}) ⇒ MoxiworksPlatform::Office
Find an Office on the Moxi Works Platform.
-
.search(opts = {}) ⇒ Hash
Search For Offices 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, 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
#address ⇒ String
Returns the office's address, street and number.
33 34 35 |
# File 'lib/moxiworks_platform/office.rb', line 33 def address @address end |
#address2 ⇒ String
Returns address cont. (ex. suite number).
38 39 40 |
# File 'lib/moxiworks_platform/office.rb', line 38 def address2 @address2 end |
#alt_phone ⇒ String
Returns the office's alternate phone number.
63 64 65 |
# File 'lib/moxiworks_platform/office.rb', line 63 def alt_phone @alt_phone end |
#city ⇒ String
Returns the office's address, city.
43 44 45 |
# File 'lib/moxiworks_platform/office.rb', line 43 def city @city end |
#client_office_id ⇒ String
Returns This is the ID of the office utilized by the company.
13 14 15 |
# File 'lib/moxiworks_platform/office.rb', line 13 def client_office_id @client_office_id end |
#common_name ⇒ String
Returns the commonly used name of the office.
28 29 30 |
# File 'lib/moxiworks_platform/office.rb', line 28 def common_name @common_name end |
#county ⇒ String
Returns the office's address, county.
48 49 50 |
# File 'lib/moxiworks_platform/office.rb', line 48 def county @county end |
#email ⇒ String
Returns the office's email address.
68 69 70 |
# File 'lib/moxiworks_platform/office.rb', line 68 def email @email end |
#facebook ⇒ String
Returns the office's facebook page URL.
73 74 75 |
# File 'lib/moxiworks_platform/office.rb', line 73 def facebook @facebook end |
#google_plus ⇒ String
Returns the office's google_plus account.
78 79 80 |
# File 'lib/moxiworks_platform/office.rb', line 78 def google_plus @google_plus end |
#image_url ⇒ String
Returns a URL to an image of the office.
18 19 20 |
# File 'lib/moxiworks_platform/office.rb', line 18 def image_url @image_url end |
#moxi_works_office_id ⇒ String
Returns the UUID of the office.
8 9 10 |
# File 'lib/moxiworks_platform/office.rb', line 8 def moxi_works_office_id @moxi_works_office_id end |
#name ⇒ String
Returns the legal name of the office.
23 24 25 |
# File 'lib/moxiworks_platform/office.rb', line 23 def name @name end |
#office_website ⇒ String
Returns url of the office's website.
98 99 100 |
# File 'lib/moxiworks_platform/office.rb', line 98 def office_website @office_website end |
#phone ⇒ String
Returns the office's primary phone number.
83 84 85 |
# File 'lib/moxiworks_platform/office.rb', line 83 def phone @phone end |
#region ⇒ String
Returns office's region.
103 104 105 |
# File 'lib/moxiworks_platform/office.rb', line 103 def region @region end |
#state ⇒ String
Returns the office's address, state.
53 54 55 |
# File 'lib/moxiworks_platform/office.rb', line 53 def state @state end |
#timezone ⇒ String
Returns the office's timezone.
88 89 90 |
# File 'lib/moxiworks_platform/office.rb', line 88 def timezone @timezone end |
#twitter ⇒ String
Returns the office's twitter handle.
93 94 95 |
# File 'lib/moxiworks_platform/office.rb', line 93 def twitter @twitter end |
#zip_code ⇒ String
Returns the office's address, zip code.
58 59 60 |
# File 'lib/moxiworks_platform/office.rb', line 58 def zip_code @zip_code end |
Class Method Details
.find(opts = {}) ⇒ MoxiworksPlatform::Office
Find an Office on the Moxi Works Platform
116 117 118 119 |
# File 'lib/moxiworks_platform/office.rb', line 116 def self.find(opts={}) url = "#{MoxiworksPlatform::Config.url}/api/offices/#{opts[:moxi_works_office_id]}" self.send_request(:get, opts, url) end |
.search(opts = {}) ⇒ Hash
Search For Offices in Moxi Works Platform
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/moxiworks_platform/office.rb', line 159 def self.search(opts={}) url = "#{MoxiworksPlatform::Config.url}/api/offices" 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, 'offices':[]} 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['offices'].each do |r| results << MoxiworksPlatform::Office.new(r) unless r.nil? or r.empty? end json['offices'] = results end json end |
.send_request(method, opts = {}, url = nil) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/moxiworks_platform/office.rb', line 121 def self.send_request(method, opts={}, url=nil) url ||= "#{MoxiworksPlatform::Config.url}/api/offices" required_opts = [:moxi_works_office_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 |