riboseinc / digicert

Ruby bindings for the Digicert Services API
https://www.digicert.com/services/v2/documentation
MIT License
8 stars 10 forks source link

When there are no duplicate certificates, don't error out #136

Closed kwkwan closed 6 years ago

kwkwan commented 6 years ago

When there are no duplicate certificates, the following calls will error out.

order.duplicate_certificates
# or
Digicert::DuplicateCertificateFinder.find_by(request_id: request_id)

Will lead to this error:

===============[API Reqeust Begin]================
[URI] GET https://www.digicert.com/services/v2/order/certificate/order_id/duplicate
[Headers] {"content-type"=>["application/json"], "x-dc-devkey"=>["xxxxxxxxx"], "host"=>["www.digicert.com"]}
[Response] #<Net::HTTPOK 200 OK readbody=true>
[Response Body] {}
================[API Reqeust End]=================
NoMethodError: private method `select' called for nil:NilClass
from /Users/user/src/digicert/lib/digicert/duplicate_certificate_finder.rb:24:in `certificates_by_date_created'

It would be more appropriate to return an empty array.

abunashir commented 6 years ago

Thanks for reporting this @kwkwan, you are right, I just updated the finder so if there is no duplicate certificate then it won't raise an error but return nil instead, thanks!