Class: Intercom::Client
- Inherits:
-
Object
- Object
- Intercom::Client
- Includes:
- DeprecatedResources, 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.
-
#rate_limit_details ⇒ Object
readonly
Returns the value of attribute rate_limit_details.
-
#timeouts ⇒ Object
readonly
Returns the value of attribute timeouts.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
- #admins ⇒ Object
- #articles ⇒ Object
- #collections ⇒ Object
- #companies ⇒ Object
- #contacts ⇒ Object
- #conversations ⇒ Object
- #counts ⇒ Object
- #data_attributes ⇒ Object
- #delete(path, payload_hash) ⇒ Object
- #events ⇒ Object
- #export_content ⇒ Object
- #get(path, params) ⇒ Object
-
#initialize(token: nil, base_url: 'https://api.intercom.io', handle_rate_limit: false, api_version: nil) ⇒ Client
constructor
A new instance of Client.
- #jobs ⇒ Object
- #leads ⇒ Object
- #messages ⇒ Object
- #notes ⇒ Object
- #phone_call_redirect ⇒ Object
- #post(path, payload_hash) ⇒ Object
- #put(path, payload_hash) ⇒ Object
- #sections ⇒ Object
- #segments ⇒ Object
- #subscription_types ⇒ Object
- #subscriptions ⇒ Object
- #tags ⇒ Object
- #teams ⇒ Object
- #users ⇒ Object
- #visitors ⇒ Object
Methods included from DeprecatedResources
#deprecated__leads, #deprecated__users
Methods included from Options
Constructor Details
#initialize(token: nil, base_url: 'https://api.intercom.io', handle_rate_limit: false, api_version: nil) ⇒ Client
Returns a new instance of Client.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/intercom/client.rb', line 31 def initialize(token: nil, base_url: 'https://api.intercom.io', handle_rate_limit: false, api_version: nil) @token = token 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.
8 9 10 |
# File 'lib/intercom/client.rb', line 8 def api_version @api_version end |
#base_url ⇒ Object
Returns the value of attribute base_url.
8 9 10 |
# File 'lib/intercom/client.rb', line 8 def base_url @base_url end |
#handle_rate_limit ⇒ Object (readonly)
Returns the value of attribute handle_rate_limit.
8 9 10 |
# File 'lib/intercom/client.rb', line 8 def handle_rate_limit @handle_rate_limit end |
#rate_limit_details ⇒ Object (readonly)
Returns the value of attribute rate_limit_details.
8 9 10 |
# File 'lib/intercom/client.rb', line 8 def rate_limit_details @rate_limit_details end |
#timeouts ⇒ Object
Returns the value of attribute timeouts.
8 9 10 |
# File 'lib/intercom/client.rb', line 8 def timeouts @timeouts end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
8 9 10 |
# File 'lib/intercom/client.rb', line 8 def token @token end |
Class Method Details
.set_base_url(base_url) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/intercom/client.rb', line 11 def set_base_url(base_url) proc do |o| old_url = o.base_url o.send(:base_url=, base_url) proc { |_obj| set_base_url(old_url).call(o) } end end |
.set_timeouts(open_timeout: nil, read_timeout: nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/intercom/client.rb', line 19 def set_timeouts(open_timeout: nil, read_timeout: nil) proc 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 { |_obj| set_timeouts(old_timeouts).call(o) } end end |
Instance Method Details
#admins ⇒ Object
47 48 49 |
# File 'lib/intercom/client.rb', line 47 def admins Intercom::Service::Admin.new(self) end |
#articles ⇒ Object
51 52 53 |
# File 'lib/intercom/client.rb', line 51 def articles Intercom::Service::Article.new(self) end |
#collections ⇒ Object
127 128 129 |
# File 'lib/intercom/client.rb', line 127 def collections Intercom::Service::Collection.new(self) end |
#companies ⇒ Object
55 56 57 |
# File 'lib/intercom/client.rb', line 55 def companies Intercom::Service::Company.new(self) end |
#contacts ⇒ Object
59 60 61 |
# File 'lib/intercom/client.rb', line 59 def contacts Intercom::Service::Contact.new(self) end |
#conversations ⇒ Object
63 64 65 |
# File 'lib/intercom/client.rb', line 63 def conversations Intercom::Service::Conversation.new(self) end |
#counts ⇒ Object
67 68 69 |
# File 'lib/intercom/client.rb', line 67 def counts Intercom::Service::Counts.new(self) end |
#data_attributes ⇒ Object
123 124 125 |
# File 'lib/intercom/client.rb', line 123 def data_attributes Intercom::Service::DataAttribute.new(self) end |
#delete(path, payload_hash) ⇒ Object
151 152 153 |
# File 'lib/intercom/client.rb', line 151 def delete(path, payload_hash) execute_request Intercom::Request.delete(path, payload_hash) end |
#events ⇒ Object
71 72 73 |
# File 'lib/intercom/client.rb', line 71 def events Intercom::Service::Event.new(self) end |
#export_content ⇒ Object
131 132 133 |
# File 'lib/intercom/client.rb', line 131 def export_content Intercom::Service::ExportContent.new(self) end |
#get(path, params) ⇒ Object
139 140 141 |
# File 'lib/intercom/client.rb', line 139 def get(path, params) execute_request Intercom::Request.get(path, params) end |
#jobs ⇒ Object
119 120 121 |
# File 'lib/intercom/client.rb', line 119 def jobs Intercom::Service::Job.new(self) end |
#leads ⇒ Object
111 112 113 |
# File 'lib/intercom/client.rb', line 111 def leads Intercom::Service::Lead.new(self) end |
#messages ⇒ Object
75 76 77 |
# File 'lib/intercom/client.rb', line 75 def Intercom::Service::Message.new(self) end |
#notes ⇒ Object
79 80 81 |
# File 'lib/intercom/client.rb', line 79 def notes Intercom::Service::Note.new(self) end |
#phone_call_redirect ⇒ Object
135 136 137 |
# File 'lib/intercom/client.rb', line 135 def phone_call_redirect Intercom::Service::PhoneCallRedirect.new(self) end |
#post(path, payload_hash) ⇒ Object
143 144 145 |
# File 'lib/intercom/client.rb', line 143 def post(path, payload_hash) execute_request Intercom::Request.post(path, payload_hash) end |
#put(path, payload_hash) ⇒ Object
147 148 149 |
# File 'lib/intercom/client.rb', line 147 def put(path, payload_hash) execute_request Intercom::Request.put(path, payload_hash) end |
#sections ⇒ Object
95 96 97 |
# File 'lib/intercom/client.rb', line 95 def sections Intercom::Service::Section.new(self) end |
#segments ⇒ Object
91 92 93 |
# File 'lib/intercom/client.rb', line 91 def segments Intercom::Service::Segment.new(self) end |
#subscription_types ⇒ Object
87 88 89 |
# File 'lib/intercom/client.rb', line 87 def subscription_types Intercom::Service::SubscriptionType.new(self) end |
#subscriptions ⇒ Object
83 84 85 |
# File 'lib/intercom/client.rb', line 83 def subscriptions Intercom::Service::Subscription.new(self) end |
#tags ⇒ Object
99 100 101 |
# File 'lib/intercom/client.rb', line 99 def Intercom::Service::Tag.new(self) end |
#teams ⇒ Object
103 104 105 |
# File 'lib/intercom/client.rb', line 103 def teams Intercom::Service::Team.new(self) end |