connectwise_sdk 0.0.9 → 0.0.10

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: c0027cf2d769f0c575d42986f3a67a3f3f56d320
4
- data.tar.gz: bb718e0126990442c571b02f2f463b1951ae0fd1
3
+ metadata.gz: 70ce73cadcc0bc9f53aef9d11f95088b34e5dc33
4
+ data.tar.gz: 03fae785f7477983b3e17d279a2c94c3bafabb08
5
5
  SHA512:
6
- metadata.gz: bba4b5f247fd9f6fd2ebe5b9b727cd0fe12af55b844dfc312d426d3d3e303d93eb7091981ddb7e223261835df6ead584224ec0baeed7903ecbac2526e76b8470
7
- data.tar.gz: 03e52d141bfc91b87d19056bd9a24f6048334eb6c380a8c4e39e3fe27faa5d34c2687d909923ef87ba4e45b10e6ca8cfe13d7ea1e41354ac7b42b3d661eb61a3
6
+ metadata.gz: 36e9eebd4e99ab3a62dbc3e9a5df86edfd34838b7d6fb7acd52b4bebf00962c78a22646a8182590b1bc98a54ff80b186d10a58a9fe30cd6014780025e23f6c5e
7
+ data.tar.gz: 4b03d8dd15d1b8b785ddb225cf78f8043fe944497abde3b639f25e272b424ab8c6f372442d9238502e18f5fdf4ad1f87531ecf118745db53ebc1970c816893d4
@@ -1,8 +1,10 @@
1
+ require 'json'
2
+
1
3
  module Connectwise
2
4
  class Ticket
3
5
  include Model
4
6
  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, :company, :company_id
7
+ attr_accessor :id, :summary, :problem_description, :status_name, :board, :site_name, :status, :resolution, :remote_internal_company_name, :priority, :source, :severity, :impact, :company, :company_id, :closed_flag, :member_id, :member_rec_id
6
8
 
7
9
  #TODO - The use of SrServiceRecid and TicketNumber instead of id - may want to configure these
8
10
  # but this is so inconsistent for tickets that it may not be worth it unless other calls do the same thing
@@ -16,6 +18,12 @@ module Connectwise
16
18
  raise RecordNotFound
17
19
  end
18
20
 
21
+ def self.parse(connection, params)
22
+ resp = JSON.parse(params.keys.first)
23
+ ticket_info = JSON.parse(resp['Entity'])
24
+ self.new(connection, id: params[:id], summary: ticket_info['Summary'], closed_flag: ticket_info['ClosedFlag'], severity: ticket_info['Severity'], company_id: ticket_info['CompanyId'], member_id: ticket_info['memberId'])
25
+ end
26
+
19
27
  def status_name
20
28
  @status_name ||= 'New'
21
29
  end
@@ -1,3 +1,3 @@
1
1
  module Connectwise
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -14,6 +14,8 @@ describe Connectwise::Ticket do
14
14
  new_ticket = subject.save
15
15
  expect(new_ticket.persisted?).to eq true
16
16
  expect(new_ticket.company_id).to eq orig_company.company_id
17
+ expect(new_ticket.closed_flag).to eq false
18
+ #expect(new_ticket.member_id).to eq ''
17
19
  end
18
20
 
19
21
  it 'finds a service ticket' do
@@ -68,4 +70,19 @@ describe Connectwise::Ticket do
68
70
  expect(ticket_note.persisted?).to eq true
69
71
  expect(ticket_note.internal?).to eq true
70
72
  end
73
+
74
+ it 'parses a post callback' do
75
+ entity = {'Summary' => 'A summary', 'ClosedFlag' => false, 'Severity' => 'High', 'CompanyId' => 'acompany Id', 'memberId' => 'Admin1'}
76
+ cw_params = {'Other data' => 'not sure what', 'Entity' => entity.to_json}
77
+ params = {
78
+ cw_params.to_json => nil,
79
+ id: 12
80
+ }
81
+ ticket = Connectwise::Ticket.parse(conn, params)
82
+ expect(ticket.summary).to eq entity['Summary']
83
+ expect(ticket.closed_flag).to eq entity['ClosedFlag']
84
+ expect(ticket.severity).to eq entity['Severity']
85
+ expect(ticket.company_id).to eq entity['CompanyId']
86
+ expect(ticket.member_id).to eq entity['memberId']
87
+ end
71
88
  end
data/spec/spec_helper.rb CHANGED
@@ -5,3 +5,7 @@ def connectwise_credentials
5
5
  conf = YAML::load_file(File.join(__dir__, 'credentials.yml'))
6
6
  conf['connectwise_credentials'].each_with_object({}) {|(k,v), h| h[k.to_sym] = v}
7
7
  end
8
+
9
+ RSpec.configure do |c|
10
+ c.filter_run_including :focus => true
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: connectwise_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emery A. Miller