class InvisibleCollector::API
Constants
- INVISIBLECOLLECTOR_API
Attributes
api_token[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/invisible_collector/api.rb, line 11 def initialize(options = {}) @api_token = options.with_indifferent_access[:api_token] @host = options.with_indifferent_access[:host] end
Public Instance Methods
alarm(options = {})
click to toggle source
# File lib/invisible_collector/api.rb, line 22 def alarm(options = {}) resources[:alarm] ||= Resources::AlarmResource.new({ connection: connection }.merge(options)) resources[:alarm] end
company(options = {})
click to toggle source
# File lib/invisible_collector/api.rb, line 27 def company(options = {}) resources[:company] ||= Resources::CompanyResource.new({ connection: connection }.merge(options)) resources[:company] end
connection()
click to toggle source
# File lib/invisible_collector/api.rb, line 16 def connection @connection ||= Faraday.new connection_options do |req| req.adapter :net_http end end
customer(options = {})
click to toggle source
# File lib/invisible_collector/api.rb, line 32 def customer(options = {}) resources[:customer] ||= Resources::CustomerResource.new({ connection: connection }.merge(options)) resources[:customer] end
debt(options = {})
click to toggle source
# File lib/invisible_collector/api.rb, line 37 def debt(options = {}) resources[:debt] ||= Resources::DebtResource.new({ connection: connection }.merge(options)) resources[:debt] end
group(options = {})
click to toggle source
# File lib/invisible_collector/api.rb, line 47 def group(options = {}) resources[:group] ||= Resources::GroupResource.new({ connection: connection }.merge(options)) resources[:group] end
payment(options = {})
click to toggle source
# File lib/invisible_collector/api.rb, line 42 def payment(options = {}) resources[:payment] ||= Resources::PaymentResource.new({ connection: connection }.merge(options)) resources[:payment] end
resources()
click to toggle source
# File lib/invisible_collector/api.rb, line 52 def resources @resources ||= {} end
Private Instance Methods
connection_options()
click to toggle source
# File lib/invisible_collector/api.rb, line 58 def connection_options { url: @host || INVISIBLECOLLECTOR_API, headers: { content_type: 'application/json', 'User-Agent' => "InvisibleCollector Ruby v#{InvisibleCollector::VERSION}", 'Authorization' => "Bearer #{api_token}" } } end