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

32
33
34
35
36
37
38
39
40
41
42

# File 'lib/moxiworks_platform/company.rb', line 32defself.find(opts={})raise::MoxiworksPlatform::Exception::ArgumentError,'arguments must be passed as named parameters'unlessopts.is_a?Hashrequired_opts=[:moxi_works_company_id]required_opts.eachdo|opt|raise::MoxiworksPlatform::Exception::ArgumentError,"#{opt} required"ifopts[opt].nil?oropts[opt].to_s.empty?endurl="#{MoxiworksPlatform::Config.url}/api/companies/#{opts[:moxi_works_company_id]}"self.send_request(:get,opts,url)end

.search(opts = {}) ⇒ Array

Show all my Companies in Moxi Works Platform

Examples:

results=MoxiworksPlatform::Companies.search

Returns:

(Array)
—

containing MoxiworksPlatform::Companies objects

Raises:

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

# File 'lib/moxiworks_platform/company.rb', line 55defself.search(opts={})raise::MoxiworksPlatform::Exception::ArgumentError,'arguments must be passed as named parameters'unlessopts.is_a?Hashurl||="#{MoxiworksPlatform::Config.url}/api/companies"required_opts=[]required_opts.eachdo|opt|raise::MoxiworksPlatform::Exception::ArgumentError,"#{opt} required"ifopts[opt].nil?oropts[opt].to_s.empty?endresults=MoxiResponseArray.new()RestClient::Request.execute(method::get,url:url,payload:opts,headers:self.headers)do|response|putsresponseifMoxiworksPlatform::Config.debugresults.headers=response.headersself.check_for_error_in_response(response)json=JSON.parse(response)results.page_number=1results.total_pages=1json.eachdo|r|results<<MoxiworksPlatform::Company.new(r)unlessr.nil?orr.empty?endendresultsend