alphaSDK 0.1.0 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,39 +1,35 @@
|
|
1
1
|
module Gameball
|
2
|
-
|
3
|
-
|
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
|
29
4
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
5
|
+
def hashBody(playerUniqueId:, transactionTime: "", amount: "") # Helper method that hashes the attributes that are sent using SHA1 algorithm
|
6
|
+
# Check if transaction Key is provided else raise Error
|
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
|
+
formatted_time = transactionTime.strftime("%y%m%d%H%M%S")
|
35
14
|
end
|
36
|
-
|
15
|
+
end
|
16
|
+
|
17
|
+
str = playerUniqueId + ":" + formatted_time + ":" + amount.to_s + ":" + Gameball.transaction_key
|
18
|
+
return Digest::SHA1.hexdigest (str)
|
19
|
+
end
|
20
|
+
|
21
|
+
def extractAttributesToHash(body) # Helper method that extracts the attributes from the body and pass it to hashing function
|
22
|
+
playerUniqueId = body[:playerUniqueId]
|
23
|
+
amount = body[:amount]
|
24
|
+
transactionTime = body[:transactionTime]
|
25
|
+
begin
|
26
|
+
body[:transactionTime] = transactionTime.iso8601
|
27
|
+
rescue NoMethodError => exception
|
28
|
+
raise Gameball::GameballError.new("Invalid Date Formate, Please use Date and Time objects")
|
29
|
+
end
|
37
30
|
|
31
|
+
body["hash"] = Gameball::Utils::hashBody(playerUniqueId: playerUniqueId, amount: (amount || ""), transactionTime: (transactionTime || ""))
|
32
|
+
body
|
38
33
|
end
|
39
|
-
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,99 +1,73 @@
|
|
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 error if not included
|
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
|
48
|
-
|
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)
|
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
|
+
req.body = body.to_json
|
32
|
+
end
|
33
|
+
req["APIKey"] = Gameball.api_key
|
34
|
+
res = https.request(req)
|
35
|
+
return res
|
36
|
+
end
|
55
37
|
|
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'})
|
38
|
+
def request_async(verb, path, body = {})
|
39
|
+
#check for api_version and key and throw exceptions
|
40
|
+
if !Gameball.api_key
|
41
|
+
raise Gameball::GameballError.new("Please provide the api_key before making a request, try Gameball::api_key='your_key'")
|
42
|
+
end
|
43
|
+
uri = URI(Gameball.api_base + "/api" + "/" + Gameball.api_version + path)
|
65
44
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
req = Net::HTTP::Put.new(uri.path, initheader = {'Content-Type' =>'application/json'})
|
45
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
46
|
+
https.max_retries = Gameball.max_retries
|
47
|
+
https.read_timeout = Gameball.read_timeout
|
48
|
+
https.keep_alive_timeout = Gameball.keep_alive_timeout
|
49
|
+
https.use_ssl = true
|
72
50
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
end
|
94
|
-
# thread.join
|
95
|
-
# return res
|
96
|
-
end
|
51
|
+
case verb.downcase
|
52
|
+
when "post"
|
53
|
+
req = Net::HTTP::Post.new(uri.path, initheader = { "Content-Type" => "application/json" })
|
54
|
+
when "get"
|
55
|
+
req = Net::HTTP::Get.new(uri.path, initheader = { "Content-Type" => "application/json" })
|
56
|
+
when "put"
|
57
|
+
req = Net::HTTP::Put.new(uri.path, initheader = { "Content-Type" => "application/json" })
|
58
|
+
when "delete"
|
59
|
+
req = Net::HTTP::Delete.new(uri.path, initheader = { "Content-Type" => "application/json" })
|
60
|
+
else
|
61
|
+
puts "Please Provide a valid verb" # will later throw an exception
|
62
|
+
end
|
63
|
+
if body != {}
|
64
|
+
req.body = body.to_json
|
65
|
+
end
|
66
|
+
req["APIKey"] = Gameball.api_key
|
67
|
+
Thread.new do
|
68
|
+
res = https.request(req)
|
69
|
+
return res
|
70
|
+
end
|
97
71
|
end
|
98
|
-
|
99
|
-
end
|
72
|
+
end
|
73
|
+
end
|
@@ -1,18 +1,20 @@
|
|
1
1
|
module Gameball
|
2
2
|
module Utils
|
3
3
|
extend self
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
|
5
|
+
def validate(hash, required, optional) # Method used to validate body parameters by checking optional fields and required fields
|
6
|
+
errors = []
|
7
|
+
# Loop on required fields and throw error if field is not in ruby hash
|
8
|
+
required.each do |val|
|
9
|
+
raise Gameball::GameballError.new("Required key: #{val.to_sym.inspect}") unless hash.has_key?(val.to_sym)
|
10
|
+
end
|
11
|
+
allowed = optional + required
|
12
|
+
# Loop on each field in ruby hash and check if it is allowed
|
13
|
+
hash.each_key do |val|
|
14
|
+
unless allowed.include?(val.to_s)
|
15
|
+
raise Gameball::GameballError.new("Unknown key: #{val.to_sym.inspect}. Valid keys are: #{allowed.map(&:inspect).join(", ")}")
|
14
16
|
end
|
15
17
|
end
|
18
|
+
end
|
16
19
|
end
|
17
20
|
end
|
18
|
-
|
data/lib/testFile.rb
CHANGED
@@ -1,13 +1,22 @@
|
|
1
|
-
require_relative
|
2
|
-
Gameball::api_key="7c7636658209418c9a82306a421f76a5"
|
3
|
-
Gameball::api_version="v2.0"
|
4
|
-
Gameball::transaction_key="26e1967d89114388bdd1772587c336c8"
|
1
|
+
require_relative "./gameball"
|
2
|
+
Gameball::api_key = "7c7636658209418c9a82306a421f76a5"
|
3
|
+
Gameball::api_version = "v2.0"
|
4
|
+
Gameball::transaction_key = "26e1967d89114388bdd1772587c336c8"
|
5
5
|
# res=Gameball::Transaction.get_player_balance("uniqueKey00")
|
6
|
-
res=Gameball::Player.initialize_player({playerUniqueId:"uniquekeys120",playerAttributes:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
# res = Gameball::Player.initialize_player({ playerUniqueId: "uniquekeys120", playerAttributes: { displayName: "Souidan", firstName: "Souidan1", lastName: "Souidan2", email: "alisouidan@gmail.com",
|
7
|
+
# gender: "Male", mobileNumber: "+201002580909",
|
8
|
+
# dateOfBirth: Date.parse("10/10/2010"), joinDate: Time.now.utc } })
|
9
|
+
res= Gameball::Action.send_action({ playerUniqueId: "player123",events:{
|
10
|
+
review:{},
|
11
|
+
reserve:{rooms:2}
|
12
|
+
|
13
|
+
},
|
14
|
+
pointsTransaction:{
|
15
|
+
rewardAmount:2,
|
16
|
+
transactionId:12
|
17
|
+
}
|
18
|
+
}
|
19
|
+
)
|
11
20
|
# res=Gameball::Transaction.hold_points({
|
12
21
|
# playerUniqueId:"uniqueKey00",
|
13
22
|
# amount:2,
|
@@ -17,13 +26,13 @@ res=Gameball::Player.initialize_player({playerUniqueId:"uniquekeys120",playerAtt
|
|
17
26
|
# holdReference:"c61153e4-fc79-4b1c-adce-f789bc061fe9",
|
18
27
|
# playerUniqueId:"uniqueKey00",
|
19
28
|
# amount:2,
|
20
|
-
#
|
29
|
+
# transactionId:12,
|
21
30
|
# transactionTime:Time.now.utc
|
22
31
|
# })
|
23
32
|
# res=Gameball::Transaction.reverse_transaction({
|
24
33
|
# playerUniqueId:"uniqueKey00",
|
25
|
-
#
|
26
|
-
#
|
34
|
+
# transactionId:12,
|
35
|
+
# reversedTransactionId:12,
|
27
36
|
# transactionTime:Time.now.utc
|
28
37
|
# })
|
29
38
|
# res=Gameball::Transaction.reverse_hold({
|
@@ -42,7 +51,7 @@ res=Gameball::Player.initialize_player({playerUniqueId:"uniquekeys120",playerAtt
|
|
42
51
|
# playerUniqueId:"uniqueKey00",
|
43
52
|
# amount:100,
|
44
53
|
# transactionTime:Time.now.utc,
|
45
|
-
#
|
54
|
+
# transactionId:"1232344",
|
46
55
|
|
47
56
|
# })
|
48
57
|
# res=Gameball::Event.sendEvent({
|
@@ -62,11 +71,10 @@ res=Gameball::Player.initialize_player({playerUniqueId:"uniquekeys120",playerAtt
|
|
62
71
|
# graduationDate:"2018-07-04T21:06:29.158Z",
|
63
72
|
# isMarried:false
|
64
73
|
# }
|
65
|
-
|
74
|
+
|
66
75
|
# }
|
67
76
|
# }
|
68
77
|
|
69
|
-
|
70
78
|
# )
|
71
79
|
# res=Gameball::Event.sendEvent({
|
72
80
|
# events:{view_product_page:{customer_id:"123",product_id:"123",product_title:"title",product_vendor:"vendor",shop_name:"shop"}},
|
metadata
CHANGED
@@ -1,38 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alphaSDK
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Alsouidan
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
11
|
+
date: 2020-08-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '12.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '12.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- alsouidan@gmail.com
|
15
44
|
executables: []
|
16
45
|
extensions: []
|
17
46
|
extra_rdoc_files: []
|
18
47
|
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
50
|
+
- ".travis.yml"
|
51
|
+
- CODE_OF_CONDUCT.md
|
52
|
+
- Gemfile
|
53
|
+
- Gemfile.lock
|
54
|
+
- LICENSE.txt
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- bin/console
|
58
|
+
- bin/setup
|
59
|
+
- examples.rb
|
60
|
+
- gameball.gemspec
|
19
61
|
- lib/gameball.rb
|
20
62
|
- lib/gameball/exceptions/gameballException.rb
|
21
63
|
- lib/gameball/models/action.rb
|
22
64
|
- lib/gameball/models/coupon.rb
|
23
65
|
- lib/gameball/models/event.rb
|
24
|
-
- lib/gameball/models/gameballResponse.rb
|
25
66
|
- lib/gameball/models/player.rb
|
26
67
|
- lib/gameball/models/referral.rb
|
27
68
|
- lib/gameball/models/transaction.rb
|
28
69
|
- lib/gameball/utils/helper.rb
|
29
70
|
- lib/gameball/utils/request.rb
|
30
71
|
- lib/gameball/utils/validation.rb
|
72
|
+
- lib/gameball/version.rb
|
31
73
|
- lib/testFile.rb
|
32
|
-
homepage:
|
74
|
+
homepage: http://mygemserver.com
|
33
75
|
licenses:
|
34
76
|
- MIT
|
35
|
-
metadata:
|
77
|
+
metadata:
|
78
|
+
homepage_uri: http://mygemserver.com
|
79
|
+
source_code_uri: http://mygemserver.com
|
80
|
+
changelog_uri: http://mygemserver.com
|
36
81
|
post_install_message:
|
37
82
|
rdoc_options: []
|
38
83
|
require_paths:
|
@@ -41,7 +86,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
86
|
requirements:
|
42
87
|
- - ">="
|
43
88
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
89
|
+
version: 2.3.0
|
45
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
91
|
requirements:
|
47
92
|
- - ">="
|
@@ -51,5 +96,5 @@ requirements: []
|
|
51
96
|
rubygems_version: 3.0.3
|
52
97
|
signing_key:
|
53
98
|
specification_version: 4
|
54
|
-
summary:
|
99
|
+
summary: Ruby gem
|
55
100
|
test_files: []
|