Class: Bandwidth::Result

Inherits:
BaseModel show all
Defined in:
lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb

Overview

Result Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(response_code = nil, message = nil, e_164_format = nil, formatted = nil, country = nil, line_type = nil, line_provider = nil, mobile_country_code = nil, mobile_network_code = nil) ⇒ Result

Returns a new instance of Result.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb', line 60

def initialize(response_code = nil,
               message = nil,
               e_164_format = nil,
               formatted = nil,
               country = nil,
               line_type = nil,
               line_provider = nil,
               mobile_country_code = nil,
               mobile_network_code = nil)
  @response_code = response_code
  @message = message
  @e_164_format = e_164_format
  @formatted = formatted
  @country = country
  @line_type = line_type
  @line_provider = line_provider
  @mobile_country_code = mobile_country_code
  @mobile_network_code = mobile_network_code
end

Instance Attribute Details

#countryString

The country of the telephone number.

Returns:

  • (String)


27
28
29
# File 'lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb', line 27

def country
  @country
end

#e_164_formatString

The telephone number in E.164 format.

Returns:

  • (String)


19
20
21
# File 'lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb', line 19

def e_164_format
  @e_164_format
end

#formattedString

The formatted version of the telephone number.

Returns:

  • (String)


23
24
25
# File 'lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb', line 23

def formatted
  @formatted
end

#line_providerString

The service provider of the telephone number.

Returns:

  • (String)


35
36
37
# File 'lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb', line 35

def line_provider
  @line_provider
end

#line_typeString

The line type of the telephone number.

Returns:

  • (String)


31
32
33
# File 'lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb', line 31

def line_type
  @line_type
end

#messageString

Message associated with the response code.

Returns:

  • (String)


15
16
17
# File 'lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb', line 15

def message
  @message
end

#mobile_country_codeString

The first half of the Home Network Identity (HNI).

Returns:

  • (String)


39
40
41
# File 'lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb', line 39

def mobile_country_code
  @mobile_country_code
end

#mobile_network_codeString

The second half of the HNI.

Returns:

  • (String)


43
44
45
# File 'lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb', line 43

def mobile_network_code
  @mobile_network_code
end

#response_codeInteger

Our vendor’s response code.

Returns:

  • (Integer)


11
12
13
# File 'lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb', line 11

def response_code
  @response_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb', line 81

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  response_code = hash['Response Code']
  message = hash['Message']
  e_164_format = hash['E.164 Format']
  formatted = hash['Formatted']
  country = hash['Country']
  line_type = hash['Line Type']
  line_provider = hash['Line Provider']
  mobile_country_code = hash['Mobile Country Code']
  mobile_network_code = hash['Mobile Network Code']

  # Create object from extracted values.
  Result.new(response_code,
             message,
             e_164_format,
             formatted,
             country,
             line_type,
             line_provider,
             mobile_country_code,
             mobile_network_code)
end

.namesObject

A mapping from model property names to API property names.



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb', line 46

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['response_code'] = 'Response Code'
  @_hash['message'] = 'Message'
  @_hash['e_164_format'] = 'E.164 Format'
  @_hash['formatted'] = 'Formatted'
  @_hash['country'] = 'Country'
  @_hash['line_type'] = 'Line Type'
  @_hash['line_provider'] = 'Line Provider'
  @_hash['mobile_country_code'] = 'Mobile Country Code'
  @_hash['mobile_network_code'] = 'Mobile Network Code'
  @_hash
end