Class: Vonage::IdentityInsights

Inherits:
Namespace
  • Object
show all
Defined in:
lib/vonage/identity_insights.rb

Defined Under Namespace

Classes: InsightsBuilder

Constant Summary collapse

VALID_INSIGHT_TYPES =
%i[format sim_swap original_carrier current_carrier].freeze

Instance Method Summary collapse

Instance Method Details

#insights_builderInsightsBuilder

Instantiate an InsightsBuilder.

Returns:



61
62
63
# File 'lib/vonage/identity_insights.rb', line 61

def insights_builder
  InsightsBuilder.new
end

#requests(phone_number:, insights: {}, **options) {|builder| ... } ⇒ Vonage::Response

Submit an Identity Insights request. The SDK currently supports the following insight types: format, sim_swap, current_carrier, and original_carrier.

for block {|builder| ... }

Examples:

with insights as a Hash

response = client.identity_insights.requests(phone_number: '447900000000', insights: { format: {} })

with insights as an InsightsBuilder

insights = client.identity_insights.insights_builder.add_format.add_sim_swap(period: 180)
response = client.identity_insights.requests(phone_number: '447900000000', insights: insights)

with a block to build insights

response = client.identity_insights.requests(phone_number: '447900000000') do |builder|
  builder.add_format
  builder.add_sim_swap(period: 180)
end

Parameters:

  • params (Hash)

    a customizable set of options

Yields:

  • (builder)

    passes a InsightsBuilder instance to the block

Yield Returns:

  • (required, InsightsBuilder)

    expects the block to return a InsightsBuilder instance

Returns:

See Also:



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vonage/identity_insights.rb', line 46

def requests(phone_number:, insights: {}, **options)
  insights = yield insights_builder if block_given?
  validate_insights(insights)

  params = {
    phone_number: phone_number,
    insights: insights.to_h
  }.merge(options)

  request('/identity-insights/v1/requests', params: params, type: Post)
end