sales_client 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 648b919e84cd741b8aba37e43dcf12ef94f6fe60
4
+ data.tar.gz: 7103980b28197941878765d3847498f594f8ff19
5
+ SHA512:
6
+ metadata.gz: 721d4cd0174198adcf713793f7149aecb683582b4b2e74008b6a52e9f5224527c73f43b1712a1d9eeea5359546ae86915961fcd747274b0b8e1fa0d87bc151f3
7
+ data.tar.gz: c5567cd2ecc8258c8f5f2e4f8a4ab62c892188f1fc96259b6dcd3dda94ea059e5e90a0679fad2794a32118f0d8d7586fc3d58c041aa38564213dae899ea30784
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sales_client.gemspec
4
+ gemspec
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,42 @@
1
+ # SalesClient
2
+
3
+ A [fastlane](https://github.com/fastlane/fastlane) extension gem to get apps sales report from itunes connect.
4
+ Get multiple apps reports with single request.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'fastlane'
12
+ gem 'sales_client'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ # Assign the apps itunes ids to an array
23
+ ids = ["1234567..", "1234567..", "1234567.."]
24
+ sales = Spaceship::SalesClient.login("username", "password")
25
+ result = sales.get_data(ids.keys, Date.today - 3.day, Date.today - 1.day)
26
+
27
+ =>
28
+ [{"metadata"=>{"key"=>"1234567..", "title"=>"Title",
29
+ ...
30
+ {"date"=>"2017-05-21", "total_tax_usd_utc"=>1.733, "units_utc"=>1, "Royalty_utc"=>1.182}
31
+ ...
32
+ }]
33
+ ```
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sadikay/sales_client.
38
+
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "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,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module SalesClient
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,53 @@
1
+ require "sales_client/version"
2
+ module Spaceship
3
+ # This class is used to upload Digital files (Images, Videos, JSON files) onto the du-itc service.
4
+ # Its implementation is tied to the tunes module (in particular using +AppVersion+ instances)
5
+ class SalesClient < Spaceship::Client #:nodoc:
6
+ #####################################################
7
+ # @!group Init and Login
8
+ #####################################################
9
+
10
+ def self.hostname
11
+ "https://reportingitc2.apple.com/"
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
53
+ end
@@ -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 'sales_client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "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 from itunes connect}
13
+ spec.description = %q{A fastlane extension to get your app transactions }
14
+ spec.homepage = "https://github.com/sadikay/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
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sales_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sadik Ay
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-06-11 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
+ - lib/sales_client.rb
56
+ - lib/sales_client/version.rb
57
+ - sales_client.gemspec
58
+ homepage: https://github.com/sadikay/sales_client
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.5.1
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Get app sales from itunes connect
82
+ test_files: []