Class: CrystalSDK::EmailSample::Request
- Inherits:
-
Object
- Object
- CrystalSDK::EmailSample::Request
- Defined in:
- lib/crystal_sdk/email_sample/request.rb
Instance Method Summary collapse
- #check_for_error(resp) ⇒ Object
- #from_all ⇒ Object
-
#initialize(id) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(id) ⇒ Request
Returns a new instance of Request.
8 9 10 |
# File 'lib/crystal_sdk/email_sample/request.rb', line 8 def initialize(id) @id = id end |
Instance Method Details
#check_for_error(resp) ⇒ Object
23 24 25 26 |
# File 'lib/crystal_sdk/email_sample/request.rb', line 23 def check_for_error(resp) raise EmailSample::NotAuthedError.new(Base.key) if resp.code == '401' raise EmailSample::NotFoundError if resp.code == '404' end |
#from_all ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/crystal_sdk/email_sample/request.rb', line 12 def from_all begin resp = Api.make_request(:get, "emails/#{@id}") rescue Nestful::ResponseError => e check_for_error(e.response) raise e end body = JSON.parse(resp.body || '{}', symbolize_names: true) end |