helpscout 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/helpscout.gemspec +3 -3
- data/lib/helpscout/client.rb +191 -38
- data/lib/helpscout/models.rb +99 -78
- metadata +53 -18
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/helpscout.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "helpscout"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["H\u{e9}ctor Ramos"]
|
12
|
-
s.date = "2013-02-
|
12
|
+
s.date = "2013-02-12"
|
13
13
|
s.description = ""
|
14
14
|
s.email = "hector@hectorramos.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.homepage = "http://github.com/hramos/helpscout"
|
29
29
|
s.licenses = ["MIT"]
|
30
30
|
s.require_paths = ["lib"]
|
31
|
-
s.rubygems_version = "1.8.
|
31
|
+
s.rubygems_version = "1.8.24"
|
32
32
|
s.summary = "HelpScout API Wrapper"
|
33
33
|
|
34
34
|
if s.respond_to? :specification_version then
|
data/lib/helpscout/client.rb
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
# Rate Limiting
|
14
14
|
# Requests will be limited to 200 requests per minute. Response code 429 will
|
15
15
|
# be returned when throttle limit has been reached. A "Retry-After" header will
|
16
|
-
#
|
16
|
+
# be returned indicating how many seconds to wait until retry.
|
17
17
|
#
|
18
18
|
# Formats
|
19
19
|
# Each endpoint will specify the response format in the URL. However, the API
|
@@ -82,13 +82,15 @@ module HelpScout
|
|
82
82
|
# Header Status Int 200
|
83
83
|
# Body item
|
84
84
|
|
85
|
-
def self.
|
85
|
+
def self.request_item(auth, url, params = {})
|
86
86
|
item = nil
|
87
87
|
|
88
88
|
request_url = ""
|
89
89
|
request_url << url
|
90
90
|
if params
|
91
|
-
|
91
|
+
query = ""
|
92
|
+
params.each { |k,v| query += "#{k}=#{v}&" }
|
93
|
+
request_url << "?" + query
|
92
94
|
end
|
93
95
|
|
94
96
|
begin
|
@@ -136,7 +138,7 @@ module HelpScout
|
|
136
138
|
# count Int Total number of objects available
|
137
139
|
# items Array Collection of objects
|
138
140
|
|
139
|
-
def self.
|
141
|
+
def self.request_items(auth, url, params = {})
|
140
142
|
items = []
|
141
143
|
|
142
144
|
request_url = ""
|
@@ -192,7 +194,7 @@ module HelpScout
|
|
192
194
|
# count Int Total number of objects available
|
193
195
|
# items Array Collection of objects
|
194
196
|
|
195
|
-
def self.
|
197
|
+
def self.request_count(auth, url, params = {})
|
196
198
|
request_url = ""
|
197
199
|
request_url << url
|
198
200
|
if params
|
@@ -222,6 +224,36 @@ module HelpScout
|
|
222
224
|
end
|
223
225
|
end
|
224
226
|
|
227
|
+
|
228
|
+
# Sends a POST request to create a single item from the Help Scout API.
|
229
|
+
#
|
230
|
+
# url String A string representing the url to POST.
|
231
|
+
# params Hash A hash of POST parameters to use for this particular
|
232
|
+
# request.
|
233
|
+
#
|
234
|
+
# Response
|
235
|
+
# Name Type Notes
|
236
|
+
# Location String https://api.helpscout.net/v1/conversations/{id}.json
|
237
|
+
|
238
|
+
def self.create_item(auth, url, params = {})
|
239
|
+
begin
|
240
|
+
response = Client.post(url, {:basic_auth => auth, :headers => { 'Content-Type' => 'application/json' }, :body => params })
|
241
|
+
rescue SocketError => se
|
242
|
+
raise StandardError, se.message
|
243
|
+
end
|
244
|
+
|
245
|
+
if response.code == 201
|
246
|
+
if response["item"]
|
247
|
+
response["item"]
|
248
|
+
else
|
249
|
+
response["Location"]
|
250
|
+
end
|
251
|
+
else
|
252
|
+
raise StandardError.new("Server Response: #{response.code} #{response.message}")
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
|
225
257
|
# HelpScout::Client.new
|
226
258
|
#
|
227
259
|
# Initializes the Help Scout Client. Once called, you may use any of the
|
@@ -230,7 +262,7 @@ module HelpScout
|
|
230
262
|
# key String Help Scout API Key. Optional. If not passed, the key will be
|
231
263
|
# loaded from @@settings, which defaults to helpscout.yml.
|
232
264
|
|
233
|
-
def initialize(key
|
265
|
+
def initialize(key=nil)
|
234
266
|
Client.settings
|
235
267
|
|
236
268
|
if key.nil?
|
@@ -252,7 +284,11 @@ module HelpScout
|
|
252
284
|
#
|
253
285
|
# Request
|
254
286
|
# REST Method: GET
|
255
|
-
# URL: https://api.helpscout.net/v1/
|
287
|
+
# URL: https://api.helpscout.net/v1/conversations/{conversationId}.json
|
288
|
+
#
|
289
|
+
# GET Parameters
|
290
|
+
# Name Type
|
291
|
+
# conversationId Int id of the Conversation being requested
|
256
292
|
#
|
257
293
|
# Response
|
258
294
|
# Name Type
|
@@ -260,7 +296,7 @@ module HelpScout
|
|
260
296
|
|
261
297
|
def user(userId)
|
262
298
|
url = "/users/#{userId}.json"
|
263
|
-
item = Client.
|
299
|
+
item = Client.request_item(@auth, url, nil)
|
264
300
|
user = nil
|
265
301
|
if item
|
266
302
|
user = User.new(item)
|
@@ -288,7 +324,7 @@ module HelpScout
|
|
288
324
|
|
289
325
|
def users
|
290
326
|
url = "/users.json"
|
291
|
-
items = Client.
|
327
|
+
items = Client.request_items(@auth, url, :page => 1)
|
292
328
|
users = []
|
293
329
|
items.each do |item|
|
294
330
|
users << User.new(item)
|
@@ -316,9 +352,9 @@ module HelpScout
|
|
316
352
|
# Name Type
|
317
353
|
# items Array Collection of User objects
|
318
354
|
|
319
|
-
def
|
355
|
+
def users_in_mailbox(mailboxId)
|
320
356
|
url ="/mailboxes/#{mailboxId}/users.json"
|
321
|
-
items = Client.
|
357
|
+
items = Client.request_items(@auth, url, :page => 1)
|
322
358
|
users = []
|
323
359
|
items.each do |item|
|
324
360
|
users << User.new(item)
|
@@ -348,12 +384,12 @@ module HelpScout
|
|
348
384
|
url = "/mailboxes.json"
|
349
385
|
mailboxes = []
|
350
386
|
begin
|
351
|
-
items = Client.
|
387
|
+
items = Client.request_items(@auth, url, {})
|
352
388
|
items.each do |item|
|
353
389
|
mailboxes << Mailbox.new(item)
|
354
390
|
end
|
355
391
|
rescue StandardError => e
|
356
|
-
|
392
|
+
puts "List Mailbox Request failed: #{e.message}"
|
357
393
|
end
|
358
394
|
mailboxes
|
359
395
|
end
|
@@ -376,7 +412,7 @@ module HelpScout
|
|
376
412
|
|
377
413
|
def mailbox(mailboxId)
|
378
414
|
url = "/mailboxes/#{mailboxId}.json"
|
379
|
-
item = Client.
|
415
|
+
item = Client.request_item(@auth, url, nil)
|
380
416
|
mailbox = nil
|
381
417
|
if item
|
382
418
|
mailbox = Mailbox.new(item)
|
@@ -404,9 +440,9 @@ module HelpScout
|
|
404
440
|
# Name Type
|
405
441
|
# items Array Collection of Mailbox objects
|
406
442
|
|
407
|
-
def
|
443
|
+
def folders_in_mailbox(mailboxId)
|
408
444
|
url = "/mailboxes/#{mailboxId}/folders.json"
|
409
|
-
items = Client.
|
445
|
+
items = Client.request_items(@auth, url, :page => 1)
|
410
446
|
folders = []
|
411
447
|
items.each do |item|
|
412
448
|
folders << Folder.new(item)
|
@@ -416,7 +452,7 @@ module HelpScout
|
|
416
452
|
|
417
453
|
|
418
454
|
# Get Conversation
|
419
|
-
# http://developer.helpscout.net/conversations/
|
455
|
+
# http://developer.helpscout.net/conversations/get/
|
420
456
|
#
|
421
457
|
# Fetches a single Conversation
|
422
458
|
#
|
@@ -434,19 +470,58 @@ module HelpScout
|
|
434
470
|
url = "/conversations/#{conversationId}.json"
|
435
471
|
|
436
472
|
begin
|
437
|
-
item = Client.
|
473
|
+
item = Client.request_item(@auth, url, nil)
|
438
474
|
conversation = nil
|
439
475
|
if item
|
440
476
|
conversation = Conversation.new(item)
|
441
477
|
end
|
442
478
|
rescue StandardError => e
|
443
|
-
|
479
|
+
puts "Could not fetch conversation with id #{conversationId}: #{e.message}"
|
480
|
+
end
|
481
|
+
end
|
482
|
+
|
483
|
+
|
484
|
+
# Create Conversation
|
485
|
+
# http://developer.helpscout.net/conversations/create/
|
486
|
+
#
|
487
|
+
# Creates a new Conversation.
|
488
|
+
#
|
489
|
+
# Request
|
490
|
+
# REST Method: POST
|
491
|
+
# URL: https://api.helpscout.net/v1/conversations.json
|
492
|
+
#
|
493
|
+
# POST Parameters
|
494
|
+
# Name Type Required Notes
|
495
|
+
# conversation Conversation Yes
|
496
|
+
# import boolean No The import parameter enables
|
497
|
+
# conversations to be created for
|
498
|
+
# historical purposes (i.e. if moving
|
499
|
+
# from a different platform, you can
|
500
|
+
# import your history). When import
|
501
|
+
# is set to true, no outgoing emails
|
502
|
+
# or notifications will be generated.
|
503
|
+
# reload boolean No Set this parameter to 'true' to
|
504
|
+
# return the created conversation in
|
505
|
+
# the response.
|
506
|
+
#
|
507
|
+
|
508
|
+
def create_conversation(conversation)
|
509
|
+
if !conversation
|
510
|
+
raise StandardError.new("Missing Conversation")
|
511
|
+
end
|
512
|
+
|
513
|
+
url = "/conversations.json"
|
514
|
+
|
515
|
+
begin
|
516
|
+
response = Client.create_item(@auth, url, conversation.to_json)
|
517
|
+
rescue StandardError => e
|
518
|
+
puts "Could not create conversation: #{e.message}"
|
444
519
|
end
|
445
520
|
end
|
446
521
|
|
447
522
|
|
448
523
|
# List Conversations
|
449
|
-
# http://developer.helpscout.net/conversations/
|
524
|
+
# http://developer.helpscout.net/conversations/list/
|
450
525
|
#
|
451
526
|
# Fetches conversations in a mailbox with a given status
|
452
527
|
#
|
@@ -513,13 +588,13 @@ module HelpScout
|
|
513
588
|
|
514
589
|
begin
|
515
590
|
options["page"] = page
|
516
|
-
items = Client.
|
591
|
+
items = Client.request_items(@auth, url, options)
|
517
592
|
items.each do |item|
|
518
593
|
conversations << Conversation.new(item)
|
519
594
|
end
|
520
595
|
page = page + 1
|
521
596
|
rescue StandardError => e
|
522
|
-
|
597
|
+
puts "List Conversations Request failed: #{e.message}"
|
523
598
|
end while items && items.count > 0 && (limit == 0 || conversations.count < limit)
|
524
599
|
|
525
600
|
if limit > 0 && conversations.count > limit
|
@@ -573,7 +648,7 @@ module HelpScout
|
|
573
648
|
# threads, you need to retrieve the full conversation object
|
574
649
|
# via the Get Conversation call.
|
575
650
|
|
576
|
-
def
|
651
|
+
def conversations_in_folder(mailboxId, folderId, status, limit=0, modifiedSince)
|
577
652
|
url = "/mailboxes/#{mailboxId}/folders/#{folderId}/conversations.json"
|
578
653
|
|
579
654
|
page = 1
|
@@ -595,13 +670,13 @@ module HelpScout
|
|
595
670
|
|
596
671
|
begin
|
597
672
|
options["page"] = page
|
598
|
-
items = Client.
|
673
|
+
items = Client.request_items(@auth, url, options)
|
599
674
|
items.each do |item|
|
600
675
|
conversations << Conversation.new(item)
|
601
676
|
end
|
602
677
|
page = page + 1
|
603
678
|
rescue StandardError => e
|
604
|
-
|
679
|
+
puts "List Conversations In Folder Request failed: #{e.message}"
|
605
680
|
end while items && items.count > 0 && (limit == 0 || conversations.count < limit)
|
606
681
|
|
607
682
|
if limit > 0 && conversations.count > limit
|
@@ -647,7 +722,7 @@ module HelpScout
|
|
647
722
|
# Name Type
|
648
723
|
# count Integer Count of Conversation objects.
|
649
724
|
|
650
|
-
def
|
725
|
+
def conversation_count(mailboxId, status, modifiedSince)
|
651
726
|
url = "/mailboxes/#{mailboxId}/conversations.json"
|
652
727
|
|
653
728
|
page = 1
|
@@ -665,9 +740,9 @@ module HelpScout
|
|
665
740
|
|
666
741
|
begin
|
667
742
|
options["page"] = page
|
668
|
-
count = Client.
|
743
|
+
count = Client.request_count(@auth, url, options)
|
669
744
|
rescue StandardError => e
|
670
|
-
|
745
|
+
puts "Conversation Count Request failed: #{e.message}"
|
671
746
|
end
|
672
747
|
end
|
673
748
|
|
@@ -687,9 +762,9 @@ module HelpScout
|
|
687
762
|
# Name Type
|
688
763
|
# item Conversation::AttachmentData
|
689
764
|
|
690
|
-
def
|
765
|
+
def attachment_data(attachmentId)
|
691
766
|
url = "/attachments/#{attachmentId}/data.json"
|
692
|
-
item = Client.
|
767
|
+
item = Client.request_item(@auth, url, nil)
|
693
768
|
attachmentData = nil
|
694
769
|
if item
|
695
770
|
attachmentData = Conversation::AttachmentData.new(item)
|
@@ -716,7 +791,7 @@ module HelpScout
|
|
716
791
|
|
717
792
|
def customer(customerId)
|
718
793
|
url = "/customers/#{customerId}.json"
|
719
|
-
item = Client.
|
794
|
+
item = Client.request_item(@auth, url, nil)
|
720
795
|
customer = nil
|
721
796
|
if item
|
722
797
|
customer = Customer.new(item)
|
@@ -729,8 +804,10 @@ module HelpScout
|
|
729
804
|
# List Customers
|
730
805
|
# http://developer.helpscout.net/customers/
|
731
806
|
#
|
732
|
-
#
|
733
|
-
#
|
807
|
+
# Customers can be filtered on any combination of first name, last name, and
|
808
|
+
# email.
|
809
|
+
#
|
810
|
+
# Customers are returned by createdAt date, from newest to oldest.
|
734
811
|
#
|
735
812
|
# Request
|
736
813
|
# REST Method: GET
|
@@ -738,21 +815,97 @@ module HelpScout
|
|
738
815
|
#
|
739
816
|
# Parameters:
|
740
817
|
# Name Type Required Default Notes
|
741
|
-
#
|
818
|
+
# Name Type Required Default
|
819
|
+
# firstName String No
|
820
|
+
# lastName String No
|
821
|
+
# email String No
|
822
|
+
# page Int No 1
|
742
823
|
#
|
743
824
|
# Response
|
744
825
|
# Name Type
|
745
826
|
# items Array Collection of Customer objects.
|
746
827
|
|
747
|
-
def customers
|
828
|
+
def customers(limit=0, firstName=nil, lastName=nil, email=nil)
|
748
829
|
url = "/customers.json"
|
749
|
-
|
830
|
+
|
831
|
+
page = 1
|
832
|
+
options = {}
|
833
|
+
|
834
|
+
if limit < 0
|
835
|
+
limit = 0
|
836
|
+
end
|
837
|
+
|
838
|
+
if firstName
|
839
|
+
options["firstName"] = firstName
|
840
|
+
end
|
841
|
+
|
842
|
+
if lastName
|
843
|
+
options["lastName"] = lastName
|
844
|
+
end
|
845
|
+
|
846
|
+
if email
|
847
|
+
options["email"] = email
|
848
|
+
end
|
849
|
+
|
750
850
|
customers = []
|
751
|
-
|
752
|
-
|
851
|
+
|
852
|
+
begin
|
853
|
+
options["page"] = page
|
854
|
+
items = Client.request_items(@auth, url, options)
|
855
|
+
items.each do |item|
|
856
|
+
customers << Customer.new(item)
|
857
|
+
end
|
858
|
+
page = page + 1
|
859
|
+
rescue StandardError => e
|
860
|
+
puts "Request failed: #{e.message}"
|
861
|
+
end while items && items.count > 0 && (limit == 0 || customers.count < limit)
|
862
|
+
|
863
|
+
if limit > 0 && customers.count > limit
|
864
|
+
customers = customers[0..limit-1]
|
753
865
|
end
|
754
866
|
|
755
867
|
customers
|
756
868
|
end
|
869
|
+
|
870
|
+
# Helper method to find customers by email
|
871
|
+
def customers_by_email(email)
|
872
|
+
customers(0, nil, nil, email)
|
873
|
+
end
|
874
|
+
|
875
|
+
# Create Customer
|
876
|
+
# http://developer.helpscout.net/customers/create/
|
877
|
+
#
|
878
|
+
# Creates a new Customer.
|
879
|
+
#
|
880
|
+
# Request
|
881
|
+
# REST Method: POST
|
882
|
+
# URL: https://api.helpscout.net/v1/customers.json
|
883
|
+
#
|
884
|
+
# POST Parameters
|
885
|
+
# Name Type Required Notes
|
886
|
+
# customer Customer Yes The body of the request
|
887
|
+
# reload boolean No Set to true to return the customer in the
|
888
|
+
# response.
|
889
|
+
# Response
|
890
|
+
# Response Name Type Notes
|
891
|
+
# Header Status Integer 201
|
892
|
+
# Header Location String https://api.helpscout.net/v1/customer/{id}.json
|
893
|
+
|
894
|
+
def create_customer(customer)
|
895
|
+
if !customer
|
896
|
+
raise StandardError.new("Missing Customer")
|
897
|
+
end
|
898
|
+
|
899
|
+
url = "/customers.json"
|
900
|
+
params = JSON.parse(customer.to_json)
|
901
|
+
|
902
|
+
begin
|
903
|
+
response = Client.create_item(@auth, url, customer.to_json)
|
904
|
+
true
|
905
|
+
rescue StandardError => e
|
906
|
+
puts "Could not create customer: #{e.message}"
|
907
|
+
false
|
908
|
+
end
|
909
|
+
end
|
757
910
|
end
|
758
911
|
end
|
data/lib/helpscout/models.rb
CHANGED
@@ -68,14 +68,14 @@ module HelpScout
|
|
68
68
|
# *name String Feedback Name of the Mailbox
|
69
69
|
# slug String 47204a026903ce6d Key used to represent this
|
70
70
|
# Mailbox
|
71
|
-
# email String feedback@
|
71
|
+
# email String feedback@parse.com Email address
|
72
72
|
# createdAt DateTime 2012-07-23T12:34:12Z UTC time when this mailbox was
|
73
73
|
# created.
|
74
74
|
# modifiedAt DateTime 2012-07-24T20:18:33Z UTC time when this mailbox was
|
75
75
|
# modified.
|
76
76
|
|
77
77
|
class Mailbox
|
78
|
-
attr_reader :id, :name, :slug, :email, :createdAt, :modifiedAt
|
78
|
+
attr_reader :id, :name, :slug, :email, :createdAt, :modifiedAt, :folders
|
79
79
|
|
80
80
|
# Creates a new Mailbox object from a Hash of attributes
|
81
81
|
def initialize(object)
|
@@ -87,6 +87,13 @@ module HelpScout
|
|
87
87
|
|
88
88
|
@slug = object["slug"]
|
89
89
|
@email = object["email"]
|
90
|
+
|
91
|
+
@folders = []
|
92
|
+
if object["folders"]
|
93
|
+
object["folders"].each do |folder|
|
94
|
+
@folders << Folder.new(folder)
|
95
|
+
end
|
96
|
+
end
|
90
97
|
end
|
91
98
|
end
|
92
99
|
|
@@ -101,12 +108,12 @@ module HelpScout
|
|
101
108
|
# isDraft Boolean false Is this a draft?
|
102
109
|
# number Int 349 The conversation number
|
103
110
|
# displayed in the UI.
|
104
|
-
# owner User
|
111
|
+
# owner Person User of the Help Scout user
|
105
112
|
# that is currently assigned
|
106
113
|
# to this conversation
|
107
114
|
# mailbox Mailbox Mailbox to which this
|
108
115
|
# conversation belongs.
|
109
|
-
# customer Customer
|
116
|
+
# customer Person Customer to which this
|
110
117
|
# conversation belongs.
|
111
118
|
# threadCount Int 4 This count represents the
|
112
119
|
# number of published threads
|
@@ -118,9 +125,9 @@ module HelpScout
|
|
118
125
|
# status String active Status of the conversation.
|
119
126
|
# subject String I need help!
|
120
127
|
# preview String Hello, I...
|
121
|
-
# createdBy
|
122
|
-
#
|
123
|
-
#
|
128
|
+
# createdBy Person Either the Customer or User
|
129
|
+
# that created this
|
130
|
+
# conversation.
|
124
131
|
# Inspect the Source object
|
125
132
|
# for clarification.
|
126
133
|
# createdAt DateTime 2012-07-23T12:34:12Z UTC time when this
|
@@ -130,7 +137,7 @@ module HelpScout
|
|
130
137
|
# closedAt DateTime UTC time when this
|
131
138
|
# conversation was closed.
|
132
139
|
# Null if not closed.
|
133
|
-
# closedBy User
|
140
|
+
# closedBy Person User of the Help Scout user
|
134
141
|
# that closed this
|
135
142
|
# conversation.
|
136
143
|
# source Source Specifies the method in
|
@@ -153,7 +160,7 @@ module HelpScout
|
|
153
160
|
# * STATUS_SPAM
|
154
161
|
|
155
162
|
class Conversation
|
156
|
-
attr_reader :id, :folderId, :isDraft, :number, :owner, :mailbox, :customer, :threadCount, :status, :subject, :preview, :createdBy, :createdAt, :modifiedAt, :closedAt, :closedBy, :source, :cc, :bcc, :tags, :threads, :url
|
163
|
+
attr_reader :id, :type, :folderId, :isDraft, :number, :owner, :mailbox, :customer, :threadCount, :status, :subject, :preview, :createdBy, :createdAt, :modifiedAt, :closedAt, :closedBy, :source, :cc, :bcc, :tags, :threads, :url
|
157
164
|
|
158
165
|
STATUS_ACTIVE = "active"
|
159
166
|
STATUS_PENDING = "pending"
|
@@ -165,32 +172,22 @@ module HelpScout
|
|
165
172
|
@createdAt = DateTime.iso8601(object["createdAt"]) if object["createdAt"]
|
166
173
|
@modifiedAt = DateTime.iso8601(object["userModifiedAt"]) if object["userModifiedAt"]
|
167
174
|
@closedAt = DateTime.iso8601(object["closedAt"]) if object["closedAt"]
|
175
|
+
|
168
176
|
@id = object["id"]
|
177
|
+
@type = object["type"]
|
169
178
|
@folderId = object["folderId"]
|
170
179
|
@isDraft = object["isDraft"]
|
171
180
|
@number = object["number"]
|
172
|
-
@owner =
|
181
|
+
@owner = Person.new(object["owner"]) if object["owner"]
|
173
182
|
@mailbox = Mailbox.new(object["mailbox"]) if object["mailbox"]
|
174
|
-
@customer =
|
183
|
+
@customer = Person.new(object["customer"]) if object["customer"]
|
175
184
|
@threadCount = object["threadCount"]
|
176
185
|
@status = object["status"]
|
177
186
|
@subject = object["subject"]
|
178
187
|
@preview = object["preview"]
|
179
|
-
@closedBy =
|
180
|
-
|
181
|
-
@source =
|
182
|
-
if object["source"]
|
183
|
-
@source = Source.new(object["source"])
|
184
|
-
|
185
|
-
if object["createdBy"]
|
186
|
-
if @source.type == Source::VIA_CUSTOMER
|
187
|
-
@createdBy = Customer.new(object["createdBy"])
|
188
|
-
elsif @source.type == Source::VIA_USER
|
189
|
-
@createdBy = User.new(object["createdBy"])
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
188
|
+
@closedBy = Person.new(object["closedBy"]) if object["closedBy"]
|
189
|
+
@createdBy = Person.new(object["person"]) if object["person"]
|
190
|
+
@source = Source.new(object["source"]) if object["source"]
|
194
191
|
@cc = object["cc"]
|
195
192
|
@bcc = object["bcc"]
|
196
193
|
@tags = object["tags"]
|
@@ -216,7 +213,7 @@ module HelpScout
|
|
216
213
|
#
|
217
214
|
# Name Type Example Notes
|
218
215
|
# id Int 88171881 Unique identifier
|
219
|
-
# assignedTo User
|
216
|
+
# assignedTo Person User of the Help Scout user
|
220
217
|
# to which this conversation
|
221
218
|
# has been assigned.
|
222
219
|
# status String active Status of the thread. Thread
|
@@ -226,9 +223,9 @@ module HelpScout
|
|
226
223
|
# be set to STATUS_NO_CHANGE.
|
227
224
|
# createdAt DateTime 2012-07-23T12:34:12Z UTC time when this thread
|
228
225
|
# was created.
|
229
|
-
# createdBy
|
230
|
-
#
|
231
|
-
#
|
226
|
+
# createdBy Person Either the Customer or User
|
227
|
+
# that created this
|
228
|
+
# conversation. Inspect the
|
232
229
|
# Source object for
|
233
230
|
# clarification.
|
234
231
|
# source Source
|
@@ -238,7 +235,7 @@ module HelpScout
|
|
238
235
|
# which it was moved.
|
239
236
|
# type String message The type of thread.
|
240
237
|
# state String published The state of the thread.
|
241
|
-
# customer
|
238
|
+
# customer Person If type is message, this is
|
242
239
|
# the Customer of the customer
|
243
240
|
# in which the message was
|
244
241
|
# sent. If type is customer,
|
@@ -319,26 +316,14 @@ module HelpScout
|
|
319
316
|
@createdAt = DateTime.iso8601(object["createdAt"]) if object["createdAt"]
|
320
317
|
|
321
318
|
@id = object["id"]
|
322
|
-
@assignedTo =
|
319
|
+
@assignedTo = Person.new(object["assignedTo"]) if object["assignedTo"]
|
320
|
+
@createdBy = Person.new(object["createdBy"]) if object["createdBy"]
|
323
321
|
@status = object["status"]
|
324
|
-
|
325
|
-
@source = nil
|
326
|
-
if object["source"]
|
327
|
-
@source = Source.new(object["source"])
|
328
|
-
|
329
|
-
if object["createdBy"]
|
330
|
-
if @source.type == Source::VIA_CUSTOMER
|
331
|
-
@createdBy = Customer.new(object["createdBy"])
|
332
|
-
elsif @source.type == Source::VIA_USER
|
333
|
-
@createdBy = User.new(object["createdBy"])
|
334
|
-
end
|
335
|
-
end
|
336
|
-
end
|
337
|
-
|
322
|
+
@source = Source.new(object["source"]) if object["source"]
|
338
323
|
@fromMailbox = Mailbox.new(object["fromMailbox"]) if object["fromMailbox"]
|
339
324
|
@type = object["type"]
|
340
325
|
@state = object["state"]
|
341
|
-
@customer =
|
326
|
+
@customer = Person.new(object["customer"]) if object["customer"]
|
342
327
|
@body = object["body"]
|
343
328
|
@to = object["to"]
|
344
329
|
@cc = object["cc"]
|
@@ -408,21 +393,56 @@ module HelpScout
|
|
408
393
|
end
|
409
394
|
|
410
395
|
|
411
|
-
#
|
412
|
-
# http://developer.helpscout.net/objects/
|
413
|
-
# http://developer.helpscout.net/objects/user/user-ref/
|
396
|
+
# Person
|
397
|
+
# http://developer.helpscout.net/objects/person/
|
414
398
|
#
|
415
|
-
#
|
416
|
-
#
|
399
|
+
# The person object is a subset of the data representing a Customer or
|
400
|
+
# User. The 'type' property will specify if this person is represented by
|
401
|
+
# a 'user' or a 'customer'.
|
417
402
|
#
|
418
|
-
#
|
419
|
-
#
|
403
|
+
# Name Type Example Notes
|
404
|
+
# id Int 1234 Unique identifier
|
405
|
+
# firstName String Jack
|
406
|
+
# lastName String Sprout
|
407
|
+
# email String jack.sprout@gmail.com
|
408
|
+
# phone String 800-555-1212
|
409
|
+
# type String user
|
410
|
+
#
|
411
|
+
# Possible values for type include:
|
412
|
+
# * TYPE_USER
|
413
|
+
# * TYPE_CUSTOMER
|
414
|
+
|
415
|
+
class Person
|
416
|
+
attr_reader :id, :firstName, :lastName, :email, :phone, :type
|
417
|
+
|
418
|
+
TYPE_USER = "user"
|
419
|
+
TYPE_CUSTOMER = "customer"
|
420
|
+
|
421
|
+
# Creates a new Person object from a Hash of attributes
|
422
|
+
def initialize(object)
|
423
|
+
@id = object["id"]
|
424
|
+
@firstName = object["firstName"]
|
425
|
+
@lastName = object["lastName"]
|
426
|
+
@email = object["email"]
|
427
|
+
@phone = object["phone"]
|
428
|
+
@type = object["type"]
|
429
|
+
end
|
430
|
+
|
431
|
+
# Returns a String suitable for display
|
432
|
+
def to_s
|
433
|
+
"#{@firstName} #{@lastName}"
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
|
438
|
+
# User
|
439
|
+
# http://developer.helpscout.net/objects/user/
|
420
440
|
#
|
421
441
|
# Name Type Example Notes
|
422
|
-
#
|
423
|
-
#
|
424
|
-
#
|
425
|
-
#
|
442
|
+
# id Int 1234 Unique identifier
|
443
|
+
# firstName String Jack
|
444
|
+
# lastName String Sprout
|
445
|
+
# email String jack.sprout@gmail.com
|
426
446
|
# role String owner Role of this user.
|
427
447
|
# timezone String America/New_York
|
428
448
|
# photoUrl String http://.../avatar.jpg The user's photo, if one
|
@@ -438,7 +458,7 @@ module HelpScout
|
|
438
458
|
# * ROLE_USER
|
439
459
|
|
440
460
|
class User
|
441
|
-
attr_reader :id, :firstName, :lastName, :email, :role, :timezone, :photoUrl, :createdAt, :
|
461
|
+
attr_reader :id, :firstName, :lastName, :email, :role, :timezone, :photoUrl, :createdAt, :modifiedAt
|
442
462
|
|
443
463
|
ROLE_OWNER = "owner"
|
444
464
|
ROLE_ADMIN = "admin"
|
@@ -447,6 +467,7 @@ module HelpScout
|
|
447
467
|
# Creates a new User object from a Hash of attributes
|
448
468
|
def initialize(object)
|
449
469
|
@createdAt = DateTime.iso8601(object["createdAt"]) if object["createdAt"]
|
470
|
+
@modifiedAt = DateTime.iso8601(object["modifiedAt"]) if object["modifiedAt"]
|
450
471
|
|
451
472
|
@id = object["id"]
|
452
473
|
@firstName = object["firstName"]
|
@@ -455,7 +476,6 @@ module HelpScout
|
|
455
476
|
@role = object["role"]
|
456
477
|
@timezone = object["timezone"]
|
457
478
|
@photoUrl = object["photoUrl"]
|
458
|
-
@createdBy = object["createdBy"]
|
459
479
|
end
|
460
480
|
|
461
481
|
# Returns a String suitable for display
|
@@ -464,18 +484,11 @@ module HelpScout
|
|
464
484
|
end
|
465
485
|
end
|
466
486
|
|
467
|
-
|
468
487
|
# Customer
|
469
488
|
# http://developer.helpscout.net/objects/customer/
|
470
|
-
# http://developer.helpscout.net/objects/customer/customer-ref/
|
471
|
-
#
|
472
|
-
# CustomerRefs are a subset of a full Customer object, and only include the
|
473
|
-
# attributes marked with a *.
|
474
|
-
#
|
475
|
-
# CustomerRefs are returned by endpoints that include multiple customers.
|
476
489
|
#
|
477
|
-
#
|
478
|
-
#
|
490
|
+
# Attributes marked with a * are returned when listing customers. Other
|
491
|
+
# attributes are only returned when fetching a single customer.
|
479
492
|
#
|
480
493
|
# Name Type Example Notes
|
481
494
|
# *id Int 29418 Unique identifier
|
@@ -483,17 +496,25 @@ module HelpScout
|
|
483
496
|
# *lastName String Bear
|
484
497
|
# *email String vbear@mywork.com If the customer has multiple
|
485
498
|
# emails, only one is returned.
|
486
|
-
#
|
487
|
-
#
|
488
|
-
#
|
489
|
-
#
|
490
|
-
#
|
491
|
-
#
|
492
|
-
#
|
493
|
-
#
|
499
|
+
# *photoUrl String http://../avatar.jpg
|
500
|
+
# *photoType String twitter Type of photo.
|
501
|
+
# *gender String Male Gender of this customer.
|
502
|
+
# *age String 30-35
|
503
|
+
# *organization String Acme, Inc
|
504
|
+
# *jobTitle String CEO and Co-Founder
|
505
|
+
# *location String Austin
|
506
|
+
# *createdAt DateTime 2012-07-23T12:34:12Z UTC time when this customer
|
494
507
|
# was created.
|
495
|
-
#
|
508
|
+
# *modifiedAt DateTime 2012-07-24T20:18:33Z UTC time when this customer
|
496
509
|
# was modified.
|
510
|
+
# background String I've worked with... This is the Background Info
|
511
|
+
# field from the UI.
|
512
|
+
# address Address
|
513
|
+
# socialProfiles Array Array of SocialProfiles
|
514
|
+
# emails Array Array of Emails
|
515
|
+
# phones Array Array of Phones
|
516
|
+
# chats Array Array of Chats
|
517
|
+
# websites Array Array of Websites
|
497
518
|
#
|
498
519
|
# Possible values for photoType include:
|
499
520
|
# * PHOTO_TYPE_UNKNOWN
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: helpscout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: bundler
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: 1.2.3
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.2.3
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: jeweler
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: 1.8.4
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.4
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: httparty
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: simplecov
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: reek
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ~>
|
@@ -76,10 +101,15 @@ dependencies:
|
|
76
101
|
version: 1.2.8
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.2.8
|
80
110
|
- !ruby/object:Gem::Dependency
|
81
111
|
name: rdoc
|
82
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
83
113
|
none: false
|
84
114
|
requirements:
|
85
115
|
- - ! '>='
|
@@ -87,7 +117,12 @@ dependencies:
|
|
87
117
|
version: '0'
|
88
118
|
type: :development
|
89
119
|
prerelease: false
|
90
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
91
126
|
description: ''
|
92
127
|
email: hector@hectorramos.com
|
93
128
|
executables: []
|
@@ -118,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
153
|
version: '0'
|
119
154
|
segments:
|
120
155
|
- 0
|
121
|
-
hash:
|
156
|
+
hash: 3673943477065505692
|
122
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
158
|
none: false
|
124
159
|
requirements:
|
@@ -127,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
162
|
version: '0'
|
128
163
|
requirements: []
|
129
164
|
rubyforge_project:
|
130
|
-
rubygems_version: 1.8.
|
165
|
+
rubygems_version: 1.8.24
|
131
166
|
signing_key:
|
132
167
|
specification_version: 3
|
133
168
|
summary: HelpScout API Wrapper
|