geocerts 0.0.25 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,6 +1,8 @@
1
+ *.gem
2
+ .bundle
1
3
  *.sw?
2
4
  .DS_Store
3
5
  coverage
4
6
  rdoc
5
- pkg
7
+ pkg/*
6
8
  test/config/test_credentials.yml
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ geocerts (1.0.0)
5
+ libxml-ruby (~> 1.1.0)
6
+ relax (~> 0.1.0)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ factory_girl (1.3.3)
12
+ fakeweb (1.3.0)
13
+ libxml-ruby (1.1.4)
14
+ mocha (0.9.10)
15
+ rake
16
+ nokogiri (1.3.3)
17
+ rake (0.8.7)
18
+ relax (0.1.3)
19
+ relief (~> 0.0.4)
20
+ rest-client (~> 0.9.2)
21
+ relief (0.0.5)
22
+ nokogiri (~> 1.3.3)
23
+ rest-client (0.9.2)
24
+ shoulda (2.11.3)
25
+ vcr (1.5.0)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ factory_girl (~> 1.3.0)
32
+ fakeweb (~> 1.3.0)
33
+ geocerts!
34
+ libxml-ruby (~> 1.1.0)
35
+ mocha (~> 0.9.0)
36
+ relax (~> 0.1.0)
37
+ shoulda (~> 2.11.0)
38
+ vcr (~> 1.5.0)
data/Rakefile CHANGED
@@ -1,28 +1,5 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "geocerts"
8
- gem.summary = %Q{A Ruby library for interfacing with the GeoCerts REST API}
9
- gem.description = %Q{A Ruby library for interfacing with the GeoCerts REST API}
10
- gem.email = "sslsupport@geocerts.com"
11
- gem.homepage = "http://www.geocerts.com/"
12
- gem.authors = ["GeoCerts, Inc."]
13
-
14
- gem.add_dependency('relax', '>=0.1.2')
15
-
16
- gem.add_development_dependency('shoulda', '>=2.10.2')
17
- gem.add_development_dependency('factory_girl', '>=1.2.2')
18
- gem.add_development_dependency('mocha', '>=0.9.5')
19
- gem.add_development_dependency('fakeweb', '>=1.2.2')
20
-
21
- end
22
-
23
- rescue LoadError
24
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
25
- end
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
26
3
 
27
4
  require 'rake/testtask'
28
5
  Rake::TestTask.new(:test) do |test|
@@ -45,8 +22,6 @@ rescue LoadError
45
22
  end
46
23
 
47
24
 
48
-
49
-
50
25
  task :default => :test
51
26
 
52
27
  require 'rake/rdoctask'
@@ -67,4 +42,3 @@ Rake::RDocTask.new do |rdoc|
67
42
  rdoc.rdoc_files.include('LICENSE*')
68
43
  rdoc.rdoc_files.include('lib/**/*.rb')
69
44
  end
70
-
@@ -1,153 +1,30 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "geo_certs/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{geocerts}
8
- s.version = "0.0.25"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["GeoCerts, Inc."]
12
- s.date = %q{2010-05-13}
6
+ s.name = "geocerts"
7
+ s.version = GeoCerts::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["GeoCerts, Inc."]
10
+ s.email = ["sslsupport@geocerts.com"]
11
+ s.homepage = "http://www.geocerts.com/"
12
+ s.summary = %q{A Ruby library for interfacing with the GeoCerts REST API}
13
13
  s.description = %q{A Ruby library for interfacing with the GeoCerts REST API}
