sift 1.1.6.2 → 4.5.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.
Files changed (45) hide show
  1. checksums.yaml +5 -13
  2. data/.circleci/config.yml +105 -0
  3. data/.github/pull_request_template.md +12 -0
  4. data/.github/workflows/publishing_sift_ruby.yml +38 -0
  5. data/.gitignore +1 -0
  6. data/.jenkins/Jenkinsfile +103 -0
  7. data/HISTORY +104 -0
  8. data/README.md +351 -0
  9. data/examples/psp_merchant_management_apis.rb +105 -0
  10. data/examples/validation_apis.rb +47 -0
  11. data/lib/sift/client/decision/apply_to.rb +129 -0
  12. data/lib/sift/client/decision.rb +66 -0
  13. data/lib/sift/client.rb +845 -112
  14. data/lib/sift/error.rb +13 -0
  15. data/lib/sift/router.rb +41 -0
  16. data/lib/sift/utils/hash_getter.rb +15 -0
  17. data/lib/sift/validate/decision.rb +65 -0
  18. data/lib/sift/validate/primitive.rb +43 -0
  19. data/lib/sift/version.rb +2 -2
  20. data/lib/sift.rb +85 -11
  21. data/sift.gemspec +5 -3
  22. data/spec/fixtures/fake_responses.rb +16 -0
  23. data/spec/spec_helper.rb +1 -1
  24. data/spec/unit/client/decision/apply_to_spec.rb +262 -0
  25. data/spec/unit/client/decision_spec.rb +83 -0
  26. data/spec/unit/client_203_spec.rb +193 -0
  27. data/spec/unit/client_205_spec.rb +117 -0
  28. data/spec/unit/client_label_spec.rb +68 -11
  29. data/spec/unit/client_psp_merchant_spec.rb +133 -0
  30. data/spec/unit/client_spec.rb +556 -79
  31. data/spec/unit/client_validationapi_spec.rb +91 -0
  32. data/spec/unit/router_spec.rb +37 -0
  33. data/spec/unit/validate/decision_spec.rb +85 -0
  34. data/spec/unit/validate/primitive_spec.rb +73 -0
  35. data/test_integration_app/decisions_api/test_decisions_api.rb +31 -0
  36. data/test_integration_app/events_api/test_events_api.rb +843 -0
  37. data/test_integration_app/globals.rb +2 -0
  38. data/test_integration_app/main.rb +67 -0
  39. data/test_integration_app/psp_merchants_api/test_psp_merchant_api.rb +44 -0
  40. data/test_integration_app/score_api/test_score_api.rb +11 -0
  41. data/test_integration_app/verification_api/test_verification_api.rb +32 -0
  42. metadata +85 -28
  43. data/.travis.yml +0 -13
  44. data/README.rdoc +0 -85
  45. data/spec/unit/sift_spec.rb +0 -6
