raise_oracle_client 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +111 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/raise_oracle_client.rb +7 -0
- data/lib/raise_oracle_client/http/client.rb +36 -0
- data/lib/raise_oracle_client/in_memory/client.rb +15 -0
- data/lib/raise_oracle_client/version.rb +3 -0
- data/raise_oracle_client.gemspec +24 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 27ef6ade1d09a0fc201a191e9c73a753a5fd4c12
|
4
|
+
data.tar.gz: 0e0355d0d4e3e09e895ca2ad8669e44fc395806d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e0872e6da444d01617fdc2c959fb8513a9460a5675b29d2af24a7e14086d043c56e7f64ef9783da95e6527876dafbc661b05ac675cbd401606da34a9e798b822
|
7
|
+
data.tar.gz: b835224111cce0cf510c5db0375b171b432b009d19b8e6723d7bbf1d3ce0b7fecdb9e920d5576220f2b854039937cd7b9d5cc1bcad17f59244cab59d626b1c0c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
# Raise Oracle Client
|
2
|
+
|
3
|
+
Client for Raise Oracle API endpoints for fraud prevention.
|
4
|
+
|
5
|
+
## Clients
|
6
|
+
|
7
|
+
Two types of clients are available:
|
8
|
+
|
9
|
+
- `RaiseOracleClient::Http`
|
10
|
+
- `RaiseOracleClient::InMemory`
|
11
|
+
|
12
|
+
The application utilizing Raise Oracle Client can dynamically define the preferred client based on development, test, staging or production environment.
|
13
|
+
|
14
|
+
When initializing clients, three arguments are passed (user, password and endpoint).
|
15
|
+
|
16
|
+
### RaiseOracleClient::Http
|
17
|
+
|
18
|
+
Interact with Raise Oracle API via HTTP and requires authentication.
|
19
|
+
|
20
|
+
### RaiseOracleClient::InMemory
|
21
|
+
|
22
|
+
Does not perform any http request but uses the same contract.
|
23
|
+
|
24
|
+
## Example (Neo)
|
25
|
+
|
26
|
+
Posts a payload to the buy event endpoint:
|
27
|
+
|
28
|
+
`RaiseOracleClient::Http::Client#post` or `RaiseOracleClient::InMemory::Client#post`.
|
29
|
+
|
30
|
+
The payload is composed with the same content of the payload used by Neo (that includes data about order, line items, addresses and payment) plus the Neo decision (approve, decline or not_review). Follow an example:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
data = {
|
34
|
+
decision: "approve",
|
35
|
+
id: "R123456789",
|
36
|
+
timestamp: "1391385178",
|
37
|
+
remoteIP: "68.52.16.22",
|
38
|
+
userAgent: "Mozilla/5.0",
|
39
|
+
forterTokenCookie: "456454-ae6544",
|
40
|
+
customer: {
|
41
|
+
id: "123",
|
42
|
+
email: "email@example.com"
|
43
|
+
},
|
44
|
+
amount: "167.9",
|
45
|
+
currency: "USD",
|
46
|
+
paymentType: "Credit Card",
|
47
|
+
orderStatus: "Completed",
|
48
|
+
cartItems: [
|
49
|
+
{
|
50
|
+
item: "111",
|
51
|
+
name: "Target",
|
52
|
+
price: "83.5",
|
53
|
+
value: "100",
|
54
|
+
quantity: "1",
|
55
|
+
sellerId: "123456",
|
56
|
+
created: "1388560227"
|
57
|
+
}
|
58
|
+
],
|
59
|
+
billingAddress: {
|
60
|
+
firstName: "Bill",
|
61
|
+
lastName: "Clinton",
|
62
|
+
company: "The White House",
|
63
|
+
address1: "5 Chance St",
|
64
|
+
address2: "apt 2",
|
65
|
+
city: "Hicksville",
|
66
|
+
region: "NY",
|
67
|
+
zip: "11801",
|
68
|
+
country: "United States",
|
69
|
+
phone: "516-942-0594",
|
70
|
+
usedSavedAddress: true
|
71
|
+
},
|
72
|
+
shippingAddress: {
|
73
|
+
firstName: "George W.",
|
74
|
+
lastName: "Bush",
|
75
|
+
company: "The White House",
|
76
|
+
address1: "173 E Interlake Blvd",
|
77
|
+
address2: "3rd floor",
|
78
|
+
city: "Lake Placid",
|
79
|
+
region: "FL",
|
80
|
+
zip: "33852",
|
81
|
+
country: "USA",
|
82
|
+
phone: "18634653101",
|
83
|
+
usedSavedAddress: true
|
84
|
+
},
|
85
|
+
creditCard: {
|
86
|
+
cardNumber: "532015",
|
87
|
+
cardType: "VISA",
|
88
|
+
nameOnCard: "Debra Smith",
|
89
|
+
last4: "4721",
|
90
|
+
avsResult: "Y",
|
91
|
+
cvvResult: "Y",
|
92
|
+
expireMonth: "12",
|
93
|
+
expireYear: "2018",
|
94
|
+
usedSavedCard: true,
|
95
|
+
choseToSaveCard: false
|
96
|
+
}
|
97
|
+
}.to_json
|
98
|
+
|
99
|
+
http_client = RaiseOracleClient::Http::Client.new("user", "password", "https://www.example.com/buy_event")
|
100
|
+
http_client.post(data)
|
101
|
+
|
102
|
+
=> #<Net::HTTPOK 200 OK readbody=true>
|
103
|
+
|
104
|
+
in_memory_client = RaiseOracleClient::InMemory::Client.new("user", "password", "https://www.example.com/buy_event")
|
105
|
+
in_memory_client.post(data)
|
106
|
+
|
107
|
+
=> true
|
108
|
+
|
109
|
+
```
|
110
|
+
|
111
|
+
Replace the credentials and the base endpoint for real ones when using `RaiseOracleClient::Http` clients. In case of `RaiseOracleClient::InMemory` you can pass any content but the contract is the same.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "raise_oracle_client"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Class to send data to Raise Oracle.
|
2
|
+
module RaiseOracleClient
|
3
|
+
module Http
|
4
|
+
class Client
|
5
|
+
|
6
|
+
def initialize(user, password, endpoint)
|
7
|
+
@user = user
|
8
|
+
@password = password
|
9
|
+
@endpoint = URI(endpoint)
|
10
|
+
end
|
11
|
+
attr_reader :user, :password, :endpoint
|
12
|
+
|
13
|
+
def post(data)
|
14
|
+
request = build_request(data)
|
15
|
+
make_request(request)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def build_request(data)
|
21
|
+
req = Net::HTTP::Post.new(endpoint)
|
22
|
+
req.basic_auth user, password
|
23
|
+
req.content_type = "application/json"
|
24
|
+
req.body = data
|
25
|
+
req
|
26
|
+
end
|
27
|
+
|
28
|
+
def make_request(request)
|
29
|
+
Net::HTTP.start(endpoint.hostname, endpoint.port, use_ssl: endpoint.scheme == 'https', verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
|
30
|
+
http.request(request)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'raise_oracle_client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "raise_oracle_client"
|
8
|
+
spec.version = RaiseOracleClient::VERSION
|
9
|
+
spec.authors = ["Raise Engineering Team"]
|
10
|
+
spec.email = ["engineering@raise.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Raise Oracle client API}
|
13
|
+
spec.description = %q{Communicates with Raise Oracle API for fraud prevention.}
|
14
|
+
spec.homepage = "https://www.raise.com"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
20
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
21
|
+
spec.add_development_dependency "rspec"
|
22
|
+
spec.add_development_dependency "vcr"
|
23
|
+
spec.add_development_dependency "webmock"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: raise_oracle_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Raise Engineering Team
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: vcr
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Communicates with Raise Oracle API for fraud prevention.
|
84
|
+
email:
|
85
|
+
- engineering@raise.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/console
|
97
|
+
- bin/setup
|
98
|
+
- lib/raise_oracle_client.rb
|
99
|
+
- lib/raise_oracle_client/http/client.rb
|
100
|
+
- lib/raise_oracle_client/in_memory/client.rb
|
101
|
+
- lib/raise_oracle_client/version.rb
|
102
|
+
- raise_oracle_client.gemspec
|
103
|
+
homepage: https://www.raise.com
|
104
|
+
licenses: []
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.4.3
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Raise Oracle client API
|
126
|
+
test_files: []
|