itunes_ingestion 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Gemfile.lock +12 -0
- data/README.rdoc +0 -0
- data/Rakefile +15 -0
- data/VERSION +1 -0
- data/lib/itunes_ingestion.rb +89 -0
- metadata +71 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.rdoc
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
require 'jeweler'
|
4
|
+
|
5
|
+
Jeweler::Tasks.new do |s|
|
6
|
+
s.name = "itunes_ingestion"
|
7
|
+
s.description = "A simple port of Apple itunes Autoingestion tool to ruby."
|
8
|
+
s.summary = "A simple port of Apple itunes Autoingestion tool to ruby."
|
9
|
+
s.authors = ["Francis Chong"]
|
10
|
+
s.email = "francis@ignition.hk"
|
11
|
+
s.homepage = "http://github.com/siuying/itunes-auto-ingestion"
|
12
|
+
s.files = FileList["[A-Z]*", "{bin,lib,spec}/**/*"]
|
13
|
+
s.test_files = FileList["{spec}/**/*"]
|
14
|
+
s.extra_rdoc_files = [ 'README.rdoc' ]
|
15
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'zlib'
|
3
|
+
class AutoIngestion
|
4
|
+
attr_reader :response
|
5
|
+
|
6
|
+
BASE_URL = "https://reportingitc.apple.com/autoingestion.tft?"
|
7
|
+
|
8
|
+
REPORT_TYPE_SALES = "Sales"
|
9
|
+
DATE_TYPE_DAILY = "Daily"
|
10
|
+
DATE_TYPE_WEEKLY = "Weekly"
|
11
|
+
|
12
|
+
REPORT_SUMMARY = "Summary"
|
13
|
+
REPORT_OPT_IN = "Opt-In"
|
14
|
+
|
15
|
+
PRODUCT_TYPE_IDENTIFIER = {
|
16
|
+
"1" => "Free or Paid Apps, iPhone and iPod Touch",
|
17
|
+
"7" => "Updates, iPhone and iPod Touch",
|
18
|
+
"IA1" => "In Apps Purchase",
|
19
|
+
"IA9" => "In Apps Subscription",
|
20
|
+
"IAY" => "Auto-Renewable Subscription",
|
21
|
+
"1F" => "Free or Paid Apps (Universal)",
|
22
|
+
"7F" => "Updates (Universal)",
|
23
|
+
"1T" => "Free or Paid Apps, iPad",
|
24
|
+
"7T" => "Updates, iPad",
|
25
|
+
"F1" => "Free or Paid Apps, Mac OS",
|
26
|
+
"F7" => "Updates, Mac OS",
|
27
|
+
"FI1" => "In Apps Purchase, Mac OS",
|
28
|
+
"1E" => "Custome iPhone and iPod Touch",
|
29
|
+
"1EP" => "Custome iPad",
|
30
|
+
"1EU" => "Custome Universal"
|
31
|
+
}
|
32
|
+
|
33
|
+
def initialize(username, password, vadnumber)
|
34
|
+
@username = username
|
35
|
+
@password = password
|
36
|
+
@vadnumber = vadnumber
|
37
|
+
end
|
38
|
+
|
39
|
+
def fetch(options={})
|
40
|
+
params = {
|
41
|
+
:USERNAME => @username, :PASSWORD => @password, :VNDNUMBER => @vadnumber
|
42
|
+
}
|
43
|
+
params[:TYPEOFREPORT] = options[:type_of_report] || REPORT_TYPE_SALES
|
44
|
+
params[:DATETYPE] = options[:date_type] || DATE_TYPE_DAILY
|
45
|
+
params[:REPORTTYPE] = options[:report_type] || REPORT_SUMMARY
|
46
|
+
params[:REPORTDATE] = options[:report_date] || (Time.now-60*60*24).strftime("%Y%m%d")
|
47
|
+
|
48
|
+
@response = RestClient.post BASE_URL, params
|
49
|
+
if @response.headers[:"errormsg"]
|
50
|
+
raise @response.headers[:"errormsg"]
|
51
|
+
elsif @response.headers[:"filename"]
|
52
|
+
report = Zlib::GzipReader.new(StringIO.new(@response.body)).read
|
53
|
+
parse_report(report)
|
54
|
+
else
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
def parse_report(report)
|
61
|
+
lines = report.split("\n")
|
62
|
+
header = lines.shift # remove first line
|
63
|
+
lines.collect do |line|
|
64
|
+
provider, country, sku, developer, title, version, product_type_id, units, developer_proceeds, begin_date, end_date, currency, country_code, currency_of_proceeds, apple_id, customer_price, promo_code, parent_id, subscription, period = line.split("\t")
|
65
|
+
{
|
66
|
+
:provider => provider.strip,
|
67
|
+
:country => country.strip,
|
68
|
+
:sku => sku.strip,
|
69
|
+
:developer => developer.strip,
|
70
|
+
:title => title.strip,
|
71
|
+
:version => version.strip,
|
72
|
+
:product_type_id => product_type_id.strip,
|
73
|
+
:units => units.to_i,
|
74
|
+
:developer_proceeds => developer_proceeds.to_f,
|
75
|
+
:begin_date => begin_date.strip,
|
76
|
+
:end_date => end_date.strip,
|
77
|
+
:currency => currency.strip,
|
78
|
+
:country_code => country_code.strip,
|
79
|
+
:currency_of_proceeds => currency_of_proceeds.strip,
|
80
|
+
:apple_id => apple_id.to_i,
|
81
|
+
:customer_price => customer_price.to_f,
|
82
|
+
:promo_code => promo_code.strip,
|
83
|
+
:parent_id => parent_id.strip,
|
84
|
+
:subscription => subscription.strip,
|
85
|
+
:period => period
|
86
|
+
}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: itunes_ingestion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Francis Chong
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-08-26 00:00:00 +08:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rest-client
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
description: A simple port of Apple itunes Autoingestion tool to ruby.
|
28
|
+
email: francis@ignition.hk
|
29
|
+
executables: []
|
30
|
+
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files:
|
34
|
+
- README.rdoc
|
35
|
+
files:
|
36
|
+
- Gemfile
|
37
|
+
- Gemfile.lock
|
38
|
+
- README.rdoc
|
39
|
+
- Rakefile
|
40
|
+
- VERSION
|
41
|
+
- lib/itunes_ingestion.rb
|
42
|
+
has_rdoc: true
|
43
|
+
homepage: http://github.com/siuying/itunes-auto-ingestion
|
44
|
+
licenses: []
|
45
|
+
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.6.2
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: A simple port of Apple itunes Autoingestion tool to ruby.
|
70
|
+
test_files: []
|
71
|
+
|