14
- s.email = %q{sslsupport@geocerts.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "autotest/discover.rb",
27
- "geocerts.gemspec",
28
- "lib/geo_certs.rb",
29
- "lib/geo_certs/agreement.rb",
30
- "lib/geo_certs/api.rb",
31
- "lib/geo_certs/api_object.rb",
32
- "lib/geo_certs/certificate.rb",
33
- "lib/geo_certs/collection.rb",
34
- "lib/geo_certs/csr.rb",
35
- "lib/geo_certs/email.rb",
36
- "lib/geo_certs/endpoints/agreements.rb",
37
- "lib/geo_certs/endpoints/certificates.rb",
38
- "lib/geo_certs/endpoints/events.rb",
39
- "lib/geo_certs/endpoints/hello.rb",
40
- "lib/geo_certs/endpoints/orders.rb",
41
- "lib/geo_certs/endpoints/products.rb",
42
- "lib/geo_certs/endpoints/resellers.rb",
43
- "lib/geo_certs/errors.rb",
44
- "lib/geo_certs/event.rb",
45
- "lib/geo_certs/exceptions.rb",
46
- "lib/geo_certs/hash_extension.rb",
47
- "lib/geo_certs/hello.rb",
48
- "lib/geo_certs/order.rb",
49
- "lib/geo_certs/order/administrator.rb",
50
- "lib/geo_certs/order/contact.rb",
51
- "lib/geo_certs/order/extended_validation_approver.rb",
52
- "lib/geo_certs/order/organization.rb",
53
- "lib/geo_certs/order/renewal_information.rb",
54
- "lib/geo_certs/parsers/order_parser.rb",
55
- "lib/geo_certs/product.rb",
56
- "lib/geo_certs/reseller.rb",
57
- "lib/geocerts.rb",
58
- "test/config/initializers/_remote_tests.rb",
59
- "test/config/initializers/fakeweb.rb",
60
- "test/config/initializers/geocerts.rb",
61
- "test/config/initializers/responses.rb",
62
- "test/config/test_credentials.example.yml",
63
- "test/factories.rb",
64
- "test/fixtures/responses.rb",
65
- "test/fixtures/responses/agreement.rb",
66
- "test/fixtures/responses/certificate.rb",
67
- "test/fixtures/responses/event.rb",
68
- "test/fixtures/responses/hello.rb",
69
- "test/fixtures/responses/order.rb",
70
- "test/fixtures/responses/product.rb",
71
- "test/integrations/agreement_test.rb",
72
- "test/integrations/api_test.rb",
73
- "test/integrations/certificate_test.rb",
74
- "test/integrations/event_test.rb",
75
- "test/integrations/hello_test.rb",
76
- "test/integrations/order_test.rb",
77
- "test/integrations/product_test.rb",
78
- "test/test_helper.rb",
79
- "test/units/certificate_test.rb",
80
- "test/units/collection_test.rb",
81
- "test/units/csr_test.rb",
82
- "test/units/geo_certs_test.rb",
83
- "test/units/order/administrator_test.rb",
84
- "test/units/order/extended_validation_approver_test.rb",
85
- "test/units/order/organization_test.rb",
86
- "test/units/order/renewal_information_test.rb",
87
- "test/units/order_test.rb",
88
- "test/units/product_test.rb"
89
- ]
90
- s.homepage = %q{http://www.geocerts.com/}
91
- s.rdoc_options = ["--charset=UTF-8"]
14
+
15
+ s.rubyforge_project = "geocerts"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
92
20
  s.require_paths = ["lib"]
93
- s.rubygems_version = %q{1.3.6}
94
- s.summary = %q{A Ruby library for interfacing with the GeoCerts REST API}
95
- s.test_files = [
96
- "test/config/initializers/_remote_tests.rb",
97
- "test/config/initializers/fakeweb.rb",
98
- "test/config/initializers/geocerts.rb",
99
- "test/config/initializers/responses.rb",
100
- "test/factories.rb",
101
- "test/fixtures/responses/agreement.rb",
102
- "test/fixtures/responses/certificate.rb",
103
- "test/fixtures/responses/event.rb",
104
- "test/fixtures/responses/hello.rb",
105
- "test/fixtures/responses/order.rb",
106
- "test/fixtures/responses/product.rb",
107
- "test/fixtures/responses.rb",
108
- "test/integrations/agreement_test.rb",
109
- "test/integrations/api_test.rb",
110
- "test/integrations/certificate_test.rb",
111
- "test/integrations/event_test.rb",
112
- "test/integrations/hello_test.rb",
113
- "test/integrations/order_test.rb",
114
- "test/integrations/product_test.rb",
115
- "test/test_helper.rb",
116
- "test/units/certificate_test.rb",
117
- "test/units/collection_test.rb",
118
- "test/units/csr_test.rb",
119
- "test/units/geo_certs_test.rb",
120
- "test/units/order/administrator_test.rb",
121
- "test/units/order/extended_validation_approver_test.rb",
122
- "test/units/order/organization_test.rb",
123
- "test/units/order/renewal_information_test.rb",
124
- "test/units/order_test.rb",
125
- "test/units/product_test.rb"
126
- ]
127
21
 
128
- if s.respond_to? :specification_version then
129
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
130
- s.specification_version = 3
22
+ s.add_development_dependency 'shoulda', '~>2.11.0'
23
+ s.add_development_dependency 'factory_girl', '~>1.3.0'
24
+ s.add_development_dependency 'mocha', '~>0.9.0'
25
+ s.add_development_dependency 'vcr', '~>1.5.0'
26
+ s.add_development_dependency 'fakeweb', '~>1.3.0'
131
27
 
132
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
133
- s.add_runtime_dependency(%q<relax>, [">= 0.1.2"])
134
- s.add_development_dependency(%q<shoulda>, [">= 2.10.2"])
135
- s.add_development_dependency(%q<factory_girl>, [">= 1.2.2"])
136
- s.add_development_dependency(%q<mocha>, [">= 0.9.5"])
137
- s.add_development_dependency(%q<fakeweb>, [">= 1.2.2"])
138
- else
139
- s.add_dependency(%q<relax>, [">= 0.1.2"])
140
- s.add_dependency(%q<shoulda>, [">= 2.10.2"])
141
- s.add_dependency(%q<factory_girl>, [">= 1.2.2"])
142
- s.add_dependency(%q<mocha>, [">= 0.9.5"])
143
- s.add_dependency(%q<fakeweb>, [">= 1.2.2"])
144
- end
145
- else
146
- s.add_dependency(%q<relax>, [">= 0.1.2"])
147
- s.add_dependency(%q<shoulda>, [">= 2.10.2"])
148
- s.add_dependency(%q<factory_girl>, [">= 1.2.2"])
149
- s.add_dependency(%q<mocha>, [">= 0.9.5"])
150
- s.add_dependency(%q<fakeweb>, [">= 1.2.2"])
151
- end
28
+ s.add_dependency 'relax', '~>0.1.0'
29
+ s.add_dependency 'libxml-ruby', '~>1.1.0'
152
30
  end
153
-
@@ -1,5 +1,6 @@
1
1
  require 'relax'
2
2
  require 'cgi'
3
+ require 'date'
3
4
 
4
5
  ##
5
6
  # To properly configure the GeoCerts library, you must provide your partner ID and api token:
@@ -9,6 +9,7 @@ require 'geo_certs/agreement'
9
9
  require 'geo_certs/event'
10
10
  require 'geo_certs/reseller'
11
11
  require 'geo_certs/hello'
12
+ require 'geo_certs/fraud_score'
12
13
  require 'geo_certs/endpoints/orders'
13
14
  require 'geo_certs/endpoints/certificates'
14
15
  require 'geo_certs/endpoints/agreements'
@@ -16,6 +17,7 @@ require 'geo_certs/endpoints/products'
16
17
  require 'geo_certs/endpoints/events'
17
18
  require 'geo_certs/endpoints/resellers'
18
19
  require 'geo_certs/endpoints/hello'
20
+ require 'geo_certs/endpoints/fraud_scores'
19
21
 
20
22
  module GeoCerts
21
23
 
@@ -30,6 +32,7 @@ module GeoCerts
30
32
  include Endpoints::Events
31
33
  include Endpoints::Resellers
32
34
  include Endpoints::Hello
35
+ include Endpoints::FraudScores
33
36
  end
34
37
 
35
38
  end
@@ -14,6 +14,7 @@ module GeoCerts
14
14
  :status,
15
15
  :certificate,
16
16
  :ca_root,
17
+ :ca_intermediates,
17
18
  :common_name,
18
19
  :serial_number,
19
20
  :start_at,
@@ -82,6 +83,10 @@ module GeoCerts
82
83
  })
