Class: RouteNGNClient::Contact::Template
- Inherits:
-
Object
- Object
- RouteNGNClient::Contact::Template
- Defined in:
- lib/routengn_client/models/contact.rb
Instance Attribute Summary collapse
-
#contact_template ⇒ Object
Returns the value of attribute contact_template.
Instance Method Summary collapse
-
#initialize(contact_template) ⇒ Template
constructor
A new instance of Template.
- #sub!(contact, sip_uri, options = {}) ⇒ Object
- #sub_inbound_rate!(rate) ⇒ Object
- #sub_outbound_rate!(rate) ⇒ Object
Constructor Details
#initialize(contact_template) ⇒ Template
Returns a new instance of Template.
77 78 79 |
# File 'lib/routengn_client/models/contact.rb', line 77 def initialize(contact_template) @contact_template = contact_template.clone end |
Instance Attribute Details
#contact_template ⇒ Object
Returns the value of attribute contact_template.
75 76 77 |
# File 'lib/routengn_client/models/contact.rb', line 75 def contact_template @contact_template end |
Instance Method Details
#sub!(contact, sip_uri, options = {}) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/routengn_client/models/contact.rb', line 81 def sub!(contact, sip_uri, = {}) = .with_indifferent_access iep_host = [:inbound_end_point_host] iep_port = [:inbound_end_point_port] #@contact_template.gsub!("${oepg.prefix}", '') # legacy as of 10/24/12 @contact_template.gsub!("${ruri.dialcode}", sip_uri.user.user_string) @contact_template.gsub!("${ruri.user_params}", !sip_uri.user.params.blank? ? ";#{sip_uri.user.params_string}" : '') @contact_template.gsub!("${ruri.params}", !sip_uri.params.blank? ? ";#{sip_uri.params_string}" : '') @contact_template.gsub!("${iep.host}", !iep_host.blank? ? iep_host : '') @contact_template.gsub!("${iep.port}", !iep_port.blank? ? ":#{iep_port}" : '') @contact_template.gsub!("${oep.host}", sip_uri.host) @contact_template.gsub!("${oep.port}", ":#{sip_uri.port}") @contact_template.gsub!("${oepg.prefix}", '') # legacy as of 10/24/12 @contact_template.gsub!("${oepg.uri_user_params}", '') #legacy as of 3/29/13 (params already merged in) @contact_template.gsub!("${oepg.uri_params}", '') #legacy as of 3/29/13 (params already merged in) self.sub_outbound_rate! contact.outbound_rate self.sub_inbound_rate! contact.inbound_rate end |
#sub_inbound_rate!(rate) ⇒ Object
112 113 114 115 116 117 118 119 |
# File 'lib/routengn_client/models/contact.rb', line 112 def sub_inbound_rate!(rate) @contact_template.gsub!("${ir.price}", rate && rate.attributes.price ? rate.attributes.price.to_s : '?') @contact_template.gsub!("${ir.type}", rate && rate.attributes.type ? rate.attributes.type : '?') @contact_template.gsub!("${ir.dialcode}", rate && rate.attributes.dialcode ? rate.attributes.dialcode : '?') @contact_template.gsub!("${ir.billing_increment}", rate && rate.attributes.billing_increment ? rate.attributes.billing_increment.to_s : '?') @contact_template.gsub!("${ir.lata}", rate && rate.attributes.lata ? rate.attributes.lata : '?') @contact_template.gsub!("${ir.ocn}", rate && rate.attributes.ocn ? rate.attributes.ocn : '?') end |
#sub_outbound_rate!(rate) ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/routengn_client/models/contact.rb', line 103 def sub_outbound_rate!(rate) @contact_template.gsub!("${or.price}", rate && rate.attributes.price ? rate.attributes.price.to_s : '?') @contact_template.gsub!("${or.type}", rate && rate.attributes.type ? rate.attributes.type : '?') @contact_template.gsub!("${or.dialcode}", rate && rate.attributes.dialcode ? rate.attributes.dialcode : '?') @contact_template.gsub!("${or.lata}", rate && rate.attributes.lata ? rate.attributes.lata : '?') @contact_template.gsub!("${or.ocn}", rate && rate.attributes.ocn ? rate.attributes.ocn : '?') @contact_template.gsub!("${or.billing_increment}", rate && rate.attributes.billing_increment ? rate.attributes.billing_increment.to_s : '?') end |