alphaSDK 0.2.0 → 0.2.4
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 +34 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gameball.gemspec +29 -0
- data/lib/gameball.rb +19 -20
- data/lib/gameball/exceptions/gameballException.rb +5 -5
- data/lib/gameball/models/action.rb +14 -10
- data/lib/gameball/models/coupon.rb +44 -28
- data/lib/gameball/models/event.rb +33 -25
- data/lib/gameball/models/player.rb +36 -28
- data/lib/gameball/models/referral.rb +24 -20
- data/lib/gameball/models/transaction.rb +90 -64
- data/lib/gameball/utils/helper.rb +33 -34
- data/lib/gameball/utils/request.rb +81 -90
- data/lib/gameball/utils/validation.rb +11 -11
- data/lib/gameball/version.rb +3 -0
- metadata +56 -13
- data/lib/gameball/models/gameballResponse.rb +0 -0
- data/lib/testFile.rb +0 -87
@@ -1,29 +1,37 @@
|
|
1
1
|
module Gameball
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
class Event
|
3
|
+
# include Gameball::Request
|
4
|
+
def self.sendEvent(eventBody)
|
5
|
+
Gameball::Utils.validate(eventBody, ["events", "playerUniqueId"], ["playerAttributes"])
|
6
|
+
if eventBody.has_key?(:playerAttributes)
|
7
|
+
# Gameball::Utils.validate(eventBody[:playerAttributes],['displayName','firstName','lastName','email','gender','mobileNumber','dateOfBirth','joinDate'],['custom'])
|
8
|
+
end
|
9
|
+
res = Gameball::Utils::request("post", "/integrations/event", eventBody)
|
10
|
+
unless res.kind_of? Net::HTTPSuccess
|
11
|
+
if res.kind_of? Net::HTTPInternalServerError
|
12
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
13
|
+
else
|
14
|
+
raise Gameball::GameballError.new(res.body) # use custom message
|
15
15
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
else
|
17
|
+
return true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
def self.sendEvent_async(eventBody)
|
21
|
+
Gameball::Utils.validate(eventBody, ["events", "playerUniqueId"], ["playerAttributes"])
|
22
|
+
if eventBody.has_key?(:playerAttributes)
|
23
|
+
# Gameball::Utils.validate(eventBody[:playerAttributes],['displayName','firstName','lastName','email','gender','mobileNumber','dateOfBirth','joinDate'],['custom'])
|
24
|
+
end
|
25
|
+
res = Gameball::Utils::request_async("post", "/integrations/event", eventBody)
|
26
|
+
unless res.kind_of? Net::HTTPSuccess
|
27
|
+
if res.kind_of? Net::HTTPInternalServerError
|
28
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
29
|
+
else
|
30
|
+
raise Gameball::GameballError.new(res.body) # use custom message
|
27
31
|
end
|
32
|
+
else
|
33
|
+
return true
|
34
|
+
end
|
28
35
|
end
|
29
|
-
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,32 +1,40 @@
|
|
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
|
+
# include Gameball::Request
|
4
|
+
def self.initialize_player(customerBody)
|
5
|
+
Gameball::Utils.validate(customerBody, ["playerAttributes", "playerUniqueId"], [])
|
6
|
+
begin
|
7
|
+
customerBody[:playerAttributes][:joinDate] = customerBody[:playerAttributes][:joinDate].iso8601
|
8
|
+
customerBody[:playerAttributes][:dateOfBirth] = customerBody[:playerAttributes][:dateOfBirth].iso8601
|
9
|
+
rescue NoMethodError => exception
|
10
|
+
# p exception
|
11
|
+
raise Gameball::GameballError.new("Invalid Date Format, Please use Time and Date objects")
|
12
|
+
end
|
13
|
+
|
14
|
+
res = Gameball::Utils::request("post", "/integrations/player", customerBody)
|
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) # use custom message
|
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
|
+
unless res.kind_of? Net::HTTPSuccess
|
30
|
+
if res.kind_of? Net::HTTPInternalServerError
|
31
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
32
|
+
else
|
33
|
+
raise Gameball::GameballError.new(res.body) # use custom message
|
30
34
|
end
|
35
|
+
else
|
36
|
+
return res
|
37
|
+
end
|
31
38
|
end
|
32
|
-
end
|
39
|
+
end
|
40
|
+
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) # use custom message
|
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) # use custom message
|
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) # use custom message
|
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) # use custom message
|
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) # use custom message
|
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) # use custom message
|
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) # use custom message
|
71
93
|
end
|
94
|
+
else
|
95
|
+
return res
|
96
|
+
end
|
72
97
|
end
|
73
|
-
end
|
98
|
+
end
|
99
|
+
end
|
@@ -1,39 +1,38 @@
|
|
1
1
|
module Gameball
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
str=playerUniqueId+":"+formatted_time+":"+amount.to_s+":"+Gameball.transaction_key
|
20
|
-
puts str
|
21
|
-
return Digest::SHA1.hexdigest (str)
|
22
|
-
end
|
23
|
-
def extractAttributesToHash(body)
|
24
|
-
playerUniqueId=body[:playerUniqueId]
|
25
|
-
amount=body[:amount]
|
26
|
-
transactionTime=body[:transactionTime]
|
27
|
-
begin
|
28
|
-
body[:transactionTime]=transactionTime.iso8601
|
2
|
+
module Utils
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def hashBody(playerUniqueId:, transactionTime: "", amount: "")
|
6
|
+
# Check if transaction Key is provided else raise Exc
|
7
|
+
if !Gameball.transaction_key
|
8
|
+
raise Gameball::GameballError.new("Please provide transaction_key, try Gameball::transaction_key='your_key'") # Raise exception
|
9
|
+
else
|
10
|
+
if transactionTime == ""
|
11
|
+
formatted_time = ""
|
12
|
+
else
|
13
|
+
# begin
|
14
|
+
formatted_time = transactionTime.strftime("%y%m%d%H%M%S")
|
15
|
+
# rescue => exception
|
29
16
|
|
30
|
-
|
31
|
-
raise Gameball::GameballError.new("Invalid Date Formate, Please use Date and Time objects")
|
32
|
-
end
|
33
|
-
body["bodyHashed"]=Gameball::Utils::hashBody(playerUniqueId:playerUniqueId,amount:(amount||""),transactionTime:(transactionTime||""))
|
34
|
-
body
|
17
|
+
# end
|
35
18
|
end
|
36
|
-
|
19
|
+
end
|
20
|
+
str = playerUniqueId + ":" + formatted_time + ":" + amount.to_s + ":" + Gameball.transaction_key
|
21
|
+
# puts str
|
22
|
+
return Digest::SHA1.hexdigest (str)
|
23
|
+
end
|
37
24
|
|
25
|
+
def extractAttributesToHash(body)
|
26
|
+
playerUniqueId = body[:playerUniqueId]
|
27
|
+
amount = body[:amount]
|
28
|
+
transactionTime = body[:transactionTime]
|
29
|
+
begin
|
30
|
+
body[:transactionTime] = transactionTime.iso8601
|
31
|
+
rescue NoMethodError => exception
|
32
|
+
raise Gameball::GameballError.new("Invalid Date Formate, Please use Date and Time objects")
|
33
|
+
end
|
34
|
+
body["hash"] = Gameball::Utils::hashBody(playerUniqueId: playerUniqueId, amount: (amount || ""), transactionTime: (transactionTime || ""))
|
35
|
+
body
|
38
36
|
end
|
39
|
-
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,99 +1,90 @@
|
|
1
1
|
module Gameball
|
2
|
-
|
3
|
-
|
4
|
-
def request(verb,path,body={})
|
5
|
-
#check for api_version and key and throw exceptions
|
6
|
-
if !Gameball.api_key
|
7
|
-
raise Gameball::GameballError.new("Please provide the api_key before making a request, try Gameball::api_key='your_key'")
|
8
|
-
end
|
9
|
-
uri=URI(Gameball.api_base+'/api'+'/'+Gameball.api_version+path)
|
2
|
+
module Utils
|
3
|
+
extend self
|
10
4
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
case verb.downcase
|
18
|
-
when "post"
|
19
|
-
req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})
|
5
|
+
def request(verb, path, body = {})
|
6
|
+
#check for api_version and key and throw exceptions
|
7
|
+
if !Gameball.api_key
|
8
|
+
raise Gameball::GameballError.new("Please provide the api_key before making a request, try Gameball::api_key='your_key'")
|
9
|
+
end
|
10
|
+
uri = URI(Gameball.api_base + "/api" + "/" + Gameball.api_version + path)
|
20
11
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
req = Net::HTTP::Put.new(uri.path, initheader = {'Content-Type' =>'application/json'})
|
12
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
13
|
+
https.max_retries = Gameball.max_retries
|
14
|
+
https.read_timeout = Gameball.read_timeout
|
15
|
+
https.keep_alive_timeout = Gameball.keep_alive_timeout
|
16
|
+
https.use_ssl = true
|
27
17
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
18
|
+
case verb.downcase
|
19
|
+
when "post"
|
20
|
+
req = Net::HTTP::Post.new(uri.path, initheader = { "Content-Type" => "application/json" })
|
21
|
+
when "get"
|
22
|
+
req = Net::HTTP::Get.new(uri.path, initheader = { "Content-Type" => "application/json" })
|
23
|
+
when "put"
|
24
|
+
req = Net::HTTP::Put.new(uri.path, initheader = { "Content-Type" => "application/json" })
|
25
|
+
when "delete"
|
26
|
+
req = Net::HTTP::Delete.new(uri.path, initheader = { "Content-Type" => "application/json" })
|
27
|
+
else
|
28
|
+
raise Gameball::GameballException.new("Please provide a valid HTTP Verb") # will later throw an exception
|
29
|
+
end
|
30
|
+
if body != {}
|
31
|
+
# puts body
|
32
|
+
# begin
|
33
|
+
req.body = body.to_json
|
34
|
+
# p req.body
|
35
|
+
# rescue JSON::ParserError => exception
|
48
36
|
|
49
|
-
|
50
|
-
#check for api_version and key and throw exceptions
|
51
|
-
if !Gameball.api_key
|
52
|
-
raise Gameball::GameballError.new("Please provide the api_key before making a request, try Gameball::api_key='your_key'")
|
53
|
-
end
|
54
|
-
uri=URI(Gameball.api_base+'/api'+'/'+Gameball.api_version+path)
|
37
|
+
# end
|
55
38
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
case verb.downcase
|
63
|
-
when "post"
|
64
|
-
req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})
|
39
|
+
end
|
40
|
+
req["APIKey"] = Gameball.api_key
|
41
|
+
res = https.request(req)
|
42
|
+
return res
|
43
|
+
end
|
65
44
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
45
|
+
def request_async(verb, path, body = {})
|
46
|
+
#check for api_version and key and throw exceptions
|
47
|
+
if !Gameball.api_key
|
48
|
+
raise Gameball::GameballError.new("Please provide the api_key before making a request, try Gameball::api_key='your_key'")
|
49
|
+
end
|
50
|
+
uri = URI(Gameball.api_base + "/api" + "/" + Gameball.api_version + path)
|
72
51
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
52
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
53
|
+
https.max_retries = Gameball.max_retries
|
54
|
+
https.read_timeout = Gameball.read_timeout
|
55
|
+
https.keep_alive_timeout = Gameball.keep_alive_timeout
|
56
|
+
https.use_ssl = true
|
57
|
+
|
58
|
+
case verb.downcase
|
59
|
+
when "post"
|
60
|
+
req = Net::HTTP::Post.new(uri.path, initheader = { "Content-Type" => "application/json" })
|
61
|
+
when "get"
|
62
|
+
req = Net::HTTP::Get.new(uri.path, initheader = { "Content-Type" => "application/json" })
|
63
|
+
when "put"
|
64
|
+
req = Net::HTTP::Put.new(uri.path, initheader = { "Content-Type" => "application/json" })
|
65
|
+
when "delete"
|
66
|
+
req = Net::HTTP::Delete.new(uri.path, initheader = { "Content-Type" => "application/json" })
|
67
|
+
else
|
68
|
+
puts "Please Provide a valid verb" # will later throw an exception
|
69
|
+
end
|
70
|
+
if body != {}
|
71
|
+
# puts body
|
72
|
+
# begin
|
73
|
+
req.body = body.to_json
|
74
|
+
# p req.body
|
75
|
+
# rescue JSON::ParserError => exception
|
98
76
|
|
99
|
-
end
|
77
|
+
# end
|
78
|
+
|
79
|
+
end
|
80
|
+
req["APIKey"] = Gameball.api_key
|
81
|
+
Thread.new do
|
82
|
+
res = https.request(req)
|
83
|
+
return res
|
84
|
+
p "I am in thread" + res.body
|
85
|
+
end
|
86
|
+
# thread.join
|
87
|
+
# return res
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|