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.
Attributes inherited from Resource
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, #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
#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 |
# File 'lib/moxiworks_platform/group.rb', line 44 def self.find(opts={}) url = "#{MoxiworksPlatform::Config.url}/api/groups/#{opts[:moxi_works_group_name]}" self.send_request(:get, opts, url) end |
.search(opts = {}) ⇒ Array
Search an Agent's Groups in Moxi Works Platform
64 65 66 67 68 69 70 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 64 def self.search(opts={}) raise ::MoxiworksPlatform::Exception::ArgumentError, 'arguments must be passed as named parameters' unless opts.is_a? Hash 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 = 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) results.page_number = 1 results.total_pages = 1 json.each do |r| results << MoxiworksPlatform::Group.new(r) unless r.nil? or r.empty? end end results end |