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.
@@ -1,29 +1,37 @@
1
1
  module Gameball
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
- raise Gameball::GameballError.new(res.body) # use custom message
12
- else
13
- return true
14
- end
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
- def self.sendEvent_async (eventBody)
17
- Gameball::Utils.validate(eventBody,['events','playerUniqueId'],['playerAttributes'])
18
- if eventBody.has_key?(:playerAttributes)
19
- # Gameball::Utils.validate(eventBody[:playerAttributes],['displayName','firstName','lastName','email','gender','mobileNumber','dateOfBirth','joinDate'],['custom'])
20
- end
21
- res=Gameball::Utils::request_async("post","/integrations/event",eventBody)
22
- unless res.kind_of? Net::HTTPSuccess
23
- raise Gameball::GameballError.new(res.body) # use custom message
24
- else
25
- return true
26
- end
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
- 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
- raise Gameball::GameballError.new(res) # use custom message
17
- else
18
- return res
19
- end
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
- def self.get_player_info(playerUniqueId)
22
- body={playerUniqueId:playerUniqueId}
23
- body["bodyHashed"]=Gameball::Utils::hashBody(playerUniqueId:playerUniqueId)
24
- res=Gameball::Utils::request("post","/integrations/Player/Info",body)
25
- unless res.kind_of? Net::HTTPSuccess
26
- raise Gameball::GameballError.new(res) # use custom message
27
- else
28
- return res
29
- end
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
- 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
- raise Gameball::GameballError.new(res.body) # use custom message
11
- else
12
- return true
13
- end
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
- 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
- bodyHashed:hashedBody
8
- }
9
- res=Gameball::Utils::request("post","/integrations/transaction/balance",body)
10
- unless res.kind_of? Net::HTTPSuccess
11
- raise Gameball::GameballError.new(res.body) # use custom message
12
- else
13
- return res
14
- end
15
- end
16
- def self.hold_points(body)
17
- puts body
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
- body=Gameball::Utils::extractAttributesToHash(body)
22
- res=Gameball::Utils::request("post","/integrations/transaction/hold",body)
23
- unless res.kind_of? Net::HTTPSuccess
24
- raise Gameball::GameballError.new(res.body) # use custom message
25
- else
26
- return res
27
- end
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
- def self.redeem_points(body)
30
- # check if attributes are available
31
- Gameball::Utils.validate(body,['holdReference','playerUniqueId','amount','transactionOnClientSystemId','transactionTime'],[])
32
- body=Gameball::Utils::extractAttributesToHash(body)
33
- res=Gameball::Utils::request("post","/integrations/transaction/redeem",body)
34
- unless res.kind_of? Net::HTTPSuccess
35
- raise Gameball::GameballError.new(res.body) # use custom message
36
- else
37
- return res
38
- end
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
- def self.reverse_transaction(body)
41
- Gameball::Utils.validate(body,['reversedTransactionOnClientSystemId','playerUniqueId','transactionOnClientSystemId','transactionTime'],[])
42
- body=Gameball::Utils::extractAttributesToHash(body)
43
- res=Gameball::Utils::request("post","/integrations/transaction/cancel",body)
44
- unless res.kind_of? Net::HTTPSuccess
45
- raise Gameball::GameballError.new(res.body) # use custom message
46
- else
47
- return res
48
- end
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
- def self.reward_points(body)
51
- Gameball::Utils.validate(body,['playerUniqueId','amount','transactionOnClientSystemId','transactionTime'],['playerAttributes'])
52
- body=Gameball::Utils::extractAttributesToHash(body)
53
- res=Gameball::Utils::request("post","/integrations/transaction/reward",body)
54
- unless res.kind_of? Net::HTTPSuccess
55
- raise Gameball::GameballError.new(res.body) # use custom message
56
- else
57
- return true
58
- end
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
- def self.reverse_hold(body)
61
- # check if holdReference is in body else throw error
62
- Gameball::Utils.validate(body,['holdReference','playerUniqueId','transactionTime'],[])
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
- body=Gameball::Utils::extractAttributesToHash(body)
65
- res=Gameball::Utils::request("post","/integrations/transaction/hold",body)
66
- unless res.kind_of? Net::HTTPSuccess
67
- raise Gameball::GameballError.new(res.body) # use custom message
68
- else
69
- return res
70
- end
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
- module Utils
3
- extend self
4
- def hashBody(playerUniqueId:,transactionTime:"",amount:"")
5
- # Check if transaction Key is provided else raise Exc
6
- if !Gameball.transaction_key
7
- raise Gameball::GameballError.new("Please provide transaction_key, try Gameball::transaction_key='your_key'") # Raise exception
8
- else
9
- if transactionTime==""
10
- formatted_time=""
11
- else
12
- # begin
13
- formatted_time=transactionTime.strftime("%y%m%d%H%M%S")
14
- # rescue => exception
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
- rescue NoMethodError => exception
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
- module Utils
3
- extend self
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
- https = Net::HTTP.new(uri.host,uri.port)
12
- https.max_retries=Gameball.max_retries
13
- https.read_timeout=Gameball.read_timeout
14
- https.keep_alive_timeout=Gameball.keep_alive_timeout
15
- https.use_ssl = true
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
- when "get"
22
-
23
- req = Net::HTTP::Get.new(uri.path, initheader = {'Content-Type' =>'application/json'})
24
- when "put"
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
- when "delete"
29
- req = Net::HTTP::Delete.new(uri.path, initheader = {'Content-Type' =>'application/json'})
30
- else
31
- puts "Please Provide a valid verb" # will later throw an exception
32
- end
33
- if body != {}
34
- puts body
35
- # begin
36
- req.body=body.to_json
37
- p req.body
38
- # rescue JSON::ParserError => exception
39
-
40
- # end
41
-
42
- end
43
- req['APIKey']=Gameball.api_key
44
- res=https.request(req)
45
- return res
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
- def request_async(verb,path,body={})
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
- https = Net::HTTP.new(uri.host,uri.port)
57
- https.max_retries=Gameball.max_retries
58
- https.read_timeout=Gameball.read_timeout
59
- https.keep_alive_timeout=Gameball.keep_alive_timeout
60
- https.use_ssl = true
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
- when "get"
67
-
68
- req = Net::HTTP::Get.new(uri.path, initheader = {'Content-Type' =>'application/json'})
69
- when "put"
70
-
71
- req = Net::HTTP::Put.new(uri.path, initheader = {'Content-Type' =>'application/json'})
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
- when "delete"
74
- req = Net::HTTP::Delete.new(uri.path, initheader = {'Content-Type' =>'application/json'})
75
- else
76
- puts "Please Provide a valid verb" # will later throw an exception
77
- end
78
- if body != {}
79
- puts body
80
- # begin
81
- req.body=body.to_json
82
- p req.body
83
- # rescue JSON::ParserError => exception
84
-
85
- # end
86
-
87
- end
88
- req['APIKey']=Gameball.api_key
89
- Thread.new do
90
- res=https.request(req)
91
- return res
92
- p "I am in thread"+res.body
93
- end
94
- # thread.join
95
- # return res
96
- end
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