forked from nomad-cli/cupertino
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ITC sales summary report as table output.
- Loading branch information
1 parent
ff38849
commit ca1db65
Showing
7 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
module Cupertino | ||
VERSION = '0.5.1' | ||
VERSION = '0.5.2' | ||
HOSTNAME = "developer.apple.com" | ||
ITC_HOSTNAME = "itunesconnect.apple.com" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'mechanize' | ||
|
||
module Cupertino | ||
module ITunesConnect | ||
|
||
class SalesSummaryReport < Struct.new(:provider, :provider_country, :sku, :developer, :title, :version, :product_type_identifier, :units, :developer_proceeds, :begin_date, :end_date, :customer_currency, :country_code, :currency_of_proceeds, :apple_identifier, :customer_price, :promo_code, :parent_identifier, :subscription, :period) | ||
def to_s | ||
"#{self.sku} - #{self.title}" | ||
end | ||
end | ||
|
||
class SalesOptInReport < Struct.new(:first_name, :last_name, :email_address, :postal_code, :apple_identifier, :start_date, :end_date) | ||
def to_s | ||
"#{self.name}" | ||
end | ||
end | ||
|
||
class UnsuccessfulAuthenticationError < RuntimeError; end | ||
end | ||
end | ||
|
||
require 'cupertino/itunes_connect/helpers' | ||
require 'cupertino/itunes_connect/commands' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include Cupertino::ITunesConnect | ||
|
||
require 'cupertino/itunes_connect/commands/report' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'itc_autoingest' | ||
require 'security' | ||
|
||
command :'itc:salessummaryreport' do |c| | ||
c.syntax = 'ios itc:salessummaryreport <vendorid> <Daily|Weekly> <date_yyyymmdd>' | ||
c.summary = 'Retrieves the sales summary report for the given app and date' | ||
c.description = '' | ||
|
||
c.action do |args, options| | ||
ipw = Security::InternetPassword.find(:server => Cupertino::ITC_HOSTNAME) | ||
username, password = ipw.attributes['acct'], ipw.password if ipw | ||
|
||
say_error "Missing arguments, expected <vendorid> <Daily|Weekly> <date_yyyymmdd>" and abort if args.nil? or args.length < 3 | ||
|
||
username ||= ask "Username:" | ||
password ||= pw "Password:" | ||
|
||
itca = ITCAutoingest::ITCAutoingest.new(username, password, args[0]) | ||
report = itca.send("#{args[1].downcase}_sales_summary_report", args[2]) | ||
|
||
if report[:error].nil? | ||
if report[:report].size == 0 | ||
puts "Nothing to report." | ||
else | ||
table = Terminal::Table.new :title => "Sales Summary Report" do |t| | ||
headers = [] | ||
report[:report][0].keys.each do |header| | ||
headers << "#{header}" | ||
end | ||
t << headers | ||
t << :separator | ||
|
||
report[:report].each do |rv| | ||
row = [] | ||
rv.values.each do |cv| | ||
row << "#{cv}" | ||
end | ||
t << row | ||
end | ||
end | ||
|
||
puts table | ||
end | ||
else | ||
say_error report[:error] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Monkey Patch Commander::UI to alias password to avoid conflicts | ||
module Commander::UI | ||
alias :pw :password | ||
end | ||
|
||
class String | ||
include Term::ANSIColor | ||
end |