itunes-sales-client 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +89 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/itunes-sales-client.gemspec +26 -0
- data/lib/analytics/client.rb +77 -0
- data/lib/itunes-sales-client/version.rb +3 -0
- data/lib/itunes-sales-client.rb +10 -0
- data/lib/sales/client.rb +52 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 95c9d20519eaca81e7e50b9e1e6dd4aa24801e29
|
4
|
+
data.tar.gz: 9b64864f0892b522a67d0240a85955df6f3f5dae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0f271ac4bdf14eb4d02c9e9d2d16df38a132fc42f7f1094543ee54dcec9f57fcfd222993424c5986059ccaa704b5d50829ad0e670eca74bce0c11e31876bf0bd
|
7
|
+
data.tar.gz: 319c71e6d85aef8c9b9d060c0574c95afa584598dce703641c9097d9b5287ed7b6d47af61d9bf50f039afc1d90db8bcfb6ae7c508946961d66acbef371ffb897
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Sadik Ay
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# Itunes Sales & Analytics Client
|
2
|
+
|
3
|
+
A [fastlane](https://github.com/fastlane/fastlane) extension gem to get apps sales and analytics reports from itunes connect.
|
4
|
+
Get multiple apps reports with single request.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add these lines to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'fastlane'
|
12
|
+
gem 'itunes-sales-client', '~> 1.0.0'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
### Sales
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
# Assign the apps itunes ids to an array
|
24
|
+
ids = ["1234567..", "1234567..", "1234567.."]
|
25
|
+
sales = Spaceship::SalesClient.login("username", "password")
|
26
|
+
result = sales.get_data(ids, Date.today - 3.day, Date.today - 1.day)
|
27
|
+
|
28
|
+
=>
|
29
|
+
[{"metadata"=>{"key"=>"1234567..", "title"=>"Title",
|
30
|
+
...
|
31
|
+
{"date"=>"2017-05-21", "total_tax_usd_utc"=>1.733, "units_utc"=>1, "Royalty_utc"=>1.182}
|
32
|
+
...
|
33
|
+
}]
|
34
|
+
```
|
35
|
+
### Analytics
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
analytics = Spaceship::AnalyticsClient.login("username", "password")
|
39
|
+
data = analytics.get_units("itunes_id", Date.today - 3.day, Date.today - 1.day)
|
40
|
+
|
41
|
+
=>
|
42
|
+
{
|
43
|
+
"size"=>1,
|
44
|
+
"results"=>[
|
45
|
+
{
|
46
|
+
"adamId"=> "asdf12345",
|
47
|
+
"meetsThreshold"=> true,
|
48
|
+
"group"=> nil,
|
49
|
+
"data"=> [
|
50
|
+
{
|
51
|
+
"date" => "2017-07-15T00:00:00Z",
|
52
|
+
"units" => 2.0
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"date" => "2017-07-16T00:00:00Z",
|
56
|
+
"units" => 1.0
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"date" => "2017-07-17T00:00:00Z",
|
60
|
+
"units"=> 3.0
|
61
|
+
}
|
62
|
+
],
|
63
|
+
"totals" =>
|
64
|
+
{
|
65
|
+
"value" => 6.0,
|
66
|
+
"type" => "COUNT",
|
67
|
+
"key" => "units"
|
68
|
+
}
|
69
|
+
}
|
70
|
+
]
|
71
|
+
}
|
72
|
+
|
73
|
+
# available analytics options:
|
74
|
+
data = analytics.get_units("itunes_id", start_time, end_time)
|
75
|
+
data = analytics.get_page_view_count("itunes_id", start_time, end_time)
|
76
|
+
data = analytics.get_iap("itunes_id", start_time, end_time)
|
77
|
+
data = analytics.get_sales("itunes_id", start_time, end_time)
|
78
|
+
data = analytics.get_paying_users("itunes_id", start_time, end_time)
|
79
|
+
data = analytics.get_impressions_total("itunes_id", start_time, end_time)
|
80
|
+
```
|
81
|
+
|
82
|
+
## Contributing
|
83
|
+
|
84
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/sadikay/sales_client.
|
85
|
+
|
86
|
+
|
87
|
+
## License
|
88
|
+
|
89
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "itunes-sales-client"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'itunes-sales-client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "itunes-sales-client"
|
8
|
+
spec.version = SalesClient::VERSION
|
9
|
+
spec.authors = ["Sadik Ay"]
|
10
|
+
spec.email = ["sadikay91@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Get app sales and analytics from itunes connect}
|
13
|
+
spec.description = %q{A fastlane extension to get your app transactions }
|
14
|
+
spec.homepage = "https://github.com/sadikay/itunes-sales-client"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Spaceship
|
2
|
+
# This class is used to upload Digital files (Images, Videos, JSON files) onto the du-itc service.
|
3
|
+
# Its implementation is tied to the tunes module (in particular using +AppVersion+ instances)
|
4
|
+
class AnalyticsClient < Spaceship::Client #:nodoc:
|
5
|
+
#####################################################
|
6
|
+
# @!group Init and Login
|
7
|
+
#####################################################
|
8
|
+
|
9
|
+
def self.hostname
|
10
|
+
"https://analytics.itunes.apple.com/"
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_units(id, start_time = Date.today - 30.day, end_time = Date.today)
|
14
|
+
measure = 'units'
|
15
|
+
get_data(id, measure, start_time, end_time)
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_page_view_count(id, start_time = Date.today - 30.day, end_time = Date.today)
|
19
|
+
measure = 'pageViewCount'
|
20
|
+
get_data(id, measure, start_time, end_time)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_iap(id, start_time = Date.today - 30.day, end_time = Date.today)
|
24
|
+
measure = 'iap'
|
25
|
+
get_data(id, measure, start_time, end_time)
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_sales(id, start_time = Date.today - 30.day, end_time = Date.today)
|
29
|
+
measure = 'sales'
|
30
|
+
get_data(id, measure, start_time, end_time)
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_paying_users(id, start_time = Date.today - 30.day, end_time = Date.today)
|
34
|
+
measure = 'payingUsers'
|
35
|
+
get_data(id, measure, start_time, end_time)
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_impressions_total(id, start_time = Date.today - 30.day, end_time = Date.today)
|
39
|
+
measure = 'impressionsTotal'
|
40
|
+
get_data(id, measure, start_time, end_time)
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_data(id, measure, start_time, end_time)
|
44
|
+
start_time = start_time.strftime('%Y-%m-%dT%H:%M:%SZ')
|
45
|
+
end_time = end_time.strftime('%Y-%m-%dT%H:%M:%SZ')
|
46
|
+
|
47
|
+
ids = [id]
|
48
|
+
|
49
|
+
body = {
|
50
|
+
"adamId": ids,
|
51
|
+
"frequency": "DAY",
|
52
|
+
"measures": [measure],
|
53
|
+
"group": nil,
|
54
|
+
"dimensionFilters": [],
|
55
|
+
"startTime": start_time,
|
56
|
+
"endTime": end_time
|
57
|
+
}
|
58
|
+
|
59
|
+
response = request(:post) do |req|
|
60
|
+
req.url "analytics/api/v1/data/time-series"
|
61
|
+
req.body = body.to_json
|
62
|
+
req.headers['Content-Type'] = 'application/json'
|
63
|
+
req.headers['Cookie'] = cookie
|
64
|
+
req.headers['Host'] = 'analytics.itunes.apple.com'
|
65
|
+
req.headers['Origin'] = 'https://analytics.itunes.apple.com'
|
66
|
+
req.headers['Referer'] = 'https://analytics.itunes.apple.com/'
|
67
|
+
req.headers['X-Requested-By'] = 'analytics.itunes.apple.com'
|
68
|
+
end
|
69
|
+
|
70
|
+
response.body
|
71
|
+
end
|
72
|
+
|
73
|
+
def send_login_request(user, password)
|
74
|
+
send_shared_login_request(user, password)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require "itunes-sales-client/version"
|
2
|
+
require "sales/client"
|
3
|
+
require "analytics/client"
|
4
|
+
module Spaceship
|
5
|
+
# @ login for sales
|
6
|
+
# sales = Spaceship::SalesClient.login("username", "password")
|
7
|
+
|
8
|
+
# @login for analytics
|
9
|
+
# analytics = Spaceship::AnalyticsClient.login("username", "password")
|
10
|
+
end
|
data/lib/sales/client.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
module Spaceship
|
2
|
+
# This class is used to upload Digital files (Images, Videos, JSON files) onto the du-itc service.
|
3
|
+
# Its implementation is tied to the tunes module (in particular using +AppVersion+ instances)
|
4
|
+
class SalesClient < Spaceship::Client #:nodoc:
|
5
|
+
#####################################################
|
6
|
+
# @!group Init and Login
|
7
|
+
#####################################################
|
8
|
+
|
9
|
+
def self.hostname
|
10
|
+
"https://reportingitc2.apple.com/"
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_data(ids, start_time = Date.today - 5.day, end_time = Date.today - 1.day)
|
14
|
+
start_time = start_time.strftime('%Y-%m-%dT%H:%M:%S.000Z')
|
15
|
+
end_time = end_time.strftime('%Y-%m-%dT%H:%M:%S.000Z')
|
16
|
+
|
17
|
+
fail 'ids must be array' unless ids.is_a?(Array)
|
18
|
+
|
19
|
+
body = {
|
20
|
+
"filters":
|
21
|
+
[
|
22
|
+
{
|
23
|
+
"dimension_key":"content",
|
24
|
+
"option_keys":ids
|
25
|
+
}
|
26
|
+
],
|
27
|
+
"group":"content",
|
28
|
+
"interval":"day",
|
29
|
+
"start_date": start_time,
|
30
|
+
"end_date": end_time,
|
31
|
+
"sort":"descending",
|
32
|
+
"limit":100,
|
33
|
+
"measures":["Royalty_utc", "total_tax_usd_utc", "units_utc"]}
|
34
|
+
|
35
|
+
response = request(:post) do |req|
|
36
|
+
req.url "api/data/timeseries"
|
37
|
+
req.body = body.to_json
|
38
|
+
req.headers['Content-Type'] = 'application/json'
|
39
|
+
req.headers['Cookie'] = cookie
|
40
|
+
req.headers['Host'] = 'reportingitc2.apple.com'
|
41
|
+
req.headers['Origin'] = 'https://reportingitc2.apple.com'
|
42
|
+
req.headers['Referer'] = "https://reportingitc2.apple.com/sales.html?filter_content=#{ids.first}"
|
43
|
+
end
|
44
|
+
|
45
|
+
response.body || []
|
46
|
+
end
|
47
|
+
|
48
|
+
def send_login_request(user, password)
|
49
|
+
send_shared_login_request(user, password)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: itunes-sales-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sadik Ay
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: 'A fastlane extension to get your app transactions '
|
42
|
+
email:
|
43
|
+
- sadikay91@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- bin/console
|
54
|
+
- bin/setup
|
55
|
+
- itunes-sales-client.gemspec
|
56
|
+
- lib/analytics/client.rb
|
57
|
+
- lib/itunes-sales-client.rb
|
58
|
+
- lib/itunes-sales-client/version.rb
|
59
|
+
- lib/sales/client.rb
|
60
|
+
homepage: https://github.com/sadikay/itunes-sales-client
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.5.1
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Get app sales and analytics from itunes connect
|
84
|
+
test_files: []
|