Class: Fastly::Invoice

Inherits:
Base
  • Object
show all
Defined in:
lib/fastly/invoice.rb

Overview

An invoice for a time period

Instance Attribute Summary collapse

Attributes inherited from Base

#fetcher

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#as_hash, #initialize, path, #require_api_key!

Constructor Details

This class inherits a constructor from Fastly::Base

Instance Attribute Details

#end_timeObject

Returns the value of attribute end_time.



7
8
9
# File 'lib/fastly/invoice.rb', line 7

def end_time
  @end_time
end

#regionsObject

Returns the value of attribute regions.



7
8
9
# File 'lib/fastly/invoice.rb', line 7

def regions
  @regions
end

#service_idObject

Returns the value of attribute service_id.



7
8
9
# File 'lib/fastly/invoice.rb', line 7

def service_id
  @service_id
end

#service_nameObject

Returns the value of attribute service_name.



7
8
9
# File 'lib/fastly/invoice.rb', line 7

def service_name
  @service_name
end

#start_timeObject

Returns the value of attribute start_time.



7
8
9
# File 'lib/fastly/invoice.rb', line 7

def start_time
  @start_time
end

#totalObject

Returns the value of attribute total.



7
8
9
# File 'lib/fastly/invoice.rb', line 7

def total
  @total
end

Class Method Details

.delete_pathObject



82
83
84
# File 'lib/fastly/invoice.rb', line 82

def self.delete_path
  fail "You can't DELETE to an invoice"
end

.get_path(*args) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/fastly/invoice.rb', line 56

def self.get_path(*args)
  opts = args.size > 0 ? args[0] : {}

  url  = '/billing'

  url += "/service/#{opts[:service_id]}" if opts.key?(:service_id)

  if opts.key?(:year) && opts.key?(:month)
    url += "/year/#{opts[:year]}/month/#{opts[:month]}"
  end

  url
end

.list_path(*args) ⇒ Object



70
71
72
# File 'lib/fastly/invoice.rb', line 70

def self.list_path(*args)
  get_path(*args)
end

.post_pathObject



74
75
76
# File 'lib/fastly/invoice.rb', line 74

def self.post_path
  fail "You can't POST to an invoice"
end

.put_pathObject



78
79
80
# File 'lib/fastly/invoice.rb', line 78

def self.put_path
  fail "You can't PUT to an invoice"
end

Instance Method Details

#endObject

Get the end time of this invoice as a DateTime object in UTC



50
51
52
# File 'lib/fastly/invoice.rb', line 50

def end
  DateTime.parse(end_time).new_offset(0)
end

#startObject

Get the start time of this invoice as a DateTime object in UTC



45
46
47
# File 'lib/fastly/invoice.rb', line 45

def start
  DateTime.parse(start_time).new_offset(0)
end