Class: InvisibleCollector::API
- Inherits:
-
Object
- Object
- InvisibleCollector::API
- Defined in:
- lib/invisible_collector/api.rb
Constant Summary collapse
- INVISIBLECOLLECTOR_API =
'https://api.invisiblecollector.com'
Instance Attribute Summary collapse
-
#api_token ⇒ Object
readonly
Returns the value of attribute api_token.
Instance Method Summary collapse
- #alarm(options = {}) ⇒ Object
- #company(options = {}) ⇒ Object
- #connection ⇒ Object
- #customer(options = {}) ⇒ Object
- #debt(options = {}) ⇒ Object
- #group(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ API
constructor
A new instance of API.
- #payment(options = {}) ⇒ Object
- #resources ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ API
Returns a new instance of API.
11 12 13 14 |
# File 'lib/invisible_collector/api.rb', line 11 def initialize( = {}) @api_token = .with_indifferent_access[:api_token] @host = .with_indifferent_access[:host] end |
Instance Attribute Details
#api_token ⇒ Object (readonly)
Returns the value of attribute api_token.
9 10 11 |
# File 'lib/invisible_collector/api.rb', line 9 def api_token @api_token end |
Instance Method Details
#alarm(options = {}) ⇒ Object
22 23 24 25 |
# File 'lib/invisible_collector/api.rb', line 22 def alarm( = {}) resources[:alarm] ||= Resources::AlarmResource.new({ connection: connection }.merge()) resources[:alarm] end |
#company(options = {}) ⇒ Object
27 28 29 30 |
# File 'lib/invisible_collector/api.rb', line 27 def company( = {}) resources[:company] ||= Resources::CompanyResource.new({ connection: connection }.merge()) resources[:company] end |
#connection ⇒ Object
16 17 18 19 20 |
# File 'lib/invisible_collector/api.rb', line 16 def connection @connection ||= Faraday.new do |req| req.adapter :net_http end end |
#customer(options = {}) ⇒ Object
32 33 34 35 |
# File 'lib/invisible_collector/api.rb', line 32 def customer( = {}) resources[:customer] ||= Resources::CustomerResource.new({ connection: connection }.merge()) resources[:customer] end |
#debt(options = {}) ⇒ Object
37 38 39 40 |
# File 'lib/invisible_collector/api.rb', line 37 def debt( = {}) resources[:debt] ||= Resources::DebtResource.new({ connection: connection }.merge()) resources[:debt] end |
#group(options = {}) ⇒ Object
47 48 49 50 |
# File 'lib/invisible_collector/api.rb', line 47 def group( = {}) resources[:group] ||= Resources::GroupResource.new({ connection: connection }.merge()) resources[:group] end |
#payment(options = {}) ⇒ Object
42 43 44 45 |
# File 'lib/invisible_collector/api.rb', line 42 def payment( = {}) resources[:payment] ||= Resources::PaymentResource.new({ connection: connection }.merge()) resources[:payment] end |
#resources ⇒ Object
52 53 54 |
# File 'lib/invisible_collector/api.rb', line 52 def resources @resources ||= {} end |