Exception: Pin::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/pin/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, json_body) ⇒ Error

Returns a new instance of Error.



18
19
20
21
# File 'lib/pin/error.rb', line 18

def initialize(status, json_body)
  @status = status
  @json_body = JSON.parse(json_body)
end

Instance Attribute Details

#json_bodyObject

Possible Responses

200 - (OK) Successful request 422 - (invalid_resource) One or more parameters were missing or invalid 400 - (card_declined) The card was declined 400 - (insufficient_funds) Bad api_key or not authorized to access a resource. 400 - (suspected_fraud) The resource requested doesn’t exist. 400 - (expired_card) Clever screwed up. 404 - (resource_not_found) No resource was found at this URL. 500 - Server errors



16
17
18
# File 'lib/pin/error.rb', line 16

def json_body
  @json_body
end

#statusObject

Possible Responses

200 - (OK) Successful request 422 - (invalid_resource) One or more parameters were missing or invalid 400 - (card_declined) The card was declined 400 - (insufficient_funds) Bad api_key or not authorized to access a resource. 400 - (suspected_fraud) The resource requested doesn’t exist. 400 - (expired_card) Clever screwed up. 404 - (resource_not_found) No resource was found at this URL. 500 - Server errors



16
17
18
# File 'lib/pin/error.rb', line 16

def status
  @status
end

Instance Method Details

#detailsObject



31
32
33
# File 'lib/pin/error.rb', line 31

def details
  @json_body
end

#errorObject



23
24
25
# File 'lib/pin/error.rb', line 23

def error
  @json_body['error']
end

#error_descriptionObject



27
28
29
# File 'lib/pin/error.rb', line 27

def error_description
  @json_body['error_description']
end

#to_sObject



35
36
37
# File 'lib/pin/error.rb', line 35

def to_s
  "HTTP Error #{@status}: #{error}"
end