alphaSDK 0.1.0 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,39 +1,35 @@
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
29
4
 
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
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
- 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 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
- 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
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
- 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'})
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
- 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
+ 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
- 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
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
- def validate (hash,required,optional)
5
- errors=[]
6
- required.each do |val|
7
- raise Gameball::GameballError.new("Required key: #{val.to_sym.inspect}") unless hash.has_key?(val.to_sym)
8
- end
9
- optional=optional+required
10
- hash.each_key do |val|
11
- unless optional.include?(val.to_s)
12
- raise Gameball::GameballError.new("Unknown key: #{val.to_sym.inspect}. Valid keys are: #{optional.map(&:inspect).join(', ')}")
13
- end
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
-
@@ -0,0 +1,3 @@
1
+ module Gameball
2
+ VERSION = "0.2.7" # Version of the SDK
3
+ end
@@ -1,13 +1,22 @@
1
- require_relative './gameball'
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
- {displayName:"Souidan",firstName:"Souidan1",lastName:"Souidan2",email:"alisouidan@gmail.com",
8
- gender:"Male",mobileNumber:"+201002580909",
9
- dateOfBirth:Date.parse("10/10/2010"),joinDate:Time.now.utc
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
- # transactionOnClientSystemId:12,
29
+ # transactionId:12,
21
30
  # transactionTime:Time.now.utc
22
31
  # })
23
32
  # res=Gameball::Transaction.reverse_transaction({
24
33
  # playerUniqueId:"uniqueKey00",
25
- # transactionOnClientSystemId:12,
26
- # reversedTransactionOnClientSystemId:12,
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
- # transactionOnClientSystemId:"1232344",
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.1.0
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
- - Souidan
7
+ - Alsouidan
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-28 00:00:00.000000000 Z
12
- dependencies: []
13
- description: SDK
14
- email: alsouidan@gmail.com
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: https://rubygems.org/gems/hola
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: '0'
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: Test
99
+ summary: Ruby gem
55
100
  test_files: []