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.
-
#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 name of the office.
-
#phone ⇒ String
The office’s primary phone number.
-
#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.
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
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.
23 24 25 |
# File 'lib/moxiworks_platform/office.rb', line 23 def address @address end |
#address2 ⇒ String
Returns address cont. (ex. suite number).
28 29 30 |
# File 'lib/moxiworks_platform/office.rb', line 28 def address2 @address2 end |
#alt_phone ⇒ String
Returns the office’s alternate phone number.
53 54 55 |
# File 'lib/moxiworks_platform/office.rb', line 53 def alt_phone @alt_phone end |
#city ⇒ String
Returns the office’s address, city.
33 34 35 |
# File 'lib/moxiworks_platform/office.rb', line 33 def city @city end |
#county ⇒ String
Returns the office’s address, county.
38 39 40 |
# File 'lib/moxiworks_platform/office.rb', line 38 def county @county end |
#email ⇒ String
Returns the office’s email address.
58 59 60 |
# File 'lib/moxiworks_platform/office.rb', line 58 def email @email end |
#facebook ⇒ String
Returns the office’s facebook page URL.
63 64 65 |
# File 'lib/moxiworks_platform/office.rb', line 63 def facebook @facebook end |
#google_plus ⇒ String
Returns the office’s google_plus account.
68 69 70 |
# File 'lib/moxiworks_platform/office.rb', line 68 def google_plus @google_plus end |
#image_url ⇒ String
Returns a URL to an image of the office.
13 14 15 |
# File 'lib/moxiworks_platform/office.rb', line 13 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 name of the office.
18 19 20 |
# File 'lib/moxiworks_platform/office.rb', line 18 def name @name end |
#phone ⇒ String
Returns the office’s primary phone number.
73 74 75 |
# File 'lib/moxiworks_platform/office.rb', line 73 def phone @phone end |
#state ⇒ String
Returns the office’s address, state.
43 44 45 |
# File 'lib/moxiworks_platform/office.rb', line 43 def state @state end |
#timezone ⇒ String
Returns the office’s timezone.
78 79 80 |
# File 'lib/moxiworks_platform/office.rb', line 78 def timezone @timezone end |
#twitter ⇒ String
Returns the office’s twitter handle.
83 84 85 |
# File 'lib/moxiworks_platform/office.rb', line 83 def twitter @twitter end |
#zip_code ⇒ String
Returns the office’s address, zip code.
48 49 50 |
# File 'lib/moxiworks_platform/office.rb', line 48 def zip_code @zip_code end |
Class Method Details
.find(opts = {}) ⇒ MoxiworksPlatform::Office
Find an Office on the Moxi Works Platform
95 96 97 98 |
# File 'lib/moxiworks_platform/office.rb', line 95 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
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/moxiworks_platform/office.rb', line 138 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 = [] 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 self.check_for_error_in_response(response) json = JSON.parse(response) 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
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/moxiworks_platform/office.rb', line 100 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 |