@@ -0,0 +1,2 @@
1
+ $user_id = "billy_jones_301";
2
+ $user_email = "billjones1@example.com";
@@ -0,0 +1,67 @@
1
+ require 'rubygems'
2
+ require 'multi_json'
3
+ require_relative '../test_integration_app/globals.rb'
4
+ require_relative '../test_integration_app/events_api/test_events_api.rb'
5
+ require_relative '../test_integration_app/score_api/test_score_api.rb'
6
+ require_relative '../test_integration_app/decisions_api/test_decisions_api.rb'
7
+ require_relative '../test_integration_app/verification_api/test_verification_api.rb'
8
+ require_relative '../test_integration_app/psp_merchants_api/test_psp_merchant_api.rb'
9
+
10
+ class Utils
11
+ def isOk(response)
12
+ # expect http status 200 and api status 0 or http status 201 if apiStatus exists.
13
+ if(response.api_status)
14
+ return ((response.api_status == 0) && (response.http_status_code == 200 || response.http_status_code == 201))
15
+ else
16
+ return ((response.http_status_code == 200) || (response.http_status_code == 201))
17
+ end
18
+ end
19
+ end
20
+
21
+ class Main
22
+ def testMethods
23
+ objUtils = Utils.new()
24
+ objEvents = EventsAPI.new()
25
+ objScore = ScoreAPI.new()
26
+ objDecision = DecisionAPI.new()
27
+ objVerification = VerificationAPI.new()
28
+ objPSPMerchant = PSPMerchantAPI.new()
29
+
30
+ raise "Failed - Events $login" unless objUtils.isOk(objEvents.login())
31
+ raise "Failed - Events $transaction" unless objUtils.isOk(objEvents.transaction())
32
+ raise "Failed - Events $create_order" unless objUtils.isOk(objEvents.create_order())
33
+ raise "Failed - Events $create_content" unless objUtils.isOk(objEvents.create_content())
34
+ raise "Failed - Events $create_content - listing" unless objUtils.isOk(objEvents.create_content_listing())
35
+ raise "Failed - Events $create_content - message" unless objUtils.isOk(objEvents.create_content_message())
36
+ raise "Failed - Events $update_account" unless objUtils.isOk(objEvents.update_account())
37
+ raise "Failed - Events $update_content - listing" unless objUtils.isOk(objEvents.update_content_listing())
38
+ raise "Failed - Events $create_account" unless objUtils.isOk(objEvents.create_account())
39
+ raise "Failed - Events $verification" unless objUtils.isOk(objEvents.verification())
40
+ raise "Failed - Events $add_item_to_cart" unless objUtils.isOk(objEvents.add_item_to_cart())
41
+ raise "Failed - Events $order_status" unless objUtils.isOk(objEvents.order_status())
42
+ raise "Failed - Events $link_session_to_user" unless objUtils.isOk(objEvents.link_session_to_user())
43
+ raise "Failed - Events $content_status" unless objUtils.isOk(objEvents.content_status())
44
+ raise "Failed - Events $update_order" unless objUtils.isOk(objEvents.update_order())
45
+ puts "Events API Tested"
46
+
47
+ raise "Failed - User Score" unless objUtils.isOk(objScore.user_score())
48
+ puts "Score API Tested"
49
+
50
+ raise "Failed - Apply decision on user" unless objUtils.isOk(objDecision.apply_user_decision())
51
+ raise "Failed - Apply decision on order" unless objUtils.isOk(objDecision.apply_order_decision())
52
+ puts "Decisions API Tested"
53
+
54
+ raise "Failed - Verification Send" unless objUtils.isOk(objVerification.send())
55
+ puts "Verifications API Tested"
56
+
57
+ merchant_id = "merchant_id_test_sift_ruby_"<< rand.to_s[5..10]
58
+ raise "Failed - Merchants API - Create" unless objUtils.isOk(objPSPMerchant.create_psp_merchant_profile(merchant_id))
59
+ raise "Failed - Merchants API - Get Profile" unless objUtils.isOk(objPSPMerchant.get_psp_merchant_profile(merchant_id))
60
+ raise "Failed - Merchants API - Get Profiles" unless objUtils.isOk(objPSPMerchant.get_all_psp_merchant_profiles())
61
+ puts "PSP Merchant API Tested"
62
+
63
+ end
64
+ end
65
+
66
+ objMain = Main.new()
67
+ objMain.testMethods()
@@ -0,0 +1,44 @@
1
+ require "sift"
2
+
3
+ class PSPMerchantAPI
4
+
5
+ @@client = Sift::Client.new(:api_key => ENV["API_KEY"], :account_id => ENV["ACCOUNT_ID"])
6
+
7
+ def create_psp_merchant_profile(merchant_id)
8
+
9
+ # Sample psp_merchant_profile
10
+ properties={
11
+ "id": merchant_id,
12
+ "name": "Wonderful Payments Inc.",
13
+ "description": "Wonderful Payments payment provider.",
14
+ "address": {
15
+ "name": "Alany",
16
+ "address_1": "Big Payment blvd, 22",
17
+ "address_2": "apt, 8",
18
+ "city": "New Orleans",
19
+ "region": "NA",
20
+ "country": "US",
21
+ "zipcode": "76830",
22
+ "phone": "0394888320"
23
+ },
24
+ "category": "1002",
25
+ "service_level": "Platinum",
26
+ "status": "active",
27
+ "risk_profile": {
28
+ "level": "low",
29
+ "score": 10
30
+ }
31
+ }
32
+
33
+ return @@client.create_psp_merchant_profile(properties)
34
+ end
35
+
36
+ def get_psp_merchant_profile(merchant_id)
37
+ return @@client.get_a_psp_merchant_profile(merchant_id)
38
+ end
39
+
40
+ def get_all_psp_merchant_profiles(batch_size = nil, batch_token = nil)
41
+ return @@client.get_psp_merchant_profiles(batch_size, batch_token)
42
+ end
43
+
44
+ end
@@ -0,0 +1,11 @@
1
+ require "sift"
2
+
3
+ class ScoreAPI
4
+
5
+ @@client = Sift::Client.new(:api_key => ENV["API_KEY"])
6
+
7
+ def user_score()
8
+ return @@client.get_user_score("billy_jones_301")
9
+ end
10
+
11
+ end
@@ -0,0 +1,32 @@
1
+ require "sift"
2
+
3
+ class VerificationAPI
4
+
5
+ @@client = Sift::Client.new(:api_key => ENV["API_KEY"], :version=>1.1)
6
+
7
+ def send()
8
+ properties = {
9
+ "$user_id" => $user_id,
10
+ "$send_to" => $user_email,
11
+ "$verification_type" => "$email",
12
+ "$brand_name" => "MyTopBrand",
13
+ "$language" => "en",
14
+ "$site_country" => "IN",
15
+ "$event" => {
16
+ "$session_id" => "SOME_SESSION_ID",
17
+ "$verified_event" => "$login",
18
+ "$verified_entity_id" => "SOME_SESSION_ID",
19
+ "$reason" => "$automated_rule",
20
+ "$ip" => "192.168.1.1",
21
+ "$browser" => {
22
+ "$user_agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
23
+ "$accept_language" => "en-US",
24
+ "$content_language" => "en-GB"
25
+ }
26
+ }
27
+ }
28
+
29
+ return @@client.verification_send(properties)
30
+ end
31
+
32
+ end
metadata CHANGED
@@ -1,84 +1,119 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sift
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6.2
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Sadaghiani
8
8
  - Yoav Schatzberg
