Class: Intercom::Client
- Inherits:
-
Object
- Object
- Intercom::Client
- Includes:
- Options
- Defined in:
- lib/intercom/client.rb
Instance Attribute Summary collapse
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#handle_rate_limit ⇒ Object
readonly
Returns the value of attribute handle_rate_limit.
-
#password_part ⇒ Object
readonly
Returns the value of attribute password_part.
-
#rate_limit_details ⇒ Object
readonly
Returns the value of attribute rate_limit_details.
-
#timeouts ⇒ Object
readonly
Returns the value of attribute timeouts.
-
#username_part ⇒ Object
readonly
Returns the value of attribute username_part.
Class Method Summary collapse
Instance Method Summary collapse
- #admins ⇒ Object
- #companies ⇒ Object
- #contacts ⇒ Object
- #conversations ⇒ Object
- #counts ⇒ Object
- #delete(path, payload_hash) ⇒ Object
- #events ⇒ Object
- #get(path, params) ⇒ Object
-
#initialize(app_id: 'my_app_id', api_key: 'my_api_key', token: nil, base_url: 'https://api.intercom.io', handle_rate_limit: false, api_version: nil) ⇒ Client
constructor
A new instance of Client.
- #jobs ⇒ Object
- #messages ⇒ Object
- #notes ⇒ Object
- #post(path, payload_hash) ⇒ Object
- #put(path, payload_hash) ⇒ Object
- #segments ⇒ Object
- #subscriptions ⇒ Object
- #tags ⇒ Object
- #users ⇒ Object
- #visitors ⇒ Object
Methods included from Options
Constructor Details
#initialize(app_id: 'my_app_id', api_key: 'my_api_key', token: nil, base_url: 'https://api.intercom.io', handle_rate_limit: false, api_version: nil) ⇒ Client
Returns a new instance of Client.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/intercom/client.rb', line 28 def initialize(app_id: 'my_app_id', api_key: 'my_api_key', token: nil, base_url:'https://api.intercom.io', handle_rate_limit: false, api_version: nil) if token @username_part = token @password_part = "" else @username_part = app_id @password_part = api_key end validate_credentials! @api_version = api_version validate_api_version! @base_url = base_url @rate_limit_details = {} @handle_rate_limit = handle_rate_limit @timeouts = { open_timeout: 30, read_timeout: 90 } end |
Instance Attribute Details
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
5 6 7 |
# File 'lib/intercom/client.rb', line 5 def api_version @api_version end |
#base_url ⇒ Object
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/intercom/client.rb', line 5 def base_url @base_url end |
#handle_rate_limit ⇒ Object (readonly)
Returns the value of attribute handle_rate_limit.
5 6 7 |
# File 'lib/intercom/client.rb', line 5 def handle_rate_limit @handle_rate_limit end |
#password_part ⇒ Object (readonly)
Returns the value of attribute password_part.
5 6 7 |
# File 'lib/intercom/client.rb', line 5 def password_part @password_part end |
#rate_limit_details ⇒ Object (readonly)
Returns the value of attribute rate_limit_details.
5 6 7 |
# File 'lib/intercom/client.rb', line 5 def rate_limit_details @rate_limit_details end |
#timeouts ⇒ Object
Returns the value of attribute timeouts.
5 6 7 |
# File 'lib/intercom/client.rb', line 5 def timeouts @timeouts end |
#username_part ⇒ Object (readonly)
Returns the value of attribute username_part.
5 6 7 |
# File 'lib/intercom/client.rb', line 5 def username_part @username_part end |
Class Method Details
.set_base_url(base_url) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/intercom/client.rb', line 8 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 |
.set_timeouts(open_timeout: nil, read_timeout: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/intercom/client.rb', line 16 def set_timeouts(open_timeout: nil, read_timeout: nil) return Proc.new do |o| old_timeouts = o.timeouts timeouts = {} timeouts[:open_timeout] = open_timeout if open_timeout timeouts[:read_timeout] = read_timeout if read_timeout o.send(:timeouts=, timeouts) Proc.new { |obj| set_timeouts(old_timeouts).call(o) } end end |
Instance Method Details
#admins ⇒ Object
50 51 52 |
# File 'lib/intercom/client.rb', line 50 def admins Intercom::Service::Admin.new(self) end |
#companies ⇒ Object
54 55 56 |
# File 'lib/intercom/client.rb', line 54 def companies Intercom::Service::Company.new(self) end |
#contacts ⇒ Object
58 59 60 |
# File 'lib/intercom/client.rb', line 58 def contacts Intercom::Service::Contact.new(self) end |
#conversations ⇒ Object
62 63 64 |
# File 'lib/intercom/client.rb', line 62 def conversations Intercom::Service::Conversation.new(self) end |
#counts ⇒ Object
66 67 68 |
# File 'lib/intercom/client.rb', line 66 def counts Intercom::Service::Counts.new(self) end |
#delete(path, payload_hash) ⇒ Object
118 119 120 |
# File 'lib/intercom/client.rb', line 118 def delete(path, payload_hash) execute_request Intercom::Request.delete(path, payload_hash) end |
#events ⇒ Object
70 71 72 |
# File 'lib/intercom/client.rb', line 70 def events Intercom::Service::Event.new(self) end |
#get(path, params) ⇒ Object
106 107 108 |
# File 'lib/intercom/client.rb', line 106 def get(path, params) execute_request Intercom::Request.get(path, params) end |
#jobs ⇒ Object
102 103 104 |
# File 'lib/intercom/client.rb', line 102 def jobs Intercom::Service::Job.new(self) end |
#messages ⇒ Object
74 75 76 |
# File 'lib/intercom/client.rb', line 74 def Intercom::Service::Message.new(self) end |
#notes ⇒ Object
78 79 80 |
# File 'lib/intercom/client.rb', line 78 def notes Intercom::Service::Note.new(self) end |
#post(path, payload_hash) ⇒ Object
110 111 112 |
# File 'lib/intercom/client.rb', line 110 def post(path, payload_hash) execute_request Intercom::Request.post(path, payload_hash) end |
#put(path, payload_hash) ⇒ Object
114 115 116 |
# File 'lib/intercom/client.rb', line 114 def put(path, payload_hash) execute_request Intercom::Request.put(path, payload_hash) end |
#segments ⇒ Object
86 87 88 |
# File 'lib/intercom/client.rb', line 86 def segments Intercom::Service::Segment.new(self) end |
#subscriptions ⇒ Object
82 83 84 |
# File 'lib/intercom/client.rb', line 82 def subscriptions Intercom::Service::Subscription.new(self) end |
#tags ⇒ Object
90 91 92 |
# File 'lib/intercom/client.rb', line 90 def Intercom::Service::Tag.new(self) end |