desk 0.3.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.mkd +305 -106
- data/TRANSITION.mkd +133 -0
- data/desk.gemspec +1 -1
- data/lib/desk.rb +1 -1
- data/lib/desk/api.rb +5 -1
- data/lib/desk/client.rb +184 -10
- data/lib/desk/client/article.rb +4 -83
- data/lib/desk/client/brand.rb +11 -0
- data/lib/desk/client/case.rb +59 -42
- data/lib/desk/client/company.rb +11 -0
- data/lib/desk/client/custom_field.rb +10 -0
- data/lib/desk/client/customer.rb +26 -124
- data/lib/desk/client/facebook_user.rb +11 -0
- data/lib/desk/client/filter.rb +11 -0
- data/lib/desk/client/group.rb +3 -29
- data/lib/desk/client/insight.rb +17 -0
- data/lib/desk/client/integration_url.rb +11 -0
- data/lib/desk/client/job.rb +11 -0
- data/lib/desk/client/label.rb +11 -0
- data/lib/desk/client/macro.rb +3 -133
- data/lib/desk/client/mailbox.rb +26 -0
- data/lib/desk/client/rule.rb +14 -0
- data/lib/desk/client/site_setting.rb +11 -0
- data/lib/desk/client/system_message.rb +16 -0
- data/lib/desk/client/topic.rb +4 -81
- data/lib/desk/client/twitter_account.rb +11 -0
- data/lib/desk/client/twitter_user.rb +11 -0
- data/lib/desk/client/user.rb +3 -30
- data/lib/desk/configuration.rb +1 -1
- data/lib/desk/connection.rb +2 -1
- data/lib/desk/deash.rb +100 -0
- data/lib/desk/request.rb +33 -20
- data/lib/desk/version.rb +1 -1
- data/lib/faraday/request/oauth.rb +6 -3
- data/lib/faraday/response/deashify.rb +23 -0
- data/spec/desk/client/article_spec.rb +62 -117
- data/spec/desk/client/brand_spec.rb +18 -0
- data/spec/desk/client/case_spec.rb +182 -66
- data/spec/desk/client/companies_spec.rb +26 -0
- data/spec/desk/client/custom_fields_spec.rb +18 -0
- data/spec/desk/client/customer_spec.rb +16 -145
- data/spec/desk/client/facebook_users_spec.rb +17 -0
- data/spec/desk/client/filter_spec.rb +28 -0
- data/spec/desk/client/group_spec.rb +32 -49
- data/spec/desk/client/inbound_mailboxes_spec.rb +70 -0
- data/spec/desk/client/integration_url_spec.rb +28 -0
- data/spec/desk/client/job_spec.rb +32 -0
- data/spec/desk/client/label_spec.rb +31 -0
- data/spec/desk/client/macro_spec.rb +22 -185
- data/spec/desk/client/rule_spec.rb +18 -0
- data/spec/desk/client/site_setting_spec.rb +18 -0
- data/spec/desk/client/system_message_spec.rb +42 -0
- data/spec/desk/client/topic_spec.rb +31 -112
- data/spec/desk/client/twitter_account_spec.rb +32 -0
- data/spec/desk/client/twitter_user_spec.rb +27 -0
- data/spec/desk/client/user_spec.rb +19 -42
- data/spec/desk_spec.rb +2 -2
- data/spec/faraday/response_spec.rb +3 -6
- data/spec/fixtures/article +50 -0
- data/spec/fixtures/article_create +50 -0
- data/spec/fixtures/article_translation +29 -0
- data/spec/fixtures/article_translation_create +29 -0
- data/spec/fixtures/article_translation_update +29 -0
- data/spec/fixtures/article_translations +81 -0
- data/spec/fixtures/article_update +50 -0
- data/spec/fixtures/articles +123 -0
- data/spec/fixtures/articles_search +124 -0
- data/spec/fixtures/brand +11 -0
- data/spec/fixtures/brands +45 -0
- data/spec/fixtures/case +44 -0
- data/spec/fixtures/case_attachment +19 -0
- data/spec/fixtures/case_attachment_create +19 -0
- data/spec/fixtures/case_attachments +61 -0
- data/spec/fixtures/case_create +51 -0
- data/spec/fixtures/case_message +26 -0
- data/spec/fixtures/case_note +21 -0
- data/spec/fixtures/case_note_create +26 -0
- data/spec/fixtures/case_notes +65 -0
- data/spec/fixtures/case_replies +75 -0
- data/spec/fixtures/case_reply +26 -0
- data/spec/fixtures/case_reply_create +26 -0
- data/spec/fixtures/case_reply_update +26 -0
- data/spec/fixtures/case_update +49 -0
- data/spec/fixtures/cases +111 -0
- data/spec/fixtures/cases_search +113 -0
- data/spec/fixtures/companies +75 -0
- data/spec/fixtures/companies_search +76 -0
- data/spec/fixtures/company +26 -0
- data/spec/fixtures/company_create +26 -0
- data/spec/fixtures/company_search +76 -0
- data/spec/fixtures/company_update +27 -0
- data/spec/fixtures/custom_field +15 -0
- data/spec/fixtures/custom_fields +58 -0
- data/spec/fixtures/customer +60 -0
- data/spec/fixtures/customer_create +54 -0
- data/spec/fixtures/customer_update +60 -0
- data/spec/fixtures/customers +143 -0
- data/spec/fixtures/customers_search +143 -0
- data/spec/fixtures/facebook_user +16 -0
- data/spec/fixtures/facebook_users +55 -0
- data/spec/fixtures/filter +16 -0
- data/spec/fixtures/filter_cases +111 -0
- data/spec/fixtures/filters +55 -0
- data/spec/fixtures/group +9 -0
- data/spec/fixtures/group_filters +55 -0
- data/spec/fixtures/group_users +63 -0
- data/spec/fixtures/groups +42 -0
- data/spec/fixtures/inbound_mailbox +32 -0
- data/spec/fixtures/inbound_mailboxes +87 -0
- data/spec/fixtures/integration_url +15 -0
- data/spec/fixtures/integration_url_create +15 -0
- data/spec/fixtures/integration_url_update +15 -0
- data/spec/fixtures/integration_urls +54 -0
- data/spec/fixtures/job +17 -0
- data/spec/fixtures/job_create +17 -0
- data/spec/fixtures/jobs +57 -0
- data/spec/fixtures/label +17 -0
- data/spec/fixtures/label_create +17 -0
- data/spec/fixtures/label_update +17 -0
- data/spec/fixtures/labels +57 -0
- data/spec/fixtures/macro +20 -0
- data/spec/fixtures/macro_action +17 -0
- data/spec/fixtures/macro_action_update +17 -0
- data/spec/fixtures/macro_actions +57 -0
- data/spec/fixtures/macro_create +20 -0
- data/spec/fixtures/macro_update +20 -0
- data/spec/fixtures/macros +63 -0
- data/spec/fixtures/rule +13 -0
- data/spec/fixtures/rules +49 -0
- data/spec/fixtures/site_setting +10 -0
- data/spec/fixtures/site_settings +43 -0
- data/spec/fixtures/system_message +4 -0
- data/spec/fixtures/topic +23 -0
- data/spec/fixtures/topic_create +23 -0
- data/spec/fixtures/topic_translation +12 -0
- data/spec/fixtures/topic_translation_create +12 -0
- data/spec/fixtures/topic_translation_update +12 -0
- data/spec/fixtures/topic_translations +47 -0
- data/spec/fixtures/topic_update +23 -0
- data/spec/fixtures/topics +69 -0
- data/spec/fixtures/twitter_account +14 -0
- data/spec/fixtures/twitter_account_tweet +20 -0
- data/spec/fixtures/twitter_account_tweet_create +20 -0
- data/spec/fixtures/twitter_account_tweets +63 -0
- data/spec/fixtures/twitter_accounts +51 -0
- data/spec/fixtures/twitter_user +18 -0
- data/spec/fixtures/twitter_user_create +18 -0
- data/spec/fixtures/twitter_users +59 -0
- data/spec/fixtures/user +20 -0
- data/spec/fixtures/user_preference +18 -0
- data/spec/fixtures/user_preference_update +14 -0
- data/spec/fixtures/user_preferences +223 -0
- data/spec/fixtures/users +63 -0
- data/spec/helper.rb +12 -0
- data/spec/shared_context.rb +16 -0
- data/spec/shared_examples.rb +312 -0
- metadata +247 -181
- data/lib/desk/client/interaction.rb +0 -75
- data/spec/desk/client/interaction_spec.rb +0 -191
- data/spec/fixtures/article.json +0 -50
- data/spec/fixtures/article_create.json +0 -54
- data/spec/fixtures/article_destroy.json +0 -3
- data/spec/fixtures/article_update.json +0 -54
- data/spec/fixtures/articles.json +0 -58
- data/spec/fixtures/case.json +0 -59
- data/spec/fixtures/case_update.json +0 -59
- data/spec/fixtures/cases.json +0 -182
- data/spec/fixtures/customer.json +0 -58
- data/spec/fixtures/customer_create.json +0 -56
- data/spec/fixtures/customer_create_email.json +0 -15
- data/spec/fixtures/customer_update.json +0 -47
- data/spec/fixtures/customer_update_email.json +0 -15
- data/spec/fixtures/customers.json +0 -98
- data/spec/fixtures/group.json +0 -8
- data/spec/fixtures/groups.json +0 -23
- data/spec/fixtures/interaction_create.json +0 -126
- data/spec/fixtures/interactions.json +0 -139
- data/spec/fixtures/macro.json +0 -8
- data/spec/fixtures/macro_action.json +0 -9
- data/spec/fixtures/macro_action_update.json +0 -12
- data/spec/fixtures/macro_actions.json +0 -69
- data/spec/fixtures/macro_create.json +0 -13
- data/spec/fixtures/macro_destroy.json +0 -3
- data/spec/fixtures/macro_update.json +0 -13
- data/spec/fixtures/macros.json +0 -24
- data/spec/fixtures/topic.json +0 -9
- data/spec/fixtures/topic_create.json +0 -14
- data/spec/fixtures/topic_destroy.json +0 -3
- data/spec/fixtures/topic_update.json +0 -14
- data/spec/fixtures/topics.json +0 -35
- data/spec/fixtures/user.json +0 -15
- data/spec/fixtures/users.json +0 -24
data/lib/desk/version.rb
CHANGED
@@ -6,11 +6,14 @@ module Faraday
|
|
6
6
|
|
7
7
|
def call(env)
|
8
8
|
params = env[:body] || {}
|
9
|
-
|
9
|
+
break
|
10
10
|
signature_params = params.reject{ |k,v| v.respond_to?(:content_type) || (env[:method] == :put) }
|
11
11
|
|
12
|
-
header = SimpleOAuth::Header.new(env[:method], env[:url], signature_params, @options)
|
13
|
-
|
12
|
+
#header = SimpleOAuth::Header.new(env[:method], env[:url], signature_params, @options)
|
13
|
+
# Runscope Support
|
14
|
+
realURL = env[:url].sub(/-desk-com-(\w)+.runscope.net/, ".desk.com")
|
15
|
+
header = SimpleOAuth::Header.new(env[:method], realURL, signature_params, @options)
|
16
|
+
env[:request_headers]['theURL'] = realURL
|
14
17
|
env[:request_headers]['Authorization'] = header.to_s
|
15
18
|
|
16
19
|
@app.call(env)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'faraday_middleware/response/mashify'
|
2
|
+
|
3
|
+
module FaradayMiddleware
|
4
|
+
# Public: Converts parsed response bodies to a Hashie::Rash if they were of
|
5
|
+
# Hash or Array type.
|
6
|
+
class Deashify < Mashify
|
7
|
+
dependency do
|
8
|
+
require 'desk/deash'
|
9
|
+
self.mash_class = ::Hashie::Deash
|
10
|
+
end
|
11
|
+
|
12
|
+
def parse(body)
|
13
|
+
case body
|
14
|
+
when Hash
|
15
|
+
raw = mash_class.new({:raw => body})
|
16
|
+
when Array
|
17
|
+
raw = body.map { |item| parse(item) }
|
18
|
+
else
|
19
|
+
raw = body
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,132 +1,77 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
describe Desk::Client do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should get the correct resource" do
|
45
|
-
@client.article(13)
|
46
|
-
a_get("articles/13.#{format}").
|
47
|
-
should have_been_made
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should return up to 100 cases worth of extended information" do
|
51
|
-
article = @client.article(13)
|
52
|
-
|
53
|
-
article.id.should == 13
|
54
|
-
article.subject.should == "API Tips"
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe ".create_article" do
|
61
|
-
|
62
|
-
context "create" do
|
63
|
-
|
64
|
-
before do
|
65
|
-
stub_post("topics/1/articles.#{format}").
|
66
|
-
to_return(:body => fixture("article_create.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should post to the correct resource" do
|
70
|
-
@client.create_article(1, :subject => "API Tips", :main_content => "Tips on using our API")
|
71
|
-
a_post("topics/1/articles.#{format}").
|
72
|
-
should have_been_made
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should return the articles" do
|
76
|
-
article = @client.create_article(1, :subject => "API Tips", :main_content => "Tips on using our API")
|
77
|
-
|
78
|
-
article.id.should == 13
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
end
|
4
|
+
context "Article" do
|
5
|
+
|
6
|
+
let(:endpoint) { "article" }
|
7
|
+
let(:id) { 1 }
|
8
|
+
let(:check_key) { "subject" }
|
9
|
+
let(:check_value) { "Awesome Subject" }
|
10
|
+
|
11
|
+
include_context "basic configuration"
|
12
|
+
|
13
|
+
it_behaves_like "a list endpoint"
|
14
|
+
|
15
|
+
it_behaves_like "a show endpoint"
|
16
|
+
|
17
|
+
it_behaves_like "a create endpoint", {
|
18
|
+
:subject => "Awesome Subject",
|
19
|
+
:body => "Simply post here",
|
20
|
+
:_links => {
|
21
|
+
:topic => {
|
22
|
+
:href => "/api/v2/topics/1",
|
23
|
+
:class => "topic"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
it_behaves_like "an update endpoint", {
|
29
|
+
:subject => "How to make your customers happy",
|
30
|
+
:body => "<strong>Use Desk.com</strong>",
|
31
|
+
:body_email => "Custom email body for article",
|
32
|
+
:body_email_auto => false,
|
33
|
+
:_links => {
|
34
|
+
:topic => {
|
35
|
+
:href => "/api/v2/topics/1",
|
36
|
+
:class => "topic"
|
37
|
+
}
|
38
|
+
}
|
39
|
+
} do
|
40
|
+
let(:check_value) { "How to make your customers happy" }
|
41
|
+
end
|
83
42
|
|
84
|
-
|
43
|
+
it_behaves_like "a delete endpoint"
|
85
44
|
|
86
|
-
|
45
|
+
it_behaves_like "a search endpoint", {
|
46
|
+
:text => "happy",
|
47
|
+
:topic_ids => "1,2,4"
|
48
|
+
}
|
87
49
|
|
88
|
-
|
89
|
-
stub_put("articles/1.#{format}").
|
90
|
-
to_return(:body => fixture("article_update.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
91
|
-
end
|
50
|
+
context "Translation" do
|
92
51
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
52
|
+
let(:sub_endpoint) { "translation" }
|
53
|
+
let(:sub_id) { "en" }
|
54
|
+
let(:check_key) { "subject" }
|
55
|
+
let(:check_value) { "Awesome Subject" }
|
98
56
|
|
99
|
-
|
100
|
-
topic = @client.update_article(1, :subject => "API Tips", :main_content => "Tips on using our API")
|
57
|
+
it_behaves_like "a sub list endpoint"
|
101
58
|
|
102
|
-
|
103
|
-
topic.main_content.should == "Tips on using our API"
|
104
|
-
end
|
59
|
+
it_behaves_like "a sub show endpoint"
|
105
60
|
|
106
|
-
|
61
|
+
it_behaves_like "a sub create endpoint", {
|
62
|
+
:locale => "es",
|
63
|
+
:subject => "Spanish Translation",
|
64
|
+
:body => "Traducción español aquí"
|
65
|
+
} do
|
66
|
+
let(:sub_id) { "es" }
|
67
|
+
let(:check_value) { "Spanish Translation" }
|
107
68
|
end
|
108
69
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
stub_delete("articles/1.#{format}").
|
115
|
-
to_return(:body => fixture("article_destroy.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should post to the correct resource" do
|
119
|
-
@client.delete_article(1)
|
120
|
-
a_delete("articles/1.#{format}").
|
121
|
-
should have_been_made
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should return a successful response" do
|
125
|
-
topic = @client.delete_article(1)
|
126
|
-
topic.success.should == true
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
70
|
+
it_behaves_like "a sub update endpoint", {
|
71
|
+
:subject => "Updated Spanish Translation"
|
72
|
+
} do
|
73
|
+
let(:sub_id) { "es" }
|
74
|
+
let(:check_value) { "Updated Spanish Translation" }
|
130
75
|
end
|
131
76
|
|
132
77
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Desk::Client do
|
4
|
+
context "Brand" do
|
5
|
+
|
6
|
+
let(:endpoint) { "brand" }
|
7
|
+
let(:id) { 1 }
|
8
|
+
let(:check_key) { "name" }
|
9
|
+
let(:check_value) { "Desk.com" }
|
10
|
+
|
11
|
+
include_context "basic configuration"
|
12
|
+
|
13
|
+
it_behaves_like "a list endpoint"
|
14
|
+
|
15
|
+
it_behaves_like "a show endpoint"
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -1,99 +1,215 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
describe Desk::Client do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
context "Case" do
|
5
|
+
|
6
|
+
let(:endpoint) { "case" }
|
7
|
+
let(:id) { 1 }
|
8
|
+
let(:check_key) { "subject" }
|
9
|
+
let(:check_value) { "Welcome" }
|
10
|
+
|
11
|
+
include_context "basic configuration"
|
12
|
+
|
13
|
+
it_behaves_like "a list endpoint"
|
14
|
+
|
15
|
+
it_behaves_like "a search endpoint", {
|
16
|
+
:subject => "please help",
|
17
|
+
:name => "jimmy"
|
18
|
+
}
|
19
|
+
|
20
|
+
it_behaves_like "a show endpoint"
|
21
|
+
|
22
|
+
it_behaves_like "a create endpoint", {
|
23
|
+
:type => "email",
|
24
|
+
:subject => "Creating a case via the API",
|
25
|
+
:priority => 4,
|
26
|
+
:status => "open",
|
27
|
+
:labels => [ "Spam", "Ignore" ],
|
28
|
+
:created_at => "2012-05-01T21:38:48Z",
|
29
|
+
:_links => {
|
30
|
+
:customer => {
|
31
|
+
:href => "/api/v2/customers/1",
|
32
|
+
:class => "customer"
|
33
|
+
},
|
34
|
+
:assigned_user => {
|
35
|
+
:href => "/api/v2/users/1",
|
36
|
+
:class => "user"
|
37
|
+
},
|
38
|
+
:assigned_group => {
|
39
|
+
:href => "/api/v2/groups/1",
|
40
|
+
:class => "group"
|
41
|
+
},
|
42
|
+
:locked_by => {
|
43
|
+
:href => "/api/v2/users/1",
|
44
|
+
:class => "user"
|
45
|
+
}
|
46
|
+
},
|
47
|
+
:message => {
|
48
|
+
:direction => "out",
|
49
|
+
:status => "pending",
|
50
|
+
:to => "someone@desk.com",
|
51
|
+
:from => "someone-else@desk.com",
|
52
|
+
:cc => "alpha@desk.com",
|
53
|
+
:bcc => "beta@desk.com",
|
54
|
+
:subject => "Creating a case via the API",
|
55
|
+
:body => "Please assist me with this case",
|
56
|
+
:created_at => "2012-05-02T21:38:48Z"
|
57
|
+
}
|
58
|
+
} do
|
59
|
+
let(:check_value) { "Creating a case via the API" }
|
60
|
+
end
|
9
61
|
|
10
|
-
|
62
|
+
it_behaves_like "an update endpoint", {
|
63
|
+
:subject => "Updated",
|
64
|
+
:status => "pending",
|
65
|
+
:labels => [ "Spam", "Test" ],
|
66
|
+
:label_action => "replace",
|
67
|
+
:custom_fields => { :level => "super" },
|
68
|
+
:_links => {
|
69
|
+
:assigned_group => {
|
70
|
+
:href => "/api/v2/groups/1",
|
71
|
+
:rel => "group"
|
72
|
+
}
|
73
|
+
}
|
74
|
+
} do
|
75
|
+
let(:check_value) { "Updated" }
|
76
|
+
end
|
11
77
|
|
12
|
-
|
78
|
+
context "Message" do
|
13
79
|
|
14
|
-
|
15
|
-
|
16
|
-
to_return(:body => fixture("cases.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
17
|
-
end
|
80
|
+
let(:sub_endpoint) { "message" }
|
81
|
+
let(:check_value) { "Please help" }
|
18
82
|
|
19
|
-
|
20
|
-
@client.cases
|
21
|
-
a_get("cases.#{format}").
|
22
|
-
should have_been_made
|
23
|
-
end
|
83
|
+
include_context "plural endpoint"
|
24
84
|
|
25
|
-
|
26
|
-
cases = @client.cases
|
85
|
+
subject { client.send("show_#{endpoint}_#{sub_endpoint}", id) }
|
27
86
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
87
|
+
before do
|
88
|
+
stub_get("#{endpoints}/#{id}/#{sub_endpoint}").
|
89
|
+
to_return(:body => fixture("#{endpoint}_#{sub_endpoint}"))
|
90
|
+
end
|
32
91
|
|
33
|
-
|
92
|
+
it "gets the correct resource" do
|
93
|
+
subject
|
94
|
+
expect(a_get("#{endpoints}/#{id}/#{sub_endpoint}")).
|
95
|
+
to have_been_made
|
34
96
|
end
|
35
97
|
|
36
|
-
|
98
|
+
it { expect(subject).to be_a Hashie::Deash }
|
99
|
+
|
100
|
+
it "has a valid entry" do
|
101
|
+
expect(subject.parent_id).to eq(id)
|
102
|
+
expect(subject.send(check_key)).to eq(check_value)
|
103
|
+
end
|
37
104
|
|
38
|
-
|
105
|
+
it "allows raw access" do
|
106
|
+
expect(subject.raw).to be_a Hashie::Deash
|
107
|
+
end
|
39
108
|
|
40
|
-
|
41
|
-
stub_get("cases/1.#{format}").
|
42
|
-
to_return(:body => fixture("case.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
43
|
-
end
|
109
|
+
end
|
44
110
|
|
45
|
-
|
46
|
-
@client.case(1)
|
47
|
-
a_get("cases/1.#{format}").
|
48
|
-
should have_been_made
|
49
|
-
end
|
111
|
+
context "Reply" do
|
50
112
|
|
51
|
-
|
52
|
-
|
113
|
+
let(:sub_endpoint) { "reply" }
|
114
|
+
let(:sub_id) { 1 }
|
115
|
+
let(:check_key) { "subject" }
|
116
|
+
let(:check_value) { "Re: Please help" }
|
53
117
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
118
|
+
it_behaves_like "a sub list endpoint" do
|
119
|
+
let(:check_value) { "Please help" }
|
120
|
+
end
|
58
121
|
|
59
|
-
|
122
|
+
it_behaves_like "a sub show endpoint" do
|
123
|
+
let(:sub_id) { 2 }
|
60
124
|
end
|
61
125
|
|
62
|
-
|
126
|
+
it_behaves_like "a sub create endpoint", {
|
127
|
+
:body => "My Reply",
|
128
|
+
:direction => "out"
|
129
|
+
}
|
130
|
+
|
131
|
+
it_behaves_like "a sub update endpoint", {
|
132
|
+
:body => "Updated reply body",
|
133
|
+
:cc => "new.email@example.com"
|
134
|
+
}
|
63
135
|
|
64
|
-
|
136
|
+
end
|
65
137
|
|
66
|
-
|
67
|
-
stub_put("cases/1.#{format}").
|
68
|
-
to_return(:body => fixture("case_update.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
69
|
-
end
|
138
|
+
context "Note" do
|
70
139
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
140
|
+
let(:sub_endpoint) { "note" }
|
141
|
+
let(:sub_id) { 1 }
|
142
|
+
let(:check_key) { "body" }
|
143
|
+
let(:check_value) { "Please assist me with this case" }
|
76
144
|
|
77
|
-
|
78
|
-
a_case = @client.update_case(1, :subject => "Welcome to Desk.com")
|
145
|
+
it_behaves_like "a sub list endpoint"
|
79
146
|
|
80
|
-
|
81
|
-
a_case.subject.should == "Welcome to Desk.com"
|
82
|
-
end
|
147
|
+
it_behaves_like "a sub show endpoint"
|
83
148
|
|
84
|
-
|
149
|
+
it_behaves_like "a sub create endpoint", {
|
150
|
+
:body => "Help me with my issue!"
|
151
|
+
} do
|
152
|
+
let(:check_value) { "Help me with my issue!" }
|
85
153
|
end
|
86
154
|
|
87
|
-
|
88
|
-
|
89
|
-
context "generating a case url" do
|
155
|
+
end
|
90
156
|
|
91
|
-
|
92
|
-
|
93
|
-
|
157
|
+
context "Attachment" do
|
158
|
+
|
159
|
+
let(:sub_endpoint) { "attachment" }
|
160
|
+
let(:sub_id) { 1 }
|
161
|
+
let(:check_key) { "file_name" }
|
162
|
+
let(:check_value) { "awesome_pic.png" }
|
163
|
+
|
164
|
+
it_behaves_like "a sub list endpoint"
|
165
|
+
|
166
|
+
it_behaves_like "a sub show endpoint"
|
167
|
+
|
168
|
+
it_behaves_like "a sub create endpoint", {
|
169
|
+
:file_name => "awesome_pic.png",
|
170
|
+
:content_type => "image/png",
|
171
|
+
:content => "iVBORw0KGgoAAAANSUhEUgAAABsAAAAXCAIAAAB1dKN5AAAAGXRFWHRTb2Z0
|
172
|
+
d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9i
|
173
|
+
ZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2Vo
|
174
|
+
aUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6
|
175
|
+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bs/g
|
206
|
+
k34W3fpfwco6sdvDc8mVyq/UtcH7fe29JRq3OcOra8w7sT7sbKWpqoGhi2W4
|
207
|
+
7TXmtx3jWOnY6C/shmt7Tftru0+3Xrh+tL6pZuPDdDf/hRWvvwIMAJE9J8AO
|
208
|
+
RSMOAAAAAElFTkSuQmCC"
|
209
|
+
}
|
210
|
+
|
211
|
+
it_behaves_like "a sub delete endpoint"
|
94
212
|
|
95
|
-
end
|
96
|
-
end
|
97
213
|
end
|
98
214
|
end
|
99
215
|
end
|