inplay_ai 0.1.2 → 0.1.3
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/lib/inplay_ai/version.rb +1 -1
- data/lib/inplay_ai.rb +13 -14
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94f6787341649cd5504fafc0088983e9785c067fc9dea501a6bcc0907ef927b9
|
4
|
+
data.tar.gz: c498c2520aeadba3d00d03660dc5cdfb5de10470b195b020ff68483c3d7b1f66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65e4e9893e71009bee1b2ff141e171c7e32756d25d1f5ad5c41d9bf8b7c27314f6838087f40e241f9896a1a18b042558a62a530773e2a3fd4990dbade62ef889
|
7
|
+
data.tar.gz: b89dc82503559f34c79036b3cd5f3b23f2835029f70e52b6078f0830d5ba3d2024191bad900b8b72d1f397d8bca261f9cb9e83b5e7a339ab81dd0ef538d5a1e0
|
data/lib/inplay_ai/version.rb
CHANGED
data/lib/inplay_ai.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "inplay_ai/version"
|
4
|
-
require "
|
5
|
-
require "uri"
|
4
|
+
require "http"
|
6
5
|
require "json"
|
6
|
+
require "singleton"
|
7
7
|
|
8
8
|
module InplayAi
|
9
9
|
class Error < StandardError; end
|
10
10
|
|
11
11
|
class Client
|
12
|
+
include Singleton
|
13
|
+
|
12
14
|
DEFAULT_API_URL = "https://api.inplay.ai"
|
13
15
|
|
14
16
|
def initialize(api_key: nil, api_url: nil)
|
@@ -16,6 +18,10 @@ module InplayAi
|
|
16
18
|
raise Error, "API key must be provided via api_key or INPLAY_API_KEY environment variable" unless @api_key
|
17
19
|
raw_url = api_url || ENV["INPLAY_API_URL"]
|
18
20
|
@api_url = (raw_url ? raw_url.sub(/\/$/, "") : DEFAULT_API_URL)
|
21
|
+
@http = HTTP.persistent(@api_url).headers(
|
22
|
+
"x-api-key" => @api_key,
|
23
|
+
"Content-Type" => "application/json"
|
24
|
+
)
|
19
25
|
end
|
20
26
|
|
21
27
|
def wager(data)
|
@@ -45,23 +51,16 @@ module InplayAi
|
|
45
51
|
private
|
46
52
|
|
47
53
|
def post(path, data)
|
48
|
-
|
49
|
-
|
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
|
54
|
+
res = @http.post(path, json: data)
|
55
|
+
if res.status >= 400
|
57
56
|
begin
|
58
|
-
err = JSON.parse(res.body)
|
57
|
+
err = JSON.parse(res.body.to_s)
|
59
58
|
rescue JSON::ParserError
|
60
|
-
err = res.body
|
59
|
+
err = res.body.to_s
|
61
60
|
end
|
62
61
|
raise Error, err
|
63
62
|
end
|
64
|
-
JSON.parse(res.body)
|
63
|
+
JSON.parse(res.body.to_s)
|
65
64
|
end
|
66
65
|
end
|
67
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,28 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- InPlay AI
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
10
|
date: 2025-06-24 00:00:00.000000000 Z
|
11
|
-
dependencies:
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: http
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
12
26
|
description: InPlay AI SDK for Ruby
|
13
27
|
email:
|
14
28
|
- team@inplay.ai
|