9
+ - Jacob Burnim
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-09-19 00:00:00.000000000 Z
13
+ date: 2024-05-17 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: rspec
16
17
  requirement: !ruby/object:Gem::Requirement
17
18
  requirements:
18
- - - ! '>='
19
+ - - "~>"
19
20
  - !ruby/object:Gem::Version
20
- version: 2.14.1
21
+ version: '3.5'
21
22
  type: :development
22
23
  prerelease: false
23
24
  version_requirements: !ruby/object:Gem::Requirement
24
25
  requirements:
25
- - - ! '>='
26
+ - - "~>"
26
27
  - !ruby/object:Gem::Version
27
- version: 2.14.1
28
+ version: '3.5'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rspec_junit_formatter
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: pry
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
28
57
  - !ruby/object:Gem::Dependency
29
58
  name: webmock
30
59
  requirement: !ruby/object:Gem::Requirement
31
60
  requirements:
32
- - - ! '>='
61
+ - - ">="
33
62
  - !ruby/object:Gem::Version
34
63
  version: 1.16.0
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '2'
35
67
  type: :development
36
68
  prerelease: false
37
69
  version_requirements: !ruby/object:Gem::Requirement
38
70
  requirements:
39
- - - ! '>='
71
+ - - ">="
40
72
  - !ruby/object:Gem::Version
41
73
  version: 1.16.0
74
+ - - "<"
75
+ - !ruby/object:Gem::Version
76
+ version: '2'
42
77
  - !ruby/object:Gem::Dependency
43
78
  name: httparty
44
79
  requirement: !ruby/object:Gem::Requirement
45
80
  requirements:
46
- - - ! '>='
81
+ - - ">="
47
82
  - !ruby/object:Gem::Version
48
83
  version: 0.11.0
49
84
  type: :runtime
50
85
  prerelease: false
51
86
  version_requirements: !ruby/object:Gem::Requirement
52
87
  requirements:
53
- - - ! '>='
88
+ - - ">="
54
89
  - !ruby/object:Gem::Version
55
90
  version: 0.11.0
56
91
  - !ruby/object:Gem::Dependency
57
92
  name: multi_json
58
93
  requirement: !ruby/object:Gem::Requirement
59
94
  requirements:
60
- - - ! '>='
95
+ - - ">="
61
96
  - !ruby/object:Gem::Version
62
97
  version: '1.0'
63
98
  type: :runtime
64
99
  prerelease: false
65
100
  version_requirements: !ruby/object:Gem::Requirement
66
101
  requirements:
67
- - - ! '>='
102
+ - - ">="
68
103
  - !ruby/object:Gem::Version
69
104
  version: '1.0'
70
105
  - !ruby/object:Gem::Dependency
71
106
  name: rake
72
107
  requirement: !ruby/object:Gem::Requirement
73
108
  requirements:
74
- - - ! '>='
109
+ - - ">="
75
110
  - !ruby/object:Gem::Version
76
111
  version: '0'
77
112
  type: :development
78
113
  prerelease: false
79
114
  version_requirements: !ruby/object:Gem::Requirement
80
115
  requirements:
81
- - - ! '>='
116
+ - - ">="
82
117
  - !ruby/object:Gem::Version
83
118
  version: '0'
84
119
  description: Sift Science Ruby API. Please see http://siftscience.com for more details.
@@ -88,23 +123,51 @@ executables: []
88
123
  extensions: []
89
124
  extra_rdoc_files: []
90
125
  files:
91
- - .gitignore
92
- - .travis.yml
126
+ - ".circleci/config.yml"
127
+ - ".github/pull_request_template.md"
128
+ - ".github/workflows/publishing_sift_ruby.yml"
129
+ - ".gitignore"
130
+ - ".jenkins/Jenkinsfile"
93
131
  - Gemfile
94
132
  - HISTORY
95
133
  - LICENSE
96
- - README.rdoc
134
+ - README.md
97
135
  - Rakefile
136
+ - examples/psp_merchant_management_apis.rb
98
137
  - examples/simple.rb
138
+ - examples/validation_apis.rb
99
139
  - lib/sift.rb
100
140
  - lib/sift/client.rb
141
+ - lib/sift/client/decision.rb
142
+ - lib/sift/client/decision/apply_to.rb
143
+ - lib/sift/error.rb
144
+ - lib/sift/router.rb
145
+ - lib/sift/utils/hash_getter.rb
146
+ - lib/sift/validate/decision.rb
147
+ - lib/sift/validate/primitive.rb
101
148
  - lib/sift/version.rb
102
149
  - sift.gemspec
150
+ - spec/fixtures/fake_responses.rb
103
151
  - spec/integration/sift_spec.rb
104
152
  - spec/spec_helper.rb
153
+ - spec/unit/client/decision/apply_to_spec.rb
154
+ - spec/unit/client/decision_spec.rb
155
+ - spec/unit/client_203_spec.rb
156
+ - spec/unit/client_205_spec.rb
105
157
  - spec/unit/client_label_spec.rb
158
+ - spec/unit/client_psp_merchant_spec.rb
106
159
  - spec/unit/client_spec.rb
107
- - spec/unit/sift_spec.rb
160
+ - spec/unit/client_validationapi_spec.rb
161
+ - spec/unit/router_spec.rb
162
+ - spec/unit/validate/decision_spec.rb
163
+ - spec/unit/validate/primitive_spec.rb
164
+ - test_integration_app/decisions_api/test_decisions_api.rb
165
+ - test_integration_app/events_api/test_events_api.rb
166
+ - test_integration_app/globals.rb
167
+ - test_integration_app/main.rb
168
+ - test_integration_app/psp_merchants_api/test_psp_merchant_api.rb
169
+ - test_integration_app/score_api/test_score_api.rb
170
+ - test_integration_app/verification_api/test_verification_api.rb
108
171
  homepage: http://siftscience.com
109
172
  licenses: []
110
173
  metadata: {}
@@ -114,23 +177,17 @@ require_paths:
114
177
  - lib
115
178
  required_ruby_version: !ruby/object:Gem::Requirement
116
179
  requirements:
117
- - - ! '>='
180
+ - - ">="
118
181
  - !ruby/object:Gem::Version
119
182
  version: '0'
120
183
  required_rubygems_version: !ruby/object:Gem::Requirement
