inplay_ai 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/LICENSE.txt +21 -0
- data/README.md +82 -0
- data/lib/inplay_ai/version.rb +5 -0
- data/lib/inplay_ai.rb +59 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4efaffd9fa8498aa0e6d6310edb618deb77d623d2790bc7d65d847cd77680e1
|
4
|
+
data.tar.gz: a2a076efbf75365570d961d13af1684901c81c3239aa03ac122ea3bd9a1cfd59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e43d54ed123624740dae21cf482ada7b08679b85a5d30a256b1113039769784246dea4bb6a30e465e1447dfa1e78cd92f80049ca477633b1301680a5c2aad6f
|
7
|
+
data.tar.gz: a2c0ca01509b8483ed7d796711b79cfc3ede13410fe7083c2cb2b189a1a72788e8f29b56ea485357e712f992cae61bbfdf37d1db852760b8c3f21793380a87b7
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2025 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# Inplay_ai Ruby SDK
|
2
|
+
|
3
|
+
A thin, type-safe Ruby client for the InPlayAI event ingestion and metadata API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'inplay_ai', path: 'sdk/ruby'
|
11
|
+
```
|
12
|
+
|
13
|
+
Or install it yourself as:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
gem install inplay_ai
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'inplay_ai'
|
23
|
+
|
24
|
+
client = InplayAi::Client.new(
|
25
|
+
api_key: 'your-api-key',
|
26
|
+
api_url: 'https://api.inplay.ai' # or your API base URL
|
27
|
+
)
|
28
|
+
|
29
|
+
# Send a wager event
|
30
|
+
client.wager({
|
31
|
+
wager_id: 'abc123',
|
32
|
+
user_id: 'user_456',
|
33
|
+
amount: 50.0,
|
34
|
+
payout: 92.0,
|
35
|
+
legs: [
|
36
|
+
{ market: '123:456:pregame', probability: 0.6, outcome: 'over', line: 26.5 },
|
37
|
+
{ market: '123:789:pregame', probability: 0.7, outcome: 'under', line: 28.0 }
|
38
|
+
],
|
39
|
+
timestamp: '2025-06-20T22:04:58Z'
|
40
|
+
})
|
41
|
+
|
42
|
+
# Send a settlement event
|
43
|
+
client.settlement({
|
44
|
+
wager_id: 'abc123',
|
45
|
+
amount: 92.0,
|
46
|
+
timestamp: '2025-06-20T22:04:58Z',
|
47
|
+
outcomes: [
|
48
|
+
{ market: '123:456:pregame', result: 'W' },
|
49
|
+
{ market: '123:789:pregame', result: 'L' }
|
50
|
+
]
|
51
|
+
})
|
52
|
+
|
53
|
+
# Upsert user metadata
|
54
|
+
client.user({
|
55
|
+
user_id: 'user_456',
|
56
|
+
first_name: 'John',
|
57
|
+
last_name: 'Doe'
|
58
|
+
})
|
59
|
+
|
60
|
+
# Upsert market metadata
|
61
|
+
client.market({
|
62
|
+
market_id: '123:456:pregame',
|
63
|
+
game: { id: 789, name: 'Lakers vs Celtics' },
|
64
|
+
team: { id: 5, name: 'Lakers' },
|
65
|
+
league: { id: 10, name: 'NBA' },
|
66
|
+
category: 'points'
|
67
|
+
})
|
68
|
+
```
|
69
|
+
|
70
|
+
## Error Handling
|
71
|
+
|
72
|
+
If the API returns an error, the client will raise `InplayAi::Error` with the error response.
|
73
|
+
|
74
|
+
## Development
|
75
|
+
|
76
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
77
|
+
|
78
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `lib/inplay_ai/version.rb`, and then run `bundle exec rake release`.
|
79
|
+
|
80
|
+
## License
|
81
|
+
|
82
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/inplay_ai.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "inplay_ai/version"
|
4
|
+
require "net/http"
|
5
|
+
require "uri"
|
6
|
+
require "json"
|
7
|
+
|
8
|
+
module InplayAi
|
9
|
+
class Error < StandardError; end
|
10
|
+
|
11
|
+
class Client
|
12
|
+
DEFAULT_API_URL = "https://api.inplay.ai"
|
13
|
+
|
14
|
+
def initialize(api_key: nil, api_url: nil)
|
15
|
+
@api_key = api_key || ENV["INPLAY_API_KEY"]
|
16
|
+
raise Error, "API key must be provided via api_key or INPLAY_API_KEY environment variable" unless @api_key
|
17
|
+
raw_url = api_url || ENV["INPLAY_API_URL"]
|
18
|
+
@api_url = (raw_url ? raw_url.sub(/\/$/, "") : DEFAULT_API_URL)
|
19
|
+
end
|
20
|
+
|
21
|
+
def wager(data)
|
22
|
+
post("/v1/events/wager", data)
|
23
|
+
end
|
24
|
+
|
25
|
+
def settlement(data)
|
26
|
+
post("/v1/events/settlement", data)
|
27
|
+
end
|
28
|
+
|
29
|
+
def user(data)
|
30
|
+
post("/v1/metadata/user", data)
|
31
|
+
end
|
32
|
+
|
33
|
+
def market(data)
|
34
|
+
post("/v1/metadata/market", data)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def post(path, data)
|
40
|
+
uri = URI.join(@api_url, path)
|
41
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
42
|
+
http.use_ssl = uri.scheme == "https"
|
43
|
+
req = Net::HTTP::Post.new(uri)
|
44
|
+
req["x-api-key"] = @api_key
|
45
|
+
req["Content-Type"] = "application/json"
|
46
|
+
req.body = data.to_json
|
47
|
+
res = http.request(req)
|
48
|
+
if res.code.to_i >= 400
|
49
|
+
begin
|
50
|
+
err = JSON.parse(res.body)
|
51
|
+
rescue JSON::ParserError
|
52
|
+
err = res.body
|
53
|
+
end
|
54
|
+
raise Error, err
|
55
|
+
end
|
56
|
+
JSON.parse(res.body)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inplay_ai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- InPlay AI
|
@@ -15,7 +15,11 @@ email:
|
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
|
-
files:
|
18
|
+
files:
|
19
|
+
- LICENSE.txt
|
20
|
+
- README.md
|
21
|
+
- lib/inplay_ai.rb
|
22
|
+
- lib/inplay_ai/version.rb
|
19
23
|
homepage: https://inplay.ai
|
20
24
|
licenses:
|
21
25
|
- MIT
|