sift 4.4.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,16 +1,16 @@
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Sadaghiani
8
8
  - Yoav Schatzberg
9
9
  - Jacob Burnim
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-10-05 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,8 +123,8 @@ executables: []
123
123
  extensions: []
124
124
  extra_rdoc_files: []
125
125
  files:
126
- - ".circleci/config.yml"
127
126
  - ".github/pull_request_template.md"
127
+ - ".github/workflows/ci.yml"
128
128
  - ".github/workflows/publishing_sift_ruby.yml"
129
129
  - ".gitignore"
130
130
  - Gemfile
@@ -160,10 +160,17 @@ files:
160
160
  - spec/unit/router_spec.rb
161
161
  - spec/unit/validate/decision_spec.rb
162
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
163
170
  homepage: http://siftscience.com
164
171
  licenses: []
165
172
  metadata: {}
166
- post_install_message:
173
+ post_install_message:
167
174
  rdoc_options: []
168
175
  require_paths:
169
176
  - lib
@@ -179,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
186
  version: '0'
180
187
  requirements: []
181
188
  rubygems_version: 3.1.6
182
- signing_key:
189
+ signing_key:
183
190
  specification_version: 4
184
191
  summary: Sift Science Ruby API Gem
185
192
  test_files: []
data/.circleci/config.yml DELETED
@@ -1,88 +0,0 @@
1
- version: 2.1
2
-
3
- orbs:
4
- slack: circleci/slack@4.4.2
5
-
6
- commands:
7
- export_slack_id:
8
- steps:
9
- - run:
10
- name : Exporting circleci username as slack id.
11
- command: echo 'export SLACK_PARAM_MENTIONS="$CIRCLE_USERNAME"' >> "$BASH_ENV"
12
- - run:
13
- name : CircleCi To Slack user mapping.
14
- command: |
15
- echo $GITHUB_SLACK_USERMAPPING | base64 --decode > github_slack
16
- while read -r line || [[ -n $line ]];
17
- do
18
- [[ ${line//[[:space:]]/} =~ ^#.* || -z "$line" ]] && continue
19
- echo "$line" | tr "=" "\n" | while read -r key; do
20
- read -r value
21
- if [ "$CIRCLE_USERNAME" = "${key}" ]; then
22
- echo "export SLACK_PARAM_MENTIONS='<@${value}>'" >> $BASH_ENV
23
- fi
24
- done
25
- done < github_slack
26
- rm github_slack
27
-
28
- slack/notify: &slack_notify
29
- branch_pattern: master
30
- event: fail
31
- channel: ci-build-status
32
- template: SLACK_TAG_CI_FAILURE_TEMPLATE
33
-
34
- context: &context
35
- - slack-templates
36
- - slack_Oauth
37
- - Github_Slack_UserMapping
38
-
39
- jobs:
40
- build:
41
- parallelism: 3 # run three instances of this job in parallel
42
- docker:
43
- - image: circleci/ruby:2.4.2-jessie-node
44
- environment:
45
- BUNDLE_JOBS: 3
46
- BUNDLE_RETRY: 3
47
- BUNDLE_PATH: vendor/bundle
48
- steps:
49
- - checkout
50
- - export_slack_id
51
-
52
- - run:
53
- name: Which bundler?
54
- command: bundle -v
55
-
56
- - restore_cache:
57
- keys:
58
- - sift-bundle-{{ checksum "sift.gemspec" }}
59
- - sift-bundle-
60
-
61
- - run:
62
- name: Bundle Install
63
- command: bundle check || bundle install
64
-
65
- - save_cache:
66
- key: sift-bundle-{{ checksum "sift.gemspec" }}
67
- paths:
68
- - vendor/bundle
69
-
70
- - run:
71
- name: Run rspec in parallel
72
- command: |
73
- bundle exec rspec --profile 10 \
74
- --format RspecJunitFormatter \
75
- --out test_results/rspec.xml \
76
- --format progress \
77
- $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
78
-
79
- - store_test_results:
80
- path: test_results
81
- - slack/notify:
82
- <<: *slack_notify
83
-
84
- workflows:
85
- ruby-test:
86
- jobs:
87
- - build:
88
- context: *context