Class: NiftyEmail
- Inherits:
-
Object
show all
- Defined in:
- lib/nifty-email.rb
Defined Under Namespace
Classes: Email, NiftyEmailError
Class Method Summary
collapse
Class Method Details
.api_token=(api_token) ⇒ Object
6
7
8
|
# File 'lib/nifty-email.rb', line 6
def self.api_token=(api_token)
@api_token = api_token
end
|
.get_email(slug_or_id, placeholders = {}) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/nifty-email.rb', line 10
def self.get_email(slug_or_id, placeholders = {})
connection = Faraday.new(url: 'http://nifty-email-production.herokuapp.com/api/emails')
connection.authorization('Token', token: @api_token)
response = connection.get("#{slug_or_id}.json", placeholders)
if response.status == 200
NiftyEmail::Email.new(JSON.parse(response.body))
else
raise NiftyEmailError, JSON.parse(response.body)['error']
end
end
|