fastly 0.9 → 0.95

Sign up to get free protection for your applications and to get access to all the features.
data/Changes CHANGED
@@ -1,3 +1,7 @@
1
+ 2011-12-19 v0.95
2
+
3
+ Fix the way invoices and stats are fetched
4
+
1
5
  2011-12-15 v0.9
2
6
 
3
7
  Add mapping from backends to directors and directors to origins
@@ -5,7 +5,7 @@
5
5
  # A client library for interacting with the Fastly web acceleration service
6
6
  class Fastly
7
7
  # The current version of the library
8
- VERSION = "0.9"
8
+ VERSION = "0.95"
9
9
 
10
10
  require 'fastly/fetcher'
11
11
  require 'fastly/client'
@@ -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, opts)
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
@@ -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
 
@@ -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
- invoices = @fastly.list_invoices(Time.now.year, Time.now.month)
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, invoices[0].class
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: 25
4
+ hash: 181
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 9
9
- version: "0.9"
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-15 00:00:00 Z
17
+ date: 2011-12-19 00:00:00 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: json