fastly 0.9 → 0.95
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes +4 -0
- data/lib/fastly.rb +1 -1
- data/lib/fastly/invoice.rb +14 -1
- data/lib/fastly/service.rb +2 -2
- data/test/common.rb +14 -2
- metadata +4 -4
data/Changes
CHANGED
data/lib/fastly.rb
CHANGED
data/lib/fastly/invoice.rb
CHANGED
@@ -38,6 +38,17 @@ class Fastly
|
|
38
38
|
#
|
39
39
|
# A hash reference with all the different regions and their subtotals
|
40
40
|
|
41
|
+
|
42
|
+
# Get the start time of this invoice as a DateTime object in UTC
|
43
|
+
def start
|
44
|
+
DateTime.parse(start_time).new_offset(0)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Get the end time of this invoice as a DateTime object in UTC
|
48
|
+
def end
|
49
|
+
DateTime.parse(end_time).new_offset(0)
|
50
|
+
end
|
51
|
+
|
41
52
|
private
|
42
53
|
|
43
54
|
def self.get_path(*args)
|
@@ -89,7 +100,9 @@ class Fastly
|
|
89
100
|
opts[:year] = year
|
90
101
|
opts[:month] = month
|
91
102
|
end
|
92
|
-
list(Fastly::Invoice
|
103
|
+
list = client.get(Fastly::Invoice.list_path(opts))
|
104
|
+
return [] if list.nil?
|
105
|
+
list.map { |hash| Fastly::Invoice.new(hash, self) }
|
93
106
|
end
|
94
107
|
|
95
108
|
end
|
data/lib/fastly/service.rb
CHANGED
@@ -37,10 +37,10 @@ class Fastly
|
|
37
37
|
# * hourly
|
38
38
|
# * daily
|
39
39
|
# * all
|
40
|
-
def stats(type=:all)
|
40
|
+
def stats(type=:all, opts={})
|
41
41
|
raise Fastly::FullAuthRequired unless fetcher.fully_authed?
|
42
42
|
raise Fastly::Error "Unknown stats type #{type}" unless [:minutely,:hourly,:daily,:all].include?(type.to_sym)
|
43
|
-
hash = fetcher.client.get(Fastly::Service.get_path(self.id)+"/stats/#{type}")
|
43
|
+
hash = fetcher.client.get(Fastly::Service.get_path(self.id)+"/stats/#{type}", opts)
|
44
44
|
return hash
|
45
45
|
end
|
46
46
|
|
data/test/common.rb
CHANGED
@@ -135,6 +135,9 @@ module CommonTests
|
|
135
135
|
|
136
136
|
stats = service.stats
|
137
137
|
assert stats
|
138
|
+
|
139
|
+
stats = service.stats(:all, :year => 2011, :month => 10)
|
140
|
+
assert stats
|
138
141
|
end
|
139
142
|
|
140
143
|
def test_invoices
|
@@ -160,7 +163,11 @@ module CommonTests
|
|
160
163
|
assert_equal Fastly::Invoice, invoices[0].class
|
161
164
|
assert invoices[0].service_id
|
162
165
|
|
163
|
-
|
166
|
+
year = Time.now.year
|
167
|
+
month = Time.now.month-1
|
168
|
+
month = 12 if month == 0
|
169
|
+
|
170
|
+
invoices = @fastly.list_invoices(year, month)
|
164
171
|
services = @fastly.list_services
|
165
172
|
begin
|
166
173
|
customer = @fastly.current_customer
|
@@ -169,7 +176,12 @@ module CommonTests
|
|
169
176
|
end
|
170
177
|
|
171
178
|
assert_equal invoices.size, services.size
|
172
|
-
assert_equal Fastly::Invoice,
|
179
|
+
assert_equal Fastly::Invoice, invoices[0].class
|
180
|
+
assert_equal year, invoices[0].start.year
|
181
|
+
assert_equal month, invoices[0].start.month
|
182
|
+
assert_equal 1, invoices[0].start.day
|
183
|
+
assert_equal year, invoices[0].end.year
|
184
|
+
assert_equal month, invoices[0].end.month
|
173
185
|
assert invoices[0].service_id
|
174
186
|
end
|
175
187
|
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 181
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 95
|
9
|
+
version: "0.95"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Fastly Inc
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-12-
|
17
|
+
date: 2011-12-19 00:00:00 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: json
|