Class: Intercom::Client

Inherits:
Object
  • Object
show all
Includes:
Options
Defined in:
lib/intercom/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Options

#options

Constructor Details

#initialize(app_id: 'my_app_id', api_key: 'my_api_key') ⇒ Client

Returns a new instance of Client.



16
17
18
19
20
21
# File 'lib/intercom/client.rb', line 16

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

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url.



4
5
6
# File 'lib/intercom/client.rb', line 4

def base_url
  @base_url
end

#rate_limit_detailsObject (readonly)

Returns the value of attribute rate_limit_details.



4
5
6
# File 'lib/intercom/client.rb', line 4

def rate_limit_details
  @rate_limit_details
end

Class Method Details

.set_base_url(base_url) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/intercom/client.rb', line 7

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

Instance Method Details

#adminsObject



23
24
25
# File 'lib/intercom/client.rb', line 23

def admins
  Intercom::Service::Admin.new(self)
end

#companiesObject



27
28
29
# File 'lib/intercom/client.rb', line 27

def companies
  Intercom::Service::Company.new(self)
end

#contactsObject



31
32
33
# File 'lib/intercom/client.rb', line 31

def contacts
  Intercom::Service::Contact.new(self)
end

#conversationsObject



35
36
37
# File 'lib/intercom/client.rb', line 35

def conversations
  Intercom::Service::Conversation.new(self)
end

#countsObject



39
40
41
# File 'lib/intercom/client.rb', line 39

def counts
  Intercom::Service::Counts.new(self)
end

#delete(path, payload_hash) ⇒ Object



83
84
85
# File 'lib/intercom/client.rb', line 83

def delete(path, payload_hash)
  execute_request Intercom::Request.delete(path, payload_hash)
end

#eventsObject



43
44
45
# File 'lib/intercom/client.rb', line 43

def events
  Intercom::Service::Event.new(self)
end

#get(path, params) ⇒ Object



71
72
73
# File 'lib/intercom/client.rb', line 71

def get(path, params)
  execute_request Intercom::Request.get(path, params)
end

#messagesObject



47
48
49
# File 'lib/intercom/client.rb', line 47

def messages
  Intercom::Service::Message.new(self)
end

#notesObject



51
52
53
# File 'lib/intercom/client.rb', line 51

def notes
  Intercom::Service::Note.new(self)
end

#post(path, payload_hash) ⇒ Object



75
76
77
# File 'lib/intercom/client.rb', line 75

def post(path, payload_hash)
  execute_request Intercom::Request.post(path, payload_hash)
end

#put(path, payload_hash) ⇒ Object



79
80
81
# File 'lib/intercom/client.rb', line 79

def put(path, payload_hash)
  execute_request Intercom::Request.put(path, payload_hash)
end

#segmentsObject



59
60
61
# File 'lib/intercom/client.rb', line 59

def segments
  Intercom::Service::Segment.new(self)
end

#subscriptionsObject



55
56
57
# File 'lib/intercom/client.rb', line 55

def subscriptions
  Intercom::Service::Subscription.new(self)
end

#tagsObject



63
64
65
# File 'lib/intercom/client.rb', line 63

def tags
  Intercom::Service::Tag.new(self)
end

#usersObject



67
68
69
# File 'lib/intercom/client.rb', line 67

def users
  Intercom::Service::User.new(self)
end