sift 4.4.0 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.4.0
4
+ version: 4.5.0
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: 2023-10-05 00:00:00.000000000 Z
13
+ date: 2024-05-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -127,6 +127,7 @@ files:
127
127
  - ".github/pull_request_template.md"
128
128
  - ".github/workflows/publishing_sift_ruby.yml"
129
129
  - ".gitignore"
130
+ - ".jenkins/Jenkinsfile"
130
131
  - Gemfile
131
132
  - HISTORY
132
133
  - LICENSE
@@ -160,6 +161,13 @@ files:
160
161
  - spec/unit/router_spec.rb
161
162
  - spec/unit/validate/decision_spec.rb
162
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
163
171
  homepage: http://siftscience.com
164
172
  licenses: []
165
173
  metadata: {}