zendesk_api 0.1.3 → 0.1.4

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/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  GIT
2
2
  remote: https://github.com/steved555/hashie.git
3
- revision: d433d8b1574130f8f3752019ea4db3519c69e6df
3
+ revision: 2fa400b58956f3ae4c4eaaaa196084ffc659072f
4
4
  specs:
5
5
  hashie (2.0.0.beta)
6
6
 
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- zendesk_api (0.1.2)
10
+ zendesk_api (0.1.3)
11
11
  faraday (>= 0.8.0)
12
12
  faraday_middleware (>= 0.8.7)
13
13
  hashie
@@ -37,15 +37,15 @@ GEM
37
37
  rspec-expectations (~> 2.11.0)
38
38
  rspec-mocks (~> 2.11.0)
39
39
  rspec-core (2.11.1)
40
- rspec-expectations (2.11.2)
40
+ rspec-expectations (2.11.3)
41
41
  diff-lcs (~> 1.1.3)
42
42
  rspec-mocks (2.11.2)
43
43
  simplecov (0.6.4)
44
44
  multi_json (~> 1.0)
45
45
  simplecov-html (~> 0.5.3)
46
46
  simplecov-html (0.5.3)
47
- vcr (2.2.4)
48
- webmock (1.8.9)
47
+ vcr (2.2.5)
48
+ webmock (1.8.10)
49
49
  addressable (>= 2.2.7)
50
50
  crack (>= 0.1.7)
51
51
  yard (0.8.2.1)
data/Readme.md CHANGED
@@ -39,8 +39,11 @@ client = ZendeskAPI::Client.new do |config|
39
39
 
40
40
  config.url = "<- your-zendesk-url ->" # e.g. https://mydesk.zendesk.com/api/v2
41
41
 
42
- config.username = "login.email@zendesk.com" # use login.email@zendesk.com/token for token auth
43
- config.password = "your zendesk password or token"
42
+ config.username = "login.email@zendesk.com"
43
+
44
+ # Choose one of the following depending on your authentication choice
45
+ config.token = "your zendesk token"
46
+ config.password = "your zendesk password"
44
47
 
45
48
  # Optional:
46
49
 
@@ -77,6 +77,11 @@ module ZendeskAPI
77
77
 
78
78
  config.retry = !!config.retry # nil -> false
79
79
 
80
+ if config.token && !config.password
81
+ config.password = config.token
82
+ config.username += "/token" unless config.username.end_with?("/token")
83
+ end
84
+
80
85
  if config.logger.nil? || config.logger == true
81
86
  require 'logger'
82
87
  config.logger = Logger.new($stderr)
@@ -6,6 +6,9 @@ module ZendeskAPI
6
6
  # @return [String] The basic auth password.
7
7
  attr_accessor :password
8
8
 
9
+ # @return [String] The basic auth token.
10
+ attr_accessor :token
11
+
9
12
  # @return [String] The API url. Must be https unless {#allow_http} is set.
10
13
  attr_accessor :url
11
14
 
@@ -1,3 +1,3 @@
1
1
  module ZendeskAPI
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe ZendeskAPI::Request do
4
+ def valid_attributes
5
+ {
6
+ :subject => "This is a question!",
7
+ :comment => { :value => "Haha, no." }
8
+ }
9
+ end
10
+
11
+ it_should_be_creatable
12
+ it_should_be_updatable :subject
13
+ it_should_be_readable :requests
14
+ it_should_be_readable user, :requests
15
+ end
data/live/ticket_spec.rb CHANGED
@@ -17,11 +17,22 @@ describe ZendeskAPI::Ticket do
17
17
  it_should_be_updatable :subject
18
18
  it_should_be_deletable
19
19
  it_should_be_readable :tickets
20
- it_should_be_readable :tickets, :recent
21
20
  it_should_be_readable user, :requested_tickets
22
21
  it_should_be_readable agent, :ccd_tickets
23
22
  it_should_be_readable organization, :tickets
24
23
 
24
+ context "recent tickets" do
25
+ before(:each) do
26
+ VCR.use_cassette("visit_recent_ticket") do
27
+ client.connection.get("/tickets/#{@object.id}") do |req|
28
+ req.headers[:Accept] = "*/*"
29
+ end
30
+ end
31
+ end
32
+
33
+ it_should_be_readable :tickets, :recent, :create => true
34
+ end
35
+
25
36
  describe ".incremental_export" do
26
37
  let(:results){ ZendeskAPI::Ticket.incremental_export(client, Time.at(1023059503)) } # ~ 10 years ago
27
38
 
data/spec/client_spec.rb CHANGED
@@ -39,6 +39,40 @@ describe ZendeskAPI::Client do
39
39
  end
40
40
  end
41
41
 
42
+ context "#token" do
43
+ context "with a username with /token" do
44
+ subject do
45
+ ZendeskAPI::Client.new do |config|
46
+ config.url = "https://example.zendesk.com"
47
+ config.username = "hello/token"
48
+ config.token = "token"
49
+ end.config
50
+ end
51
+
52
+ it "should not add /token to the username" do
53
+ subject.username.should == "hello/token"
54
+ end
55
+ end
56
+
57
+ context "with no password" do
58
+ subject do
59
+ ZendeskAPI::Client.new do |config|
60
+ config.url = "https://example.zendesk.com"
61
+ config.username = "hello"
62
+ config.token = "token"
63
+ end.config
64
+ end
65
+
66
+ it "should copy token to password" do
67
+ subject.token.should == subject.password
68
+ end
69
+
70
+ it "should add /token to the username" do
71
+ subject.username.should == "hello/token"
72
+ end
73
+ end
74
+ end
75
+
42
76
  context "#logger" do
43
77
  before(:each) do
44
78
  @client = ZendeskAPI::Client.new do |config|
@@ -130,7 +130,7 @@ module ResourceMacros
130
130
  VCR.use_cassette("#{described_class.to_s}_#{context_name}_delete") do
131
131
  @object.destroy
132
132
  end
133
- end if create
133
+ end if create
134
134
 
135
135
  it "should be findable" do
136
136
  result = klass
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-09-08 00:00:00.000000000 Z
13
+ date: 2012-09-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -266,6 +266,7 @@ files:
266
266
  - live/macro_spec.rb
267
267
  - live/mobile_device_spec.rb
268
268
  - live/organization_spec.rb
269
+ - live/request_spec.rb
269
270
  - live/satisfaction_rating_spec.rb
270
271
  - live/setting_spec.rb
271
272
  - live/suspended_ticket_spec.rb