alphaSDK 0.0.3 → 0.1.0

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,38 +1,39 @@
1
1
  module Gameball
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
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
16
29
 
17
- # end
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
18
35
  end
19
- end
20
- str = playerUniqueId + ":" + formatted_time + ":" + amount.to_s + ":" + Gameball.transaction_key
21
- # puts str
22
- return Digest::SHA1.hexdigest (str)
23
- end
36
+
24
37
 
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
36
38
  end
37
- end
38
- end
39
+ end
@@ -1,90 +1,99 @@
1
1
  module Gameball
2
- module Utils
3
- extend self
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)
4
10
 
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)
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'})
11
20
 
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
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'})
17
27
 
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
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
36
48
 
37
- # end
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)
38
55
 
39
- end
40
- req["APIKey"] = Gameball.api_key
41
- res = https.request(req)
42
- return res
43
- end
44
-
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)
51
-
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
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'})
57
65
 
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
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'})
76
72
 
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
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
88
97
  end
89
- end
90
- end
98
+
99
+ end
@@ -1,18 +1,18 @@
1
1
  module Gameball
2
2
  module Utils
3
3
  extend self
4
-
5
- def validate(hash, required, optional)
6
- errors = []
7
- required.each do |val|
8
- raise Gameball::GameballError.new("Required key: #{val.to_sym.inspect}") unless hash.has_key?(val.to_sym)
9
- end
10
- optional = optional + required
11
- hash.each_key do |val|
12
- unless optional.include?(val.to_s)
13
- raise Gameball::GameballError.new("Unknown key: #{val.to_sym.inspect}. Valid keys are: #{optional.map(&:inspect).join(", ")}")
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
14
14
  end
15
15
  end
16
- end
17
16
  end
18
17
  end
18
+
data/lib/testFile.rb ADDED
@@ -0,0 +1,87 @@
1
+ require_relative './gameball'
2
+ Gameball::api_key="7c7636658209418c9a82306a421f76a5"
3
+ Gameball::api_version="v2.0"
4
+ Gameball::transaction_key="26e1967d89114388bdd1772587c336c8"
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
+ }})
11
+ # res=Gameball::Transaction.hold_points({
12
+ # playerUniqueId:"uniqueKey00",
13
+ # amount:2,
14
+ # transactionTime:Time.now.utc
15
+ # })
16
+ # res=Gameball::Transaction.redeem_points({
17
+ # holdReference:"c61153e4-fc79-4b1c-adce-f789bc061fe9",
18
+ # playerUniqueId:"uniqueKey00",
19
+ # amount:2,
20
+ # transactionOnClientSystemId:12,
21
+ # transactionTime:Time.now.utc
22
+ # })
23
+ # res=Gameball::Transaction.reverse_transaction({
24
+ # playerUniqueId:"uniqueKey00",
25
+ # transactionOnClientSystemId:12,
26
+ # reversedTransactionOnClientSystemId:12,
27
+ # transactionTime:Time.now.utc
28
+ # })
29
+ # res=Gameball::Transaction.reverse_hold({
30
+ # playerUniqueId:"uniqueKey00",
31
+ # holdReference:"80144eaa-8e5b-4c6b-8f4d-58f0d8766797",
32
+ # transactionTime:Time.now.utc
33
+ # })
34
+
35
+ # res=Gameball::Referral.create_referral({
36
+ # playerCode:"CODE11",
37
+ # playerUniqueId:"player456"
38
+ # }
39
+ # )
40
+ # res=Gameball::Player.get_player_info("uniqueKey00")
41
+ # res=Gameball::Transaction.reward_points({
42
+ # playerUniqueId:"uniqueKey00",
43
+ # amount:100,
44
+ # transactionTime:Time.now.utc,
45
+ # transactionOnClientSystemId:"1232344",
46
+
47
+ # })
48
+ # res=Gameball::Event.sendEvent({
49
+ # events:{
50
+ # reserve:{
51
+ # rooms:2
52
+ # }
53
+ # },
54
+ # playerUniqueId:" player123",
55
+ # playerAttributes:{
56
+ # displayName:" Jon Snow",
57
+ # email:"jon.snow@example.com",
58
+ # dateOfBirth:"1980-09-19T00:00:00.000Z",
59
+ # joinDate:"2019-09-19T21:06:29.158Z",
60
+ # custom:{
61
+ # location:"Miami",
62
+ # graduationDate:"2018-07-04T21:06:29.158Z",
63
+ # isMarried:false
64
+ # }
65
+
66
+ # }
67
+ # }
68
+
69
+
70
+ # )
71
+ # res=Gameball::Event.sendEvent({
72
+ # events:{view_product_page:{customer_id:"123",product_id:"123",product_title:"title",product_vendor:"vendor",shop_name:"shop"}},
73
+ # playerUniqueId:"uniquekeys120",
74
+ # playerAttributes:{displayName:"Souidan",firstName:"Souidan1",lastName:"Souidan2",email:"alisouidan1@gmail.com",gender:"Male",mobileNumber:"+201002580909",dateOfBirth:"0123",joinDate:Time.now.utc}
75
+ # })
76
+ p res.body
77
+ # p res
78
+ # # puts Gameball::Helper::hashBody(playerUniqueId:"123",transactionId:"34",transactionTime:Time.now.utc)
79
+ # res=Gameball::Event.sendEvent({
80
+ # events:{view_product_page:{customer_id:"123",product_id:"123",product_title:"title",product_vendor:"vendor",shop_name:"shop"}},
81
+ # playerUniqueId:"uinqueKeys123"
82
+ # }) #Check the sinatra server window for the output.
83
+ # p res
84
+ # sleep 5 #Do some time consuming task.
85
+ # p res
86
+ # puts "Sending response..."
87
+ # #The response(which the rails app ignores).
metadata CHANGED
@@ -1,53 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alphaSDK
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Alsouidan
7
+ - Souidan
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-11 00:00:00.000000000 Z
11
+ date: 2020-07-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
14
- email:
15
- - alsouidan@gmail.com
13
+ description: SDK
14
+ email: alsouidan@gmail.com
16
15
  executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
