https://github.com/taskrabbit/smyte
For fraud checking
https://github.com/taskrabbit/smyte
Last synced: 20 days ago
JSON representation
For fraud checking
- Host: GitHub
- URL: https://github.com/taskrabbit/smyte
- Owner: taskrabbit
- License: mit
- Created: 2016-04-26T21:51:45.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-02T18:48:43.000Z (over 9 years ago)
- Last Synced: 2025-10-27T05:59:19.666Z (5 months ago)
- Language: Ruby
- Size: 14.6 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Smyte
[Smyte](https://www.smyte.com) is a fraud-checking service. This gem makes it a bit easier to work with their [API](https://docs.smyte.com/).
## Setup
`gem install smyte`
```ruby
require 'smyte'
Smyte.enabled = true
Smyte.api_key = '123456789'
Smyte.api_secret = 'qwertyuiopasdfghjkl'
Smyte.webhook_secret = 'zxcvbnmpoiuytrewq'
```
## Sending data to Smyte
Uses this [API](https://docs.smyte.com/docs/sending-data-to-smyte).
```ruby
payload = {
data: {
custom_id: 1
},
http_request: {
headers: {
"X-Real-IP" => "5.6.7.8"
},
path: "/login"
},
session: {
id: 'sessionguid',
action: {
user_id: 2
}
},
timestamp: Time.now
}
Smyte.action('my_event', payload)
```
## Receiving classification results
Uses this [API](https://docs.smyte.com/docs/receiving-classification-results).
```ruby
# payload same as before (or other, of course)
classification = Smyte.classify('my_event', payload)
puts classification.action # will be :block, :review, or :allow
puts classification.label_report # for example on block ["exp:high_fail_rate_payment", "cc_country_mismatch"]
```
## Webhooks
Uses this [API](https://docs.smyte.com/docs/webhooks).
Smyte does a POST to your endpoint
```ruby
# for example in a Rails controller action
secret = request.headers["X-Smyte-Signature"]
notification = ::Smyte.webhook(secret, params)
notification.items.each do |item|
puts item.action # will be :block, :review, or :allow
puts item.type # for example "user"
puts item.id # user id
puts item.label_report # for example on block ["bad_user"]
end
```