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
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MzdkOThmNmZiYWRmMDI3ODgyYjI4MjYyMjc2ZDg1YjhkOTdlNGU0MQ==
5
- data.tar.gz: !binary |-
6
- N2RiZGI4ZTFlZWI1YjBkNDQ1MDQyM2MxYTNmMDNlMzUxZjMyZDM1OA==
2
+ SHA256:
3
+ metadata.gz: 71be696ff04ffb1503d22a724241e5087809d2ffa2ab29f08666939ecd6bb98b
4
+ data.tar.gz: e2e841d8259fbea8c247b1b2bd3cdf208bd53ded613a765a75f595714a2e1e8d
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- M2YzZTYyZmJhMzBjMDVmZmJiNWM5N2ZmNmJmNjkzOTMzN2ExODIxMTIwOGRh
10
- OTBmYThlZDA1ZDVmMDYzZTI4MjIxZDcxYTFjYjZhMzc0MzlkYjk1ZThhZTMy
11
- YjhlNGUwMzEwOTI2MjhlNGI5ODYwZTJmYmRkNGI4YzlkM2IzYTE=
12
- data.tar.gz: !binary |-
13
- NGVjMmZjYTJiOWI0NDA4N2Y5NjU3NGNkNDk1NTNjMDdhZGQ3NGZmNDEwNTYw
14
- MTVmZGQ5ZDQ4NTY4ZmEyMTkwNjYwZDFhMTBmZDgwNDNiYWVjMWUyZWE0OTk1
15
- NThlNTY5N2M2ZDAyZTBkMWI5Mjg4YzVhMmM2M2MyZDU5YjU1MDE=
6
+ metadata.gz: 9b578f6bccf6323d4ef53947cea5a517678920d882439da1d1df262cf5eb39e45064aab3a1dee702da01f41f29a522df0c5e7b850c68e1ac302fa0f7d9830e29
7
+ data.tar.gz: 3c4565ffc5f98626ac67a07b378adfd80aaef787e47ffc50d84780da4b62788bdfb43e1b2e4ed90ca59cb4ee0fe23ec727dad8d1c0dd9413c137d7ec1de95510
@@ -0,0 +1,105 @@
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
+ run_integration_tests:
85
+ docker:
86
+ - image: circleci/ruby:2.4.2-jessie-node
87
+ steps:
88
+ - checkout
89
+ - run:
90
+ name: Install bundle and run the tests
91
+ command: |
92
+ bundle check || bundle install
93
+ bundle exec ruby test_integration_app/main.rb
94
+
95
+ workflows:
96
+ ruby-test:
97
+ jobs:
98
+ - build:
99
+ context: *context
100
+ ruby-integration-tests:
101
+ jobs:
102
+ - run_integration_tests:
103
+ filters:
104
+ branches:
105
+ only: master
@@ -0,0 +1,12 @@
1
+ ## Purpose
2
+
3
+ ## Summary
4
+
5
+ ## Testing
6
+
7
+ ## Checklist
8
+ - [ ] The change was thoroughly tested manually
9
+ - [ ] The change was covered with unit tests
10
+ - [ ] The change was tested with real API calls (if applicable)
11
+ - [ ] Necessary changes were made in the integration tests (if applicable)
12
+ - [ ] New functionality is reflected in README
@@ -0,0 +1,38 @@
1
+ name: Build and Publish Gem
2
+ on:
3
+ release:
4
+ types: [published]
5
+
6
+ env:
7
+ GH_TOKEN: ${{ github.token }}
8
+
9
+ jobs:
10
+ build_and_publish:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout code
14
+ uses: actions/checkout@v3
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: 2.7
19
+ - name: Install Bundler
20
+ run: |
21
+ sudo gem install bundler
22
+ bundle install
23
+ - name: Build and push gem
24
+ run: |
25
+ mkdir -p $HOME/.gem
26
+ touch $HOME/.gem/credentials
27
+ chmod 0600 $HOME/.gem/credentials
28
+ printf -- "---\n:rubygems_api_key: ${{ secrets.GH_RGEMS_KEY }}\n" > $HOME/.gem/credentials
29
+ version=$(awk -F'"' '/ VERSION = / {print $2}' < lib/sift/version.rb)
30
+ all_versions=$(gem list -r -e --all sift --no-verbose)
31
+ if [[ $all_versions != *"$version"* ]]; then
32
+ echo "Gem version does not exist on RubyGems. Building and pushing!"
33
+ gem build sift.gemspec
34
+ gem push sift-$version.gem
35
+ rm -rf $HOME/.gem
36
+ else
37
+ echo "Gem version $version exists on RubyGems"
38
+ fi
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  .bundle
4
4
  Gemfile.lock
