deliver 0.7.10 → 0.7.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -4
- data/lib/assets/DeliverLanguageMapping.json +167 -0
- data/lib/assets/DeliverfileDefault +1 -1
- data/lib/deliver.rb +0 -1
- data/lib/deliver/app.rb +2 -2
- data/lib/deliver/deliverfile/deliverfile_creator.rb +17 -12
- data/lib/deliver/itunes_connect/itunes_connect.rb +1 -0
- data/lib/deliver/itunes_connect/itunes_connect_screenshot_fetcher.rb +55 -0
- data/lib/deliver/version.rb +1 -1
- metadata +6 -5
- data/lib/deliver/itunes_search_api.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae2a7efba86742205dd2fc3e8da2190613b359f1
|
4
|
+
data.tar.gz: f8c901ab211e04c82a6c891487c1e4b85ca7926f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88989c941b95a4cf84cdd765c78c97449a8a71c2bc553d0fd24f937fc162aaaece7615766f67f340bb42b7de85cd2f88fd5363c26993d67b6fd4d8acbb45b196
|
7
|
+
data.tar.gz: 568c867e81a72391635f553636e797c3ff691c5953cf6861aa13d80026ca2354a963f1c8eed1bbd73913bcad6378557927a8c1d4a3ca596395958c7ba0108b2d
|
data/README.md
CHANGED
@@ -11,7 +11,9 @@
|
|
11
11
|
<a href="https://github.com/KrauseFx/frameit">frameit</a> •
|
12
12
|
<a href="https://github.com/KrauseFx/PEM">PEM</a> •
|
13
13
|
<a href="https://github.com/KrauseFx/sigh">sigh</a> •
|
14
|
-
<a href="https://github.com/KrauseFx/produce">produce</a>
|
14
|
+
<a href="https://github.com/KrauseFx/produce">produce</a> •
|
15
|
+
<a href="https://github.com/KrauseFx/cert">cert</a> •
|
16
|
+
<a href="https://github.com/KrauseFx/codes">codes</a>
|
15
17
|
</p>
|
16
18
|
-------
|
17
19
|
|
@@ -60,6 +62,8 @@ Get in contact with the developer on Twitter: [@KrauseFx](https://twitter.com/Kr
|
|
60
62
|
- Automatically create new screenshots with [Snapshot](https://github.com/KrauseFx/snapshot)
|
61
63
|
- Upload new builds to the new Apple TestFlight
|
62
64
|
|
65
|
+
##### [Like this tool? Be the first to know about updates and new fastlane tools](https://tinyletter.com/krausefx)
|
66
|
+
|
63
67
|
# Installation
|
64
68
|
|
65
69
|
Install the gem
|
@@ -125,8 +129,6 @@ The guide will create all the necessary files for you, using the existing app me
|
|
125
129
|
- Enjoy a good drink, while the computer does all the work for you
|
126
130
|
- When it's a new app: ```n```
|
127
131
|
|
128
|
-
Copy your screenshots into the ```deliver/screenshots/[language]``` folders (see [Available language codes](#available-language-codes))
|
129
|
-
|
130
132
|
From now on, you can run ```deliver``` to deploy a new update, or just upload new app metadata and screenshots.
|
131
133
|
|
132
134
|
### Customize the ```Deliverfile```
|
@@ -287,7 +289,7 @@ app.metadata.set_all_screenshots_from_path("./screenshots")
|
|
287
289
|
app.upload_metadata!
|
288
290
|
app.itc.submit_for_review!(app)
|
289
291
|
|
290
|
-
|
292
|
+
FastlaneCore::ItunesSearchApi.fetch_by_identifier("net.sunapps.15") # => Fetches public metadata
|
291
293
|
```
|
292
294
|
This project is well documented, check it out on [Rubydoc](http://www.rubydoc.info/github/KrauseFx/deliver/frames).
|
293
295
|
|
@@ -320,6 +322,10 @@ Before actually uploading anything to iTunes, ```Deliver``` will generate a [PDF
|
|
320
322
|
- [`PEM`](https://github.com/KrauseFx/pem): Automatically generate and renew your push notification profiles
|
321
323
|
- [`sigh`](https://github.com/KrauseFx/sigh): Because you would rather spend your time building stuff than fighting provisioning
|
322
324
|
- [`produce`](https://github.com/KrauseFx/produce): Create new iOS apps on iTunes Connect and Dev Portal using the command line
|
325
|
+
- [`cert`](https://github.com/KrauseFx/cert): Automatically create and maintain iOS code signing certificates
|
326
|
+
- [`codes`](https://github.com/KrauseFx/codes): Create promo codes for iOS Apps using the command line
|
327
|
+
|
328
|
+
##### [Like this tool? Be the first to know about updates and new fastlane tools](https://tinyletter.com/krausefx)
|
323
329
|
|
324
330
|
## Available language codes
|
325
331
|
```ruby
|
@@ -0,0 +1,167 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"locale": "cmn-Hans",
|
4
|
+
"name": "Simplified Chinese",
|
5
|
+
"game-center": true
|
6
|
+
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"locale": "cmn-Hant",
|
10
|
+
"name": "Traditional Chinese",
|
11
|
+
"game-center": true
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"locale": "da-DK",
|
15
|
+
"name": "Danish",
|
16
|
+
"game-center": true,
|
17
|
+
"alternatives": ["da"]
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"locale": "nl-NL",
|
21
|
+
"name": "Dutch",
|
22
|
+
"game-center": true,
|
23
|
+
"alternatives": ["nl"]
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"locale": "en-AU",
|
27
|
+
"name": "Australian English",
|
28
|
+
"game-center": false,
|
29
|
+
"readable-alternatives": ["English_Australian"]
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"locale": "en-CA",
|
33
|
+
"name": "Canadian English",
|
34
|
+
"game-center": false,
|
35
|
+
"readable-alternatives": ["English_CA"]
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"locale": "en-GB",
|
39
|
+
"name": "UK English",
|
40
|
+
"game-center": true,
|
41
|
+
"readable-alternatives": ["English_UK"]
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"locale": "en-US",
|
45
|
+
"name": "English",
|
46
|
+
"game-center": true
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"locale": "fi-FI",
|
50
|
+
"name": "Finnish",
|
51
|
+
"game-center": true,
|
52
|
+
"alternatives": ["fi"]
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"locale": "fr-CA",
|
56
|
+
"name": "Canadian French",
|
57
|
+
"game-center": false,
|
58
|
+
"readable-alternatives": ["French_CA"]
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"locale": "fr-FR",
|
62
|
+
"name": "French",
|
63
|
+
"game-center": true,
|
64
|
+
"alternatives": ["fr"]
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"locale": "de-DE",
|
68
|
+
"name": "German",
|
69
|
+
"game-center": true,
|
70
|
+
"alternatives": ["de"]
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"locale": "el-GR",
|
74
|
+
"name": "Greek",
|
75
|
+
"game-center": true,
|
76
|
+
"alternatives": ["el"]
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"locale": "id-ID",
|
80
|
+
"name": "Indonesian",
|
81
|
+
"game-center": true,
|
82
|
+
"alternatives": ["id"]
|
83
|
+
},
|
84
|
+
{
|
85
|
+
"locale": "it-IT",
|
86
|
+
"name": "Italian",
|
87
|
+
"game-center": true,
|
88
|
+
"alternatives": ["it"]
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"locale": "ja-JP",
|
92
|
+
"name": "Japanese",
|
93
|
+
"game-center": true,
|
94
|
+
"alternatives": ["ja"]
|
95
|
+
},
|
96
|
+
{
|
97
|
+
"locale": "ko-KR",
|
98
|
+
"name": "Korean",
|
99
|
+
"game-center": true,
|
100
|
+
"alternatives": ["ko"]
|
101
|
+
},
|
102
|
+
{
|
103
|
+
"locale": "ms-MY",
|
104
|
+
"name": "Malay",
|
105
|
+
"game-center": true,
|
106
|
+
"alternatives": ["ms"]
|
107
|
+
},
|
108
|
+
{
|
109
|
+
"locale": "no-NO",
|
110
|
+
"name": "Norwegian",
|
111
|
+
"game-center": true,
|
112
|
+
"alternatives": ["no"]
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"locale": "pt-BR",
|
116
|
+
"name": "Brazilian Portuguese",
|
117
|
+
"game-center": true
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"locale": "pt-PT",
|
121
|
+
"name": "Portuguese",
|
122
|
+
"game-center": true,
|
123
|
+
"alternatives": ["pt"]
|
124
|
+
},
|
125
|
+
{
|
126
|
+
"locale": "ru-RU",
|
127
|
+
"name": "Russian",
|
128
|
+
"game-center": true,
|
129
|
+
"alternatives": ["ru"]
|
130
|
+
},
|
131
|
+
{
|
132
|
+
"locale": "es-MX",
|
133
|
+
"name": "Mexican Spanish",
|
134
|
+
"game-center": false,
|
135
|
+
"readable-alternatives": ["Spanish_MX"]
|
136
|
+
},
|
137
|
+
{
|
138
|
+
"locale": "es-ES",
|
139
|
+
"name": "Spanish",
|
140
|
+
"game-center": true,
|
141
|
+
"alternatives": ["es"]
|
142
|
+
},
|
143
|
+
{
|
144
|
+
"locale": "sv-SE",
|
145
|
+
"name": "Swedish",
|
146
|
+
"game-center": true,
|
147
|
+
"alternatives": ["sv"]
|
148
|
+
},
|
149
|
+
{
|
150
|
+
"locale": "th-TH",
|
151
|
+
"name": "Thai",
|
152
|
+
"game-center": true,
|
153
|
+
"alternatives": ["th"]
|
154
|
+
},
|
155
|
+
{
|
156
|
+
"locale": "tr-TR",
|
157
|
+
"name": "Turkish",
|
158
|
+
"game-center": true,
|
159
|
+
"alternatives": ["tr"]
|
160
|
+
},
|
161
|
+
{
|
162
|
+
"locale": "vi-VI",
|
163
|
+
"name" : "Vietnamese",
|
164
|
+
"game-center": true,
|
165
|
+
"alternatives": ["vi"]
|
166
|
+
}
|
167
|
+
]
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# This folder has to include one folder for each language
|
13
13
|
# More information about automatic screenshot upload:
|
14
14
|
# https://github.com/KrauseFx/deliver#upload-screenshots-to-itunes-connect
|
15
|
-
screenshots_path "./
|
15
|
+
screenshots_path "./screenshots/"
|
16
16
|
|
17
17
|
|
18
18
|
# version '1.2' # you can pass this if you want to verify the version number with the ipa file
|
data/lib/deliver.rb
CHANGED
@@ -5,7 +5,6 @@ require 'deliver/app_metadata'
|
|
5
5
|
require 'deliver/metadata_item'
|
6
6
|
require 'deliver/app_screenshot'
|
7
7
|
require 'deliver/itunes_connect/itunes_connect'
|
8
|
-
require 'deliver/itunes_search_api'
|
9
8
|
require 'deliver/itunes_transporter'
|
10
9
|
require 'deliver/deliverfile/deliverfile'
|
11
10
|
require 'deliver/deliverfile/deliverfile_creator'
|
data/lib/deliver/app.rb
CHANGED
@@ -37,11 +37,11 @@ module Deliver
|
|
37
37
|
|
38
38
|
if apple_id and not app_identifier
|
39
39
|
# Fetch the app identifier based on the given Apple ID
|
40
|
-
self.app_identifier =
|
40
|
+
self.app_identifier = FastlaneCore::ItunesSearchApi.fetch_bundle_identifier(apple_id)
|
41
41
|
elsif app_identifier and not apple_id
|
42
42
|
# Fetch the Apple ID based on the given app identifier
|
43
43
|
begin
|
44
|
-
self.apple_id =
|
44
|
+
self.apple_id = FastlaneCore::ItunesSearchApi.fetch_by_identifier(app_identifier)['trackId']
|
45
45
|
rescue
|
46
46
|
unless Helper.is_test?
|
47
47
|
Helper.log.info "Could not find Apple ID based on the app identifier in the US App Store. Maybe the app is not yet in the store?".yellow
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'credentials_manager/password_manager'
|
2
2
|
require 'credentials_manager/appfile_config'
|
3
|
+
require 'deliver/itunes_connect/itunes_connect'
|
3
4
|
|
4
5
|
module Deliver
|
5
6
|
# Helps new user quickly adopt Deliver
|
@@ -45,8 +46,6 @@ module Deliver
|
|
45
46
|
example.gsub!("[[APP_NAME]]", project_name)
|
46
47
|
File.write(path, example)
|
47
48
|
|
48
|
-
FileUtils.mkdir_p './screenshots/'
|
49
|
-
|
50
49
|
puts "Successfully created new Deliverfile at '#{path}'".green
|
51
50
|
end
|
52
51
|
|
@@ -62,16 +61,28 @@ module Deliver
|
|
62
61
|
file_path = [deliver_path, Deliver::Deliverfile::Deliverfile::FILE_NAME].join('/')
|
63
62
|
json = generate_deliver_file(app, deliver_path, project_name)
|
64
63
|
File.write(file_path, json)
|
64
|
+
|
65
|
+
FileUtils.mkdir_p './screenshots/'
|
66
|
+
begin
|
67
|
+
Helper.log.info "Downloading all previously used app screenshots.".green
|
68
|
+
ItunesConnect.new.download_existing_screenshots(app)
|
69
|
+
rescue
|
70
|
+
Helper.log.error "Couldn't download already existing screenshots from iTunesConnect. You have to add them manually!".red
|
71
|
+
end
|
72
|
+
|
73
|
+
# Add a README to the screenshots folder
|
74
|
+
FileUtils.mkdir_p File.join(deliver_path, 'screenshots') # just in case the fetching didn't work
|
75
|
+
File.write(File.join(deliver_path, 'screenshots', 'README.txt'), File.read("#{Helper.gem_path('deliver')}/lib/assets/ScreenshotsHelp"))
|
65
76
|
|
66
|
-
|
77
|
+
Helper.log.info "Successfully created new Deliverfile at '#{file_path}'".green
|
67
78
|
end
|
68
79
|
|
69
80
|
private
|
70
81
|
# This method takes care of creating a new 'deliver' folder, containg the app metadata
|
71
82
|
# and screenshots folders
|
72
83
|
def self.generate_deliver_file(app, path, project_name)
|
73
|
-
metadata_path =
|
74
|
-
FileUtils.mkdir_p metadata_path
|
84
|
+
metadata_path = File.join(path, 'deliver')
|
85
|
+
FileUtils.mkdir_p metadata_path rescue nil # never mind if it's already there
|
75
86
|
|
76
87
|
json = create_json_based_on_xml(app, metadata_path)
|
77
88
|
|
@@ -79,15 +90,12 @@ module Deliver
|
|
79
90
|
json[key].delete(:version_whats_new)
|
80
91
|
end
|
81
92
|
|
82
|
-
meta_path = "
|
93
|
+
meta_path = File.join(metadata_path, "metadata.json")
|
83
94
|
File.write(meta_path, JSON.pretty_generate(json))
|
84
95
|
puts "Successfully created new metadata JSON file at '#{meta_path}'".green
|
85
96
|
|
86
97
|
gem_path = Helper.gem_path('deliver')
|
87
98
|
|
88
|
-
# Add a README to the screenshots folder
|
89
|
-
File.write("#{metadata_path}screenshots/README.txt", File.read("#{gem_path}/lib/assets/ScreenshotsHelp"))
|
90
|
-
|
91
99
|
# Generate the final Deliverfile here
|
92
100
|
deliver = File.read("#{gem_path}/lib/assets/DeliverfileDefault")
|
93
101
|
deliver.gsub!("[[APP_IDENTIFIER]]", app.app_identifier)
|
@@ -112,9 +120,6 @@ module Deliver
|
|
112
120
|
end
|
113
121
|
|
114
122
|
json[locale] = current
|
115
|
-
|
116
|
-
# Create an empty folder for the screenshots too
|
117
|
-
FileUtils.mkdir_p "#{path}screenshots/#{locale}/"
|
118
123
|
end
|
119
124
|
|
120
125
|
return json
|
@@ -7,6 +7,7 @@ require 'deliver/itunes_connect/itunes_connect_new_version'
|
|
7
7
|
require 'deliver/itunes_connect/itunes_connect_app_icon'
|
8
8
|
require 'deliver/itunes_connect/itunes_connect_app_rating'
|
9
9
|
require 'deliver/itunes_connect/itunes_connect_additional'
|
10
|
+
require 'deliver/itunes_connect/itunes_connect_screenshot_fetcher'
|
10
11
|
|
11
12
|
module Deliver
|
12
13
|
ItunesConnect = FastlaneCore::ItunesConnect
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
module FastlaneCore
|
4
|
+
# For all the information reading (e.g. version number)
|
5
|
+
class ItunesConnect
|
6
|
+
ALL_INFORMATION_URL = "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/version/"
|
7
|
+
|
8
|
+
# This method will download all existing app screenshots
|
9
|
+
# @param app (Deliver::App) the app you want this information from
|
10
|
+
# @raise [ItunesConnectGeneralError] General error while executing
|
11
|
+
# this action
|
12
|
+
# @raise [ItunesConnectLoginError] Login data is wrong
|
13
|
+
def download_existing_screenshots(app)
|
14
|
+
languages = JSON.parse(File.read(File.join(Helper.gem_path('deliver'), "lib", "assets", "DeliverLanguageMapping.json")))
|
15
|
+
|
16
|
+
begin
|
17
|
+
verify_app(app)
|
18
|
+
|
19
|
+
url = ALL_INFORMATION_URL + app.apple_id.to_s
|
20
|
+
|
21
|
+
# Turn off/on the async mode of jQuery
|
22
|
+
evaluate_script("jQuery.ajaxSetup({async:false});")
|
23
|
+
response = evaluate_script("$.get('#{url}').responseText")
|
24
|
+
evaluate_script("jQuery.ajaxSetup({async:true});")
|
25
|
+
|
26
|
+
raise "Could not fetch previously uploaded screenshots" unless response
|
27
|
+
|
28
|
+
data = JSON.parse(response)
|
29
|
+
screenshots = data['data']['details']['value'].each do |language_values|
|
30
|
+
language_code = languages.find { |a| a['name'] == language_values['language'] }
|
31
|
+
unless language_code
|
32
|
+
Helper.log.error "Could not find language information for language #{language_values['language']}".red
|
33
|
+
next
|
34
|
+
end
|
35
|
+
language_code = language_code['locale']
|
36
|
+
|
37
|
+
language_values['screenshots']['value'].each do |type, value|
|
38
|
+
value['value'].each do |screenshot|
|
39
|
+
url = screenshot['value']['url']
|
40
|
+
file_name = [screenshot['value']['sortOrder'], type, screenshot['value']['originalFileName']].join("_")
|
41
|
+
Helper.log.info "Downloading existing screenshot '#{file_name}' of device type: '#{type}'"
|
42
|
+
|
43
|
+
containing_folder = File.join(".", "screenshots", language_code)
|
44
|
+
FileUtils.mkdir_p containing_folder rescue nil # if it's already there
|
45
|
+
path = File.join(containing_folder, file_name)
|
46
|
+
File.write(path, open(url).read)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
rescue Exception => ex
|
51
|
+
error_occured(ex)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/deliver/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deliver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Krause
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastlane_core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.1.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.1.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,6 +204,7 @@ files:
|
|
204
204
|
- LICENSE
|
205
205
|
- README.md
|
206
206
|
- bin/deliver
|
207
|
+
- lib/assets/DeliverLanguageMapping.json
|
207
208
|
- lib/assets/DeliverfileDefault
|
208
209
|
- lib/assets/DeliverfileExample
|
209
210
|
- lib/assets/ScreenshotsHelp
|
@@ -228,8 +229,8 @@ files:
|
|
228
229
|
- lib/deliver/itunes_connect/itunes_connect_app_rating.rb
|
229
230
|
- lib/deliver/itunes_connect/itunes_connect_new_version.rb
|
230
231
|
- lib/deliver/itunes_connect/itunes_connect_reader.rb
|
232
|
+
- lib/deliver/itunes_connect/itunes_connect_screenshot_fetcher.rb
|
231
233
|
- lib/deliver/itunes_connect/itunes_connect_submission.rb
|
232
|
-
- lib/deliver/itunes_search_api.rb
|
233
234
|
- lib/deliver/itunes_transporter.rb
|
234
235
|
- lib/deliver/metadata_item.rb
|
235
236
|
- lib/deliver/pdf_generator.rb
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
|
3
|
-
module Deliver
|
4
|
-
# A wrapper around the Apple iTunes Search API to access app information like
|
5
|
-
# the app identifier of an app.
|
6
|
-
class ItunesSearchApi
|
7
|
-
|
8
|
-
# Fetch all information you can get from a specific AppleID of an app
|
9
|
-
# @param id (int) The AppleID of the given app. This usually consists of 9 digits.
|
10
|
-
# @return (Hash) the response of the first result from Apple (https://itunes.apple.com/lookup?id=284882215)
|
11
|
-
# @example Response of Facebook App: https://itunes.apple.com/lookup?id=284882215
|
12
|
-
# {
|
13
|
-
# ...
|
14
|
-
# artistName: "Facebook, Inc.",
|
15
|
-
# price: 0,
|
16
|
-
# version: "14.9",
|
17
|
-
# ...
|
18
|
-
# }
|
19
|
-
def self.fetch(id)
|
20
|
-
# Example: https://itunes.apple.com/lookup?id=284882215
|
21
|
-
fetch_url("https://itunes.apple.com/lookup?id=#{id.to_s}")
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.fetch_by_identifier(app_identifier)
|
25
|
-
# Example: http://itunes.apple.com/lookup?bundleId=net.sunapps.1
|
26
|
-
fetch_url("https://itunes.apple.com/lookup?bundleId=#{app_identifier}")
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
# This method only fetches the bundle identifier of a given app
|
31
|
-
# @param id (int) The AppleID of the given app. This usually consists of 9 digits.
|
32
|
-
# @return (String) the Bundle identifier of the app
|
33
|
-
def self.fetch_bundle_identifier(id)
|
34
|
-
self.fetch(id)['bundleId']
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
def self.fetch_url(url)
|
39
|
-
response = JSON.parse(open(url).read)
|
40
|
-
return nil if response['resultCount'] == 0
|
41
|
-
|
42
|
-
return response['results'].first
|
43
|
-
rescue
|
44
|
-
Helper.log.error "Could not find object '#{url}' using the iTunes API"
|
45
|
-
nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|