Class: Emites::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/emites/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Client

Returns a new instance of Client.



5
6
7
# File 'lib/emites/client.rb', line 5

def initialize(token)
  @http = Http.new(token)
end

Instance Attribute Details

#httpObject (readonly)

Returns the value of attribute http.



3
4
5
# File 'lib/emites/client.rb', line 3

def http
  @http
end

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
# File 'lib/emites/client.rb', line 9

def authenticated?
  http.get("") do |response|
    response.code == 200
  end
rescue RequestError => e
  raise e unless e.code == 401
  false
end

#emittersObject



18
19
20
# File 'lib/emites/client.rb', line 18

def emitters
  Resources::Emitter.new(http)
end

#nfseObject



26
27
28
# File 'lib/emites/client.rb', line 26

def nfse
  Resources::Nfse.new(http)
end

#servicesObject



34
35
36
# File 'lib/emites/client.rb', line 34

def services
  Resources::Service.new(http)
end

#takersObject



30
31
32
# File 'lib/emites/client.rb', line 30

def takers
  Resources::Taker.new(http)
end

#webhooksObject



22
23
24
# File 'lib/emites/client.rb', line 22

def webhooks
  Resources::Webhook.new(http)
end