sift 4.1.0 → 4.5.1

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.
@@ -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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sift
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Sadaghiani
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-07-11 00:00:00.000000000 Z
13
+ date: 2025-04-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -123,14 +123,18 @@ executables: []
123
123
  extensions: []
124
124
  extra_rdoc_files: []
125
125
  files:
126
- - ".circleci/config.yml"
126
+ - ".github/pull_request_template.md"
127
+ - ".github/workflows/ci.yml"
128
+ - ".github/workflows/publishing_sift_ruby.yml"
127
129
  - ".gitignore"
128
130
  - Gemfile
129
131
  - HISTORY
130
132
  - LICENSE
131
133
  - README.md
132
134
  - Rakefile
135
+ - examples/psp_merchant_management_apis.rb
133
136
  - examples/simple.rb
137
+ - examples/validation_apis.rb
134
138
  - lib/sift.rb
135
139
  - lib/sift/client.rb
136
140
  - lib/sift/client/decision.rb
@@ -148,11 +152,21 @@ files:
148
152
  - spec/unit/client/decision/apply_to_spec.rb
149
153
  - spec/unit/client/decision_spec.rb
150
154
  - spec/unit/client_203_spec.rb
155
+ - spec/unit/client_205_spec.rb
151
156
  - spec/unit/client_label_spec.rb
157
+ - spec/unit/client_psp_merchant_spec.rb
152
158
  - spec/unit/client_spec.rb
159
+ - spec/unit/client_validationapi_spec.rb
153
160
  - spec/unit/router_spec.rb
154
161
  - spec/unit/validate/decision_spec.rb
155
162
  - spec/unit/validate/primitive_spec.rb
163
+ - test_integration_app/decisions_api/test_decisions_api.rb
164
+ - test_integration_app/events_api/test_events_api.rb
165
+ - test_integration_app/globals.rb
166
+ - test_integration_app/main.rb
167
+ - test_integration_app/psp_merchants_api/test_psp_merchant_api.rb
168
+ - test_integration_app/score_api/test_score_api.rb
169
+ - test_integration_app/verification_api/test_verification_api.rb
156
170
  homepage: http://siftscience.com
157
171
  licenses: []
158
172
  metadata: {}
@@ -171,19 +185,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
185
  - !ruby/object:Gem::Version
172
186
  version: '0'
173
187
  requirements: []
174
- rubygems_version: 3.1.4
188
+ rubygems_version: 3.1.6
175
189
  signing_key:
176
190
  specification_version: 4
177
191
  summary: Sift Science Ruby API Gem
178
- test_files:
179
- - spec/fixtures/fake_responses.rb
180
- - spec/integration/sift_spec.rb
181
- - spec/spec_helper.rb
182
- - spec/unit/client/decision/apply_to_spec.rb
183
- - spec/unit/client/decision_spec.rb
184
- - spec/unit/client_203_spec.rb
185
- - spec/unit/client_label_spec.rb
186
- - spec/unit/client_spec.rb
187
- - spec/unit/router_spec.rb
188
- - spec/unit/validate/decision_spec.rb
189
- - spec/unit/validate/primitive_spec.rb
192
+ test_files: []
data/.circleci/config.yml DELETED
@@ -1,43 +0,0 @@
1
- version: 2
2
-
3
- jobs:
4
- build:
5
- parallelism: 3 # run three instances of this job in parallel
6
- docker:
7
- - image: circleci/ruby:2.4.2-jessie-node
8
- environment:
9
- BUNDLE_JOBS: 3
10
- BUNDLE_RETRY: 3
11
- BUNDLE_PATH: vendor/bundle
12
- steps:
13
- - checkout
14
-
15
- - run:
16
- name: Which bundler?
17
- command: bundle -v
18
-
19
- - restore_cache:
20
- keys:
21
- - sift-bundle-{{ checksum "sift.gemspec" }}
22
- - sift-bundle-
23
-
24
- - run:
25
- name: Bundle Install
26
- command: bundle check || bundle install
27
-
28
- - save_cache:
29
- key: sift-bundle-{{ checksum "sift.gemspec" }}
30
- paths:
31
- - vendor/bundle
32
-
33
- - run:
34
- name: Run rspec in parallel
35
- command: |
36
- bundle exec rspec --profile 10 \
37
- --format RspecJunitFormatter \
38
- --out test_results/rspec.xml \
39
- --format progress \
40
- $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
41
-
42
- - store_test_results:
43
- path: test_results