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', token: nil) ⇒ Client

Returns a new instance of Client.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/intercom/client.rb', line 17

def initialize(app_id: 'my_app_id', api_key: 'my_api_key', token: nil)
  if token
    @username_part = token
    @password_part = ""
  else
    @username_part = app_id
    @password_part = api_key
  end
  validate_credentials!

  @base_url = 'https://api.intercom.io'
  @rate_limit_details = {}
end

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url.



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

def base_url
  @base_url
end

#password_partObject (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_detailsObject (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

#username_partObject (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

Instance Method Details

#adminsObject



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

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

#companiesObject



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

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

#contactsObject



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

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

#conversationsObject



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

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

#countsObject



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

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

#delete(path, payload_hash) ⇒ Object



99
100
101
# File 'lib/intercom/client.rb', line 99

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

#eventsObject



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

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

#get(path, params) ⇒ Object



87
88
89
# File 'lib/intercom/client.rb', line 87

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

#jobsObject



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

def jobs
  Intercom::Service::Job.new(self)
end

#messagesObject



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

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

#notesObject



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

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

#post(path, payload_hash) ⇒ Object



91
92
93
# File 'lib/intercom/client.rb', line 91

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

#put(path, payload_hash) ⇒ Object



95
96
97
# File 'lib/intercom/client.rb', line 95

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

#segmentsObject



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

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

#subscriptionsObject



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

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

#tagsObject



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

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

#usersObject



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

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

#visitorsObject



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

def visitors
  Intercom::Service::Visitor.new(self)
end