Class: GeoCerts::Certificate

Inherits:
ApiObject show all
Defined in:
lib/geo_certs/certificate.rb

Overview

Contains the information for a secure server certificate. Generally, these objects would be created and populated via GeoCerts::Order.certificate, unless you are looking for a listing of certificates in your account (see GeoCerts::Certificate.all).

Instance Attribute Summary (collapse)

Attributes inherited from ApiObject

#response_parameters

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from ApiObject

#errors, #errors=, #initialize, #warnings, #warnings=

Constructor Details

This class inherits a constructor from GeoCerts::ApiObject

Instance Attribute Details

- (Object) approver_email

Returns the value of attribute approver_email



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def approver_email
  @approver_email
end

- (Object) ca_intermediates

Returns the value of attribute ca_intermediates



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def ca_intermediates
  @ca_intermediates
end

- (Object) ca_root

Returns the value of attribute ca_root



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def ca_root
  @ca_root
end

- (Object) certificate

Returns the value of attribute certificate



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def certificate
  @certificate
end

- (Object) city

Returns the value of attribute city



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def city
  @city
end

- (Object) common_name

Returns the value of attribute common_name



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def common_name
  @common_name
end

- (Object) country

Returns the value of attribute country



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def country
  @country
end

- (Object) end_at

Returns the value of attribute end_at



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def end_at
  @end_at
end

- (Object) geotrust_order_id

Returns the value of attribute geotrust_order_id



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def geotrust_order_id
  @geotrust_order_id
end

- (Object) order_id

Returns the value of attribute order_id



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def order_id
  @order_id
end

- (Object) organization

Returns the value of attribute organization



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def organization
  @organization
end

- (Object) organizational_unit

Returns the value of attribute organizational_unit



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def organizational_unit
  @organizational_unit
end

- (Object) reissue_email

Returns the value of attribute reissue_email



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def reissue_email
  @reissue_email
end

- (Object) serial_number

Returns the value of attribute serial_number



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def serial_number
  @serial_number
end

- (Object) start_at

Returns the value of attribute start_at



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def start_at
  @start_at
end

- (Object) state

Returns the value of attribute state



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def state
  @state
end

- (Object) status

Returns the value of attribute status



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def status
  @status
end

- (Object) trial

Returns the value of attribute trial



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def trial
  @trial
end

- (Object) url

Returns the value of attribute url



12
13
14
# File 'lib/geo_certs/certificate.rb', line 12

def url
  @url
end

Class Method Details

+ (Object) all(options = {})

Returns all certificates for a given window of time. The server defaults to a 1 month window.

Options

:start_at

The starting DateTime for the date range

:end_at

The ending DateTime for the date range



43
44
45
46
47
# File 'lib/geo_certs/certificate.rb', line 43

def self.all(options = {})
  prep_date_ranges!(options)
  response = call_api { GeoCerts.api.certificates(options) }
  build_collection(response) { |response| response[:certificates][:certificate] }
end

+ (Object) find(order_id)

Returns the certificate for the given GeoCerts::Order

Exceptions

This method will raise exceptions if the given order_id cannot be found in the GeoCerts system.



57
58
59
60
# File 'lib/geo_certs/certificate.rb', line 57

def self.find(order_id)
  order_id = order_id.id if order_id.kind_of?(GeoCerts::Order)
  new(call_api { GeoCerts.api.find_certificate(:order_id => order_id)[:certificate] })
end

+ (Object) find_by_order_id(order_id)

Returns the certificate for the given GeoCerts::Order by ID.

If the order_id cannot be found in the GeoCerts system, this method will return nil.



67
68
69
70
71
# File 'lib/geo_certs/certificate.rb', line 67

def self.find_by_order_id(order_id)
  find(order_id)
rescue GeoCerts::AllowableExceptionWithResponse
  nil
end

Instance Method Details

- (Object) reissue!(csr)

Reissues the certificate given a proper CSR.



77
78
79
80
81
82
83
84
85
# File 'lib/geo_certs/certificate.rb', line 77

def reissue!(csr)
  csr = csr.body if csr.kind_of?(GeoCerts::CSR)
  update_attributes(self.class.call_api {
    GeoCerts.api.reissue_certificate({
      :order_id => self.order_id,
      :csr_body => GeoCerts.escape(csr || '')
    })
  })
end