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
|