Class: Emites::Client
- Inherits:
-
Object
- Object
- Emites::Client
- Defined in:
- lib/emites/client.rb
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
Instance Method Summary collapse
- #authenticated? ⇒ Boolean
- #emitters ⇒ Object
-
#initialize(token) ⇒ Client
constructor
A new instance of Client.
- #nfse ⇒ Object
- #services ⇒ Object
- #takers ⇒ Object
- #webhooks ⇒ Object
Constructor Details
#initialize(token) ⇒ Client
5 6 7 |
# File 'lib/emites/client.rb', line 5 def initialize(token) @http = Http.new(token) end |
Instance Attribute Details
#http ⇒ Object (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
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 |
#emitters ⇒ Object
18 19 20 |
# File 'lib/emites/client.rb', line 18 def emitters Resources::Emitter.new(http) end |
#nfse ⇒ Object
26 27 28 |
# File 'lib/emites/client.rb', line 26 def nfse Resources::Nfse.new(http) end |
#services ⇒ Object
34 35 36 |
# File 'lib/emites/client.rb', line 34 def services Resources::Service.new(http) end |
#takers ⇒ Object
30 31 32 |
# File 'lib/emites/client.rb', line 30 def takers Resources::Taker.new(http) end |
#webhooks ⇒ Object
22 23 24 |
# File 'lib/emites/client.rb', line 22 def webhooks Resources::Webhook.new(http) end |