Sha256: 54030d154ad0f2c2d363d96990cbb8d3d57d2295c9ad8a9408e5727ff0d760bc
Contents?: true
Size: 1.93 KB
Versions: 1
Compression:
Stored size: 1.93 KB
Contents
module Intercom class Client include Options attr_reader :base_url, :rate_limit_details class << self def set_base_url(base_url) return Proc.new do |o| old_url = o.base_url o.send(:base_url=, base_url) Proc.new { |obj| set_base_url(old_url).call(o) } end end end def initialize(app_id: 'my_app_id', api_key: 'my_api_key') @app_id = app_id @api_key = api_key @base_url = 'https://api.intercom.io' @rate_limit_details = {} end def admins Intercom::Service::Admin.new(self) end def companies Intercom::Service::Company.new(self) end def contacts Intercom::Service::Contact.new(self) end def conversations Intercom::Service::Conversation.new(self) end def events Intercom::Service::Event.new(self) end def messages Intercom::Service::Message.new(self) end def notes Intercom::Service::Note.new(self) end def subscriptions Intercom::Service::Subscription.new(self) end def segments Intercom::Service::Segment.new(self) end def tags Intercom::Service::Tag.new(self) end def users Intercom::Service::User.new(self) end def get(path, params) execute_request Intercom::Request.get(path, params) end def post(path, payload_hash) execute_request Intercom::Request.post(path, payload_hash) end def put(path, payload_hash) execute_request Intercom::Request.put(path, payload_hash) end def delete(path, payload_hash) execute_request Intercom::Request.delete(path, payload_hash) end private def execute_request(request) result = request.execute(@base_url, username: @app_id, secret: @api_key) @rate_limit_details = request.rate_limit_details result end def base_url=(new_url) @base_url = new_url end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
intercom-3.0.0b1 | lib/intercom/client.rb |