Class: Plivo::Resources::PhoneNumberCompliance

Inherits:
Base::Resource show all
Defined in:
lib/plivo/resources/phone_number_compliance.rb

Constant Summary

Constants included from Utils

Utils::TYPE_WHITELIST

Instance Attribute Summary

Attributes inherited from Base::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) ⇒ PhoneNumberCompliance

Returns a new instance of PhoneNumberCompliance.



55
56
57
58
59
# File 'lib/plivo/resources/phone_number_compliance.rb', line 55

def initialize(client, options = nil)
  @_name = 'PhoneNumber/Compliance'
  @_identifier_string = 'compliance_id'
  super
end

Instance Method Details

#deleteObject



78
79
80
# File 'lib/plivo/resources/phone_number_compliance.rb', line 78

def delete
  perform_delete
end

#to_sObject



82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/plivo/resources/phone_number_compliance.rb', line 82

def to_s
  {
    api_id: @api_id,
    compliance_id: @compliance_id,
    alias: @alias,
    status: @status,
    country_iso: @country_iso,
    number_type: @number_type,
    user_type: @user_type,
    created_at: @created_at,
    updated_at: @updated_at
  }.delete_if { |key, value| value.nil? }.to_s
end

#update(params) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/plivo/resources/phone_number_compliance.rb', line 61

def update(params)
  unless @id
    raise_invalid_request("Cannot update a #{@_name} resource "\
                            'without an identifier')
  end

  response_json = @_client.send_request(@_resource_uri, 'PATCH', params, nil, true, is_voice_request: false)

  # Unwrap compliance wrapper if present (API returns {api_id, message, compliance: {...}})
  compliance_data = response_json['compliance'] || response_json
  compliance_data['api_id'] = response_json['api_id'] if response_json['api_id']
  # Include message from response so callers can access update status via resp.message
  compliance_data['message'] = response_json['message'] if response_json['message']
  parse_and_set(compliance_data)
  self
end