connectwise_sdk 0.0.11 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59719857b1137c92f2069632546dafb209909cbc
4
- data.tar.gz: ebb3dd44f5feaa449268e97013e802bca925e8b0
3
+ metadata.gz: 7c496eabc57d7fe1e9df44d89ccd55b7cc86f1f6
4
+ data.tar.gz: a239f7fe73a2973a0609396c58d50aee687bc29d
5
5
  SHA512:
6
- metadata.gz: 7610d28b69c7f71ff751c43fbd5b48cf94e45a26be07757dd581caf41cb4a67d81a75e6480d8a7cc9eb757e594c510fd9e6caac1908731fd04a5296d0205809e
7
- data.tar.gz: 73e74dffb140980811b5750b2780ef39ca6893c2559799a00252b2db8d792e7393e3f73c173266b369a669e2d59ab9e629091a7adc6c046baee148adf6bd703d
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' => @company.company_id} if @company
28
- attrs['Contact'] = {'Id' => @contact.id} if @contact
45
+ attrs['Company'] = {'CompanyID' => company_id} if @company
46
+ attrs['Contact'] = {'Id' => contact_id} if @contact
29
47
  attrs
30
48
  end
31
49
 
@@ -1,3 +1,3 @@
1
1
  module Connectwise
2
- VERSION = "0.0.11"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -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
@@ -7,5 +7,5 @@ def connectwise_credentials
7
7
  end
8
8
 
9
9
  RSpec.configure do |c|
10
- c.filter_run_including :focus => true
10
+ #c.filter_run_including :focus => true
11
11
  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.11
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-14 00:00:00.000000000 Z
11
+ date: 2014-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler