Class: SendPulse::Api

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id, client_secret, protocol = 'https', token = '') ⇒ Api



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sendpulse/api.rb', line 9

def initialize(client_id, client_secret, protocol = 'https', token = '')
  main_url = SendPulse::Host.main_url
  @url = "#{protocol}://#{main_url}"
  @client_id = client_id
  @client_secret = client_secret
  @protocol = protocol
  @refresh_token = 0
  @token = token

  if @token.nil? || @token.empty?
    raise 'Could not connect to API, check your CLIENT_ID and CLIENT_SECRET' unless refresh_token
  end
end

Instance Attribute Details

#client_idObject (readonly)

Returns the value of attribute client_id.



7
8
9
# File 'lib/sendpulse/api.rb', line 7

def client_id
  @client_id
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



7
8
9
# File 'lib/sendpulse/api.rb', line 7

def client_secret
  @client_secret
end

#protocolObject (readonly)

Returns the value of attribute protocol.



7
8
9
# File 'lib/sendpulse/api.rb', line 7

def protocol
  @protocol
end

#tokenObject (readonly)

Returns the value of attribute token.



7
8
9
# File 'lib/sendpulse/api.rb', line 7

def token
  @token
end