appfigures 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.
- data/VERSION +1 -1
- data/appfigures.gemspec +4 -2
- data/lib/appfigures.rb +2 -1
- data/lib/appfigures/archive.rb +40 -0
- data/lib/appfigures/external.rb +2 -0
- data/test/test_archive.rb +55 -0
- data/test/test_external.rb +1 -1
- metadata +15 -13
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/appfigures.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "appfigures"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Francis Chong"]
|
@@ -20,12 +20,14 @@ Gem::Specification.new do |s|
|
|
20
20
|
"VERSION",
|
21
21
|
"appfigures.gemspec",
|
22
22
|
"lib/appfigures.rb",
|
23
|
+
"lib/appfigures/archive.rb",
|
23
24
|
"lib/appfigures/data.rb",
|
24
25
|
"lib/appfigures/external.rb",
|
25
26
|
"lib/appfigures/rank.rb",
|
26
27
|
"lib/appfigures/sale.rb",
|
27
28
|
"lib/appfigures/user.rb",
|
28
29
|
"test/appfigures_fixture.yml.default",
|
30
|
+
"test/test_archive.rb",
|
29
31
|
"test/test_data.rb",
|
30
32
|
"test/test_external.rb",
|
31
33
|
"test/test_rank.rb",
|
@@ -34,7 +36,7 @@ Gem::Specification.new do |s|
|
|
34
36
|
]
|
35
37
|
s.homepage = "https://github.com/siuying/appfigures"
|
36
38
|
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = "1.8.
|
39
|
+
s.rubygems_version = "1.8.10"
|
38
40
|
s.summary = "AppFigures API"
|
39
41
|
|
40
42
|
if s.respond_to? :specification_version then
|
data/lib/appfigures.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Appfigures
|
4
|
+
class Archive
|
5
|
+
include HTTParty
|
6
|
+
base_uri API_URL
|
7
|
+
format :json
|
8
|
+
TYPE = {
|
9
|
+
:DAILY => "daily",
|
10
|
+
:WEEKLY => "weekly",
|
11
|
+
:FINANCIAL => "financial",
|
12
|
+
:PAYMENT => "payment",
|
13
|
+
:ALL => "all"
|
14
|
+
}
|
15
|
+
|
16
|
+
def initialize(username, password)
|
17
|
+
@auth = {:username => username, :password => password}
|
18
|
+
end
|
19
|
+
|
20
|
+
def archives(type="all")
|
21
|
+
raise ArgumentError, "Type must be one of TYPE: #{TYPE.values.join(", ")}" unless TYPE.values.index(type)
|
22
|
+
self.class.get("/archive", {:basic_auth => @auth, :type => type})
|
23
|
+
end
|
24
|
+
|
25
|
+
def latest(type="all")
|
26
|
+
self.class.get("/archive/latest", {:basic_auth => @auth, :type => type})
|
27
|
+
end
|
28
|
+
|
29
|
+
def by_date(date, type="all")
|
30
|
+
self.class.get("/archive/#{date}", {:basic_auth => @auth, :type => type})
|
31
|
+
end
|
32
|
+
|
33
|
+
# get the raw report by report id
|
34
|
+
# requires admin
|
35
|
+
def raw(id)
|
36
|
+
self.class.get("/archive/raw/#{id}", {:basic_auth => @auth})
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/lib/appfigures/external.rb
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require "test/unit"
|
3
|
+
|
4
|
+
require "rubygems"
|
5
|
+
require "bundler"
|
6
|
+
Bundler.require(:default)
|
7
|
+
|
8
|
+
require "./lib/appfigures"
|
9
|
+
|
10
|
+
class TestArchive < Test::Unit::TestCase
|
11
|
+
def setup
|
12
|
+
path = File.expand_path(File.dirname(__FILE__))
|
13
|
+
@config = YAML::load(open("#{path}/appfigures_fixture.yml"))
|
14
|
+
|
15
|
+
assert_not_nil(@config, "you must create appfigures_fixture.yml")
|
16
|
+
assert_not_nil(@config[:username], "you must configure username")
|
17
|
+
assert_not_nil(@config[:password], "you must configure password")
|
18
|
+
|
19
|
+
assert_not_equal("", @config[:username], "you must configure username")
|
20
|
+
assert_not_equal("", @config[:password], "you must configure password")
|
21
|
+
|
22
|
+
@archive = Appfigures::Archive.new @config[:username], @config[:password]
|
23
|
+
@user = Appfigures::User.new @config[:username], @config[:password]
|
24
|
+
|
25
|
+
@day_minutes_one = (Time.now - 24*60*60).strftime("%Y-%m-%d")
|
26
|
+
@day_minutes_two = (Time.now - 2*24*60*60).strftime("%Y-%m-%d")
|
27
|
+
|
28
|
+
@apps = @user.products(@config[:username])
|
29
|
+
@first_app = @apps[@apps.keys.first]
|
30
|
+
assert_kind_of(Hash, @first_app)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_archives
|
34
|
+
daily = @archive.archives("daily")
|
35
|
+
assert_not_nil(daily, "daily archives should be okay")
|
36
|
+
assert_kind_of(Hash, daily)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_latest
|
40
|
+
latest = @archive.latest("daily")
|
41
|
+
assert_not_nil(latest, "latest archives should be okay")
|
42
|
+
assert_kind_of(Hash, latest)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_by_date_and_raw
|
46
|
+
by_date = @archive.by_date("2012-09-10", "daily")
|
47
|
+
assert_not_nil(by_date, "by_date report should be okay")
|
48
|
+
assert_kind_of(Hash, by_date)
|
49
|
+
|
50
|
+
# requires admin permission
|
51
|
+
# raw = @archive.raw(by_date.values.first["id"])
|
52
|
+
# assert_not_nil(raw, "raw report should be okay")
|
53
|
+
# assert_kind_of(String, raw)
|
54
|
+
end
|
55
|
+
end
|
data/test/test_external.rb
CHANGED
@@ -7,7 +7,7 @@ Bundler.require(:default)
|
|
7
7
|
|
8
8
|
require "./lib/appfigures"
|
9
9
|
|
10
|
-
class
|
10
|
+
class TestExternal < Test::Unit::TestCase
|
11
11
|
# def test_external
|
12
12
|
# path = File.expand_path(File.dirname(__FILE__))
|
13
13
|
# @config = YAML::load(open("#{path}/appfigures_fixture.yml"))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appfigures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-09-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &70184358524400 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70184358524400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: httparty
|
27
|
-
requirement: &
|
27
|
+
requirement: &70184358521260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70184358521260
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70184358520320 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70184358520320
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: gemcutter
|
49
|
-
requirement: &
|
49
|
+
requirement: &70184358555480 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70184358555480
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jeweler
|
60
|
-
requirement: &
|
60
|
+
requirement: &70184358554200 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70184358554200
|
69
69
|
description: AppFigures API ruby edition
|
70
70
|
email: francis@ignition.hk
|
71
71
|
executables: []
|
@@ -79,12 +79,14 @@ files:
|
|
79
79
|
- VERSION
|
80
80
|
- appfigures.gemspec
|
81
81
|
- lib/appfigures.rb
|
82
|
+
- lib/appfigures/archive.rb
|
82
83
|
- lib/appfigures/data.rb
|
83
84
|
- lib/appfigures/external.rb
|
84
85
|
- lib/appfigures/rank.rb
|
85
86
|
- lib/appfigures/sale.rb
|
86
87
|
- lib/appfigures/user.rb
|
87
88
|
- test/appfigures_fixture.yml.default
|
89
|
+
- test/test_archive.rb
|
88
90
|
- test/test_data.rb
|
89
91
|
- test/test_external.rb
|
90
92
|
- test/test_rank.rb
|
@@ -104,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
106
|
version: '0'
|
105
107
|
segments:
|
106
108
|
- 0
|
107
|
-
hash:
|
109
|
+
hash: 1744420675123302140
|
108
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
111
|
none: false
|
110
112
|
requirements:
|
@@ -113,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
115
|
version: '0'
|
114
116
|
requirements: []
|
115
117
|
rubyforge_project:
|
116
|
-
rubygems_version: 1.8.
|
118
|
+
rubygems_version: 1.8.10
|
117
119
|
signing_key:
|
118
120
|
specification_version: 3
|
119
121
|
summary: AppFigures API
|