121
184
  requirements:
122
- - - ! '>='
185
+ - - ">="
123
186
  - !ruby/object:Gem::Version
124
187
  version: '0'
125
188
  requirements: []
126
- rubyforge_project: sift
127
- rubygems_version: 2.1.11
189
+ rubygems_version: 3.1.6
128
190
  signing_key:
129
191
  specification_version: 4
130
192
  summary: Sift Science Ruby API Gem
131
- test_files:
132
- - spec/integration/sift_spec.rb
133
- - spec/spec_helper.rb
134
- - spec/unit/client_label_spec.rb
135
- - spec/unit/client_spec.rb
136
- - spec/unit/sift_spec.rb
193
+ test_files: []
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- script: "bundle exec rake spec"
3
- rvm:
4
- - 1.9.3
5
- - 2.0.0
6
- env:
7
- # None for now
8
- gemfile:
9
- - Gemfile
10
- services:
11
- # None for now
12
- notifications:
13
- # None for now
data/README.rdoc DELETED
@@ -1,85 +0,0 @@
1
- = Sift Science Ruby bindings {<img src="https://travis-ci.org/SiftScience/sift-ruby.png?branch=master" alt="Build Status" />}[https://travis-ci.org/SiftScience/sift-ruby]
2
-
3
- == Requirements
4
-
5
- * Ruby 1.8.7 or above. (Ruby 1.8.6 might work if you load ActiveSupport.)
6
- * HTTParty, 0.11.0 or greater
7
- * Multi Json, 1.0 or greater
8
-
9
- For development only:
10
- * bundler
11
- * rspec, 2.14.1 or greater
12
- * webmock, 1.16 or greater
13
- * rake, any version
14
-
15
- == Installation
16
-
17
- If you want to build the gem from source:
18
-
19
- $ gem build sift.gemspec
20
-
21
- Alternatively, you can install the gem from Rubyforge:
22
-
23
- $ gem install sift
24
-
25
- == Usage
26
- require "sift"
27
-
28
- Sift.api_key = '<your_api_key_here>'
29
- client = Sift::Client.new()
30
-
31
- # send a transaction event -- note this is blocking
32
- event = "$transaction"
33
-
34
- user_id = "23056" # User ID's may only contain a-z, A-Z, 0-9, =, ., -, _, +, @, :, &, ^, %, !, $
35
-
36
- properties = {
37
- "$user_id" => user_id,
38
- "$user_email" => "buyer@gmail.com",
39
- "$seller_user_id" => "2371",
40
- "seller_user_email" => "seller@gmail.com",
41
- "$transaction_id" => "573050",
42
- "$payment_method" => {
43
- "$payment_type" => "$credit_card",
44
- "$payment_gateway" => "$braintree",
45
- "$card_bin" => "542486",
46
- "$card_last4" => "4444"
47
- },
48
- "$currency_code" => "USD",
49
- "$amount" => 15230000,
50
- }
51
-
52
- response = client.track(event, properties)
53
-
54
- response.ok? # returns true or false
55
-
56
- response.http_status_code # HTTP response code, 200 is ok.
57
-
58
- response.api_status # status field in the return body, Link to Error Codes
59
-
60
- response.api_error_message # Error message associated with status Error Code
61
-
62
- # Request a score forthe user with user_id 23056
63
- response = client.score(user_id)
64
-
65
- # Label the user with user_id 23056 as Bad with all optional fields
66
- response = client.label(user_id,{ "$is_bad" => true, "$reasons" => ["$chargeback", ], "$description" => "Chargeback issued", "$source" => "Manual Review", "$analyst" => "analyst.name@your_domain.com"})
67
-
68
- == Building
69
-
70
- Building and publishing the gem is captured by the following steps:
71
-
72
- $ gem build sift.gemspec
73
- $ gem push sift-<current version>.gem
74
-
75
- $ bundle
76
- $ rake -T
77
- $ rake build
78
- $ rake install
79
- $ rake release
80
-
81
- == Testing
82
-
83
- To run the various tests use the rake command as follows:
84
-
85
- $ rake spec
@@ -1,6 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
2
-
3
- describe Sift do
4
-
5
-
6
- end