20
- - ".gitignore"
21
- - ".rspec"
22
- - ".travis.yml"
23
- - CODE_OF_CONDUCT.md
24
- - Gemfile
25
- - Gemfile.lock
26
- - LICENSE.txt
27
- - README.md
28
- - Rakefile
29
- - bin/console
30
- - bin/setup
31
- - gameball.gemspec
32
19
  - lib/gameball.rb
33
20
  - lib/gameball/exceptions/gameballException.rb
34
21
  - lib/gameball/models/action.rb
35
22
  - lib/gameball/models/coupon.rb
36
23
  - lib/gameball/models/event.rb
24
+ - lib/gameball/models/gameballResponse.rb
37
25
  - lib/gameball/models/player.rb
38
26
  - lib/gameball/models/referral.rb
39
27
  - lib/gameball/models/transaction.rb
40
28
  - lib/gameball/utils/helper.rb
41
29
  - lib/gameball/utils/request.rb
42
30
  - lib/gameball/utils/validation.rb
43
- - lib/gameball/version.rb
44
- homepage: http://mygemserver.com
31
+ - lib/testFile.rb
32
+ homepage: https://rubygems.org/gems/hola
45
33
  licenses:
46
34
  - MIT
47
- metadata:
48
- homepage_uri: http://mygemserver.com
49
- source_code_uri: http://mygemserver.com
50
- changelog_uri: http://mygemserver.com
35
+ metadata: {}
51
36
  post_install_message:
52
37
  rdoc_options: []
53
38
  require_paths:
@@ -56,7 +41,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
41
  requirements:
57
42
  - - ">="
58
43
  - !ruby/object:Gem::Version
59
- version: 2.3.0
44
+ version: '0'
60
45
  required_rubygems_version: !ruby/object:Gem::Requirement
61
46
  requirements:
62
47
  - - ">="
@@ -66,5 +51,5 @@ requirements: []
66
51
  rubygems_version: 3.0.3
67
52
  signing_key:
68
53
  specification_version: 4
69
- summary: Ruby gem
54
+ summary: Test
70
55
  test_files: []