File tree Expand file tree Collapse file tree 6 files changed +105
-0
lines changed Expand file tree Collapse file tree 6 files changed +105
-0
lines changed Original file line number Diff line number Diff line change 14
14
require 'intercom/service/job'
15
15
require 'intercom/service/subscription'
16
16
require 'intercom/service/segment'
17
+ require 'intercom/service/section'
17
18
require 'intercom/service/tag'
18
19
require 'intercom/service/team'
19
20
require 'intercom/service/visitor'
33
34
require 'intercom/job'
34
35
require 'intercom/tag'
35
36
require 'intercom/segment'
37
+ require 'intercom/section'
36
38
require 'intercom/event'
37
39
require 'intercom/conversation'
38
40
require 'intercom/message'
Original file line number Diff line number Diff line change @@ -88,6 +88,10 @@ def segments
88
88
Intercom ::Service ::Segment . new ( self )
89
89
end
90
90
91
+ def sections
92
+ Intercom ::Service ::Section . new ( self )
93
+ end
94
+
91
95
def tags
92
96
Intercom ::Service ::Tag . new ( self )
93
97
end
Original file line number Diff line number Diff line change
1
+ require 'intercom/api_operations/list'
2
+ require 'intercom/api_operations/find'
3
+ require 'intercom/api_operations/save'
4
+ require 'intercom/api_operations/delete'
5
+
6
+ module Intercom
7
+ module Service
8
+ class Section < BaseService
9
+ include ApiOperations ::List
10
+ include ApiOperations ::Find
11
+ include ApiOperations ::Save
12
+ include ApiOperations ::Delete
13
+
14
+ def collection_class
15
+ Intercom ::Section
16
+ end
17
+
18
+ def collection_name
19
+ 'help_center/sections'
20
+ end
21
+ end
22
+ end
23
+ end
Original file line number Diff line number Diff line change
1
+ require 'intercom/traits/api_resource'
2
+
3
+ module Intercom
4
+ class Section
5
+ include Traits ::ApiResource
6
+ end
7
+ end
Original file line number Diff line number Diff line change @@ -850,6 +850,43 @@ def test_app_count
850
850
}
851
851
end
852
852
853
+ def test_section
854
+ {
855
+ 'id' => '18' ,
856
+ 'workspace_id' => 'tx2p130c' ,
857
+ 'name' => 'Section 1' ,
858
+ 'url' => 'http://www.intercom.test/help/' ,
859
+ 'order' => 0 ,
860
+ 'created_at' => 1_589_801_953 ,
861
+ 'updated_at' => 1_589_801_953 ,
862
+ 'type' => 'section' ,
863
+ 'parent_id' => 1
864
+ }
865
+ end
866
+
867
+ def test_section_list
868
+ {
869
+ 'type' => 'list' ,
870
+ 'total_count' => 1 ,
871
+ 'pages' => {
872
+ 'page' => 1 ,
873
+ 'per_page' => 20 ,
874
+ 'total_pages' => 1
875
+ } ,
876
+ 'data' => [ {
877
+ 'id' => '18' ,
878
+ 'workspace_id' => 'tx2p130c' ,
879
+ 'name' => 'Section 1' ,
880
+ 'url' => 'http://www.intercom.test/help/' ,
881
+ 'order' => 0 ,
882
+ 'created_at' => 1_589_801_953 ,
883
+ 'updated_at' => 1_589_801_953 ,
884
+ 'type' => 'section' ,
885
+ 'parent_id' => 1
886
+ } ]
887
+ }
888
+ end
889
+
853
890
def test_segment_count
854
891
{
855
892
'type' => 'count' ,
Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
2
+
3
+ describe Intercom ::Section do
4
+ let ( :client ) { Intercom ::Client . new ( token : 'token' ) }
5
+
6
+ it 'creates a section' do
7
+ client . expects ( :post ) . with ( '/help_center/sections' , { 'name' => 'Section 1' , 'parent_id' => '1' } ) . returns ( test_section )
8
+ client . sections . create ( :name => 'Section 1' , :parent_id => '1' )
9
+ end
10
+
11
+ it 'lists sections' do
12
+ client . expects ( :get ) . with ( '/help_center/sections' , { } ) . returns ( test_section_list )
13
+ client . sections . all . each { |t | }
14
+ end
15
+
16
+ it 'finds a section' do
17
+ client . expects ( :get ) . with ( '/help_center/sections/1' , { } ) . returns ( test_section )
18
+ client . sections . find ( id : '1' )
19
+ end
20
+
21
+ it 'updates a section' do
22
+ section = Intercom ::Section . new ( id : '12345' )
23
+ client . expects ( :put ) . with ( '/help_center/sections/12345' , { } )
24
+ client . sections . save ( section )
25
+ end
26
+
27
+ it 'deletes a section' do
28
+ section = Intercom ::Section . new ( id : '12345' )
29
+ client . expects ( :delete ) . with ( '/help_center/sections/12345' , { } )
30
+ client . sections . delete ( section )
31
+ end
32
+ end
You can’t perform that action at this time.
0 commit comments