Class: RouteNGNClient::OutboundEndPointGroup

Inherits:
RemoteModel show all
Defined in:
lib/routengn_client/models/outbound_end_point_group.rb

Constant Summary

Constants inherited from RemoteModel

RemoteModel::DEFAULT_RESOURCE_ATTRIBUTES

Instance Attribute Summary

Attributes included from RemoteModel::ClassMethods

#resource_attributes

Attributes inherited from Model

#attributes, #request_account_id

Attributes included from Model::ClassMethods

#children, #only_children, #parents

Instance Method Summary collapse

Methods included from RemoteModel::ClassMethods

#all, #collection_name, #create!, #find, #index_method, #path_base, #path_ext, #set_resource_attributes, #where

Methods inherited from Model

#initialize, #to_hash, #to_json, #to_log

Methods included from Model::ClassMethods

#belongs_to, #from_hash, #from_json, #has_many, #has_one

Methods included from Logging

#init_logger, #logger

Constructor Details

This class inherits a constructor from RouteNGNClient::Model

Instance Method Details

#build_uri_parts(options = {}) ⇒ Object



32
33
34
35
36
37
# File 'lib/routengn_client/models/outbound_end_point_group.rb', line 32

def build_uri_parts(options = {})
  {
    :uri_user_params => self.s_to_h(self.attributes.uri_user_params ? self.attributes.uri_user_params.strip : ''),
    :uri_params => self.s_to_h(self.attributes.uri_params ? self.attributes.uri_params.strip : '')
  }
end

#dialcode_regexpObject



28
29
30
# File 'lib/routengn_client/models/outbound_end_point_group.rb', line 28

def dialcode_regexp
  Regexp.new(self.attributes.dialcode_expression) unless self.attributes.dialcode_expression.blank?
end

#prioritized_end_pointsObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/routengn_client/models/outbound_end_point_group.rb', line 15

def prioritized_end_points
  eps_with_priority = self.end_points.select { |ep| !ep.attributes.priority.nil? }
  eps_with_priority.shuffle!
  eps_without_priority = self.end_points.select { |ep| ep.attributes.priority.nil? }
  eps_without_priority.shuffle!

  eps_with_priority.sort! { |x,y| x.attributes.priority <=> y.attributes.priority }
  eps_without_priority.sort! { |x,y| x.random_priority <=> y.random_priority }

  eps = (eps_with_priority + eps_without_priority)
  self.attributes.max_contact_end_points ? eps[0, self.attributes.max_contact_end_points] : eps
end