class Fastly::Service

Represents something you want to serve - this can be, for example, a whole web site, a Wordpress site, or just your image servers

def customer

Get the Customer object for this Service
def customer
  fetcher.get(Customer, customer_id)
end

def details(opts = {})

A deep hash of nested details
def details(opts = {})
  fetcher.client.get("#{Service.get_path(id)}/details", opts)
end

def invoice(year = nil, month = nil)

Otherwise it returns the invoice for the current month so far.

If a year and month are passed in returns the invoice for that whole month.

Return a Invoice object representing the invoice for this service
def invoice(year = nil, month = nil)
  opts = { service_id: id }
  unless year.nil? || month.nil?
    opts[:year]  = year
    opts[:month] = month
  end
  fetcher.get(Invoice, opts)
end

def purge_all

See README.md for examples of purging

Purge all assets from this service.
def purge_all
  fetcher.client.post("#{Service.get_path(id)}/purge_all")
end

def purge_by_key(key, soft=false)

See README.md for examples of purging

Purge anything with the specific key from the given service.
def purge_by_key(key, soft=false)
  require_api_key!
  fetcher.client.post("#{Service.get_path(id)}/purge/#{key}", soft ? { headers: { 'Fastly-Soft-Purge' => "1"} } : {})
end

def stats(type = :all, opts = {})

* all
* daily
* hourly
* minutely
Type can be one of

Get a hash of stats from different data centers.

#
def stats(type = :all, opts = {})
  fail Error, "Unknown stats type #{type}" unless [:minutely, :hourly, :daily, :all].include?(type.to_sym)
  fetcher.client.get("#{Service.get_path(id)}/stats/#{type}", opts)
end

def version(number = -1)

Get an individual Version object. By default returns the latest version
def version(number = -1)
  versions[number]
end

def versions

Get a sorted array of all the versions that this service has had.
def versions
  @versions.map { |v| Version.new(v, fetcher) }.sort { |a, b| a.number.to_i <=> b.number.to_i }
end