Class: PlayTime::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/play_time/client.rb

Defined Under Namespace

Classes: VersionCodeNotFound

Constant Summary collapse

TOKEN_URI =
'https://accounts.google.com/o/oauth2/token'.freeze
SCOPE =
'https://www.googleapis.com/auth/androidpublisher'.freeze
API =
'androidpublisher'.freeze
API_VERSION =
'v2'.freeze

Instance Method Summary collapse

Instance Method Details

#authorize!Object



15
16
17
18
# File 'lib/play_time/client.rb', line 15

def authorize!
  client.authorization = oauth2_client
  client.authorization.fetch_access_token!
end

#commit(track) ⇒ Object



20
21
22
23
24
25
# File 'lib/play_time/client.rb', line 20

def commit(track)
  create_insert
  version_code = upload_apk
  update_track(track, version_code)
  save
end

#update(track, version_code) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/play_time/client.rb', line 27

def update(track, version_code)
  create_insert
  old_track = get_old_track! version_code
  update_track(old_track.track, *old_track.versionCodes - [version_code])
  update_track(track, version_code)
  save
end