zendesk_api 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa3544c5e08b828371b17825f4241cbace2312bb
4
- data.tar.gz: 7e1909d97426a6d092c73a65b4505e83b09e95c0
3
+ metadata.gz: 738a6a408575a7686612e21e3c0778fdf51de2ba
4
+ data.tar.gz: 7e11351db8cf9f54bb0057b8ac66c8f30203df19
5
5
  SHA512:
6
- metadata.gz: 8dd96ac26287dc751acd2ebc0f53dc7d3fc2950ed50d3a13e05982998275ef9c64b85e99abdbf371cb7553172b5488e756daec4f503cd42d12a6b7ef8044284b
7
- data.tar.gz: fa06182c9968a63eb3b1e4caff6af8f05d878c5b53620c1cb8da20c345cae3c86bfdc0d45fb043808bd971c9aced2b23e328907da4f9b24b8d6b8908da39afa1
6
+ metadata.gz: d047462c93fa23570309dea0fc10ea4259bf8051b6c4aad4f942c53bbebb38488e572c5b5cade0077a0fd955a9c8c1c2599fdb88be068c49bf3e3f9c677f2f3e
7
+ data.tar.gz: aff758204c53103e268e9e0a4a600d727b9db7b02d1278d41aa594fbed6a289c0aaaece502d57d1d0839981dbffadbf114918d34034f9bbc4d451a67afefd3e7
data/.travis.yml CHANGED
@@ -1,6 +1,9 @@
1
+ language: ruby
2
+
1
3
  rvm:
2
4
  - 1.9.3
3
5
  - 2.0.0
4
- - 2.1.5
6
+ - 2.1
5
7
  - jruby
6
- cache: bundler
8
+
9
+ sudo: false
data/README.md CHANGED
@@ -18,6 +18,7 @@ Please check out the [wiki](https://github.com/zendesk/zendesk_api_client_rb/wik
18
18
  * Version 1.3.8 had a bug where attachments were created, but the response was not handled properly
19
19
  * Version >= 1.0 and < 1.4.2 had a bug where non application/json response bodies were discarded
20
20
  * Version 1.5.0 removed support for Ruby 1.8
21
+ * Version 1.6.0 ZendeskAPI::Voice::CertificationAddress is now ZendeskAPI::Voice::Address
21
22
 
22
23
  ## Installation
23
24
 
@@ -55,6 +55,9 @@ module ZendeskAPI
55
55
  :accept_encoding => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
56
56
  :user_agent => "ZendeskAPI API #{ZendeskAPI::VERSION}"
57
57
  },
58
+ :request => {
59
+ :open_timeout => 10
60
+ },
58
61
  :url => @url
59
62
  }.merge(client_options)
60
63
  end
@@ -465,7 +465,40 @@ module ZendeskAPI
465
465
  end
466
466
  end
467
467
 
468
+ module Conditions
469
+ def all_conditions=(all_conditions)
470
+ self.conditions ||= {}
471
+ self.conditions[:all] = all_conditions
472
+ end
473
+
474
+ def any_conditions=(any_conditions)
475
+ self.conditions ||= {}
476
+ self.conditions[:any] = any_conditions
477
+ end
478
+
479
+ def add_all_condition(field, operator, value)
480
+ self.conditions ||= {}
481
+ self.conditions[:all] ||= []
482
+ self.conditions[:all] << { :field => field, :operator => operator, :value => value }
483
+ end
484
+
485
+ def add_any_condition(field, operator, value)
486
+ self.conditions ||= {}
487
+ self.conditions[:any] ||= []
488
+ self.conditions[:any] << { :field => field, :operator => operator, :value => value }
489
+ end
490
+ end
491
+
492
+ module Actions
493
+ def add_action(field, value)
494
+ self.actions ||= []
495
+ self.actions << { :field => field, :value => value }
496
+ end
497
+ end
498
+
468
499
  class View < Rule
