alphaSDK 0.1.0 → 0.2.7
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/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +36 -0
- data/LICENSE.txt +21 -0
- data/README.md +202 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/examples.rb +140 -0
- data/gameball.gemspec +29 -0
- data/lib/gameball.rb +21 -20
- data/lib/gameball/exceptions/gameballException.rb +5 -5
- data/lib/gameball/models/action.rb +28 -10
- data/lib/gameball/models/coupon.rb +50 -29
- data/lib/gameball/models/event.rb +30 -25
- data/lib/gameball/models/player.rb +37 -28
- data/lib/gameball/models/referral.rb +24 -20
- data/lib/gameball/models/transaction.rb +90 -64
- data/lib/gameball/utils/helper.rb +30 -34
- data/lib/gameball/utils/request.rb +65 -91
- data/lib/gameball/utils/validation.rb +13 -11
- data/lib/gameball/version.rb +3 -0
- data/lib/testFile.rb +23 -15
- metadata +57 -12
- data/lib/gameball/models/gameballResponse.rb +0 -0
data/gameball.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative 'lib/gameball/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "alphaSDK"
|
5
|
+
spec.version = Gameball::VERSION
|
6
|
+
spec.authors = ["Alsouidan"]
|
7
|
+
spec.email = ["alsouidan@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = "Ruby gem"
|
10
|
+
spec.homepage = "http://mygemserver.com"
|
11
|
+
spec.license = "MIT"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
+
spec.add_dependency 'rake','>= 12.0'
|
14
|
+
spec.add_dependency 'rspec','>= 3.0'
|
15
|
+
# spec.metadata["allowed_push_host"] = "https://github.com/Alsouidan/alphasdk"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "http://mygemserver.com"
|
19
|
+
spec.metadata["changelog_uri"] = "http://mygemserver.com"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
end
|
data/lib/gameball.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
+
# Requiring all dependencies needed
|
1
2
|
require "net/http"
|
2
3
|
require "net/http"
|
3
4
|
require "openssl"
|
4
5
|
require "uri"
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
6
|
+
require "Time"
|
7
|
+
require "digest/sha1"
|
8
|
+
require "json"
|
9
|
+
# Requiring all the other files to help us require this fiel only
|
9
10
|
require_relative "./gameball/utils/request"
|
10
11
|
require_relative "./gameball/utils/helper"
|
11
12
|
require_relative "./gameball/utils/validation"
|
@@ -13,23 +14,23 @@ require_relative "./gameball/models/player"
|
|
13
14
|
require_relative "./gameball/models/event"
|
14
15
|
require_relative "./gameball/models/transaction"
|
15
16
|
require_relative "./gameball/models/referral"
|
17
|
+
require_relative "./gameball/models/coupon"
|
18
|
+
require_relative "./gameball/models/action"
|
16
19
|
require_relative "./gameball/exceptions/gameballException"
|
17
20
|
|
18
|
-
|
19
21
|
module Gameball
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
22
|
+
@api_base = "https://gb-api.azurewebsites.net"
|
23
|
+
@max_retries = 1
|
24
|
+
@read_timeout = 60
|
25
|
+
@keep_alive_timeout = 30
|
26
|
+
@api_version = "v2.0"
|
27
|
+
class << self
|
28
|
+
attr_accessor :api_key
|
29
|
+
attr_accessor :api_version
|
30
|
+
attr_accessor :transaction_key
|
31
|
+
attr_accessor :read_timeout
|
32
|
+
attr_accessor :max_retries
|
33
|
+
attr_reader :keep_alive_timeout
|
34
|
+
attr_reader :api_base
|
35
|
+
end
|
35
36
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Gameball
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
end
|
2
|
+
class GameballError < StandardError # Custom GameballError that inherits from Ruby StandardError
|
3
|
+
def initialize(msg = "Something went wrong while authorizing your request")
|
4
|
+
super(msg)
|
6
5
|
end
|
7
|
-
end
|
6
|
+
end
|
7
|
+
end
|
@@ -1,13 +1,31 @@
|
|
1
1
|
module Gameball
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
class Action
|
3
|
+
def self.send_action(body)
|
4
|
+
# Validating keys in incoming body
|
5
|
+
Gameball::Utils.validate(body, ["playerUniqueId"], ["playerAttributes", "events", "pointsTransaction"])
|
6
|
+
if body.has_key? (:pointsTransaction)
|
7
|
+
# Validating pointsTransaction object in body
|
8
|
+
Gameball::Utils.validate(body[:pointsTransaction], ['transactionId'],['rewardAmount','holdReference'])
|
9
|
+
body[:pointsTransaction][:transactionTime]=Time.now.utc
|
10
|
+
amount=''
|
11
|
+
if body[:pointsTransaction].has_key?(:rewardAmount)
|
12
|
+
amount=body[:pointsTransaction][:rewardAmount]
|
11
13
|
end
|
14
|
+
body[:pointsTransaction]['hash']=Gameball::Utils.hashBody(playerUniqueId:body[:playerUniqueId],transactionTime:body[:pointsTransaction][:transactionTime],amount:amount)
|
15
|
+
body[:pointsTransaction][:transactionTime]=Time.now.utc.iso8601
|
16
|
+
end
|
17
|
+
|
18
|
+
res = Gameball::Utils::request("post", "/Integrations/Action", body)
|
19
|
+
# Check for HTTP Success and throws error if not success
|
20
|
+
unless res.kind_of? Net::HTTPSuccess
|
21
|
+
if res.kind_of? Net::HTTPInternalServerError
|
22
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
23
|
+
else
|
24
|
+
raise Gameball::GameballError.new(res.body)
|
25
|
+
end
|
26
|
+
else
|
27
|
+
return res
|
28
|
+
end
|
12
29
|
end
|
13
|
-
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,37 +1,58 @@
|
|
1
1
|
module Gameball
|
2
|
-
|
3
|
-
def self.create_discount_coupon(body)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
2
|
+
class Coupon
|
3
|
+
def self.create_discount_coupon(body)
|
4
|
+
# Validating keys in incoming body
|
5
|
+
Gameball::Utils.validate(body, ["playerUniqueId"], ["startAt", "endsAt", "entitledCollectionIds", "entitledProductIds",
|
6
|
+
"oncePerCustomer", "prerequisiteQuantityRange", "prerequisiteShippingPriceRange", "prerequisiteSubtotalRange",
|
7
|
+
"prerequisiteCollectionIds", "prerequisiteProductIds", "code", "usageLimit", "value", "valueType", "cap"])
|
8
|
+
|
9
|
+
body[:transactionTime] = Time.now.utc
|
10
|
+
body["hash"] = Gameball::Utils::hashBody(playerUniqueId: body[:playerUniqueId])
|
11
|
+
res = Gameball::Utils::request("post", "/Integrations/Coupon", body)
|
12
|
+
# Check for HTTP Success and throws error if not success
|
13
|
+
unless res.kind_of? Net::HTTPSuccess
|
14
|
+
if res.kind_of? Net::HTTPInternalServerError
|
15
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
16
|
+
else
|
17
|
+
raise Gameball::GameballError.new(res.body)
|
18
|
+
end
|
19
|
+
else
|
20
|
+
return res
|
21
|
+
end
|
14
22
|
end
|
15
23
|
def self.validate_discount_coupon(body)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
24
|
+
# Validating keys in incoming body
|
25
|
+
Gameball::Utils.validate(body, ["playerUniqueId", "code"])
|
26
|
+
body[:transactionTime] = Time.now.utc
|
27
|
+
body["hash"] = Gameball::Utils::hashBody(playerUniqueId: body[:playerUniqueId])
|
28
|
+
res = Gameball::Utils::request("post", "/Integrations/Coupon/Validate", body)
|
29
|
+
# Check for HTTP Success and throws error if not success
|
30
|
+
unless res.kind_of? Net::HTTPSuccess
|
31
|
+
if res.kind_of? Net::HTTPInternalServerError
|
32
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
33
|
+
else
|
34
|
+
raise Gameball::GameballError.new(res.body)
|
23
35
|
end
|
36
|
+
else
|
37
|
+
return res
|
38
|
+
end
|
24
39
|
end
|
25
40
|
def self.redeem_discount_coupon(body)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
41
|
+
# Check for HTTP Success and throws error if not success
|
42
|
+
Gameball::Utils.validate(body, ["playerUniqueId", "code"])
|
43
|
+
body[:transactionTime] = Time.now.utc
|
44
|
+
body["hash"] = Gameball::Utils::hashBody(playerUniqueId: body[:playerUniqueId])
|
45
|
+
res = Gameball::Utils::request("post", "/Integrations/Coupon/Redeem", body)
|
46
|
+
# Check for HTTP Success and throws error if not success
|
47
|
+
unless res.kind_of? Net::HTTPSuccess
|
48
|
+
if res.kind_of? Net::HTTPInternalServerError
|
49
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
50
|
+
else
|
51
|
+
raise Gameball::GameballError.new(res.body)
|
33
52
|
end
|
53
|
+
else
|
54
|
+
return true
|
55
|
+
end
|
34
56
|
end
|
35
|
-
|
36
|
-
|
37
|
-
end
|
57
|
+
end
|
58
|
+
end
|
@@ -1,29 +1,34 @@
|
|
1
1
|
module Gameball
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
return true
|
14
|
-
end
|
2
|
+
class Event
|
3
|
+
def self.sendEvent(eventBody)
|
4
|
+
# Validating keys in incoming body
|
5
|
+
Gameball::Utils.validate(eventBody, ["events", "playerUniqueId"], ["playerAttributes"])
|
6
|
+
res = Gameball::Utils::request("post", "/integrations/event", eventBody)
|
7
|
+
# Check for HTTP Success and throws error if not success
|
8
|
+
unless res.kind_of? Net::HTTPSuccess
|
9
|
+
if res.kind_of? Net::HTTPInternalServerError
|
10
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
11
|
+
else
|
12
|
+
raise Gameball::GameballError.new(res.body)
|
15
13
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
else
|
15
|
+
return true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
def self.sendEvent_async(eventBody)
|
19
|
+
# Validating keys in incoming body
|
20
|
+
Gameball::Utils.validate(eventBody, ["events", "playerUniqueId"], ["playerAttributes"])
|
21
|
+
res = Gameball::Utils::request_async("post", "/integrations/event", eventBody)
|
22
|
+
# Check for HTTP Success and throws error if not success
|
23
|
+
unless res.kind_of? Net::HTTPSuccess
|
24
|
+
if res.kind_of? Net::HTTPInternalServerError
|
25
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
26
|
+
else
|
27
|
+
raise Gameball::GameballError.new(res.body)
|
27
28
|
end
|
29
|
+
else
|
30
|
+
return true
|
31
|
+
end
|
28
32
|
end
|
29
|
-
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,32 +1,41 @@
|
|
1
1
|
module Gameball
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
2
|
+
class Player
|
3
|
+
def self.initialize_player(body)
|
4
|
+
# Validating keys in incoming body
|
5
|
+
Gameball::Utils.validate(body, ["playerAttributes", "playerUniqueId"], [])
|
6
|
+
# .iso8601 Throws an exception if not invoked on a valid date object, so it is used to check if the dates are valid
|
7
|
+
begin
|
8
|
+
body[:playerAttributes][:joinDate] = body[:playerAttributes][:joinDate].iso8601
|
9
|
+
body[:playerAttributes][:dateOfBirth] = body[:playerAttributes][:dateOfBirth].iso8601
|
10
|
+
rescue NoMethodError => exception
|
11
|
+
raise Gameball::GameballError.new("Invalid Date Format, Please use Time and Date objects")
|
12
|
+
end
|
13
|
+
# Check for HTTP Success and throws error if not success
|
14
|
+
res = Gameball::Utils::request("post", "/integrations/player", body)
|
15
|
+
unless res.kind_of? Net::HTTPSuccess
|
16
|
+
if res.kind_of? Net::HTTPInternalServerError
|
17
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
18
|
+
else
|
19
|
+
raise Gameball::GameballError.new(res.body)
|
20
20
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
else
|
22
|
+
return res
|
23
|
+
end
|
24
|
+
end
|
25
|
+
def self.get_player_info(playerUniqueId)
|
26
|
+
body = { playerUniqueId: playerUniqueId }
|
27
|
+
body["hash"] = Gameball::Utils::hashBody(playerUniqueId: playerUniqueId)
|
28
|
+
res = Gameball::Utils::request("post", "/integrations/Player/Info", body)
|
29
|
+
# Check for HTTP Success and throws error if not success
|
30
|
+
unless res.kind_of? Net::HTTPSuccess
|
31
|
+
if res.kind_of? Net::HTTPInternalServerError
|
32
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
33
|
+
else
|
34
|
+
raise Gameball::GameballError.new(res.body)
|
30
35
|
end
|
36
|
+
else
|
37
|
+
return res
|
38
|
+
end
|
31
39
|
end
|
32
|
-
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,23 +1,27 @@
|
|
1
1
|
module Gameball
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
def self.create_referral_async(body)
|
16
|
-
Gameball::Utils.validate(body,['playerUniqueId','playerCode'],['playerAttributes'])
|
17
|
-
if body.has_key?(:playerAttributes)
|
18
|
-
# Gameball::Utils.validate(body[:playerAttributes],['displayName','firstName','lastName','email','gender','mobileNumber','dateOfBirth','joinDate'],['custom'])
|
19
|
-
end
|
20
|
-
Gameball::Utils::request_async("post","/integrations/referral",body)
|
2
|
+
class Referral
|
3
|
+
def self.create_referral(body)
|
4
|
+
Gameball::Utils.validate(body, ["playerUniqueId", "playerCode"], ["playerAttributes"])
|
5
|
+
if body.has_key?(:playerAttributes)
|
6
|
+
# Gameball::Utils.validate(body[:playerAttributes],['displayName','firstName','lastName','email','gender','mobileNumber','dateOfBirth','joinDate'],['custom'])
|
7
|
+
end
|
8
|
+
res = Gameball::Utils::request("post", "/integrations/referral", body)
|
9
|
+
unless res.kind_of? Net::HTTPSuccess
|
10
|
+
if res.kind_of? Net::HTTPInternalServerError
|
11
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
12
|
+
else
|
13
|
+
raise Gameball::GameballError.new(res.body)
|
21
14
|
end
|
15
|
+
else
|
16
|
+
return true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
def self.create_referral_async(body)
|
20
|
+
Gameball::Utils.validate(body, ["playerUniqueId", "playerCode"], ["playerAttributes"])
|
21
|
+
if body.has_key?(:playerAttributes)
|
22
|
+
# Gameball::Utils.validate(body[:playerAttributes],['displayName','firstName','lastName','email','gender','mobileNumber','dateOfBirth','joinDate'],['custom'])
|
23
|
+
end
|
24
|
+
Gameball::Utils::request_async("post", "/integrations/referral", body)
|
22
25
|
end
|
23
|
-
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,73 +1,99 @@
|
|
1
1
|
module Gameball
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
# check if attributes are available
|
19
|
-
Gameball::Utils.validate(body,['playerUniqueId','amount','transactionTime'],['otp'])
|
2
|
+
class Transaction
|
3
|
+
# include Gameball::Utils
|
4
|
+
def self.get_player_balance(playerId)
|
5
|
+
hashedBody = Gameball::Utils::hashBody(playerUniqueId: playerId)
|
6
|
+
body = { playerUniqueId: playerId,
|
7
|
+
hash: hashedBody }
|
8
|
+
res = Gameball::Utils::request("post", "/integrations/transaction/balance", body)
|
9
|
+
unless res.kind_of? Net::HTTPSuccess
|
10
|
+
raise Gameball::GameballError.new(res.body)
|
11
|
+
else
|
12
|
+
return res
|
13
|
+
end
|
14
|
+
end
|
15
|
+
def self.hold_points(body)
|
16
|
+
# puts body
|
17
|
+
# check if attributes are available
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
19
|
+
Gameball::Utils.validate(body, ["playerUniqueId", "amount"], ["otp"])
|
20
|
+
body[:transactionTime] = Time.now.utc
|
21
|
+
body = Gameball::Utils::extractAttributesToHash(body)
|
22
|
+
res = Gameball::Utils::request("post", "/integrations/transaction/hold", body)
|
23
|
+
unless res.kind_of? Net::HTTPSuccess
|
24
|
+
if res.kind_of? Net::HTTPInternalServerError
|
25
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
26
|
+
else
|
27
|
+
raise Gameball::GameballError.new(res.body)
|
28
28
|
end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
29
|
+
else
|
30
|
+
return res
|
31
|
+
end
|
32
|
+
end
|
33
|
+
def self.redeem_points(body)
|
34
|
+
# check if attributes are available
|
35
|
+
Gameball::Utils.validate(body, ["holdReference", "playerUniqueId", "transactionId"], [])
|
36
|
+
body[:transactionTime] = Time.now.utc
|
37
|
+
body = Gameball::Utils::extractAttributesToHash(body)
|
38
|
+
res = Gameball::Utils::request("post", "/integrations/transaction/redeem", body)
|
39
|
+
unless res.kind_of? Net::HTTPSuccess
|
40
|
+
if res.kind_of? Net::HTTPInternalServerError
|
41
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
42
|
+
else
|
43
|
+
raise Gameball::GameballError.new(res.body)
|
39
44
|
end
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
else
|
46
|
+
return res
|
47
|
+
end
|
48
|
+
end
|
49
|
+
def self.reverse_transaction(body)
|
50
|
+
Gameball::Utils.validate(body, ["reversedTransactionId", "playerUniqueId", "transactionId"], [])
|
51
|
+
body[:transactionTime] = Time.now.utc
|
52
|
+
|
53
|
+
body = Gameball::Utils::extractAttributesToHash(body)
|
54
|
+
res = Gameball::Utils::request("post", "/integrations/transaction/cancel", body)
|
55
|
+
unless res.kind_of? Net::HTTPSuccess
|
56
|
+
if res.kind_of? Net::HTTPInternalServerError
|
57
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
58
|
+
else
|
59
|
+
raise Gameball::GameballError.new(res.body)
|
49
60
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
61
|
+
else
|
62
|
+
return res
|
63
|
+
end
|
64
|
+
end
|
65
|
+
def self.reward_points(body)
|
66
|
+
Gameball::Utils.validate(body, ["playerUniqueId", "amount", "transactionId"], ["playerAttributes"])
|
67
|
+
body[:transactionTime] = Time.now.utc
|
68
|
+
|
69
|
+
body = Gameball::Utils::extractAttributesToHash(body)
|
70
|
+
res = Gameball::Utils::request("post", "/integrations/transaction/reward", body)
|
71
|
+
unless res.kind_of? Net::HTTPSuccess
|
72
|
+
if res.kind_of? Net::HTTPInternalServerError
|
73
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
74
|
+
else
|
75
|
+
raise Gameball::GameballError.new(res.body)
|
59
76
|
end
|
60
|
-
|
61
|
-
|
62
|
-
|
77
|
+
else
|
78
|
+
return true
|
79
|
+
end
|
80
|
+
end
|
81
|
+
def self.reverse_hold(body)
|
82
|
+
# check if holdReference is in body else throw error
|
83
|
+
Gameball::Utils.validate(body, ["holdReference", "playerUniqueId"], [])
|
84
|
+
body[:transactionTime] = Time.now.utc
|
63
85
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
86
|
+
body = Gameball::Utils::extractAttributesToHash(body)
|
87
|
+
res = Gameball::Utils::request("post", "/integrations/transaction/hold", body)
|
88
|
+
unless res.kind_of? Net::HTTPSuccess
|
89
|
+
if res.kind_of? Net::HTTPInternalServerError
|
90
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
91
|
+
else
|
92
|
+
raise Gameball::GameballError.new(res.body)
|
71
93
|
end
|
94
|
+
else
|
95
|
+
return res
|
96
|
+
end
|
72
97
|
end
|
73
|
-
end
|
98
|
+
end
|
99
|
+
end
|