Class: NiftyEmail

Inherits:
Object
  • Object
show all
Defined in:
lib/nifty-email.rb

Defined Under Namespace

Classes: Email, NiftyEmailError

Class Method Summary collapse

Class Method Details

.get_email(slug_or_id, placeholders = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/nifty-email.rb', line 14

def self.get_email(slug_or_id, placeholders = {})
  connection = Faraday.new(url: 'http://nifty-email-production.herokuapp.com/api/emails')
  connection.authorization('Token', token: @token)

  response = connection.get("#{slug_or_id}.json", placeholders)

  if response.status == 200
    NiftyEmail::Email.new(JSON.parse(response.body))
  else
    raise NiftyEmailError, response.body
  end
end

.tokenObject



10
11
12
# File 'lib/nifty-email.rb', line 10

def self.token
  @token
end

.token=(token) ⇒ Object



6
7
8
# File 'lib/nifty-email.rb', line 6

def self.token=(token)
  @token = token
end