zendesk2 0.5.4 → 1.0.0
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.
- checksums.yaml +4 -4
- data/lib/zendesk2/client.rb +18 -33
- data/lib/zendesk2/version.rb +1 -1
- data/spec/spec_helper.rb +4 -3
- data/spec/tickets_spec.rb +1 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fb950fdc0ae118b3bba5edfb7a2729bec53561d
|
4
|
+
data.tar.gz: 2d427b0a21b5b0fdc8551013a2c76f1a36bf7587
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4094b670f1a2f9e40a391ad70db20f3e5699b8eb1661d643d5a1e62ad80e0e81238470c67d7fa1d64e38f958b331ff4164bbe06f476b3329a8d0b144a087d6f4
|
7
|
+
data.tar.gz: 5f42f0d0fc4fe7948baf89c14c424ee31a4b3c0794fbf31302c1af80b37b25416b58488607d3afa369ba0ccb4e763b7574b92694570a5fad1d057ab95b5e1641
|
data/lib/zendesk2/client.rb
CHANGED
@@ -121,7 +121,7 @@ class Zendesk2::Client < Cistern::Service
|
|
121
121
|
request :update_user_field
|
122
122
|
request :update_user_identity
|
123
123
|
|
124
|
-
recognizes :url, :
|
124
|
+
recognizes :url, :logger, :adapter, :username, :password, :token, :jwt_token
|
125
125
|
|
126
126
|
module Shared
|
127
127
|
def require_parameters(params, *requirements)
|
@@ -129,23 +129,6 @@ class Zendesk2::Client < Cistern::Service
|
|
129
129
|
raise ArgumentError, "missing parameters: #{missing.join(", ")}"
|
130
130
|
end
|
131
131
|
end
|
132
|
-
|
133
|
-
private
|
134
|
-
|
135
|
-
def zendesk_url(options)
|
136
|
-
options[:url] || Zendesk2.defaults[:url] || form_zendesk_url(options)
|
137
|
-
end
|
138
|
-
|
139
|
-
def form_zendesk_url(options)
|
140
|
-
host = options[:host]
|
141
|
-
subdomain = options[:subdomain] || Zendesk2.defaults[:subdomain]
|
142
|
-
|
143
|
-
host ||= "#{subdomain}.zendesk.com"
|
144
|
-
scheme = options[:scheme] || "https"
|
145
|
-
port = options[:port] || (scheme == "https" ? 443 : 80)
|
146
|
-
|
147
|
-
"#{scheme}://#{host}:#{port}"
|
148
|
-
end
|
149
132
|
end
|
150
133
|
|
151
134
|
class Real
|
@@ -154,19 +137,23 @@ class Zendesk2::Client < Cistern::Service
|
|
154
137
|
attr_accessor :username, :url, :token, :logger, :jwt_token
|
155
138
|
|
156
139
|
def initialize(options={})
|
157
|
-
url =
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
@username
|
164
|
-
@token
|
165
|
-
password
|
166
|
-
|
167
|
-
|
168
|
-
@jwt_token = options[:jwt_token]
|
140
|
+
@url = if url = options[:url] || Zendesk2.defaults[:url]
|
141
|
+
::URI.parse(url).to_s
|
142
|
+
end
|
143
|
+
|
144
|
+
@logger = options[:logger] || Logger.new(nil)
|
145
|
+
adapter = options[:adapter] || Faraday.default_adapter
|
146
|
+
@username = options[:username] || Zendesk2.defaults[:username]
|
147
|
+
@token = options[:token] || Zendesk2.defaults[:token]
|
148
|
+
password = options[:password] || Zendesk2.defaults[:password]
|
149
|
+
|
150
|
+
connection_options = options[:connection_options] || {}
|
169
151
|
|
152
|
+
@auth_token = password || @token
|
153
|
+
@username += "/token" if @auth_token == @token
|
154
|
+
@jwt_token = options[:jwt_token]
|
155
|
+
|
156
|
+
raise "Missing required options: :url" unless @url
|
170
157
|
raise "Missing required options: :username" unless @username
|
171
158
|
raise "Missing required options: :password or :token" unless password || @token
|
172
159
|
|
@@ -242,9 +229,7 @@ class Zendesk2::Client < Cistern::Service
|
|
242
229
|
end
|
243
230
|
|
244
231
|
def initialize(options={})
|
245
|
-
url
|
246
|
-
|
247
|
-
@url = url
|
232
|
+
@url = options[:url]
|
248
233
|
@path = ::URI.parse(url).path
|
249
234
|
@username, @password = options[:username], options[:password]
|
250
235
|
@token = options[:token]
|
data/lib/zendesk2/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -13,9 +13,10 @@ end
|
|
13
13
|
Cistern.formatter = Cistern::Formatter::AwesomePrint
|
14
14
|
|
15
15
|
RSpec.configure do |config|
|
16
|
-
|
17
|
-
Zendesk2::Client.reset!
|
16
|
+
if Zendesk2::Client.mocking?
|
17
|
+
config.before(:each) { Zendesk2::Client.reset! }
|
18
18
|
end
|
19
|
+
|
19
20
|
config.order = "random"
|
20
|
-
config.filter_run_excluding(:
|
21
|
+
config.filter_run_excluding(mock_only: true) unless Zendesk2::Client.mocking?
|
21
22
|
end
|
data/spec/tickets_spec.rb
CHANGED
@@ -69,9 +69,7 @@ describe "Zendesk2::Client" do
|
|
69
69
|
expect(ticket.submitter).to eq(client.users.current)
|
70
70
|
end
|
71
71
|
|
72
|
-
it "should have empty custom fields by default" do
|
73
|
-
pending if !Zendesk2::Client.mocking?
|
74
|
-
|
72
|
+
it "should have empty custom fields by default", mock_only: true do
|
75
73
|
expect(ticket.custom_fields).to eq([])
|
76
74
|
end
|
77
75
|
end
|