sales_client 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +20 -8
- data/lib/analytics/client.rb +39 -0
- data/lib/sales/client.rb +52 -0
- data/lib/sales_client/version.rb +1 -1
- data/lib/sales_client.rb +6 -49
- data/sales_client.gemspec +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aabfad7cb84a6651e2024556d529b5bccdb8ea74
|
4
|
+
data.tar.gz: 0f2f549b68cf205bc8b72fc5949f50f0b1424331
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ae15d507952048ff21f1715d5a6488c3ddac65d72f69f7b7c4c45040c5ac102a89055428835cdcc82ab4c50541586f005201f2eae4f00f454279cbfabc480fe
|
7
|
+
data.tar.gz: 12d442cb9acc7bd0f205bc3d34b50e2ed27c83c62aa71f6b1e9dc3dcc7851c97c8c4bda526e0c1546b67ef88743169b5f8828ece12b0be25470bfc8ce2891184
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# SalesClient
|
2
2
|
|
3
|
-
A [fastlane](https://github.com/fastlane/fastlane) extension gem to get apps sales
|
3
|
+
A [fastlane](https://github.com/fastlane/fastlane) extension gem to get apps sales and analytics reports from itunes connect.
|
4
4
|
Get multiple apps reports with single request.
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
8
|
-
Add this
|
8
|
+
Add this lines to your application's Gemfile:
|
9
9
|
|
10
10
|
```ruby
|
11
11
|
gem 'fastlane'
|
@@ -17,19 +17,31 @@ And then execute:
|
|
17
17
|
$ bundle
|
18
18
|
|
19
19
|
## Usage
|
20
|
+
### Sales
|
20
21
|
|
21
22
|
```ruby
|
22
23
|
# Assign the apps itunes ids to an array
|
23
24
|
ids = ["1234567..", "1234567..", "1234567.."]
|
24
25
|
sales = Spaceship::SalesClient.login("username", "password")
|
25
|
-
result = sales.get_data(ids
|
26
|
+
result = sales.get_data(ids, Date.today - 3.day, Date.today - 1.day)
|
26
27
|
|
27
28
|
=>
|
28
|
-
[{"metadata"=>{"key"=>"1234567..", "title"=>"Title",
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
}]
|
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_data("itunes_id", Date.today - 3.day, Date.today - 1.day)
|
40
|
+
|
41
|
+
=>
|
42
|
+
{"itcBaseUrl"=>
|
43
|
+
...
|
44
|
+
}
|
33
45
|
```
|
34
46
|
|
35
47
|
## Contributing
|
@@ -0,0 +1,39 @@
|
|
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_data(id, start_time = Date.today - 30.day, end_time = Date.today)
|
14
|
+
start_time = start_time.strftime('%Y-%m-%dT%H:%M:%SZ')
|
15
|
+
end_time = end_time.strftime('%Y-%m-%dT%H:%M:%SZ')
|
16
|
+
|
17
|
+
ids = [id]
|
18
|
+
|
19
|
+
body = {"adamId":ids,"frequency":"DAY","measures":["units", "impressionsTotal", "pageViewCount", "iap", "sales", "payingUsers"],"group":nil,"dimensionFilters":[],"startTime":start_time,"endTime":end_time}
|
20
|
+
|
21
|
+
response = request(:post) do |req|
|
22
|
+
req.url "analytics/api/v1/data/time-series"
|
23
|
+
req.body = body.to_json
|
24
|
+
req.headers['Content-Type'] = 'application/json'
|
25
|
+
req.headers['Cookie'] = cookie
|
26
|
+
req.headers['Host'] = 'analytics.itunes.apple.com'
|
27
|
+
req.headers['Origin'] = 'https://analytics.itunes.apple.com'
|
28
|
+
req.headers['Referer'] = 'https://analytics.itunes.apple.com/'
|
29
|
+
req.headers['X-Requested-By'] = 'analytics.itunes.apple.com'
|
30
|
+
end
|
31
|
+
|
32
|
+
response.body
|
33
|
+
end
|
34
|
+
|
35
|
+
def send_login_request(user, password)
|
36
|
+
send_shared_login_request(user, password)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
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
|
data/lib/sales_client/version.rb
CHANGED
data/lib/sales_client.rb
CHANGED
@@ -1,53 +1,10 @@
|
|
1
1
|
require "sales_client/version"
|
2
|
+
require "sales/client"
|
3
|
+
require "analytics/client"
|
2
4
|
module Spaceship
|
3
|
-
#
|
4
|
-
#
|
5
|
-
class SalesClient < Spaceship::Client #:nodoc:
|
6
|
-
#####################################################
|
7
|
-
# @!group Init and Login
|
8
|
-
#####################################################
|
5
|
+
# @ login for sales
|
6
|
+
# sales = Spaceship::SalesClient.login("username", "password")
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
def get_data(ids, start_time = Date.today - 5.day, end_time = Date.today - 1.day)
|
15
|
-
start_time = start_time.strftime('%Y-%m-%dT%H:%M:%S.000Z')
|
16
|
-
end_time = end_time.strftime('%Y-%m-%dT%H:%M:%S.000Z')
|
17
|
-
|
18
|
-
fail 'ids must be array' unless ids.is_a?(Array)
|
19
|
-
|
20
|
-
body = {
|
21
|
-
"filters":
|
22
|
-
[
|
23
|
-
{
|
24
|
-
"dimension_key":"content",
|
25
|
-
"option_keys":ids
|
26
|
-
}
|
27
|
-
],
|
28
|
-
"group":"content",
|
29
|
-
"interval":"day",
|
30
|
-
"start_date": start_time,
|
31
|
-
"end_date": end_time,
|
32
|
-
"sort":"descending",
|
33
|
-
"limit":100,
|
34
|
-
"measures":["Royalty_utc", "total_tax_usd_utc", "units_utc"]}
|
35
|
-
|
36
|
-
response = request(:post) do |req|
|
37
|
-
req.url "api/data/timeseries"
|
38
|
-
req.body = body.to_json
|
39
|
-
req.headers['Content-Type'] = 'application/json'
|
40
|
-
req.headers['Cookie'] = cookie
|
41
|
-
req.headers['Host'] = 'reportingitc2.apple.com'
|
42
|
-
req.headers['Origin'] = 'https://reportingitc2.apple.com'
|
43
|
-
req.headers['Referer'] = "https://reportingitc2.apple.com/sales.html?filter_content=#{ids.first}"
|
44
|
-
end
|
45
|
-
|
46
|
-
response.body
|
47
|
-
end
|
48
|
-
|
49
|
-
def send_login_request(user, password)
|
50
|
-
send_shared_login_request(user, password)
|
51
|
-
end
|
52
|
-
end
|
8
|
+
# @login for analytics
|
9
|
+
# analytics = Spaceship::AnalyticsClient.login("username", "password")
|
53
10
|
end
|
data/sales_client.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Sadik Ay"]
|
10
10
|
spec.email = ["sadikay91@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{Get app sales from itunes connect}
|
12
|
+
spec.summary = %q{Get app sales and analytics from itunes connect}
|
13
13
|
spec.description = %q{A fastlane extension to get your app transactions }
|
14
14
|
spec.homepage = "https://github.com/sadikay/sales_client"
|
15
15
|
spec.license = "MIT"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sales_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadik Ay
|
@@ -52,6 +52,8 @@ files:
|
|
52
52
|
- Rakefile
|
53
53
|
- bin/console
|
54
54
|
- bin/setup
|
55
|
+
- lib/analytics/client.rb
|
56
|
+
- lib/sales/client.rb
|
55
57
|
- lib/sales_client.rb
|
56
58
|
- lib/sales_client/version.rb
|
57
59
|
- sales_client.gemspec
|
@@ -78,5 +80,5 @@ rubyforge_project:
|
|
78
80
|
rubygems_version: 2.5.1
|
79
81
|
signing_key:
|
80
82
|
specification_version: 4
|
81
|
-
summary: Get app sales from itunes connect
|
83
|
+
summary: Get app sales and analytics from itunes connect
|
82
84
|
test_files: []
|