500
+ include Conditions
501
+
469
502
  has_many :tickets, :class => Ticket
470
503
  has_many :feed, :class => Ticket, :path => "feed"
471
504
 
@@ -473,20 +506,39 @@ module ZendeskAPI
473
506
  has :execution, :class => RuleExecution
474
507
  has ViewCount, :path => "count"
475
508
 
509
+ def add_column(column)
510
+ columns = execution.columns.map(&:id)
511
+ columns << column
512
+ self.columns = columns
513
+ end
514
+
515
+ def columns=(columns)
516
+ self.output ||= {}
517
+ self.output[:columns] = columns
518
+ end
519
+
476
520
  def self.preview(client, options = {})
477
521
  Collection.new(client, ViewRow, options.merge(:path => "views/preview", :verb => :post))
478
522
  end
479
523
  end
480
524
 
481
525
  class Trigger < Rule
526
+ include Conditions
527
+ include Actions
528
+
482
529
  has :execution, :class => RuleExecution
483
530
  end
484
531
 
485
532
  class Automation < Rule
533
+ include Conditions
534
+ include Actions
535
+
486
536
  has :execution, :class => RuleExecution
487
537
  end
488
538
 
489
539
  class Macro < Rule
540
+ include Actions
541
+
490
542
  has :execution, :class => RuleExecution
491
543
 
492
544
  # Returns the update to a ticket that happens when a macro will be applied.
@@ -632,7 +684,7 @@ module ZendeskAPI
632
684
  namespace "channels/voice"
633
685
  end
634
686
 
635
- class CertificationAddress < Resource
687
+ class Address < Resource
636
688
  namespace "channels/voice"
637
689
  end
638
690
 
@@ -1,3 +1,3 @@
1
1
  module ZendeskAPI
2
- VERSION = "1.5.1"
2
+ VERSION = "1.6.0"
3
3
  end
@@ -271,7 +271,7 @@ describe ZendeskAPI::Client do
271
271
  end
272
272
 
273
273
  it "manages namespace correctly" do
274
- expect(client.certification_addresses.path).to match(/channels\/voice\/certification_addresses/)
274
+ expect(client.addresses.path).to match(/channels\/voice\/addresses/)
275
275
  expect(client.phone_numbers.path).to match(/channels\/voice\/phone_numbers/)
276
276
  expect(client.greetings.path).to match(/channels\/voice\/greetings/)
277
277
  expect(client.greeting_categories.path).to match(/channels\/voice\/greeting_categories/)
@@ -17,6 +17,10 @@ describe ZendeskAPI::Configuration do
17
17
  expect(subject.options[:headers][:user_agent]).to match(/ZendeskAPI API/)
18
18
  end
19
19
 
20
+ it "should set a default open_timeout" do
21
+ expect(subject.options[:request][:open_timeout]).to eq(10)
22
+ end
23
+
20
24
  it "should merge options with client_options" do
21
25
  subject.client_options = {:ssl => false}
22
26
  expect(subject.options[:ssl]).to eq(false)
@@ -0,0 +1,81 @@
1
+ require 'core/spec_helper'
2
+
3
+ describe ZendeskAPI::Automation do
4
+ def valid_attributes
5
+ {
6
+ :title => "my test automation",
7
+ :conditions => {
8
+ :any => [{ :field => "assignee_id", :operator => "is", :value => 1}],
9
+ :all => [{ :field => "status", :operator => "is", :value => "open" }]
10
+ },
11
+ :actions => [{ :field => "priority", :value => "urgent" }],
12
+ }
13
+ end
14
+
15
+ subject do
16
+ described_class.new(double, valid_attributes)
17
+ end
18
+
19
+ describe "#all_conditions=" do
20
+ it "should assign new values to all conditions" do
21
+ new_conditions = [
22
+ { "field" => "type", "operator" => "is", "value" => "question" },
23
+ { "field" => "status", "operator" => "less_than", "value" => "solved" }
24
+ ]
25
+ subject.all_conditions = new_conditions
26
+
27
+ expect(subject.conditions[:all]).to eq(new_conditions)
28
+ end
29
+ end
30
+
31
+ describe "#any_conditions=" do
32
+ it "should assign new values to any conditions" do
33
+ new_conditions = [
34
+ { "field" => "type", "operator" => "is", "value" => "question" },
35
+ { "field" => "status", "operator" => "less_than", "value" => "solved" }
36
+ ]
37
+ subject.any_conditions = new_conditions
38
+
39
+ expect(subject.conditions[:any]).to eq(new_conditions)
40
+ end
41
+ end
42
+
43
+ describe "#add_all_condition" do
44
+ it "should add a condition to all condition" do
45
+ new_condition = { :field => "type", :operator => "is", :value => "problem" }
46
+ existing_conditions = subject.conditions[:all]
47
+
48
+ expect(existing_conditions).not_to include(new_condition)
49
+
50
+ subject.add_all_condition("type", "is", "problem")
51
+
52
+ expect(subject.conditions[:all]).to eq(existing_conditions << new_condition)
53
+ end
54
+ end
55
+
56
+ describe "#add_any_condition" do
57
+ it "should add a condition to any condition" do
58
+ new_condition = { :field => "type", :operator => "is", :value => "task" }
59
+ existing_conditions = subject.conditions[:any]
60
+
61
+ expect(existing_conditions).not_to include(new_condition)
62
+
63
+ subject.add_any_condition("type", "is", "task")
64
+
65
+ expect(subject.conditions[:any]).to eq(existing_conditions << new_condition)
66
+ end
67
+ end
68
+
69
+ describe "#add_action" do
70
+ it "should add an action to the current actions" do
71
+ new_action = { :field => "status", :value => "solved" }
72
+ existing_actions = subject.actions
73
+
74
+ expect(existing_actions).not_to include(new_action)
75
+
76
+ subject.add_action("status", "solved")
77
+
78
+ expect(subject.actions).to eq(existing_actions << new_action)
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,27 @@
1
+ require 'core/spec_helper'
2
+
3
+ describe ZendeskAPI::Macro do
4
+ def valid_attributes
5
+ {
6
+ :title => "my test macro",
7
+ :actions => [{ :field => "priority", :value => "urgent" }],
8
+ }
9
+ end
10
+
11
+ subject do
12
+ described_class.new(double, valid_attributes)
13
+ end
14
+
15
+ describe "#add_action" do
16
+ it "should add an action to the current actions" do
17
+ new_action = { :field => "status", :value => "solved" }
18
+ existing_actions = subject.actions
19
+
20
+ expect(existing_actions).not_to include(new_action)
21
+
22
+ subject.add_action("status", "solved")
23
+
24
+ expect(subject.actions).to eq(existing_actions << new_action)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,67 @@
1
+ require 'core/spec_helper'
2
+
3
+ describe ZendeskAPI::Trigger do
4
+ def valid_attributes
5
+ {
6
+ :title => "my test trigger",
7
+ :conditions => {
8
+ :any => [{ :field => "assignee_id", :operator => "is", :value => 1}],
9
+ :all => [{ :field => "status", :operator => "is", :value => "open" }]
10
+ },
11
+ }
12
+ end
13
+
14
+ subject do
15
+ described_class.new(double, valid_attributes)
16
+ end
17
+
18
+ describe "#all_conditions=" do
19
+ it "should assign new values to all conditions" do
20
+ new_conditions = [
21
+ { "field" => "type", "operator" => "is", "value" => "question" },
22
+ { "field" => "status", "operator" => "less_than", "value" => "solved" }
23
+ ]
24
+ subject.all_conditions = new_conditions
25
+
26
+ expect(subject.conditions[:all]).to eq(new_conditions)
27
+ end
28
+ end
29
+
30
+ describe "#any_conditions=" do
31
+ it "should assign new values to any conditions" do
32
+ new_conditions = [
33
+ { "field" => "type", "operator" => "is", "value" => "question" },
34
+ { "field" => "status", "operator" => "less_than", "value" => "solved" }
35
+ ]
36
+ subject.any_conditions = new_conditions
37
+
38
+ expect(subject.conditions[:any]).to eq(new_conditions)
39
+ end
40
+ end
41
+
42
+ describe "#add_all_condition" do
43
+ it "should add a condition to all condition" do
44
+ new_condition = { :field => "type", :operator => "is", :value => "problem" }
45
+ existing_conditions = subject.conditions[:all]
46
+
47
+ expect(existing_conditions).not_to include(new_condition)
48
+
49
+ subject.add_all_condition("type", "is", "problem")
50
+
51
+ expect(subject.conditions[:all]).to eq(existing_conditions << new_condition)
52
+ end
53
+ end
54
+
55
+ describe "#add_any_condition" do
56
+ it "should add a condition to any condition" do
57
+ new_condition = { :field => "type", :operator => "is", :value => "task" }
58
+ existing_conditions = subject.conditions[:any]
59
+
60
+ expect(existing_conditions).not_to include(new_condition)
61
+
62
+ subject.add_any_condition("type", "is", "task")
63
+
64
+ expect(subject.conditions[:any]).to eq(existing_conditions << new_condition)
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,97 @@
1
+ require 'core/spec_helper'
2
+
3
+ describe ZendeskAPI::View do
4
+ def valid_attributes
5
+ {
6
+ :title => "my test view",
7
+ :conditions => {
8
+ :any => [{ :field => "assignee_id", :operator => "is", :value => 1}],
9
+ :all => [{ :field => "status", :operator => "is", :value => "open" }]
10
+ },
11
+ :execution => {
12
+ :columns => [:id => "status", :title=> "Status"]
13
+ }
14
+ }
15
+ end
16
+
17
+ subject do
18
+ described_class.new(double, valid_attributes)
19
+ end
20
+
21
+ describe "#columns=" do
22
+ it "should add a single column" do
23
+ new_column = ["priority"]
24
+ subject.columns = new_column
25
+
26
+ expect(subject.output["columns"]).to eq(new_column)
27
+ end
28
+
29
+ it "should set columns on output" do
30
+ new_columns = ["type", "priority"]
31
+ subject.columns = new_columns
32
+
33
+ expect(subject.output["columns"]).to eq(new_columns)
34
+ end
35
+ end
36
+
37
+ describe "#add_column" do
38
+ it "should add a column to the existing columns" do
39
+ existing_columns = subject.execution.columns.map {|c| c["id"]}
40
+ expect(existing_columns.include?("type")).to eq(false)
41
+
42
+ subject.add_column("type")
43
+
44
+ expect(subject.output["columns"]).to eq(existing_columns << "type")
45
+ end
46
+ end
47
+
48
+ describe "#all_conditions=" do
49
+ it "should assign new values to all conditions" do
50
+ new_conditions = [
51
+ { "field" => "type", "operator" => "is", "value" => "question" },
52
+ { "field" => "status", "operator" => "less_than", "value" => "solved" }
53
+ ]
54
+ subject.all_conditions = new_conditions
55
+
56
+ expect(subject.conditions[:all]).to eq(new_conditions)
57
+ end
58
+ end
59
+
60
+ describe "#any_conditions=" do
61
+ it "should assign new values to any conditions" do
62
+ new_conditions = [
63
+ { "field" => "type", "operator" => "is", "value" => "question" },
64
+ { "field" => "status", "operator" => "less_than", "value" => "solved" }
65
+ ]
66
+ subject.any_conditions = new_conditions
67
+
68
+ expect(subject.conditions[:any]).to eq(new_conditions)
69
+ end
70
+ end
71
+
72
+ describe "#add_all_condition" do
73
+ it "should add a condition to all condition" do
74
+ new_condition = { :field => "type", :operator => "is", :value => "problem" }
75
+ existing_conditions = subject.conditions[:all]
76
+
77
+ expect(existing_conditions).not_to include(new_condition)
78
+
79
+ subject.add_all_condition("type", "is", "problem")
80
+
81
+ expect(subject.conditions[:all]).to eq(existing_conditions << new_condition)
82
+ end
83
+ end
84
+
85
+ describe "#add_any_condition" do
86
+ it "should add a condition to any condition" do
87
+ new_condition = { :field => "type", :operator => "is", :value => "task" }
88
+ existing_conditions = subject.conditions[:any]
89
+
90
+ expect(existing_conditions).not_to include(new_condition)
91
+
92
+ subject.add_any_condition("type", "is", "task")
93
+
94
+ expect(subject.conditions[:any]).to eq(existing_conditions << new_condition)
95
+ end
96
+ end
97
+ end
@@ -3,7 +3,7 @@ require 'core/spec_helper'
3
3
  describe ZendeskAPI::DynamicContent::Item::Variant, :delete_after do
4
4
  def valid_attributes
5
5
  {
6
- :locale_id => 127,
6
+ :locale_id => 43,
7
7
  :active => true,
8
8
  :default => false,
9
9
  :content => 'Mon dieu!'
@@ -9,7 +9,7 @@ describe ZendeskAPI::Request do
9
9
  end
10
10
 
11
11
  it_should_be_creatable
12
- it_should_be_updatable :subject
12
+ it_should_be_updatable :solved, true
13
13
  it_should_be_readable :requests
14
14
  it_should_be_readable user, :requests
15
15
 
@@ -68,7 +68,7 @@ describe ZendeskAPI::Ticket do
68
68
  VCR.use_cassette("ticket_import_can_import") do
69
69
  old = Time.now - 5*365*24*60*60
70
70
  ticket = ZendeskAPI::Ticket.import(client, valid_attributes.merge(:created_at => old.iso8601))
71
- expect(ZendeskAPI::Ticket.find(client, ticket).created_at.year).to eq(old.year)
71
+ expect(ZendeskAPI::Ticket.find(client, :id => ticket.id).created_at.year).to eq(old.year)
72
72
  end
73
73
  end
74
74
 
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: 1.5.1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Davidovitz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-14 00:00:00.000000000 Z
12
+ date: 2015-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bump
@@ -198,7 +198,6 @@ files:
198
198
  - ".travis.yml"
199
199
  - ".yardopts"
200
200
  - Gemfile
201
- - Gemfile.lock
202
201
  - LICENSE
203
202
  - README.md
204
203
  - Rakefile
@@ -255,6 +254,10 @@ files:
255
254
  - spec/core/middleware/response/raise_error_spec.rb
256
255
  - spec/core/read_resource_spec.rb
257
256
  - spec/core/resource_spec.rb
257
+ - spec/core/resources/automation_spec.rb
258
+ - spec/core/resources/macro_spec.rb
259
+ - spec/core/resources/trigger_spec.rb
260
+ - spec/core/resources/view_spec.rb
258
261
  - spec/core/search_spec.rb
259
262
  - spec/core/spec_helper.rb
260
263
  - spec/core/trackie_spec.rb
@@ -368,6 +371,10 @@ test_files:
368
371
  - spec/core/middleware/response/raise_error_spec.rb
369
372
  - spec/core/read_resource_spec.rb
370
373
  - spec/core/resource_spec.rb
374
+ - spec/core/resources/automation_spec.rb
375
+ - spec/core/resources/macro_spec.rb
376
+ - spec/core/resources/trigger_spec.rb
377
+ - spec/core/resources/view_spec.rb
371
378
  - spec/core/search_spec.rb
372
379
  - spec/core/spec_helper.rb
373
380
  - spec/core/trackie_spec.rb
data/Gemfile.lock DELETED
@@ -1,108 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- zendesk_api (1.5.1)
5
- faraday (~> 0.9)
6
- hashie (>= 1.2, < 4.0)
7
- inflection
8
- mime-types
9
- multi_json
10
- multipart-post (~> 2.0)
11
-
12
- GEM
13
- remote: https://rubygems.org/
14
- specs:
15
- actionpack (3.2.20)
16
- activemodel (= 3.2.20)
17
- activesupport (= 3.2.20)
18
- builder (~> 3.0.0)
19
- erubis (~> 2.7.0)
20
- journey (~> 1.0.4)
21
- rack (~> 1.4.5)
22
- rack-cache (~> 1.2)
23
- rack-test (~> 0.6.1)
24
- sprockets (~> 2.2.1)
25
- activemodel (3.2.20)
26
- activesupport (= 3.2.20)
27
- builder (~> 3.0.0)
28
- activesupport (3.2.20)
29
- i18n (~> 0.6, >= 0.6.4)
30
- multi_json (~> 1.0)
31
- addressable (2.3.6)
32
- builder (3.0.4)
33
- bump (0.5.1)
34
- byebug (3.5.1)
35
- columnize (~> 0.8)
36
- debugger-linecache (~> 1.2)
37
- slop (~> 3.6)
38
- columnize (0.8.9)
39
- crack (0.4.2)
40
- safe_yaml (~> 1.0.0)
41
- debugger-linecache (1.2.0)
42
- diff-lcs (1.2.5)
43
- docile (1.1.5)
44
- erubis (2.7.0)
45
- faraday (0.9.0)
46
- multipart-post (>= 1.2, < 3)
47
- hashie (3.3.1)
48
- hike (1.2.3)
49
- i18n (0.6.11)
50
- inflection (1.0.0)
51
- journey (1.0.4)
52
- json (1.8.1)
53
- mime-types (2.4.3)
54
- multi_json (1.10.1)
55
- multipart-post (2.0.0)
56
- rack (1.4.5)
57
- rack-cache (1.2)
58
- rack (>= 0.4)
59
- rack-test (0.6.2)
60
- rack (>= 1.0)
61
- rake (10.3.2)
62
- rspec (3.1.0)
63
- rspec-core (~> 3.1.0)
64
- rspec-expectations (~> 3.1.0)
65
- rspec-mocks (~> 3.1.0)
66
- rspec-core (3.1.7)
67
- rspec-support (~> 3.1.0)
68
- rspec-expectations (3.1.2)
69
- diff-lcs (>= 1.2.0, < 2.0)
70
- rspec-support (~> 3.1.0)
71
- rspec-mocks (3.1.3)
72
- rspec-support (~> 3.1.0)
73
- rspec-support (3.1.2)
74
- safe_yaml (1.0.4)
75
- simplecov (0.9.1)
76
- docile (~> 1.1.0)
77
- multi_json (~> 1.0)
78
- simplecov-html (~> 0.8.0)
79
- simplecov-html (0.8.0)
80
- slop (3.6.0)
81
- sprockets (2.2.3)
82
- hike (~> 1.2)
83
- multi_json (~> 1.0)
84
- rack (~> 1.0)
85
- tilt (~> 1.1, != 1.3.0)
86
- tilt (1.4.1)
87
- vcr (2.9.3)
88
- webmock (1.20.4)
89
- addressable (>= 2.3.6)
90
- crack (>= 0.3.2)
91
- yard (0.8.7.6)
92
-
93
- PLATFORMS
94
- ruby
95
-
96
- DEPENDENCIES
97
- actionpack (~> 3.2)
98
- bump
99
- byebug
100
- jruby-openssl
101
- json
102
- rake
103
- rspec
104
- simplecov
105
- vcr
106
- webmock
107
- yard
108
- zendesk_api!