poke-go-api 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d6420e1aade6708df823d2b829b9373700e6e6c
4
- data.tar.gz: d32155e58a4e2ee523ad9f2bb95918c77a60cccc
3
+ metadata.gz: edcbf91a753d6de2dca22476e90170a4b7a5eede
4
+ data.tar.gz: a37f12e9e92a30701e2854bd8f9c895264611278
5
5
  SHA512:
6
- metadata.gz: c27ed287d74eed85335f9015ec5707faa3001d89821ef9ad993cb7376b88c9929ccc0179e271f3ef7aa68048f12745a29f998148dfb15897d465c84f64774ce1
7
- data.tar.gz: b74ae692e0f3e2562efa7aa34e4b8894eb4787b947a127c9d74903a172b75fee4bac9212272f9ffcad8bc59cf478cb8aebaaafaa7bda3f4c8cb9b0edaa0d0bc6
6
+ metadata.gz: 6140ba8ffa02732f18497a42d5e09d7c4355f67a6a02700d6814cbf88a673a15bd267c96b2a783b7256e12884f2b77f7801a0d5b2bc8f835f5d5878a247f3afe
7
+ data.tar.gz: 9363b5ccf97b224f322f723e70d7f948ae229c44cb45abda08a63e89ffb70954db88de657ebf6948bdfe49dd3ac08d359640defdda79500fe56ba310ffa568d1
@@ -15,7 +15,7 @@ module Poke
15
15
 
16
16
  def login(username, password, provider)
17
17
  provider = provider.upcase
18
- raise Errors::InvalidProvider.new(provider) unless ['PTC', 'GOOGLE'].include?(provider)
18
+ raise Errors::InvalidProvider, provider unless %w(PTC GOOGLE).include?(provider)
19
19
  logger.info "[+] Logging in user: #{username}"
20
20
 
21
21
  begin
@@ -30,13 +30,13 @@ module Poke
30
30
  end
31
31
 
32
32
  def call
33
- raise Errors::LoginRequired.new unless @auth
33
+ raise Errors::LoginRequired unless @auth
34
34
  req = RequestBuilder.new(@auth, [@lat, @lng, @alt], @endpoint)
35
35
 
36
36
  begin
37
37
  resp = req.request(@reqs)
38
38
  rescue StandardError => ex
39
- raise Errors::UnknownProtoFault.new(ex)
39
+ raise Errors::UnknownProtoFault, ex
40
40
  ensure
41
41
  @reqs = []
42
42
  logger.info '[+] Cleaning up RPC requests'
@@ -50,7 +50,14 @@ module Poke
50
50
  logger.info "[+] Given location: #{pos.address}"
51
51
 
52
52
  logger.info "[+] Lat/Long: #{pos.latitude}, #{pos.longitude}"
53
- @lat, @lng = pos.latitude, pos.longitude
53
+ @lat = pos.latitude
54
+ @lng = pos.longitude
55
+ end
56
+
57
+ def store_lat_lng(lat, lng)
58
+ logger.info "[+] Lat/Long: #{lat}, #{lng}"
59
+ @lat = lat
60
+ @lng = lng
54
61
  end
55
62
 
56
63
  def inspect
@@ -67,17 +74,22 @@ module Poke
67
74
  check_awarded_badges
68
75
  download_settings(hash: '4a2e9bc330dae60e7b74fc85b98868ab4700802e')
69
76
 
70
- @endpoint = "https://#{call.response[:api_url]}/rpc"
77
+ resp = call.response
78
+
79
+ if !resp[:api_url] && resp[:api_url].empty?
80
+ logger.debug '[+] Login failed, please try again'
81
+ return
82
+ end
83
+
84
+ @endpoint = "https://#{resp[:api_url]}/rpc"
71
85
  logger.debug "[+] Setting endpoint to #{@endpoint}"
72
86
  end
73
87
 
74
88
  def method_missing(method, *args)
75
- begin
76
- POGOProtos::Networking::Requests::RequestType.const_get(method.upcase)
77
- @reqs << (args.empty? ? method.to_sym.upcase : { method.to_sym.upcase => args.first })
78
- rescue NameError
79
- super
80
- end
89
+ POGOProtos::Networking::Requests::RequestType.const_get(method.upcase)
90
+ @reqs << (args.empty? ? method.to_sym.upcase : { method.to_sym.upcase => args.first })
91
+ rescue NameError
92
+ super
81
93
  end
82
94
  end
83
95
  end
@@ -1,5 +1,5 @@
1
1
  module Poke
2
2
  module API
3
- VERSION = '0.0.6'.freeze
3
+ VERSION = '0.0.7'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poke-go-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nabeel Amjad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-22 00:00:00.000000000 Z
11
+ date: 2016-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient