Class: MoxiworksPlatform::Group
- Defined in:
- lib/moxiworks_platform/group.rb
Overview
Moxi Works Platform Group
Instance Attribute Summary collapse
-
#contacts ⇒ Array
the contacts in the group.
-
#moxi_works_agent_id ⇒ String
moxi_works_agent_id is the Moxi Works Platform ID of the agent which the group is associated with.
-
#moxi_works_group_id ⇒ String
your system’s group ID for the group.
-
#moxi_works_group_name ⇒ String
your system’s group ID for the group.
Class Method Summary collapse
-
.find(opts = {}) ⇒ MoxiworksPlatform::Group
Find a Group your system has previously created in Moxi Works Platform.
-
.search(opts = {}) ⇒ Array
Search an Agent’s Groups in Moxi Works Platform.
Methods inherited from Resource
accept_header, attr_accessor, attributes, #attributes, auth_header, check_for_error_in_response, content_type_header, #float_attrs, headers, #initialize, #int_attrs, #method_missing, #numeric_attrs, #numeric_value_for, #to_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
#contacts ⇒ Array
the contacts in the group
23 24 25 |
# File 'lib/moxiworks_platform/group.rb', line 23 def contacts @contacts end |
#moxi_works_agent_id ⇒ String
moxi_works_agent_id is the Moxi Works Platform ID of the agent which the group is associated with.
this must be set for any Moxi Works Platform transaction
11 12 13 |
# File 'lib/moxiworks_platform/group.rb', line 11 def moxi_works_agent_id @moxi_works_agent_id end |
#moxi_works_group_id ⇒ String
your system’s group ID for the group
17 |
# File 'lib/moxiworks_platform/group.rb', line 17 attr_accessor :moxi_works_group_name |
#moxi_works_group_name ⇒ String
your system’s group ID for the group
17 18 19 |
# File 'lib/moxiworks_platform/group.rb', line 17 def moxi_works_group_name @moxi_works_group_name end |
Class Method Details
.find(opts = {}) ⇒ MoxiworksPlatform::Group
Find a Group your system has previously created in Moxi Works Platform
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/moxiworks_platform/group.rb', line 44 def self.find(opts={}) url = "#{MoxiworksPlatform::Config.url}/api/groups/#{opts[:moxi_works_group_name]}" contacts = [] response = self.send_request(:get, opts, url) response.contacts.each do |c| contacts << MoxiworksPlatform::Contact.new(c) unless c.nil? or c.empty? end response.contacts = contacts response end |
.search(opts = {}) ⇒ Array
Search an Agent’s Groups in Moxi Works Platform
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/moxiworks_platform/group.rb', line 71 def self.search(opts={}) url ||= "#{MoxiworksPlatform::Config.url}/api/groups" required_opts = [:moxi_works_agent_id] required_opts.each do |opt| raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if opts[opt].nil? or opts[opt].to_s.empty? end results = [] 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.each do |r| results << MoxiworksPlatform::Group.new(r) unless r.nil? or r.empty? end end results end |