Class: Maxmind::Request
- Inherits:
-
Object
- Object
- Maxmind::Request
- Defined in:
- lib/maxmind/request.rb
Constant Summary collapse
- DefaultTimeout =
60
Class Attribute Summary collapse
-
.default_request_type ⇒ Object
Returns the value of attribute default_request_type.
-
.timeout ⇒ Object
Returns the value of attribute timeout.
Instance Attribute Summary collapse
-
#accept_language ⇒ Object
Optional Fields.
-
#avs_result ⇒ 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.
-
#cvv_result ⇒ Object
Optional Fields.
-
#domain ⇒ Object
Optional Fields.
-
#email ⇒ Object
Optional Fields.
-
#forwarded_ip ⇒ Object
Optional Fields.
-
#order_amount ⇒ Object
Optional Fields.
-
#order_currency ⇒ Object
Optional Fields.
-
#password ⇒ Object
Optional Fields.
-
#postal ⇒ Object
Required Fields.
-
#region ⇒ Object
Required Fields.
-
#request_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.
-
#txn_type ⇒ Object
Optional Fields.
-
#user_agent ⇒ Object
Optional Fields.
-
#username ⇒ Object
Optional Fields.
Instance Method Summary collapse
- #attributes=(attrs = {}) ⇒ Object
-
#initialize(attrs = {}) ⇒ Request
constructor
A new instance of Request.
- #process ⇒ Object
- #process! ⇒ Object
- #query ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Request
Returns a new instance of Request.
22 23 24 |
# File 'lib/maxmind/request.rb', line 22 def initialize(attrs={}) self.attributes = attrs end |
Class Attribute Details
.default_request_type ⇒ Object
Returns the value of attribute default_request_type.
8 9 10 |
# File 'lib/maxmind/request.rb', line 8 def default_request_type @default_request_type end |
.timeout ⇒ Object
Returns the value of attribute timeout.
9 10 11 |
# File 'lib/maxmind/request.rb', line 9 def timeout @timeout end |
Instance Attribute Details
#accept_language ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def accept_language @accept_language end |
#avs_result ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def avs_result @avs_result end |
#bin ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def bin @bin end |
#bin_name ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def bin_name @bin_name end |
#bin_phone ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def bin_phone @bin_phone end |
#city ⇒ Object
Required Fields
13 14 15 |
# File 'lib/maxmind/request.rb', line 13 def city @city end |
#client_ip ⇒ Object
Required Fields
13 14 15 |
# File 'lib/maxmind/request.rb', line 13 def client_ip @client_ip end |
#country ⇒ Object
Required Fields
13 14 15 |
# File 'lib/maxmind/request.rb', line 13 def country @country end |
#cust_phone ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def cust_phone @cust_phone end |
#cvv_result ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def cvv_result @cvv_result end |
#domain ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def domain @domain end |
#email ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def email @email end |
#forwarded_ip ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def forwarded_ip @forwarded_ip end |
#order_amount ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def order_amount @order_amount end |
#order_currency ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def order_currency @order_currency end |
#password ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def password @password end |
#postal ⇒ Object
Required Fields
13 14 15 |
# File 'lib/maxmind/request.rb', line 13 def postal @postal end |
#region ⇒ Object
Required Fields
13 14 15 |
# File 'lib/maxmind/request.rb', line 13 def region @region end |
#request_type ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def request_type @request_type end |
#session_id ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def session_id @session_id end |
#shipping_address ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def shipping_address @shipping_address end |
#shipping_city ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def shipping_city @shipping_city end |
#shipping_country ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def shipping_country @shipping_country end |
#shipping_postal ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def shipping_postal @shipping_postal end |
#shipping_region ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def shipping_region @shipping_region end |
#transaction_id ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def transaction_id @transaction_id end |
#txn_type ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def txn_type @txn_type end |
#user_agent ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def user_agent @user_agent end |
#username ⇒ Object
Optional Fields
16 17 18 |
# File 'lib/maxmind/request.rb', line 16 def username @username end |
Instance Method Details
#attributes=(attrs = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/maxmind/request.rb', line 26 def attributes=(attrs={}) attrs.each do |k, v| self.send("#{k}=", v) end end |
#process ⇒ Object
67 68 69 70 71 |
# File 'lib/maxmind/request.rb', line 67 def process process! rescue Exception => e false end |
#process! ⇒ Object
61 62 63 64 65 |
# File 'lib/maxmind/request.rb', line 61 def process! resp = post(query) resp.body.encode!("utf-8", "iso-8859-1") if resp.body.respond_to?(:encode!) Maxmind::Response.new(resp.body, resp.code) end |
#query ⇒ Object
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 |
# File 'lib/maxmind/request.rb', line 73 def query validate required_fields = { :i => @client_ip, :city => @city, :region => @region, :postal => @postal, :country => @country, :license_key => Maxmind::license_key } optional_fields = { :domain => @domain, :bin => @bin, :binName => @bin_name, :binPhone => @bin_phone, :custPhone => @cust_phone, :requested_type => @request_type || self.class.default_request_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_language, :avs_result => @avs_result, :cvv_result => @cvv_result, :txn_type => @txn_type, :order_amount => @order_amount } field_set = required_fields.merge(optional_fields) field_set.reject {|k, v| v.nil? } end |