Class: GeoCerts::Order
- Inherits:
-
ApiObject
- Object
- ApiObject
- GeoCerts::Order
- Defined in:
- lib/geo_certs/order.rb,
lib/geo_certs/order/contact.rb,
lib/geo_certs/order/organization.rb,
lib/geo_certs/order/administrator.rb,
lib/geo_certs/order/renewal_information.rb,
lib/geo_certs/order/extended_validation_approver.rb
Overview
Contains the details, attributes, and methods to interact with a GeoCerts order.
Defined Under Namespace
Classes: Administrator, Contact, ExtendedValidationApprover, Organization, RenewalInformation
Instance Attribute Summary (collapse)
-
- (Object) administrator
Returns the value of attribute administrator.
-
- (Object) approver_confirmed_at
Returns the value of attribute approver_confirmed_at.
-
- (Object) approver_email
Returns the value of attribute approver_email.
-
- (Object) approver_notified_at
Returns the value of attribute approver_notified_at.
-
- (Object) completed_at
Returns the value of attribute completed_at.
-
- (Object) created_at
Returns the value of attribute created_at.
-
- (Object) csr
Returns the value of attribute csr.
-
- (Object) domain
Returns the value of attribute domain.
-
- (Object) ev_approver
Returns the value of attribute ev_approver.
-
- (Object) flagged
readonly
Returns the value of attribute flagged.
-
- (Object) geotrust_order_id
Returns the value of attribute geotrust_order_id.
-
- (Object) id
Returns the value of attribute id.
-
- (Object) licenses
Returns the value of attribute licenses.
-
- (Object) organization
Returns the value of attribute organization.
-
- (Object) renewal
readonly
Returns the value of attribute renewal.
-
- (Object) renewal_information
Returns the value of attribute renewal_information.
-
- (Object) sans
Returns the value of attribute sans.
-
- (Object) state
Returns the value of attribute state.
-
- (Object) status_major
Returns the value of attribute status_major.
-
- (Object) status_minor
Returns the value of attribute status_minor.
-
- (Object) total_price
Returns the value of attribute total_price.
-
- (Object) trial
readonly
Returns the value of attribute trial.
-
- (Object) years
Returns the value of attribute years.
Attributes inherited from ApiObject
Class Method Summary (collapse)
-
+ (Object) all(options = {})
Returns all orders within the requested date range.
-
+ (Object) approvers(domain)
Returns a collection of Email addresses which may approve the given domain.
-
+ (Object) create(attributes = {}, &block)
Creates a new order on GeoCerts with the attributes given.
-
+ (Object) create!(attributes = {}, &block)
Creates a new order on GeoCerts with the attributes given.
-
+ (Object) find(id)
Returns a GeoCerts order by the order id given.
-
+ (Object) find_by_id(id)
Similar to GeoCerts::Product.find, but instead of raising an exception when an order cannot be located, instead it will return nil.
-
+ (Object) validate(attributes = {}, &block)
Validates an order with the attributes provided.
-
+ (Object) validate!(attributes = {}, &block)
See GeoCerts::Order.validate for more information.
Instance Method Summary (collapse)
-
- (Object) certificate
Returns a GeoCerts::Certificate associated with this order.
-
- (Object) change_approver_email!(email)
Updates the approver email for the SSL certificate in the order.
-
- (Object) events(options = {})
Returns a collection of events for the order.
-
- (Object) modify!(action)
Modifies the order state by setting it to the action requested.
-
- (Boolean) new_record?
Returns true if the Order has not been saved.
- - (Object) product
-
- (Object) product=(input)
Sets the product for the order.
-
- (Object) resend_approval_email!
Instructs GeoCerts to resend the SSL certificate approval email to the approval address on the order.
-
- (Object) save
Creates the order in the GeoCerts system.
-
- (Object) save!
Acts similarly to save, but raises a GeoCerts::ResourceNotCreated exception if the order cannot be saved.
-
- (Object) validate
Validates the order attributes provided.
-
- (Object) validate!
Acts similarly to validate, but will raise a GeoCerts::ResourceInvalid exception if validation fails.
Methods inherited from ApiObject
#errors, #errors=, #initialize, #warnings, #warnings=
Constructor Details
This class inherits a constructor from GeoCerts::ApiObject
Instance Attribute Details
- (Object) administrator
Returns the value of attribute administrator
30 31 32 |
# File 'lib/geo_certs/order.rb', line 30 def administrator @administrator end |
- (Object) approver_confirmed_at
Returns the value of attribute approver_confirmed_at
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def approver_confirmed_at @approver_confirmed_at end |
- (Object) approver_email
Returns the value of attribute approver_email
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def approver_email @approver_email end |
- (Object) approver_notified_at
Returns the value of attribute approver_notified_at
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def approver_notified_at @approver_notified_at end |
- (Object) completed_at
Returns the value of attribute completed_at
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def completed_at @completed_at end |
- (Object) created_at
Returns the value of attribute created_at
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def created_at @created_at end |
- (Object) csr
Returns the value of attribute csr
30 31 32 |
# File 'lib/geo_certs/order.rb', line 30 def csr @csr end |
- (Object) domain
Returns the value of attribute domain
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def domain @domain end |
- (Object) ev_approver
Returns the value of attribute ev_approver
30 31 32 |
# File 'lib/geo_certs/order.rb', line 30 def ev_approver @ev_approver end |
- (Object) flagged (readonly)
Returns the value of attribute flagged
30 31 32 |
# File 'lib/geo_certs/order.rb', line 30 def flagged @flagged end |
- (Object) geotrust_order_id
Returns the value of attribute geotrust_order_id
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def geotrust_order_id @geotrust_order_id end |
- (Object) id
Returns the value of attribute id
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def id @id end |
- (Object) licenses
Returns the value of attribute licenses
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def licenses @licenses end |
- (Object) organization
Returns the value of attribute organization
30 31 32 |
# File 'lib/geo_certs/order.rb', line 30 def organization @organization end |
- (Object) renewal (readonly)
Returns the value of attribute renewal
30 31 32 |
# File 'lib/geo_certs/order.rb', line 30 def renewal @renewal end |
- (Object) renewal_information
Returns the value of attribute renewal_information
30 31 32 |
# File 'lib/geo_certs/order.rb', line 30 def renewal_information @renewal_information end |
- (Object) sans
Returns the value of attribute sans
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def sans @sans end |
- (Object) state
Returns the value of attribute state
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def state @state end |
- (Object) status_major
Returns the value of attribute status_major
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def status_major @status_major end |
- (Object) status_minor
Returns the value of attribute status_minor
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def status_minor @status_minor end |
- (Object) total_price
Returns the value of attribute total_price
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def total_price @total_price end |
- (Object) trial (readonly)
Returns the value of attribute trial
30 31 32 |
# File 'lib/geo_certs/order.rb', line 30 def trial @trial end |
- (Object) years
Returns the value of attribute years
15 16 17 |
# File 'lib/geo_certs/order.rb', line 15 def years @years end |
Class Method Details
+ (Object) all(options = {})
Returns all orders within the requested date range. By default the server will return orders within the past month (30 days).
Options
:start_at |
The starting DateTime for the date range |
:end_at |
The ending DateTime for the date range |
54 55 56 57 58 |
# File 'lib/geo_certs/order.rb', line 54 def self.all( = {}) prep_date_ranges!() response = call_api { GeoCerts.api.orders() } build_collection(response) { |response| response[:orders][:order] } end |
+ (Object) approvers(domain)
Returns a collection of Email addresses which may approve the given domain.
88 89 90 91 92 93 |
# File 'lib/geo_certs/order.rb', line 88 def self.approvers(domain) response = call_api { GeoCerts.api.domain_approvers(:domain => domain) } collection = Collection.new response[:emails][:email].each { |email| collection << Email.new(email) } collection end |
+ (Object) create(attributes = {}, &block)
Creates a new order on GeoCerts with the attributes given.
This method will return an Order regardless of whether or not it was saved. You should check new_record? to determine whether or not there was a failure. Also, errors should not be empty if there was a failure.
102 103 104 105 106 |
# File 'lib/geo_certs/order.rb', line 102 def self.create(attributes = {}, &block) object = new(attributes, &block) object.save object end |
+ (Object) create!(attributes = {}, &block)
Creates a new order on GeoCerts with the attributes given.
Exceptions
This method will raise a GeoCerts::ResourceNotCreated exception if the order cannot be created.
116 117 118 119 120 |
# File 'lib/geo_certs/order.rb', line 116 def self.create!(attributes = {}, &block) instance = create(attributes, &block) raise(ResourceNotCreated, instance.errors.collect { |e| e. }.join(', ')) if instance.new_record? instance end |
+ (Object) find(id)
Returns a GeoCerts order by the order id given.
Exceptions
If the id cannot be found on the GeoCerts system, a GeoCerts::ResourceNotFound exception will be raised.
68 69 70 |
# File 'lib/geo_certs/order.rb', line 68 def self.find(id) new(call_api { GeoCerts.api.find_order(:id => id)[:order] }) end |
+ (Object) find_by_id(id)
Similar to GeoCerts::Product.find, but instead of raising an exception when an order cannot be located, instead it will return nil.
See GeoCerts::Product.find for more information.
78 79 80 81 82 |
# File 'lib/geo_certs/order.rb', line 78 def self.find_by_id(id) find(id) rescue GeoCerts::AllowableExceptionWithResponse nil end |
+ (Object) validate(attributes = {}, &block)
Validates an order with the attributes provided. This method will also parse a given CSR body and populate the returned Order's CSR object with the parsed data.
An Order will be returned whether or not validation was successful. To determine if validation was unsuccessful, you should check for errors (i.e. order.errors.empty? should be true).
130 131 132 133 134 |
# File 'lib/geo_certs/order.rb', line 130 def self.validate(attributes = {}, &block) object = new(attributes, &block) object.validate object end |
+ (Object) validate!(attributes = {}, &block)
See GeoCerts::Order.validate for more information.
Exceptions
This method will raise GeoCerts::ResourceInvalid if the order is invalid.
143 144 145 146 147 |
# File 'lib/geo_certs/order.rb', line 143 def self.validate!(attributes = {}, &block) instance = validate(attributes, &block) raise(ResourceInvalid, instance.errors.collect { |e| e. }.join(', ')) unless instance.errors.empty? instance end |
Instance Method Details
- (Object) certificate
Returns a GeoCerts::Certificate associated with this order.
355 356 357 |
# File 'lib/geo_certs/order.rb', line 355 def certificate GeoCerts::Certificate.find_by_order_id(self.id) end |
- (Object) change_approver_email!(email)
Updates the approver email for the SSL certificate in the order.
174 175 176 177 178 |
# File 'lib/geo_certs/order.rb', line 174 def change_approver_email!(email) update_attributes(self.class.call_api { GeoCerts.api.change_order_approval_email(:id => self.id, :approver_email => email) }) end |
- (Object) events(options = {})
Returns a collection of events for the order.
348 349 350 |
# File 'lib/geo_certs/order.rb', line 348 def events( = {}) GeoCerts::Event.find_by_order_id(self.id, ) end |
- (Object) modify!(action)
Modifies the order state by setting it to the action requested.
Acceptable actions are: 'APPROVE' and 'CANCEL'
155 156 157 158 159 |
# File 'lib/geo_certs/order.rb', line 155 def modify!(action) update_attributes(self.class.call_api { GeoCerts.api.modify_order(:id => self.id, :state => action) }) end |
- (Boolean) new_record?
Returns true if the Order has not been saved.
238 239 240 |
# File 'lib/geo_certs/order.rb', line 238 def new_record? self.id.nil? || self.id == '' end |
- (Object) product
301 302 303 |
# File 'lib/geo_certs/order.rb', line 301 def product @product ||= @_product_id ? Product.find(@_product_id) : nil end |
- (Object) product=(input)
Sets the product for the order. You can either pass a GeoCerts::Product object or the SKU for a GeoCerts product.
order.product = GeoCerts::Product.new(:sku => 'QP')
order.product = 'QP'
290 291 292 293 294 295 296 297 298 299 |
# File 'lib/geo_certs/order.rb', line 290 def product=(input) @product = case input when Product input when String Product.find(input) when Hash @_product_id = input[:sku] if input[:sku]; nil end end |
- (Object) resend_approval_email!
Instructs GeoCerts to resend the SSL certificate approval email to the approval address on the order.
165 166 167 168 169 |
# File 'lib/geo_certs/order.rb', line 165 def resend_approval_email! update_attributes(self.class.call_api { GeoCerts.api.resend_approval_email(:id => self.id) }) end |
- (Object) save
Creates the order in the GeoCerts system. This will also deduct the cost of the order from your available balance.
If the order cannot be created, this method will return false.
222 223 224 225 |
# File 'lib/geo_certs/order.rb', line 222 def save new_record? ? create : raise("Cannot update an existing Order") self.errors.empty? ? self : false end |
- (Object) save!
Acts similarly to save, but raises a GeoCerts::ResourceNotCreated exception if the order cannot be saved.
231 232 233 |
# File 'lib/geo_certs/order.rb', line 231 def save! save ? self : raise(GeoCerts::ResourceNotCreated) end |
- (Object) validate
Validates the order attributes provided. You must, at least, provide a CSR and Product:
GeoCerts::Order.new({
:csr => "-----BEGIN CERTIFICATE REQUEST-----\n....",
:product => 'QP'
}).validate
This method will return false if the order is invalid. Details of the validation errors can be found in errors.
192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/geo_certs/order.rb', line 192 def validate parameters = {} parameters[:years] = self.years parameters[:licenses] = self.licenses parameters[:sans] = GeoCerts.escape(self.sans) if self.sans parameters.merge!(self.csr.to_geocerts_hash) if self.csr parameters.merge!(self.product.to_geocerts_hash) if self.product update_attributes(self.class.call_api {GeoCerts.api.validate_order(parameters)[:order]}) rescue GeoCerts::AllowableExceptionWithResponse store_exception_errors_and_warnings($!) false end |
- (Object) validate!
Acts similarly to validate, but will raise a GeoCerts::ResourceInvalid exception if validation fails.
210 211 212 213 214 |
# File 'lib/geo_certs/order.rb', line 210 def validate! validate raise(GeoCerts::ResourceInvalid) unless self.errors.empty? self end |