Class: Newslettre::API

Inherits:
Object
  • Object
show all
Defined in:
lib/newslettre/api.rb

Defined Under Namespace

Classes: ClientFailure, EndpointFailure, NotAuthenticatedFailure

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ API

Returns a new instance of API.



4
5
6
7
8
9
# File 'lib/newslettre/api.rb', line 4

def initialize options = {}
  @url = "https://sendgrid.com/api/newsletter"
  @email = options.delete :email
  @password = options.delete :password
  @format = :json
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



2
3
4
# File 'lib/newslettre/api.rb', line 2

def email
  @email
end

#formatObject

Returns the value of attribute format.



2
3
4
# File 'lib/newslettre/api.rb', line 2

def format
  @format
end

#passwordObject

Returns the value of attribute password.



2
3
4
# File 'lib/newslettre/api.rb', line 2

def password
  @password
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/newslettre/api.rb', line 2

def url
  @url
end

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/newslettre/api.rb', line 11

def authenticated?
  not email.nil? and not password.nil?
end