Class: Plivo::Base::SecondaryResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/plivo/base/resource.rb

Constant Summary

Constants included from Utils

Utils::TYPE_WHITELIST

Instance Attribute Summary collapse

Attributes inherited from Resource

#id

Instance Method Summary collapse

Methods included from Utils

GetSortedQueryParamString?, compute_signatureV3?, expected_type?, expected_value?, generate_url?, getMapFromQueryString?, is_one_among_string_url?, multi_valid_param?, raise_invalid_request, valid_account?, valid_date_format?, valid_mainaccount?, valid_multiple_destination_integers?, valid_multiple_destination_nos?, valid_param?, valid_range?, valid_signature?, valid_signatureV3?, valid_subaccount?, valid_url?

Constructor Details

#initialize(client, options = nil) ⇒ SecondaryResource

Returns a new instance of SecondaryResource.



120
121
122
123
124
# File 'lib/plivo/base/resource.rb', line 120

def initialize(client, options = nil)
  super
  configure_secondary_options(options) if options
  configure_secondary_resource_uri
end

Instance Attribute Details

#secondary_idObject (readonly)

Returns the value of attribute secondary_id.



119
120
121
# File 'lib/plivo/base/resource.rb', line 119

def secondary_id
  @secondary_id
end

Instance Method Details

#configure_secondary_options(options) ⇒ Object



126
127
128
129
130
# File 'lib/plivo/base/resource.rb', line 126

def configure_secondary_options(options)
  valid_param?(:options, options, Hash, false)
  @secondary_id = options[:member_id] if options.key?(:member_id)
  secondary_parse_and_set(options[:resource_json]) if options.key?(:resource_json)
end

#configure_secondary_resource_uriObject



140
141
142
143
144
145
# File 'lib/plivo/base/resource.rb', line 140

def configure_secondary_resource_uri
  to_join = @secondary_id ? [@_client.auth_id, @_name, @id, @_secondary_name, @secondary_id] : [@_client.auth_id, @_name, @id]
  to_join = ['', 'v1', 'Account'] << to_join
  to_join << ''
  @_resource_uri = to_join.join('/')
end

#secondary_parse_and_set(resource_json) ⇒ Object



132
133
134
135
136
137
138
# File 'lib/plivo/base/resource.rb', line 132

def secondary_parse_and_set(resource_json)
  return unless resource_json

  valid_param?(:resource_json, resource_json, Hash, true)
  return unless @_secondary_identifier_string && (resource_json.key? @_secondary_identifier_string)
  @secondary_id = resource_json[@_secondary_identifier_string]
end