83
84
  })
84
85
  end
86
+
87
+ def ca_intermediates=(input) #:nodoc:
88
+ @ca_intermediates = input[:ca_intermediate].to_a
89
+ end
85
90
 
86
91
  end
87
92
 
@@ -9,6 +9,9 @@ module GeoCerts
9
9
  element :status
10
10
  element :certificate
11
11
  element 'ca-root', :as => :ca_root
12
+ element 'ca-intermediates', :as => :ca_intermediates do
13
+ elements 'ca-intermediate', :as => :ca_intermediate
14
+ end
12
15
  element 'common-name', :as => :common_name
13
16
  element 'serial-number', :as => :serial_number
14
17
  element 'start-date', :as => :start_at, :type => DateTime
@@ -0,0 +1,59 @@
1
+ require 'geo_certs/parsers/order_parser'
2
+
3
+ module GeoCerts
4
+ module Endpoints
5
+ module FraudScores
6
+
7
+ def self.included(base)
8
+ base.class_eval do
9
+ endpoint GeoCerts::API::ENDPOINT do
10
+ action :query_fraud_score, :url => '/fraud_score.xml', :method => :post do
11
+ parameter 'fraud_score[ip]', :required => true, :as => :ip
12
+ parameter 'fraud_score[city]', :required => true, :as => :city
13
+ parameter 'fraud_score[region]', :required => true, :as => :region
14
+ parameter 'fraud_score[postal_code]', :required => true, :as => :postal_code
15
+ parameter 'fraud_score[country]', :required => true, :as => :country
16
+
17
+ parser Parsers::OrderParser do
18
+ element 'fraud-score' do
19
+ element 'country-match', :as => :country_match
20
+ element 'country-code', :as => :country_code
21
+ element 'high-risk-country', :as => :high_risk_country
22
+ element 'distance', :type => Float
23
+ element 'ip-region', :as => :ip_region
24
+ element 'ip-city', :as => :ip_city
25
+ element 'ip-latitude', :as => :ip_latitude, :type => Float
26
+ element 'ip-longitude', :as => :ip_longitude, :type => Float
27
+ element 'ip-isp', :as => :ip_isp
28
+ element 'ip-org', :as => :ip_org
29
+ element 'anonymous-proxy', :as => :anonymous_proxy
30
+ element 'proxy-score', :as => :proxy_score, :type => Float
31
+ element 'transparent-proxy', :as => :transparent_proxy
32
+ element 'freemail'
33
+ element 'carder-email', :as => :carder_email
34
+ element 'high-risk-username', :as => :high_risk_username
35
+ element 'high-risk-password', :as => :high_risk_password
36
+ element 'bin-match', :as => :bin_match
37
+ element 'bin-country', :as => :bin_country
38
+ element 'bin-name-match', :as => :bin_name_match
39
+ element 'bin-name', :as => :bin_name
40
+ element 'bin-phone-match', :as => :bin_phone_match
41
+ element 'bin-phone', :as => :bin_phone
42
+ element 'phone-in-billing-location', :as => :phone_in_billing_location
43
+ element 'ship-forward', :as => :ship_forward
44
+ element 'city-postal-match', :as => :city_postal_match
45
+ element 'ship-city-postal-match', :as => :ship_city_postal_match
46
+ element 'explanation'
47
+ element 'queries-remaining', :as => :queries_remaining, :type => Integer
48
+ element 'risk-score', :as => :risk_score, :type => Float
49
+ element 'error'
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,38 @@
1
+ module GeoCerts
2
+
3
+ class FraudScore < ApiObject
4
+
5
+ attr_accessor :ip, :city, :region, :postal_code, :country, :domain, :bin, :bin_name, :bin_phone, :phone, :forwarded_ip, :email, :username, :password, :shipping_address, :shipping_city, :shipping_region, :shipping_postal_code, :shipping_country, :transaction_id, :session_id, :user_agent, :accept_language
6
+ attr_accessor :country_match, :country_code, :high_risk_country, :distance, :ip_region, :ip_city, :ip_latitude, :ip_longitude, :ip_isp, :ip_org, :anonymous_proxy, :proxy_score, :transparent_proxy, :freemail, :carder_email, :high_risk_username, :high_risk_password, :bin_match, :bin_country, :bin_name_match, :bin_name, :bin_phone_match, :bin_phone, :phone_in_billing_location, :ship_forward, :city_postal_match, :ship_city_postal_match, :explanation, :risk_score, :queries_remaining, :error
7
+
8
+ force_boolean :country_match, :high_risk_country, :anonymous_proxy, :transparent_proxy, :freemail, :carder_email, :high_risk_username, :high_risk_password, :bin_match, :bin_phone_match, :ship_forward, :city_postal_match, :ship_city_postal_match, :phone_in_billing_location
9
+
10
+ def self.query(attributes = {}, &block)
11
+ new(attributes, &block).query
12
+ end
13
+
14
+ ##
15
+ # Queries the GeoCerts FraudScore API for details about the
16
+ # payment being processed.
17
+ #
18
+ def query
19
+ update_attributes(self.class.call_api {GeoCerts.api.query_fraud_score(api_attributes)['fraud-score']})
20
+ end
21
+
22
+
23
+ private
24
+
25
+
26
+ def api_attributes
27
+ {
28
+ :ip => @ip,
29
+ :city => @city,
30
+ :region => @region,
31
+ :postal_code => @postal_code,
32
+ :country => @country
33
+ }
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,3 @@
1
+ module GeoCerts
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1,14 @@
1
+ VCR.config do |c|
2
+ c.stub_with :fakeweb
3
+ c.cassette_library_dir = File.expand_path("../../../fixtures/remote", __FILE__)
4
+ c.default_cassette_options = {:record => :none}
5
+ c.before_record do |i|
6
+ i.uri.sub!(GeoCerts.partner_id, '%{PARTNER_ID}')
7
+ i.uri.sub!(GeoCerts.api_token, '%{API_TOKEN}')
8
+ i.request.headers.delete("authorization")
9
+ end
10
+ c.before_playback do |i|
11
+ i.uri.sub!('%{PARTNER_ID}', GeoCerts.partner_id)
12
+ i.uri.sub!('%{API_TOKEN}', GeoCerts.api_token)
13
+ end
14
+ end