connectwise_sdk 0.0.6 → 0.0.7
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/README.md +2 -3
- data/lib/connectwise/model.rb +7 -3
- data/lib/connectwise/ticket.rb +8 -5
- data/lib/connectwise/ticket_note.rb +46 -0
- data/lib/connectwise/version.rb +1 -1
- data/lib/connectwise_sdk.rb +1 -0
- data/spec/lib/connectwise/ticket_note_spec.rb +21 -0
- data/spec/lib/connectwise/ticket_spec.rb +16 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 671e29c4c5672a85c98003621cc98720e306d375
|
4
|
+
data.tar.gz: 7fcb0eb04be9f02db99a3f7663a6cd028deb87b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfbd2ae2a774a0d7aedbc5c7ce614458c2ebc225d9694f249a1d464624f936061816c3b40bc0c4653eea37d9e204a010cc5d88b3d9bd51b9588fd6065262bc6b
|
7
|
+
data.tar.gz: 8dab21de5c673309fd743a6c3b38e82d1c0cc8d1060e257b93b2cea6607b9d6caf528ab51dc1d07ebedfe7ea66f360698187aa1786584b51bfec34ae04b3a64d
|
data/README.md
CHANGED
@@ -39,7 +39,7 @@ conn = Connectwise::Connection.new host: 'host.domain.com', company_name: 'compa
|
|
39
39
|
conn.call :contact, :find_contacts, conditions: 'EmailAddress like "test@test.com"'
|
40
40
|
```
|
41
41
|
|
42
|
-
- The first parameter is the api you wish to use. In this case the `contactApi`.
|
42
|
+
- The first parameter is the api you wish to use. In this case the `contactApi`.
|
43
43
|
- The second parameter is the specific api call you wish to use (from the Connectwise Api documentation)
|
44
44
|
- The third paramater is the data you wish to send the api
|
45
45
|
|
@@ -62,8 +62,7 @@ Currently the low level `Connection.call` method is working, as well as basic Me
|
|
62
62
|
|
63
63
|
Remaining items include:
|
64
64
|
|
65
|
-
1.
|
66
|
-
2. Support Notes for Opportunities (submitting them)
|
65
|
+
1. Support Notes for Opportunities (submitting them)
|
67
66
|
2. Creating a Facade layer so that the connection object doesn't need to be passed to each object
|
68
67
|
3. Supporting a late binding way of accessing internal objects (accessing the company object within an opportunity for example)
|
69
68
|
4. Supporting an intuitive way of accessing lists of phone numbers, addresses, and email addresses, while still allowing simple access to the first one of each.
|
data/lib/connectwise/model.rb
CHANGED
@@ -8,7 +8,7 @@ module Connectwise
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def find(connection, id)
|
11
|
-
if (attrs = connection.call(cw_api_name, "get_#{
|
11
|
+
if (attrs = connection.call(cw_api_name, "get_#{cw_model_name}".to_sym, {id: id}))
|
12
12
|
self.new(connection, find_transform(attrs))
|
13
13
|
else
|
14
14
|
fail RecordNotFound
|
@@ -33,6 +33,10 @@ module Connectwise
|
|
33
33
|
base_class_name.downcase.to_sym
|
34
34
|
end
|
35
35
|
|
36
|
+
def cw_model_name
|
37
|
+
base_class_name.downcase.to_sym
|
38
|
+
end
|
39
|
+
|
36
40
|
def plural_class_name
|
37
41
|
ending = base_class_name[/[aeiou]$/] ? 'es' : 's'
|
38
42
|
@plural_form ||= "#{base_class_name.downcase}#{ending}"
|
@@ -85,12 +89,12 @@ module Connectwise
|
|
85
89
|
end
|
86
90
|
|
87
91
|
def save
|
88
|
-
attrs = connection.call self.class.cw_api_name, "add_or_update_#{self.class.
|
92
|
+
attrs = connection.call self.class.cw_api_name, "add_or_update_#{self.class.cw_model_name}".to_sym, {self.class.cw_model_name => to_cw_h}
|
89
93
|
self.class.new(connection, self.class.save_transform(attrs))
|
90
94
|
end
|
91
95
|
|
92
96
|
def destroy
|
93
|
-
connection.call self.class.cw_api_name, "delete_#{self.class.
|
97
|
+
connection.call self.class.cw_api_name, "delete_#{self.class.cw_model_name}".to_sym, {id: id}
|
94
98
|
self
|
95
99
|
end
|
96
100
|
|
data/lib/connectwise/ticket.rb
CHANGED
@@ -2,7 +2,7 @@ module Connectwise
|
|
2
2
|
class Ticket
|
3
3
|
include Model
|
4
4
|
model_name 'service_ticket'
|
5
|
-
attr_accessor :id, :summary, :problem_description, :status_name, :board, :site_name, :status, :resolution, :remote_internal_company_name, :priority, :source, :severity, :impact,
|
5
|
+
attr_accessor :id, :summary, :problem_description, :status_name, :board, :site_name, :status, :resolution, :remote_internal_company_name, :priority, :source, :severity, :impact, :company
|
6
6
|
|
7
7
|
#TODO - The use of SrServiceRecid and TicketNumber instead of id - may want to configure these
|
8
8
|
# but this is so inconsistent for tickets that it may not be worth it unless other calls do the same thing
|
@@ -20,10 +20,6 @@ module Connectwise
|
|
20
20
|
@status_name ||= 'New'
|
21
21
|
end
|
22
22
|
|
23
|
-
def company=(company)
|
24
|
-
@company = company
|
25
|
-
end
|
26
|
-
|
27
23
|
def save
|
28
24
|
return false unless @company
|
29
25
|
attrs = {companyId: @company.company_id, 'serviceTicket' => to_cw_h}
|
@@ -36,6 +32,11 @@ module Connectwise
|
|
36
32
|
self
|
37
33
|
end
|
38
34
|
|
35
|
+
def add_note(msg, **options)
|
36
|
+
note = TicketNote.new(connection, {note: msg, ticket: self}.merge(options))
|
37
|
+
note.save
|
38
|
+
end
|
39
|
+
|
39
40
|
private
|
40
41
|
def self.find_transform(attrs)
|
41
42
|
attrs[:id] = attrs.delete(:ticket_number)
|
@@ -44,11 +45,13 @@ module Connectwise
|
|
44
45
|
|
45
46
|
def self.save_transform(attrs)
|
46
47
|
attrs[:id] = attrs.delete(:ticket_number)
|
48
|
+
attrs[:company] = OpenStruct.new id: attrs.delete(:company_rec_id)
|
47
49
|
attrs
|
48
50
|
end
|
49
51
|
|
50
52
|
def to_cw_h
|
51
53
|
attrs = super
|
54
|
+
attrs.delete('Company')
|
52
55
|
attrs['TicketNumber'] = attrs[:id] || 0
|
53
56
|
attrs
|
54
57
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Connectwise
|
2
|
+
class TicketNote
|
3
|
+
include Model
|
4
|
+
model_name 'ticket_note'
|
5
|
+
attr_accessor :id, :note, :note_text, :is_part_of_internal_analysis, :is_part_of_resolution, :is_part_of_detail_description
|
6
|
+
|
7
|
+
def self.cw_api_name
|
8
|
+
:service_ticket
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.transform(attrs)
|
12
|
+
type = attrs.delete(:type)
|
13
|
+
attrs[:note_text] ||= attrs.delete(:note)
|
14
|
+
if type == :internal
|
15
|
+
attrs[:is_part_of_internal_analysis] = true
|
16
|
+
elsif type == :resolution
|
17
|
+
attrs[:is_part_of_resolution] = true
|
18
|
+
else
|
19
|
+
attrs[:is_part_of_detail_description] = true
|
20
|
+
end
|
21
|
+
attrs
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(connection, **attributes)
|
25
|
+
@ticket = attributes.delete(:ticket)
|
26
|
+
super(connection, attributes)
|
27
|
+
end
|
28
|
+
|
29
|
+
def save
|
30
|
+
attrs = connection.call self.class.cw_api_name, "update_#{self.class.cw_model_name}".to_sym, {'note' => to_cw_h, 'srServiceRecid' => @ticket.id}
|
31
|
+
self.class.new(connection, self.class.save_transform(attrs))
|
32
|
+
end
|
33
|
+
|
34
|
+
def external?
|
35
|
+
!!is_part_of_detail_description
|
36
|
+
end
|
37
|
+
|
38
|
+
def internal?
|
39
|
+
!!is_part_of_internal_analysis
|
40
|
+
end
|
41
|
+
|
42
|
+
def resolution?
|
43
|
+
!!is_part_of_resolution
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/connectwise/version.rb
CHANGED
data/lib/connectwise_sdk.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Connectwise::TicketNote do
|
4
|
+
let(:credentials) { connectwise_credentials }
|
5
|
+
let(:conn) { Connectwise::Connection.new(credentials) }
|
6
|
+
let(:company_attrs) { {name: 'Pandorica'} }
|
7
|
+
let(:ticket_attrs) { {summary: 'Help me', problem_description: 'I need the doctor!'} }
|
8
|
+
let(:company) { Connectwise::Company.new(conn, company_attrs) }
|
9
|
+
let(:ticket) {
|
10
|
+
t = Connectwise::Ticket.new(conn, ticket_attrs)
|
11
|
+
t.company = company.save
|
12
|
+
t.save
|
13
|
+
}
|
14
|
+
let(:ticket_note_attrs) { {note: 'some text to describe the note', type: :internal} }
|
15
|
+
subject { Connectwise::TicketNote.new(conn, ticket_note_attrs.merge({ticket: ticket})) }
|
16
|
+
|
17
|
+
it 'creates a ticket note' do
|
18
|
+
new_ticket_note = subject.save
|
19
|
+
expect(new_ticket_note.persisted?).to eq true
|
20
|
+
end
|
21
|
+
end
|
@@ -49,4 +49,20 @@ describe Connectwise::Ticket do
|
|
49
49
|
expect(deleted_ticket).not_to be_nil
|
50
50
|
expect {Connectwise::Ticket.find(conn, new_ticket.id)}.to raise_error Connectwise::RecordNotFound
|
51
51
|
end
|
52
|
+
|
53
|
+
it 'adds a note to the ticket' do
|
54
|
+
subject.company = company.save
|
55
|
+
new_ticket = subject.save
|
56
|
+
ticket_note = new_ticket.add_note('Message of some kind')
|
57
|
+
expect(ticket_note.persisted?).to eq true
|
58
|
+
expect(ticket_note.external?).to eq true
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'adds an internal note to the ticket' do
|
62
|
+
subject.company = company.save
|
63
|
+
new_ticket = subject.save
|
64
|
+
ticket_note = new_ticket.add_note('Message of some kind', type: :internal)
|
65
|
+
expect(ticket_note.persisted?).to eq true
|
66
|
+
expect(ticket_note.internal?).to eq true
|
67
|
+
end
|
52
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: connectwise_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emery A. Miller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/connectwise/model.rb
|
90
90
|
- lib/connectwise/opportunity.rb
|
91
91
|
- lib/connectwise/ticket.rb
|
92
|
+
- lib/connectwise/ticket_note.rb
|
92
93
|
- lib/connectwise/version.rb
|
93
94
|
- lib/connectwise_sdk.rb
|
94
95
|
- spec/credentials.yml.sample
|
@@ -98,6 +99,7 @@ files:
|
|
98
99
|
- spec/lib/connectwise/contact_spec.rb
|
99
100
|
- spec/lib/connectwise/member_spec.rb
|
100
101
|
- spec/lib/connectwise/opportunity_spec.rb
|
102
|
+
- spec/lib/connectwise/ticket_note_spec.rb
|
101
103
|
- spec/lib/connectwise/ticket_spec.rb
|
102
104
|
- spec/lib/connectwise_sdk_spec.rb
|
103
105
|
- spec/spec_helper.rb
|
@@ -133,6 +135,7 @@ test_files:
|
|
133
135
|
- spec/lib/connectwise/contact_spec.rb
|
134
136
|
- spec/lib/connectwise/member_spec.rb
|
135
137
|
- spec/lib/connectwise/opportunity_spec.rb
|
138
|
+
- spec/lib/connectwise/ticket_note_spec.rb
|
136
139
|
- spec/lib/connectwise/ticket_spec.rb
|
137
140
|
- spec/lib/connectwise_sdk_spec.rb
|
138
141
|
- spec/spec_helper.rb
|