5
5
  pkg/*
6
+ .idea
@@ -0,0 +1,103 @@
1
+ // Load Jenkins shared library
2
+ jenkinsBranch = 'v0.37.0'
3
+ sharedLib = library("shared-lib@${jenkinsBranch}")
4
+
5
+ def siftRubyWorkflow = sharedLib.com.sift.ci.SiftRubyWorkflow.new()
6
+ def ciUtil = sharedLib.com.sift.ci.CIUtil.new()
7
+ def stackdriver = sharedLib.com.sift.ci.StackDriverMetrics.new()
8
+
9
+ // Default GitHub status context for automatically triggered builds
10
+ def defaultStatusContext = 'Jenkins:auto'
11
+
12
+ // Pod template file for Jenkins agent pod
13
+ // Pod template yaml file is defined in https://github.com/SiftScience/jenkins/tree/master/resources/jenkins-k8s-pod-templates
14
+ def ruby2PodTemplateFile = 'ruby-2-4-2-pod-template.yaml'
15
+ def ruby2PodLabel = "ruby2-${BUILD_TAG}"
16
+
17
+
18
+ // GitHub repo name
19
+ def repoName = 'sift-ruby'
20
+
21
+ pipeline {
22
+ agent none
23
+ options {
24
+ timestamps()
25
+ skipDefaultCheckout()
26
+ disableConcurrentBuilds()
27
+ disableRestartFromStage()
28
+ parallelsAlwaysFailFast()
29
+ buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '30', numToKeepStr: '')
30
+ timeout(time: 1, unit: 'HOURS')
31
+ }
32
+ environment {
33
+ GIT_BRANCH = "${env.CHANGE_BRANCH != null? env.CHANGE_BRANCH : env.BRANCH_NAME}"
34
+ }
35
+ stages {
36
+ stage('Initialize') {
37
+ steps {
38
+ script {
39
+ statusContext = defaultStatusContext
40
+ // Get the commit sha for the build
41
+ commitSha = ciUtil.commitHashForBuild()
42
+ ciUtil.updateGithubCommitStatus(repoName, statusContext, 'Started', 'pending', commitSha)
43
+ }
44
+ }
45
+ }
46
+ stage ('Build and Test Workflows') {
47
+ steps {
48
+ script {
49
+ def workflows = [:]
50
+ def stage1 = 'Run Integration Tests - ruby'
51
+ workflows[stage1] = {
52
+ stage(stage1) {
53
+ if (env.GIT_BRANCH.equals('master')) {
54
+ ciUtil.updateGithubCommitStatus(repoName, stage1, 'Started', 'pending', commitSha)
55
+ try {
56
+ siftRubyWorkflow.runSiftRubyIntegration(ruby2PodTemplateFile, ruby2PodLabel)
57
+ ciUtil.updateGithubCommitStatus(repoName, stage1, 'SUCCESS', 'success', commitSha)
58
+ } catch (Exception e) {
59
+ ciUtil.updateGithubCommitStatus(repoName, stage1, 'FAILURE', 'failure', commitSha)
60
+ print("${stage1} failed")
61
+ throw e
62
+ }
63
+ }
64
+ }
65
+ }
66
+ def stage2 = 'Test - ruby'
67
+ workflows[stage2] = {
68
+ stage(stage2) {
69
+ ciUtil.updateGithubCommitStatus(repoName, stage2, 'Started', 'pending', commitSha)
70
+ try {
71
+ siftRubyWorkflow.runSiftRubyTest(ruby2PodTemplateFile, ruby2PodLabel)
72
+ ciUtil.updateGithubCommitStatus(repoName, stage2, 'SUCCESS', 'success', commitSha)
73
+ } catch (Exception e) {
74
+ ciUtil.updateGithubCommitStatus(repoName, stage2, 'FAILURE', 'failure', commitSha)
75
+ print("${stage2} failed")
76
+ throw e
77
+ }
78
+ }
79
+ }
80
+ parallel workflows
81
+ }
82
+ }
83
+ }
84
+ }
85
+ post {
86
+ success {
87
+ script {
88
+ ciUtil.updateGithubCommitStatus(repoName, statusContext, currentBuild.currentResult, 'success', commitSha)
89
+ }
90
+ }
91
+ unsuccessful {
92
+ script {
93
+ ciUtil.updateGithubCommitStatus(repoName, statusContext, currentBuild.currentResult, 'failure', commitSha)
94
+ ciUtil.notifySlack(repoName, commitSha)
95
+ }
96
+ }
97
+ always {
98
+ script {
99
+ stackdriver.updatePipelineStatistics(this)
100
+ }
101
+ }
102
+ }
103
+ }
data/HISTORY CHANGED
@@ -1,3 +1,107 @@
1
+ === 4.5.0 2024-05-16
2
+ - Support for warnings in Events API
3
+
4
+ === 4.4.0 2023-10-05
5
+ - Score percentiles in Score API
6
+
7
+ === 4.3.0 2023-08-21
8
+ - PSP Merchant Management API
9
+
10
+ === 4.2.0 2023-06-20
11
+ - Verification API support [Verification API](https://sift.com/developers/docs/curl/verification-api/overview)
12
+ - Support for score percentiles (only applicable for the accounts with the feature enabled)
13
+
14
+ === 4.1.0 2022-06-22
15
+ - Add return_route_info query param
16
+
17
+ === 4.0.0 2019-05-15
18
+ - Breaking change: Propagate exception in Client.track() – previously we were silently swallowing exceptions and now we are bubbling them up. You will need to add exception handling code.
19
+ - Fix URL encoding
20
+ - Add Circle build
21
+
22
+ === 3.3.0 2018-07-31
23
+ - Add support for rescore_user and get_user_score APIs
24
+
25
+ === 3.2.0 2018-07-05
26
+ - Add new query parameter force_workflow_run
27
+
28
+ === 3.1.0 2018-06-04
29
+ - Adds support for get session decisions to [Decisions API](https://siftscience.com/developers/docs/curl/decisions-api)
30
+
31
+ === 3.0.1 2018-04-06
32
+ - Improved documentation on HISTORY and README.MD
33
+
34
+ === 3.0.0 2018-03-05
35
+ - Adds support for Sift Science API Version 205, including new [`$create_content`](https://siftscience.com/developers/docs/curl/events-api/reserved-events/create-content) and [`$update_content`](https://siftscience.com/developers/docs/curl/events-api/reserved-events/update-content) formats
36
+ - V205 APIs are now called -- **this is an incompatible change**
37
+ - (use `:version => 204` to call the previous API version)
38
+ - Adds support for content decisions to [Decisions API](https://siftscience.com/developers/docs/curl/decisions-api)
39
+
40
+ INCOMPATIBLE CHANGES INTRODUCED IN API V205:
41
+ - `$create_content` and `$update_content` have significantly changed, and the old format will be rejected
42
+ - `$send_message` and `$submit_review` events are no longer valid
43
+ - V205 improves server-side event data validation. In V204 and earlier, server-side validation accepted some events that did not conform to the published APIs in our [developer documentation](https://siftscience.com/developers/docs/curl/events-api). V205 does not modify existing event APIs other than those mentioned above, but may reject invalid event data that were previously accepted. **Please test your integration on V205 in sandbox before using in production.**
44
+
45
+ === 2.2.1.0 2018-02-12
46
+ * Add session level decisions in Apply Decisions APIs.
47
+
48
+ === 2.0.0.0 2016-07-19
49
+ * adds support for v204 of Sift Science's APIs
50
+ * adds Workflow Status API, User Decisions API, Order Decisions API
51
+ * v204 APIs are now called by default -- this is an incompatible change
52
+ (use :version => 203 to call the previous API version)
53
+ * uses Hash arg for optional params in Client methods -- incompatible change
54
+
55
+ === 1.1.7.2 2015-04-13
56
+ * Fixed backwards compatibility issue
57
+
58
+ === 1.1.7.0 2015-02-24
59
+ * Added Unlabel functionality
60
+
61
+ === 1.1.6.2 2014-09-19
62
+ * added API key parameter to track and label functions
63
+
64
+ === 1.1.6.0 2014-09-03
65
+ * added module scoped API key variable
66
+
67
+ === 1.1.4 2014-01-02
68
+ * removed support for ruby 1.9.2
69
+ * track/label return nil on failure
70
+
71
+ === 1.1.3 2013-12-10
72
+ * nil values are removed from JSON body sent to track/label now.
73
+ * relaxed multi_json requirement to 1.0 or newer
74
+ * relaxed httparty requirement to 0.11.0 or newer
75
+ * migrated from fakeweb to webmock 1.16.0 or newer
76
+
77
+ === 1.1.1 2013-11-14
78
+ * score request now requires API key
79
+
80
+ === 1.1.0 2013-11-08
81
+ * now uses v203 API endpoint by default
82
+
83
+ === 1.0.13 2014-10-22
84
+ * added path parameter to track function
85
+ * added label function for applying labels
86
+ * now requires httparty 0.12.0 or newer
87
+ * now requires multi_json 1.8.2 or newer
88
+ * now requires rspec 2.14.1 or newer for compilation only
89
+
90
+ === 1.0.12 2013-06-13
91
+ * added score function for getting user scores.
92
+ * now requires httparty 0.10.0 or newer
93
+ * added rspec 2.0 or newer and rake dependency
94
+
95
+ === 1.0.10 2013-01-09
96
+ * Add configurable path variable to Client
97
+
98
+ === 1.0.5 2012-07-20
99
+
100
+ === 1.0.3 2012-05-05
101
+
102
+ === 1.0.2 2012-05-03
103
+
104
+ === 1.0.1 2012-05-02
1
105
 
2
106
  === 1.0 2012-05-02
3
107
  * Initial release