connectwise_sdk 0.0.11 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/connectwise/opportunity.rb +21 -3
- data/lib/connectwise/version.rb +1 -1
- data/spec/lib/connectwise/opportunity_spec.rb +12 -3
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c496eabc57d7fe1e9df44d89ccd55b7cc86f1f6
|
4
|
+
data.tar.gz: a239f7fe73a2973a0609396c58d50aee687bc29d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33eb89be5d8001bf092894a3bec732e49e4dd51e293cbcb0dfbf6a573f80e896afa9bcf7545bab4a9577b9363134aee155a64e78acd8fc7bbf6f2d75131c3223
|
7
|
+
data.tar.gz: a32dfd67e4ced046e5ea00a8c750b81361987b85154b7dfe64a7b3dde2b60c62547f72342b1459449fe687aff3f7b4c2a13d783a65bd780fd1d72369a53a6832
|
@@ -14,8 +14,26 @@ module Connectwise
|
|
14
14
|
@contact = contact
|
15
15
|
end
|
16
16
|
|
17
|
+
# TODO - These two id methods are both hacky - should have a contact or company object
|
18
|
+
# Probably need two different objects, one for finds, and another for gets (need to confirm save and get return the same thing)
|
17
19
|
def company_id
|
18
|
-
@company
|
20
|
+
if @company.respond_to?(:to_hash)
|
21
|
+
@company.fetch(:company_id) { @company }
|
22
|
+
elsif @company.respond_to?(:company_id)
|
23
|
+
@company.company_id
|
24
|
+
else
|
25
|
+
@company
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def contact_id
|
30
|
+
if @contact.respond_to?(:to_hash)
|
31
|
+
@contact.fetch(:contact_rec_id) { @contact }
|
32
|
+
elsif @contact.respond_to?(:id)
|
33
|
+
@contact.id
|
34
|
+
else
|
35
|
+
@contact
|
36
|
+
end
|
19
37
|
end
|
20
38
|
|
21
39
|
private
|
@@ -24,8 +42,8 @@ module Connectwise
|
|
24
42
|
attrs = super
|
25
43
|
attrs.delete('CompanyId')
|
26
44
|
attrs.delete('ContactId')
|
27
|
-
attrs['Company'] = {'CompanyID' =>
|
28
|
-
attrs['Contact'] = {'Id' =>
|
45
|
+
attrs['Company'] = {'CompanyID' => company_id} if @company
|
46
|
+
attrs['Contact'] = {'Id' => contact_id} if @contact
|
29
47
|
attrs
|
30
48
|
end
|
31
49
|
|
data/lib/connectwise/version.rb
CHANGED
@@ -7,9 +7,9 @@ describe Connectwise::Opportunity do
|
|
7
7
|
let(:contact_attrs) { {first_name: 'Malcom', last_name: 'Reynolds'} }
|
8
8
|
let(:opp_attrs) { {name: 'Something', source: 'EOP', primary_sales_rep: 'Admin1'} }
|
9
9
|
let(:full_op) {
|
10
|
-
new_company = Connectwise::Company.new(conn, company_attrs).save
|
11
|
-
new_contact = Connectwise::Contact.new(conn, contact_attrs.merge(company: new_company)).save
|
12
|
-
Connectwise::Opportunity.new(conn, opp_attrs.merge(company: new_company, contact: new_contact)).save
|
10
|
+
@new_company = Connectwise::Company.new(conn, company_attrs).save
|
11
|
+
@new_contact = Connectwise::Contact.new(conn, contact_attrs.merge(company: @new_company)).save
|
12
|
+
Connectwise::Opportunity.new(conn, opp_attrs.merge(company: @new_company, contact: @new_contact)).save
|
13
13
|
}
|
14
14
|
subject {Connectwise::Opportunity}
|
15
15
|
|
@@ -35,6 +35,15 @@ describe Connectwise::Opportunity do
|
|
35
35
|
new_opp = full_op
|
36
36
|
found_opp = Connectwise::Opportunity.find(conn, new_opp.id)
|
37
37
|
expect(found_opp.id).not_to be_nil
|
38
|
+
expect(found_opp.company_id).to eq @new_company.company_id
|
39
|
+
expect(found_opp.contact_id).to eq @new_contact.id
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'can change and resave a found opportunity' do
|
43
|
+
new_opp = full_op
|
44
|
+
found_opp = Connectwise::Opportunity.find(conn, new_opp.id)
|
45
|
+
found_opp.primary_sales_rep = 'Admin2'
|
46
|
+
expect {found_opp.save}.not_to raise_error
|
38
47
|
end
|
39
48
|
|
40
49
|
it 'fails to find an opportunity' do
|
data/spec/spec_helper.rb
CHANGED
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.1.0
|
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-11-
|
11
|
+
date: 2014-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|