inplay_ai 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a0102e450b21a74d8f0d4ec99fd2f378f0203a1a85df36d105bbc561ccd3744
4
- data.tar.gz: 0c768428ae461edeb66ced5dda1a4cb0f4703b2e414f87812fceb1129d19ae8a
3
+ metadata.gz: e971e67dd7f067239f057db765d673bd37e4ff015adfe631192492e080c63123
4
+ data.tar.gz: f61bed16f6334741835b8857b420f2e72b1a6068bee934e7389b5503debcaa22
5
5
  SHA512:
6
- metadata.gz: e0a2df5e20a333dd1c16b49e362d06c794348fed774e9c38dd7bae206e7b0f420d9fefab12b53d18128c130b2a6384e713e0d0041c2224c2bcf688d9c305de13
7
- data.tar.gz: dc71cfe0ec971713da92913e90e6b0bee78c85e3c40e12e208e2e375aeca8fc3eb4f770c7f1fae4cb6dbfcc261fd42a106a9fa0f62f3c06f52160694f0aa87a3
6
+ metadata.gz: 306ee52155dca1c6c1d39f9a92683a3e2823f32724b276d89fed98ee8292cad5d4e2cfc1b1d413ee311ca7e367b38c36954e5bb6d4a0c2221964cc14507056a4
7
+ data.tar.gz: 6936651a57251283b980b1169eee62e429980518962a4f5e39f25f3884cd53d8ca0db67147f7e72fba69deb1bb0be4efd26509fb73bc47a7a0ac223273ac23dd
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,93 @@
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).
83
+
84
+ ## API
85
+
86
+ All methods return a Promise and throw on API errors.
87
+
88
+ - `wager(data)` — POST `/v1/events/wager`
89
+ - `settlement(data)` — POST `/v1/events/settlement`
90
+ - `user(data)` — POST `/v1/metadata/user`
91
+ - `market(data)` — POST `/v1/metadata/market`
92
+ - `target(data)` — POST `/v1/metadata/target`
93
+ - `event(data)` — POST `/v1/metadata/event`
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InplayAi
4
+ VERSION = "0.1.2"
5
+ end
data/lib/inplay_ai.rb ADDED
@@ -0,0 +1,67 @@
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
+ def target(data)
38
+ post("/v1/metadata/target", data)
39
+ end
40
+
41
+ def event(data)
42
+ post("/v1/metadata/event", data)
43
+ end
44
+
45
+ private
46
+
47
+ def post(path, data)
48
+ uri = URI.join(@api_url, path)
49
+ http = Net::HTTP.new(uri.host, uri.port)
50
+ http.use_ssl = uri.scheme == "https"
51
+ req = Net::HTTP::Post.new(uri)
52
+ req["x-api-key"] = @api_key
53
+ req["Content-Type"] = "application/json"
54
+ req.body = data.to_json
55
+ res = http.request(req)
56
+ if res.code.to_i >= 400
57
+ begin
58
+ err = JSON.parse(res.body)
59
+ rescue JSON::ParserError
60
+ err = res.body
61
+ end
62
+ raise Error, err
63
+ end
64
+ JSON.parse(res.body)
65
+ end
66
+ end
67
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inplay_ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - InPlay AI
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-06-22 00:00:00.000000000 Z
10
+ date: 2025-06-24 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: InPlay AI SDK for Ruby
13
13
  email:
@@ -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