apple_reporter 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -18
- data/lib/apple_reporter/finance.rb +18 -21
- data/lib/apple_reporter/reporter.rb +4 -4
- data/lib/apple_reporter/sale.rb +18 -22
- data/lib/apple_reporter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9609786844909fdf453e6429dc6ebe596eada77
|
4
|
+
data.tar.gz: cba7b3351e012f9d7f6c32723c888a0ca4919436
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d382919f316fe29ba521cb777d4d00a76d09df85f0168ed1ccd2e7304bab29ebe2755d15b028dd5d3d96f984c92c542c87b50065e53c9ab2a9986848e481b8e
|
7
|
+
data.tar.gz: b1d1692fedb41e54e7fe7409cdf1db676ac09d9d82f5175948d07e5e8cff1f6b14189d49779cf962d06b24eae614047062feb02ca6781fa3fb0565892a54470d
|
data/README.md
CHANGED
@@ -28,33 +28,45 @@ Or install it yourself as:
|
|
28
28
|
|
29
29
|
### Sales
|
30
30
|
|
31
|
-
-
|
31
|
+
- get_report
|
32
32
|
|
33
33
|
```
|
34
34
|
reporter = AppleReporter::Sale.new(user_id: 'your user id', access_token: 'your access token')
|
35
|
-
report = reporter.
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
date: '20161212'
|
42
|
-
}
|
35
|
+
report = reporter.get_report(
|
36
|
+
vendor_number: 'your vender id',
|
37
|
+
report_type: 'Sales',
|
38
|
+
report_sub_type: 'Summary',
|
39
|
+
date_type: 'Daily',
|
40
|
+
date: '20161212'
|
43
41
|
)
|
44
42
|
```
|
45
43
|
### Finance
|
46
44
|
|
47
|
-
-
|
45
|
+
- get_report
|
48
46
|
```
|
49
47
|
reporter = AppleReporter::Finance.new(user_id: 'your user id', access_token: 'your access token')
|
50
|
-
report = reporter.
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
48
|
+
report = reporter.get_report(
|
49
|
+
vendor_number: 'your vender id',
|
50
|
+
region_code: 'US',
|
51
|
+
report_type: 'Financial',
|
52
|
+
fiscal_year: '2016',
|
53
|
+
fiscal_period: '02'
|
54
|
+
)
|
55
|
+
```
|
56
|
+
|
57
|
+
- get_report with version
|
58
|
+
```
|
59
|
+
reporter = AppleReporter::Finance.new(
|
60
|
+
user_id: 'your user id',
|
61
|
+
access_token: 'your access token'
|
62
|
+
version: '1_1'
|
63
|
+
)
|
64
|
+
report = reporter.get_report(
|
65
|
+
vendor_number: 'your vender id',
|
66
|
+
region_code: 'US',
|
67
|
+
report_type: 'Financial',
|
68
|
+
fiscal_year: '2016',
|
69
|
+
fiscal_period: '02'
|
58
70
|
)
|
59
71
|
```
|
60
72
|
|
@@ -1,49 +1,46 @@
|
|
1
1
|
module AppleReporter
|
2
2
|
class Finance < Reporter
|
3
|
-
|
4
|
-
# getAccounts
|
3
|
+
# accounts
|
5
4
|
#
|
6
5
|
# Usage:
|
7
|
-
# report = reporter.
|
8
|
-
def
|
6
|
+
# report = reporter.accounts
|
7
|
+
def accounts
|
9
8
|
fetch(@config[:finance_path], 'Finance.getAccounts')
|
10
9
|
end
|
11
10
|
|
12
|
-
#
|
11
|
+
# status
|
13
12
|
#
|
14
13
|
# Usage:
|
15
|
-
# report = reporter.
|
16
|
-
def
|
14
|
+
# report = reporter.status
|
15
|
+
def status
|
17
16
|
fetch(@config[:finance_path], 'Finance.getStatus')
|
18
17
|
end
|
19
18
|
|
20
|
-
#
|
19
|
+
# vendors_and_regions
|
21
20
|
#
|
22
21
|
# Usage:
|
23
|
-
# report = reporter.
|
24
|
-
def
|
22
|
+
# report = reporter.vendors_and_regions
|
23
|
+
def vendors_and_regions
|
25
24
|
fetch(@config[:finance_path], 'Finance.getVendorsAndRegions')
|
26
25
|
end
|
27
26
|
|
28
|
-
#
|
27
|
+
# get_report
|
29
28
|
# Refer to: https://help.apple.com/itc/appsreporterguide/
|
30
29
|
#
|
31
30
|
# Usage:
|
32
31
|
#
|
33
|
-
# report = reporter.
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
# fiscal_period: '02'
|
40
|
-
# }
|
32
|
+
# report = reporter.get_report(
|
33
|
+
# vendor_number: 'myVendor',
|
34
|
+
# region_code: 'US',
|
35
|
+
# report_type: 'Financial',
|
36
|
+
# fiscal_year: '2016',
|
37
|
+
# fiscal_period: '02'
|
41
38
|
# )
|
42
|
-
def
|
39
|
+
def get_report(params = {})
|
43
40
|
fetch(@config[:finance_path], (['Finance.getReport'] + [params.slice(:vendor_number, :region_code, :report_type, :fiscal_year, :fiscal_period).values.join(',')]).join(', '))
|
44
41
|
end
|
45
42
|
|
46
|
-
def
|
43
|
+
def version
|
47
44
|
@config[:version]
|
48
45
|
end
|
49
46
|
end
|
@@ -11,7 +11,7 @@ module AppleReporter
|
|
11
11
|
sales_path: '/sales/v1',
|
12
12
|
finance_path: '/finance/v1',
|
13
13
|
mode: 'Robot.XML',
|
14
|
-
version: '
|
14
|
+
version: '1_0'
|
15
15
|
}.merge(config)
|
16
16
|
end
|
17
17
|
|
@@ -31,13 +31,13 @@ module AppleReporter
|
|
31
31
|
payload[:account] = @config[:account] if @config[:account]
|
32
32
|
|
33
33
|
response = RestClient.post("#{ENDPOINT}#{api_path}", "jsonRequest=#{payload.to_json}", headers)
|
34
|
-
|
34
|
+
handle_response(@config[:mode], response)
|
35
35
|
rescue RestClient::ExceptionWithResponse => err
|
36
|
-
|
36
|
+
handle_response(@config[:mode], err.response)
|
37
37
|
end
|
38
38
|
|
39
39
|
#
|
40
|
-
def
|
40
|
+
def handle_response(mode, response)
|
41
41
|
if response.code == 200
|
42
42
|
if response.headers[:content_type] == 'application/a-gzip'
|
43
43
|
io = StringIO.new(response.body)
|
data/lib/apple_reporter/sale.rb
CHANGED
@@ -1,51 +1,47 @@
|
|
1
1
|
module AppleReporter
|
2
2
|
class Sale < Reporter
|
3
|
-
|
4
|
-
# getAccounts
|
3
|
+
# accounts
|
5
4
|
#
|
6
5
|
# Usage:
|
7
|
-
# report = reporter.
|
8
|
-
def
|
6
|
+
# report = reporter.accounts
|
7
|
+
def accounts
|
9
8
|
fetch(@config[:sales_path], 'Sales.getAccounts')
|
10
9
|
end
|
11
10
|
|
12
|
-
#
|
11
|
+
# status
|
13
12
|
#
|
14
13
|
# Usage:
|
15
|
-
# report = reporter.
|
16
|
-
def
|
14
|
+
# report = reporter.status
|
15
|
+
def status
|
17
16
|
fetch(@config[:sales_path], 'Sales.getStatus')
|
18
17
|
end
|
19
18
|
|
20
|
-
#
|
19
|
+
# vendors
|
21
20
|
#
|
22
21
|
# Usage:
|
23
|
-
# report = reporter.
|
24
|
-
def
|
22
|
+
# report = reporter.vendors
|
23
|
+
def vendors
|
25
24
|
fetch(@config[:sales_path], 'Sales.getVendors')
|
26
25
|
end
|
27
26
|
|
28
|
-
def
|
27
|
+
def version
|
29
28
|
@config[:version]
|
30
29
|
end
|
31
30
|
|
32
|
-
#
|
31
|
+
# get_report
|
33
32
|
# Refer to: https://help.apple.com/itc/appsreporterguide/
|
34
33
|
#
|
35
34
|
# Usage:
|
36
35
|
#
|
37
|
-
# report = reporter.
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
# date: '20161212'
|
44
|
-
# }
|
36
|
+
# report = reporter.get_report(
|
37
|
+
# vendor_number: 'myVendor',
|
38
|
+
# report_type: 'Sales',
|
39
|
+
# report_sub_type: 'Summary',
|
40
|
+
# date_type: 'Daily',
|
41
|
+
# date: '20161212'
|
45
42
|
# )
|
46
|
-
def
|
43
|
+
def get_report(params = {})
|
47
44
|
fetch(@config[:sales_path], (['Sales.getReport'] + [params.slice(:vendor_number, :report_type, :report_sub_type, :date_type, :date).values.join(',')]).join(', '))
|
48
45
|
end
|
49
|
-
|
50
46
|
end
|
51
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apple_reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dean Lin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|