Class: Telesignature::PhoneId
- Inherits:
-
Object
- Object
- Telesignature::PhoneId
- Includes:
- Helpers
- Defined in:
- lib/telesignature/phone_id.rb
Instance Attribute Summary collapse
-
#conn ⇒ Object
Returns the value of attribute conn.
-
#customer_id ⇒ Object
Returns the value of attribute customer_id.
-
#secret_key ⇒ Object
Returns the value of attribute secret_key.
Instance Method Summary collapse
- #contact(phone_number, use_case_code) ⇒ Object
-
#initialize(opts = {}) ⇒ PhoneId
constructor
A new instance of PhoneId.
- #live(phone_number, use_case_code) ⇒ Object
- #score(phone_number, use_case_code) ⇒ Object
- #standard(phone_number) ⇒ Object
Methods included from Helpers
#random_with_N_digits, #validate_response
Constructor Details
#initialize(opts = {}) ⇒ PhoneId
Returns a new instance of PhoneId.
7 8 9 10 11 |
# File 'lib/telesignature/phone_id.rb', line 7 def initialize opts = {} @conn = opts[:conn] @customer_id = opts[:customer_id] @secret_key = opts[:secret_key] end |
Instance Attribute Details
#conn ⇒ Object
Returns the value of attribute conn.
5 6 7 |
# File 'lib/telesignature/phone_id.rb', line 5 def conn @conn end |
#customer_id ⇒ Object
Returns the value of attribute customer_id.
5 6 7 |
# File 'lib/telesignature/phone_id.rb', line 5 def customer_id @customer_id end |
#secret_key ⇒ Object
Returns the value of attribute secret_key.
5 6 7 |
# File 'lib/telesignature/phone_id.rb', line 5 def secret_key @secret_key end |
Instance Method Details
#contact(phone_number, use_case_code) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/telesignature/phone_id.rb', line 118 def contact phone_number, use_case_code # In addition to the information retrieved by **standard**, # this service provides the Name & Address associated with the specified phone number. # * - Parameters # - # * - `phone_number` # - The phone number you want details about. You must specify the phone number in its entirety. That is, it must begin with the country code, followed by the area code, and then by the local number. For example, you would specify the phone number (310) 555-1212 as 13105551212. # * - `use_case_code` # - A four letter code used to specify a particular usage scenario for the web service. # http://docs.telesign.com/rest/content/xt/xt-use-case-codes.html#xref-use-case-codes # **Example**:: # cust_id = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890" # secret_key = "EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==" # phone_number = "13107409700" # use_case_code = "LEAD" # phoneid = PhoneId(cust_id, secret_key) # Instantiate a PhoneId object. # try: # phone_info = phoneid.contact(phone_number, use_case_code) # except AuthorizationError as ex: # # API authorization failed, the API response should tell you the reason # ... # except TelesignError as ex: # # failed to completely execute the PhoneID service, check the API response # # for details; data returned may be incomplete or not be valid # ... resource = "/v1/phoneid/contact/%s" % phone_number method = 'GET' headers = Telesignature::Auth.generate_auth_headers( customer_id: @customer_id, secret_key: @secret_key, resource: resource, method: method) response = @conn.get do |req| req.url resource req.params[:ucid] = use_case_code req.headers = headers # proxies=@proxy end return Telesignature::Response.new validate_response(response), response end |
#live(phone_number, use_case_code) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/telesignature/phone_id.rb', line 169 def live phone_number, use_case_code # In addition to the information retrieved by **standard**, # this service provides actionable data associated with the specified phone number. # * - Parameters # - # * - `phone_number` # - The phone number you want details about. You must specify the phone number in its entirety. # That is, it must begin with the country code, followed by the area code, # and then by the local number. # For example, you would specify the phone number (310) 555-1212 as 13105551212. # * - `use_case_code` # - A four letter code used to specify a particular usage scenario for the web service. # The following table list the available use-case codes, and includes a description of each. # http://docs.telesign.com/rest/content/xt/xt-use-case-codes.html#xref-use-case-codes # **Example**:: # cust_id = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890" # secret_key = "EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==" # phone_number = "13107409700" # use_case_code = "RXPF" # phoneid = PhoneId(cust_id, secret_key) # Instantiate a PhoneId object. # try: # phone_info = phoneid.live(phone_number, use_case_code) # except AuthorizationError as ex: # # API authorization failed, the API response should tell you the reason # ... # except TelesignError as ex: # # failed to completely execute the PhoneID service, check the API response # # for details; data returned may be incomplete or not be valid # ... resource = "/v1/phoneid/live/%s" % phone_number method = 'GET' headers = Telesignature::Auth.generate_auth_headers( customer_id: @customer_id, secret_key: @secret_key, resource: resource, method: method) response = @conn.get do |req| req.url resource req.params[:ucid] = use_case_code req.headers = headers # proxies=@proxy end return Telesignature::Response.new validate_response(response), response end |
#score(phone_number, use_case_code) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 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 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/telesignature/phone_id.rb', line 64 def score phone_number, use_case_code # Retrieves a score for the specified phone number. # This ranks the phone number's "risk level" on a scale from 0 to 1000, # so you can code your web application to handle particular use cases # (e.g., to stop things like chargebacks, identity theft, fraud, and spam). # * - Parameters # - # * - `phone_number` # - The phone number you want details about. You must specify the phone number in its entirety. # That is, it must begin with the country code, followed by the area code, and then by the local number. # For example, you would specify the phone number (310) 555-1212 as 13105551212. # * - `use_case_code` # - A four letter code used to specify a particular usage scenario for the web service. # The following table list the available use-case codes, and includes a description of each. # http://docs.telesign.com/rest/content/xt/xt-use-case-codes.html#xref-use-case-codes # **Example**:: # cust_id = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890" # secret_key = "EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==" # phone_number = "13107409700" # use_case_code = "ATCK" # phoneid = PhoneId(cust_id, secret_key) # Instantiate a PhoneId object. # try: # score_info = phoneid.score(phone_number, use_case_code) # except AuthorizationError as ex: # ... # except TelesignError as ex: # ... resource = "/v1/phoneid/score/%s" % phone_number method = 'GET' headers = Telesignature::Auth.generate_auth_headers( customer_id: @customer_id, secret_key: @secret_key, resource: resource, method: method) response = @conn.get do |req| req.url resource req.params[:ucid] = use_case_code req.headers = headers # proxies=@proxy end return Telesignature::Response.new validate_response(response), response end |
#standard(phone_number) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/telesignature/phone_id.rb', line 13 def standard phone_number # Retrieves the standard set of details about the specified phone number. # This includes the type of phone (e.g., land line or mobile), # and it's approximate geographic location. # * - Parameters # - # * - `phone_number` # - The phone number you want details about. You must specify the phone number # in its entirety. That is, it must begin with the country code, followed by # the area code, and then by the local number. # For example, you would specify the phone number (310) 555-1212 as 13105551212. # **Example**:: # cust_id = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890" # secret_key = "EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==" # phone_number = "13107409700" # phoneid = PhoneId(cust_id, secret_key) # Instantiate a PhoneId object. # try: # phone_info = phoneid.standard(phone_number) # except AuthorizationError as ex: # # API authorization failed. Check the API response for details. # ... # except TelesignError as ex: # # Failed to completely execute the PhoneID service. Check the API response # # for details. Data returned might be incomplete or invalid. # ... resource = "/v1/phoneid/standard/%s" % phone_number method = 'GET' headers = Telesignature::Auth.generate_auth_headers( customer_id: @customer_id, secret_key: @secret_key, resource: resource, method: method) response = @conn.get do |req| req.url resource req.headers = headers # proxies=@proxy end return Telesignature::Response.new validate_response(response), response end |