Class: MoxiworksPlatform::Team

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

Overview

Moxi Works Platform Teams

Instance Attribute Summary collapse

Attributes inherited from Resource

#headers

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, send_request, #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

#activeObject

Returns boolean Whether the team is active or not.

Returns:

  • boolean Whether the team is active or not



129
130
131
# File 'lib/moxiworks_platform/team.rb', line 129

def active
  @active
end

#address1Object

Returns string First line of contact address for the team.

Returns:

  • string First line of contact address for the team



31
32
33
# File 'lib/moxiworks_platform/team.rb', line 31

def address1
  @address1
end

#address2Object

Returns string Second line of contact address for the team.

Returns:

  • string Second line of contact address for the team



38
39
40
# File 'lib/moxiworks_platform/team.rb', line 38

def address2
  @address2
end

#alt_emailObject

Returns string Alternate contact email address for the team.

Returns:

  • string Alternate contact email address for the team



115
116
117
# File 'lib/moxiworks_platform/team.rb', line 115

def alt_email
  @alt_email
end

#alt_phoneObject

Returns string Alternate contact phone number for the team.

Returns:

  • string Alternate contact phone number for the team



108
109
110
# File 'lib/moxiworks_platform/team.rb', line 108

def alt_phone
  @alt_phone
end

#cityObject

Returns string City portion of contact address for the team.

Returns:

  • string City portion of contact address for the team



45
46
47
# File 'lib/moxiworks_platform/team.rb', line 45

def city
  @city
end

#descriptionObject

Returns string Description of the team. can contain embedded HTML.

Returns:

  • string Description of the team. can contain embedded HTML



94
95
96
# File 'lib/moxiworks_platform/team.rb', line 94

def description
  @description
end

#emailObject

Returns string Contact email address for the team.

Returns:

  • string Contact email address for the team



24
25
26
# File 'lib/moxiworks_platform/team.rb', line 24

def email
  @email
end

#faxObject

Returns string fax number for the team.

Returns:

  • string fax number for the team



73
74
75
# File 'lib/moxiworks_platform/team.rb', line 73

def fax
  @fax
end

#logo_urlObject

Returns string URL to a logo image for the team.

Returns:

  • string URL to a logo image for the team



80
81
82
# File 'lib/moxiworks_platform/team.rb', line 80

def logo_url
  @logo_url
end

#nameObject

Returns string The human readable name of the team.

Returns:

  • string The human readable name of the team



17
18
19
# File 'lib/moxiworks_platform/team.rb', line 17

def name
  @name
end

#phoneObject

Returns string contact phone number for the team.

Returns:

  • string contact phone number for the team



66
67
68
# File 'lib/moxiworks_platform/team.rb', line 66

def phone
  @phone
end

#photo_urlObject

Returns string First URL to a image representing the team.

Returns:

  • string First URL to a image representing the team



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

def photo_url
  @photo_url
end

#social_media_urlsObject

Returns array Social media URLs associated with the team.

Returns:

  • array Social media URLs associated with the team



101
102
103
# File 'lib/moxiworks_platform/team.rb', line 101

def social_media_urls
  @social_media_urls
end

#stateObject

Returns string State portion of contact address for the team.

Returns:

  • string State portion of contact address for the team



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

def state
  @state
end

#uuidObject

Returns string The unique ID of the Team.

Returns:

  • string The unique ID of the Team



10
11
12
# File 'lib/moxiworks_platform/team.rb', line 10

def uuid
  @uuid
end

#website_urlObject

Returns string URL to the website for the team.

Returns:

  • string URL to the website for the team



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

def website_url
  @website_url
end

#zipcodeObject

Returns string Postal Code portion of the contact address for the team.

Returns:

  • string Postal Code portion of the contact address for the team



59
60
61
# File 'lib/moxiworks_platform/team.rb', line 59

def zipcode
  @zipcode
end

Class Method Details

.find(opts = {}) ⇒ MoxiworksPlatform::Team

Find a Team by ID in Moxi Works Platform

Parameters:

  • opts (Hash) (defaults to: {})

    named parameter Hash

Options Hash (opts):

  • :moxi_works_team_id (String)

    REQUIRED The Moxi Works TEam ID

Returns:

Raises:

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



140
141
142
143
144
145
146
147
148
149
150
# File 'lib/moxiworks_platform/team.rb', line 140

def self.find(opts={})
  raise ::MoxiworksPlatform::Exception::ArgumentError,
        'arguments must be passed as named parameters' unless opts.is_a? Hash
  required_opts = [:moxi_works_team_id]
  required_opts.each do |opt|
    raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
        opts[opt].nil? or opts[opt].to_s.empty?
  end
  url = "#{MoxiworksPlatform::Config.url}/api/teams/#{opts[:moxi_works_team_id]}"
  self.send_request(:get, opts, url)
end

.search(opts = {}) ⇒ Array

Search For Teams in Moxi Works Platform

Examples:

results = MoxiworksPlatform::Team.search(
moxi_works_company_id: 'the_company',
)
MoxiworksPlatform::Team.search(
   moxi_works_company_id: 'the_company') { |teams| puts teams.count }

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)

    optional Search parameters

Returns:

  • (Array)

    with the format:

Raises:

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



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/moxiworks_platform/team.rb', line 180

def self.search(opts={})
  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

  url = "#{MoxiworksPlatform::Config.url}/api/teams"

  results = MoxiResponseArray.new()
  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)
    json = self.underscore_attribute_names json

    results.page_number = 1
    results.total_pages = 1

    json.each do |r|
      results << MoxiworksPlatform::Team.new(r) unless r.nil? or r.empty?
    end
  end
  if block_given?
    yield(results)
  end
  results
end