ireporter 0.1.0 → 0.1.1
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/Gemfile +0 -1
- data/README.md +58 -9
- data/ireporter.gemspec +2 -0
- data/lib/ireporter/reporter.rb +108 -108
- data/lib/ireporter/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 997fee57d686d48ad5e8a7042f24c9872f13cf22
|
|
4
|
+
data.tar.gz: f6f6c484623f3f596bbed8c1a29af8e3f6bd9b85
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bece219ed2412aab7e7ad6ae3ad8d697e37d7af624a1a8990217aeb091d97e008446f4885020ffefb09f2496c138bed930dd5f0b132b90a0f53d30a63fe90bb7
|
|
7
|
+
data.tar.gz: a2763a73efcfef4fb8cc14a7097e5fec5aff67bf7972f3e2bb3ba8cb900bc8a1f0b74a12578466ea17e1a4a726115f12142bb99d5d17bf6565ad1b3cb70fbf4e
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# Ireporter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This gem is the Ruby alternative to **iTunes Connect Reporter** written in java library used to fetch sales and finance reports.
|
|
4
|
+
|
|
5
|
+
This gem is written considering requirement of Rails app, but can be used as a regular ruby gem.
|
|
6
|
+
|
|
4
7
|
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
|
6
8
|
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
@@ -22,20 +24,67 @@ Or install it yourself as:
|
|
|
22
24
|
|
|
23
25
|
## Usage
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
Create a reporter object
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
reporterObj= Ireporter::Reporter.new('user id','password')
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
And use below awesome methods, and see the Magic happen.
|
|
34
|
+
|
|
35
|
+
Get the status of services (Sales and Finance)
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
reporterObj.get_status('Sales')
|
|
39
|
+
reporterObj.get_status('Finance')
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Fetch the sales report
|
|
26
44
|
|
|
27
|
-
|
|
45
|
+
```
|
|
46
|
+
report_data=reporterObj.get_sales_report('daily','20160818')
|
|
47
|
+
```
|
|
28
48
|
|
|
29
|
-
|
|
49
|
+
And then wrap it in the Array
|
|
30
50
|
|
|
31
|
-
|
|
51
|
+
```
|
|
52
|
+
array = reporterObj.wrap(report_data)
|
|
53
|
+
```
|
|
32
54
|
|
|
33
55
|
## Contributing
|
|
34
56
|
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
57
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nakshay/ireporter.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Contributors
|
|
61
|
+
|
|
62
|
+
Akshay Naik
|
|
63
|
+
|
|
64
|
+
Rushikesh Kawadkar
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
## Contributors
|
|
68
|
+
|
|
69
|
+
The MIT License (MIT)
|
|
70
|
+
|
|
71
|
+
Copyright (c) 2017 Akshay Naik
|
|
36
72
|
|
|
73
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
74
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
75
|
+
in the Software without restriction, including without limitation the rights
|
|
76
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
77
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
78
|
+
furnished to do so, subject to the following conditions:
|
|
37
79
|
|
|
38
|
-
|
|
80
|
+
The above copyright notice and this permission notice shall be included in
|
|
81
|
+
all copies or substantial portions of the Software.
|
|
39
82
|
|
|
40
|
-
|
|
83
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
84
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
85
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
86
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
87
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
88
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
89
|
+
THE SOFTWARE.
|
|
41
90
|
|
data/ireporter.gemspec
CHANGED
data/lib/ireporter/reporter.rb
CHANGED
|
@@ -19,114 +19,114 @@ DATE_TYPE_WEEKLY = "Weekly"
|
|
|
19
19
|
|
|
20
20
|
#constructor
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
22
|
+
def initialize(username,password)
|
|
23
|
+
@username = username
|
|
24
|
+
@password = password
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def get_status (service)
|
|
28
|
+
|
|
29
|
+
command = "[p=Reporter.properties, "+service+".getStatus]"
|
|
30
|
+
url = service == 'Sales' ? URL_SALES : URL_FINANCE
|
|
31
|
+
|
|
32
|
+
parameters = build_json_request(command)
|
|
33
|
+
|
|
34
|
+
response = post_request(parameters,url)
|
|
35
|
+
|
|
36
|
+
if response.headers[:"errormsg"]
|
|
37
|
+
raise "error fetching status"
|
|
38
|
+
else response.headers[:"filename"]
|
|
39
|
+
return response.body
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def get_vendor()
|
|
45
|
+
|
|
46
|
+
command = '[p=Reporter.properties, Sales.getVendors]'
|
|
47
|
+
|
|
48
|
+
parameters = build_json_request(command)
|
|
49
|
+
response = post_request(parameters,URL_SALES)
|
|
50
|
+
|
|
51
|
+
if response.headers[:"errormsg"]
|
|
52
|
+
raise "vendor number not found"
|
|
53
|
+
else response.headers[:"filename"]
|
|
54
|
+
return response.body
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def get_sales_report(datetype,reportdate)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
datetype ||= DATE_TYPE_DAILY
|
|
62
|
+
reportdate ||= (Time.now-60*60*24).strftime("%Y%m%d")
|
|
63
|
+
|
|
64
|
+
vendorNumber=get_vendor().chomp
|
|
65
|
+
|
|
66
|
+
command = '[p=Reporter.properties, Sales.getReport, '+vendorNumber+',Sales,Summary,'+datetype+','+reportdate+']'
|
|
67
|
+
parameters = build_json_request(command)
|
|
68
|
+
|
|
69
|
+
response = post_request(parameters,URL_SALES)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if response.headers[:"errormsg"]
|
|
73
|
+
raise ITunesConnectError.new response.headers[:"errormsg"]
|
|
74
|
+
elsif response.headers[:"filename"]
|
|
75
|
+
Zlib::GzipReader.new(StringIO.new(response.body)).read
|
|
76
|
+
else
|
|
77
|
+
raise "no data returned from itunes: #{response.body}"
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def build_json_request(command)
|
|
83
|
+
|
|
84
|
+
request_data = { :userid => @username ,:queryInput => command, :version => VERSION,:password => @password}
|
|
85
|
+
#Convert request paramters in JSON format
|
|
86
|
+
request_data=request_data.to_json
|
|
87
|
+
|
|
88
|
+
return 'jsonRequest='+ request_data
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def post_request(parameters,url)
|
|
93
|
+
|
|
94
|
+
RestClient.post( url, parameters, headers = {:Accept => 'text/html,image/gif,image/jpeg; q=.2, */*; q=.2'} )
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Wrap data into Array
|
|
98
|
+
def wrap(report)
|
|
99
|
+
lines = report.split("\n")
|
|
100
|
+
header = lines.shift
|
|
101
|
+
lines.collect do |line|
|
|
102
|
+
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")
|
|
103
|
+
{
|
|
104
|
+
:provider => provider.strip,
|
|
105
|
+
:country => country.strip,
|
|
106
|
+
:sku => sku.strip,
|
|
107
|
+
:developer => developer.strip,
|
|
108
|
+
:title => title.strip,
|
|
109
|
+
:version => version.strip,
|
|
110
|
+
:product_type_id => product_type_id.strip,
|
|
111
|
+
:units => units.to_i,
|
|
112
|
+
:developer_proceeds => developer_proceeds.to_f,
|
|
113
|
+
:begin_date => Date.strptime(begin_date.strip, '%m/%d/%Y'),
|
|
114
|
+
:end_date => Date.strptime(end_date.strip, '%m/%d/%Y'),
|
|
115
|
+
:currency => currency.strip,
|
|
116
|
+
:country_code => country_code.strip,
|
|
117
|
+
:currency_of_proceeds => currency_of_proceeds.strip,
|
|
118
|
+
:apple_id => apple_id.to_i,
|
|
119
|
+
:customer_price => customer_price.to_f,
|
|
120
|
+
:promo_code => promo_code.strip,
|
|
121
|
+
:parent_id => parent_id.strip,
|
|
122
|
+
:subscription => subscription.strip,
|
|
123
|
+
:period => period
|
|
124
|
+
}
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
private :build_json_request,:post_request
|
|
130
130
|
end # class end
|
|
131
131
|
|
|
132
132
|
end #module end
|
data/lib/ireporter/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ireporter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Akshay Naik
|
|
@@ -39,6 +39,20 @@ dependencies:
|
|
|
39
39
|
- - "~>"
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
41
|
version: '10.0'
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: rest-client
|
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '0'
|
|
49
|
+
type: :runtime
|
|
50
|
+
prerelease: false
|
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
42
56
|
description:
|
|
43
57
|
email:
|
|
44
58
|
- akshaynaik93@gmail.com
|