Class: Maxmind::Request
- Inherits:
-
Object
- Object
- Maxmind::Request
- Defined in:
- lib/maxmind/request.rb
Instance Attribute Summary collapse
-
#accept_language ⇒ Object
Optional Fields.
-
#bin ⇒ Object
Optional Fields.
-
#bin_name ⇒ Object
Optional Fields.
-
#bin_phone ⇒ Object
Optional Fields.
-
#city ⇒ Object
Required Fields.
-
#client_ip ⇒ Object
Required Fields.
-
#country ⇒ Object
Required Fields.
-
#cust_phone ⇒ Object
Optional Fields.
-
#domain ⇒ Object
Optional Fields.
-
#email ⇒ Object
Optional Fields.
-
#forwarded_ip ⇒ Object
Optional Fields.
-
#license_key ⇒ Object
Required Fields.
-
#password ⇒ Object
Optional Fields.
-
#postal ⇒ Object
Required Fields.
-
#region ⇒ Object
Required Fields.
-
#requested_type ⇒ Object
Optional Fields.
-
#session_id ⇒ Object
Optional Fields.
-
#shipping_address ⇒ Object
Optional Fields.
-
#shipping_city ⇒ Object
Optional Fields.
-
#shipping_country ⇒ Object
Optional Fields.
-
#shipping_postal ⇒ Object
Optional Fields.
-
#shipping_region ⇒ Object
Optional Fields.
-
#transaction_id ⇒ Object
Optional Fields.
-
#user_agent ⇒ Object
Optional Fields.
-
#username ⇒ Object
Optional Fields.
Instance Method Summary collapse
- #get(query) ⇒ Object
-
#initialize(license_key, options = {}) ⇒ Request
constructor
A new instance of Request.
- #query(string = false) ⇒ Object
Constructor Details
#initialize(license_key, options = {}) ⇒ Request
Returns a new instance of Request.
12 13 14 15 16 17 18 |
# File 'lib/maxmind/request.rb', line 12 def initialize(license_key, = {}) @license_key = license_key .each do |k, v| self.instance_variable_set("@#{k}", v) end end |
Instance Attribute Details
#accept_language ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def accept_language @accept_language end |
#bin ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def bin @bin end |
#bin_name ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def bin_name @bin_name end |
#bin_phone ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def bin_phone @bin_phone end |
#city ⇒ Object
Required Fields
4 5 6 |
# File 'lib/maxmind/request.rb', line 4 def city @city end |
#client_ip ⇒ Object
Required Fields
4 5 6 |
# File 'lib/maxmind/request.rb', line 4 def client_ip @client_ip end |
#country ⇒ Object
Required Fields
4 5 6 |
# File 'lib/maxmind/request.rb', line 4 def country @country end |
#cust_phone ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def cust_phone @cust_phone end |
#domain ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def domain @domain end |
#email ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def email @email end |
#forwarded_ip ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def forwarded_ip @forwarded_ip end |
#license_key ⇒ Object
Required Fields
4 5 6 |
# File 'lib/maxmind/request.rb', line 4 def license_key @license_key end |
#password ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def password @password end |
#postal ⇒ Object
Required Fields
4 5 6 |
# File 'lib/maxmind/request.rb', line 4 def postal @postal end |
#region ⇒ Object
Required Fields
4 5 6 |
# File 'lib/maxmind/request.rb', line 4 def region @region end |
#requested_type ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def requested_type @requested_type end |
#session_id ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def session_id @session_id end |
#shipping_address ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def shipping_address @shipping_address end |
#shipping_city ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def shipping_city @shipping_city end |
#shipping_country ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def shipping_country @shipping_country end |
#shipping_postal ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def shipping_postal @shipping_postal end |
#shipping_region ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def shipping_region @shipping_region end |
#transaction_id ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def transaction_id @transaction_id end |
#user_agent ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def user_agent @user_agent end |
#username ⇒ Object
Optional Fields
7 8 9 |
# File 'lib/maxmind/request.rb', line 7 def username @username end |
Instance Method Details
#get(query) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/maxmind/request.rb', line 62 def get(query) url = URI.parse("https://minfraud1.maxmind.com/app/ccv2r") req = Net::HTTP::Get.new("#{url.path}?#{query}") h = Net::HTTP.new(url.host, url.port) h.use_ssl = true response = h.start { |http| http.request(req) } return response.body end |
#query(string = false) ⇒ Object
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 |
# File 'lib/maxmind/request.rb', line 20 def query(string = false) validate required_fields = { :i => @client_ip, :city => @city, :region => @region, :postal => @postal, :country => @country, :license_key => @license_key } optional_fields = { :domain => @domain, :bin => @bin, :binName => @bin_name, :binPhone => @bin_phone, :custPhone => @cust_phone, :requested_type => @requested_type, :forwardedIP => @forwarded_ip, :emailMD5 => @email, :usernameMD5 => @username, :passwordMD5 => @password, :shipAddr => @shipping_address, :shipCity => @shipping_city, :shipRegion => @shipping_region, :shipPostal => @shipping_postal, :shipCountry => @shipping_country, :txnID => @transaction_id, :sessionID => @session_id, :user_agent => @user_agent, :accept_language => @accept_langage } query = required_fields.merge(optional_fields) if string == false return get(query.reject {|k, v| v.nil? }.to_query) else return query.reject {|k, v| v.nil? }.to_query end end |